Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cGraphRuler.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_GraphRuler_H
6 #define _INC_GraphRuler_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "../CGraphCfg.h"
12 
13 #ifdef _MFC_VER
14 namespace GrayGraph
15 {
16 class CGraphRuler : public CWnd
17 {
20 
21 public:
22  CGraphRuler();
23 
24 // Attributes
25 private:
26  int m_Precision;
27 
28 protected:
29  cString m_sTitle;
30  cString m_sUOM;
31  cString m_sFormatStrings[3];
32  CGraphFont m_Font;
33 
34 public:
35  GraphVal_t m_MinValue;
36  GraphVal_t m_MaxValue;
37 
38 // Operations
39 protected:
40  COLORREF DrawBorder( CDC& dc, CRect& rect );
41  void CalculateFormatStrings();
42  virtual bool IsSynced() const = 0;
43 public:
44 
45 #if 0
46  void SetNewPrecision(int newPrecision)
47  {
48  m_Precision = newPrecision;
49  CalculateFormatStrings();
50  InvalidateRect( nullptr );
51  }
52  int GetPrecision() const
53  {return m_Precision;};
54 
55  void SetNewTitle( const cString & title)
56  {
57  m_sTitle = title;
58  CalculateFormatStrings();
59  InvalidateRect( nullptr );
60  }
61 #endif
62  const cString& GetTitle() const
63  {return m_sTitle;};
64 
65  const cString& GetUnitsOfMeasure() const
66  {return m_sUOM;};
67  void SetUnitsOfMeasure( const cString& newUOM );
68 
69  void GetFormattedOutput(double value, int formatLevel, cString& str) const;
70  cString GetFullTitle() const
71  {
72  return GetTitle() + ", " + GetUnitsOfMeasure();
73  }
74 
75  int GetLabelsFitMax( bool fRulerVert, const TCHAR* pszText );
76 
77  bool IsVerticalFont() const
78  {
79  return( m_Font.m_FontCfg.lfEscapement == 900 );
80  }
81 
82  void SetFont( const CGraphFont * pfont, bool fVert );
83  int GetTickHeight() const;
84  void SetMinMax(GraphVal_t minv, GraphVal_t maxv, bool bRedraw = true );
85 
86  virtual void OnLButtonDown( bool fHoriz, UINT nFlags, CPoint point );
87  virtual INT_PTR OnToolHitTest( CPoint point, TOOLINFO* pTI );
88 
89 // Overrides
90  // ClassWizard generated virtual function overrides
91  //{{AFX_VIRTUAL(CGraphRuler)
92  //}}AFX_VIRTUAL
93 
94 // Implementation
95 public:
96  virtual ~CGraphRuler();
97 #ifdef _DEBUG
98  virtual void AssertValid() const;
99  virtual void Dump(CDumpContext& dc) const;
100 #endif
101 
102  // Generated message map functions
103 protected:
104  //{{AFX_MSG(CGraphRuler)
105  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
106  afx_msg BOOL OnEraseBkgnd(CDC* pDC);
107  //}}AFX_MSG
108  DECLARE_MESSAGE_MAP()
109 };
110 
112 
114 // CGraphRulerScale window
115 class CGraphIntervals;
116 
117 class CGraphRulerScale : public CGraphRuler
118 {
120 // Construction
121 public:
122  CGraphRulerScale();
123 
124 // Attributes
125 private:
126  bool m_bShowExp;
127 
128 private:
129  CGraphIntervals* GetRulerFormatUnits( cString &sFormat, cString &sUnitName );
130 
131 public:
132  void SetShowExp( bool fExpShow )
133  {
134  m_bShowExp = fExpShow;
135  }
136 
137 // Operations
138 public:
139  int GetLabelsFitMax();
140  void GetToolHitText( int iVal, cString& strTextTip ) const;
141  bool IsSynced() const;
142  void GetRulerFormatUnits( cString &sFormat, cString &sUnitName, int iMaxExp );
143 
144 // Overrides
145  // ClassWizard generated virtual function overrides
146  //{{AFX_VIRTUAL(CGraphRulerScale)
147  //}}AFX_VIRTUAL
148 
149 // Implementation
150 public:
151  virtual ~CGraphRulerScale();
152 
153  // Generated message map functions
154 protected:
155  //{{AFX_MSG(CGraphRulerScale)
156  afx_msg void OnPaint();
157  afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
158  afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
159  //}}AFX_MSG
160  DECLARE_MESSAGE_MAP()
161 };
162 
164 // CGraphRulerTime window
165 
166 class CGraphRulerTime : public CGraphRuler
167 {
169 // Construction
170 public:
171  CGraphRulerTime();
172 
173 // Attributes
174 public:
175  int m_iPrvTimeTick; // <0 = not painted.
176 
177 private:
178  void PaintTimeTick( CDC* pDC );
179  void UpdateTimeTick( CDC* pDC, bool fPaint );
180  CGraphIntervals * GetRulerFormatUnits( CString &sFormat, CString &sUnitName );
181 
182 // Operations
183 public:
184  int GetLabelsFitMax();
185  void UpdateTimeTick( bool fPaint );
186  void GetToolHitText( int iVal, CString & strTextTip ) const;
187  bool IsSynced() const;
188 
189 // Overrides
190  // ClassWizard generated virtual function overrides
191  //{{AFX_VIRTUAL(CGraphRulerTime)
192  //}}AFX_VIRTUAL
193 
194 // Implementation
195 public:
196  virtual ~CGraphRulerTime();
197 
198  // Generated message map functions
199 protected:
200  //{{AFX_MSG(CGraphRulerTime)
201  afx_msg void OnPaint();
202  afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
203  afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
204  //}}AFX_MSG
205  DECLARE_MESSAGE_MAP()
206 };
207 
209 //{{AFX_INSERT_LOCATION}}
210 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
211 };
212 #endif
213 #endif // !defined(_INC_GraphRuler_H)
UINT32 COLORREF
ABGR (high to low bits)
Definition: cVariantData.h:21
Definition: GrayGraph.cpp:29
double GraphVal_t
this is the value type we are plotting. Must also be able to hold GraphTime_t.
Definition: cGraphCfg.h:66
cRectI CRect
Compatible with MFC 2d CRect.
Definition: cRectI.h:243
cWndHandle CWnd
Definition: cWndHandle.h:669
interface const RECTQ_t & rect
Definition: cQuadtree.h:44
cPoint2i CPoint
Compatible with MFC 2d CPoint,CRect.
Definition: cPoint2.h:65
cString CString
Definition: cString.h:639
cStringT< GChar_t > cString
Definition: cString.h:636