XSTATUSBAR.H
上传用户:bjaaa555
上传日期:2013-01-31
资源大小:40k
文件大小:11k
源码类别:

状态条

开发平台:

Visual C++

  1. /*****************************************************************************
  2.  *
  3.  * Autor: Joachim Raidl
  4.  * Adresse: Joachim.Raidl@iname.com
  5.  * Klasse: XPaneInfo, XStatusBar
  6.  * JRRC: %J%
  7.  * Inlines: SetFont(), SetFontSize(), SetFontName(), Increment(), 
  8.  * (XPaneInfo) Decrement(), GetFgColor(), GetBkColor(), GetText(), 
  9.  * GetBitmap(), GetNumber(), GetProgressCtrl(), 
  10.  * GetFont(), GetFontName(), GetFontSize(), GetMode(), 
  11.  * IsHScroll(), IsVScroll(), SetRange(), SetPos(), 
  12.  * OffsetPos(), SetStep(), StepIt(), 
  13.  * Inlines: GetProgressCtrl(), SetFgColor(), SetBkColor(), 
  14.  * (XStatusBar) SetBitmap(), SetText(), SetNumber(), SetFont(), 
  15.  * SetFontSize(), SetFontName(), SetMode(), SetRange(), 
  16.  * EnablePane(), CheckKey(), Increment(), Decrement(), 
  17.  * SetPos(), OffsetPos(), SetStep(), StepIt(), 
  18.  * GetFgColor(), GetBkColor(), GetBitmap(), GetText(), 
  19.  * GetNumber(), GetFont(), GetFontName(), GetFontSize(), 
  20.  * GetMode(), IsHScroll(), IsVScroll(), _XPI(), 
  21.  *
  22.  ****************************************************************************/
  23. #ifndef __XSTATUSBAR__
  24. #define __XSTATUSBAR__
  25. #include <afxtempl.h>
  26. #define XSB_TOP DT_TOP // Styles werden aus DrawText 黚ernommen.
  27. #define XSB_LEFT DT_LEFT // Theoretisch k鰊nen auch alle anderen
  28. #define XSB_CENTER DT_CENTER // Format-Styles aus Draw-Text benutzt
  29. #define XSB_RIGHT DT_RIGHT // werden. Diese werden direkt an die
  30. #define XSB_VCENTER DT_VCENTER // jeweiligen Panes 黚ergeben. F黵 Bitmaps
  31. #define XSB_BOTTOM DT_BOTTOM // werden jedoch nur diese Styles benutzt.
  32. #define XSB_LEER 0x00000000
  33. #define XSB_TEXT 0x00100000 // Darstellung eines Textes im Pane
  34. #define XSB_NUMBER 0x00200000 // Darstellung eines Zahlenwertes im Pane
  35. #define XSB_BITMAP 0x00400000 // Darstellung eines Bitmaps im Pane
  36. #define XSB_PROGRESS 0x00800000 // Darstellung eines Progress-Bars im Pane
  37. #define XSB_HSCROLL 0x01000000 // Horizontales Scrollen des Textes bzw. Bitmaps
  38. #define XSB_VSCROLL 0x02000000 // Vertikales Scrollen des Textes bzw. Bitmaps
  39. #define XSB_DSCROLL 0x03000000 // Diagonales Scrollen des Textes bzw. Bitmaps
  40. #define XSB_REPEAT 0x10000000 // Mehrfaches hinter- bzw. untereinandersetzen
  41. #define XSB_STRETCH 0x20000000 // Bitmap an die Panegr鲞e anpassen
  42. #define XSB_SMOOTH 0x40000000 // Progress-Bar smooth darstellen
  43. #define XSB_ALIGN 0x000fffff
  44. #define XSB_MODE 0x00f00000
  45. #define XSB_SCROLL 0x0f000000
  46. #define XSB_MISC 0xf0000000
  47. class XPaneInfo : public CObject
  48. {
  49. protected: // 0 = aus, 1 = ein
  50. COLORREF fgColor[2]; // Textfarbe
  51. COLORREF bkColor[2]; // Hintergrundfarbe
  52. CString string[2]; // Text, Nummer oder Bitmapname
  53. CProgressCtrl *progress; // Fortschrittskontrolle
  54. LOGFONT font; // Schriftart
  55. int mode; // Darstellungsart
  56. int hScrollPos; // Position f黵 horizontales Scrollen
  57. int vScrollPos; // Position f黵 vertikales Scrollen
  58. // Funktionen
  59. public:
  60. XPaneInfo();
  61. XPaneInfo(const XPaneInfo& paneInfo);
  62. ~XPaneInfo();
  63. XPaneInfo operator=(const XPaneInfo& paneInfo);
  64. void SetDefault();
  65. void HScroll(CRect& rect, int maxWidth, int nullValue);
  66. void VScroll(CRect& rect, int maxHeight, int nullValue);
  67. // Zugriffsfunktionen
  68. public:
  69. void SetFgColor(COLORREF newOnColor, COLORREF newOffColor = -1);
  70. void SetBkColor(COLORREF newOnColor, COLORREF newOffColor = -1);
  71. void SetBitmap(LPCSTR newOnBitmap, LPCSTR newOffBitmap = "");
  72. void SetText(LPCSTR onText, LPCSTR offText = "");
  73. void SetNumber(int onValue, int offValue = 0);
  74. void SetMode(int newMode);
  75. void SetFont(LOGFONT& newFont) { font = newFont; }
  76. void SetFont(CFont& newFont) { newFont.GetLogFont(&font); }
  77. void SetFont(CFont *newFont) { newFont->GetLogFont(&font); }
  78. void SetFontSize(int size) { font.lfHeight = size; }
  79. void SetFontName(LPCSTR name) { strcpy(font.lfFaceName, name); }
  80. void SetFont(LPCSTR name, int size);
  81. int Increment(bool on = true) { int n = atoi(string[on ? 1 : 0]); string[on ? 1 : 0].Format("%d", ++n); return n; }
  82. int Decrement(bool on = true) { int n = atoi(string[on ? 1 : 0]); string[on ? 1 : 0].Format("%d", --n); return n; }
  83. COLORREF GetFgColor(bool on = true) { return fgColor[on ? 1 : 0]; }
  84. COLORREF GetBkColor(bool on = true) { return bkColor[on ? 1 : 0]; }
  85. CString GetText(bool on = true) { return string[on ? 1 : 0]; }
  86. CString GetBitmap(bool on = true) { return string[on ? 1 : 0]; }
  87. int GetNumber(bool on = true) { return atoi(string[on ? 1 : 0]); }
  88. CProgressCtrl *GetProgressCtrl() { return progress; }
  89. LOGFONT& GetFont() { return font; }
  90. CString GetFontName() { return font.lfFaceName; }
  91. int GetFontSize() { return font.lfHeight; }
  92. int GetMode() { return mode; }
  93. bool IsHScroll() { return ((mode & XSB_HSCROLL) != 0); }
  94. bool IsVScroll() { return ((mode & XSB_VSCROLL) != 0); }
  95. void SetRange(int nLower, int nUpper){ if (progress) progress->SetRange(nLower, nUpper); }
  96. int SetPos(int nPos) { return (progress ? progress->SetPos(nPos) : -1); }
  97. int OffsetPos(int nPos) { return (progress ? progress->OffsetPos(nPos) : -1); }
  98. int SetStep(int nStep) { return (progress ? progress->SetStep(nStep) : -1); }
  99. int StepIt() { return (progress ? progress->StepIt() : -1); }
  100. #ifdef _DEBUG
  101. void Dump(CDumpContext& dc) const;
  102. void AssertValid() const;
  103. friend CDumpContext& AFXAPI operator<<(CDumpContext& dc, XPaneInfo& b);
  104. #endif //_DEBUG
  105. };
  106. //****************************************************************************
  107. //****************************************************************************
  108. //****************************************************************************
  109. class XStatusBar : public CStatusBar
  110. {
  111. public:
  112. static XStatusBar *aktBar;
  113. // Konstruktion
  114. public:
  115. XStatusBar();
  116. bool CreateStatusBar(CWnd *pParent, const UINT* lpIDArray, int nIDCount, UINT pane0Style = SBPS_STRETCH);
  117. XPaneInfo& GetXPaneInfo(int ix);
  118. CProgressCtrl *GetProgressCtrl(int ix) { return GetXPaneInfo(ix).GetProgressCtrl(); }
  119. void SavePane(int ix);
  120. void RestorePane(int ix);
  121. int GetPaneAtPosition(CPoint& point);
  122. // Durchgriff auf die XPaneInfo-Members
  123. public:
  124. void SetFgColor(int ix, COLORREF on, COLORREF off = -1) { _XPI(ix).SetFgColor(on, off); Invalidate(FALSE); }
  125. void SetBkColor(int ix, COLORREF on, COLORREF off = -1) { _XPI(ix).SetBkColor(on, off); Invalidate(FALSE); }
  126. void SetBitmap(int ix, LPCSTR on, LPCSTR off = "") { _XPI(ix).SetBitmap(on, off); Invalidate(FALSE); }
  127. void SetText(int ix, LPCSTR on, LPCSTR off = "") { _XPI(ix).SetText(on, off); Invalidate(FALSE); }
  128. void SetNumber(int ix, int on, int off = 0) { _XPI(ix).SetNumber(on, off); Invalidate(FALSE); }
  129. void SetFont(int ix, LOGFONT& newFont) { _XPI(ix).SetFont(newFont); Invalidate(FALSE); }
  130. void SetFont(int ix, CFont& newFont) { _XPI(ix).SetFont(newFont); Invalidate(FALSE); }
  131. void SetFont(int ix, CFont *newFont) { _XPI(ix).SetFont(newFont); Invalidate(FALSE); }
  132. void SetFont(int ix, LPCSTR name, int size) { _XPI(ix).SetFont(name, size); Invalidate(FALSE); }
  133. void SetFontSize(int ix, int size) { _XPI(ix).SetFontSize(size); Invalidate(FALSE); }
  134. void SetFontName(int ix, LPCSTR name) { _XPI(ix).SetFontName(name); Invalidate(FALSE); }
  135. void SetMode(int ix, int newMode) { _XPI(ix).SetMode(newMode);  Invalidate(FALSE); }
  136. void SetRange(int ix, int nLow, int nUp) { _XPI(ix).SetRange(nLow, nUp); Invalidate(FALSE); }
  137. void EnablePane(int ix, bool enable = true) { SetPaneStyle(ix, enable ? 0 : SBPS_DISABLED); }
  138. void CheckKey(int ix, int nVirtKey) { EnablePane(ix, ::GetKeyState(nVirtKey) & 1); }
  139. int  Increment(int ix, bool on = true) { int ret = _XPI(ix).Increment(on); Invalidate(FALSE); return ret; }
  140. int  Decrement(int ix, bool on = true) { int ret = _XPI(ix).Decrement(on); Invalidate(FALSE); return ret; }
  141. int  SetPos(int ix, int nPos) { return _XPI(ix).SetPos(nPos); }
  142. int  OffsetPos(int ix, int nPos) { return _XPI(ix).OffsetPos(nPos); }
  143. int  SetStep(int ix, int nStep) { return _XPI(ix).SetStep(nStep); }
  144. int  StepIt(int ix) { return _XPI(ix).StepIt(); }
  145. UINT SetStyle(int ix, UINT style);
  146. int  SetWidth(int ix, int width);
  147. COLORREF GetFgColor(int ix, bool on = true) { return _XPI(ix).GetFgColor(on); }
  148. COLORREF GetBkColor(int ix, bool on = true) { return _XPI(ix).GetBkColor(on); }
  149. CString GetBitmap(int ix, bool on = true) { return _XPI(ix).GetBitmap(on); }
  150. CString GetText(int ix, bool on = true) { return _XPI(ix).GetText(on); }
  151. int GetNumber(int ix, bool on = true) { return _XPI(ix).GetNumber(on); }
  152. LOGFONT& GetFont(int ix) { return _XPI(ix).GetFont(); }
  153. CString GetFontName(int ix) { return _XPI(ix).GetFontName(); }
  154. int GetFontSize(int ix) { return _XPI(ix).GetFontSize(); }
  155. int GetMode(int ix) { return _XPI(ix).GetMode(); }
  156. bool IsHScroll(int ix) { return _XPI(ix).IsHScroll(); }
  157. bool IsVScroll(int ix) { return _XPI(ix).IsVScroll(); }
  158. UINT GetStyle(int ix);
  159. int GetWidth(int ix);
  160. UINT GetID(int ix);
  161. // Hilfsfunktionen
  162. protected:
  163. XPaneInfo& _XPI(int ix) { return GetXPaneInfo(ix); }
  164. void DrawSizing(CDC *pDC);
  165. void DrawTextPane(CDC *pDC, int ix, CRect& rect, XPaneInfo& aktPane);
  166. void DrawBitmapPane(CDC *pDC, int ix, CRect& rect, XPaneInfo& aktPane);
  167. void DrawProgressPane(CDC *pDC, int ix, CRect& rect, XPaneInfo& aktPane);
  168. // Attribute
  169. public:
  170. CArray<XPaneInfo, XPaneInfo&> paneInfo; // Liste mit den Zusatzinformationen
  171. CMap<int, int, XPaneInfo, XPaneInfo&> buffer; // Zwischenpuffer f黵 jeweils ein Pane
  172. UINT timerID; // ID des Refresh-Timers
  173. bool on; // Aktueller Pane aktiv oder inaktiv?
  174. CWnd *pParent; // Vaterfenster der Statusbar
  175. // 躡erschreibungen
  176. // Vom Klassen-Assistenten generierte virtuelle Funktions黚erschreibungen
  177. //{{AFX_VIRTUAL(XStatusBar)
  178. virtual BOOL SetIndicators(const UINT* lpIDArray, int nIDCount);
  179. //}}AFX_VIRTUAL
  180. // Implementierung
  181. public:
  182. virtual ~XStatusBar();
  183. // Generierte Nachrichtenzuordnungsfunktionen
  184. protected:
  185. //{{AFX_MSG(XStatusBar)
  186. afx_msg void OnDestroy();
  187. afx_msg void OnTimer(UINT nIDEvent);
  188. afx_msg void OnPaint();
  189. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  190. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  191. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  192. afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
  193. afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  194. afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  195. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  196. afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  197. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  198. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  199. //}}AFX_MSG
  200. DECLARE_MESSAGE_MAP()
  201. };
  202. //{{AFX_INSERT_LOCATION}}
  203. // Microsoft Developer Studio f黦t zus鋞zliche Deklarationen unmittelbar vor der vorhergehenden Zeile ein.
  204. #endif // __XSTATUSBAR__