5#ifndef __RulerToolbar_h__
6#define __RulerToolbar_h__ 1
8#include "Stroika/Foundation/StroikaPreComp.h"
12#include "Stroika/Frameworks/Led/Support.h"
13#include "Stroika/Frameworks/Led/WordProcessor.h"
15#include "LedItConfig.h"
20class RulerBar :
public CControlBar {
22 RulerBar (BOOL b3DExt = TRUE);
26 virtual BOOL Create (CWnd* pParentWnd, DWORD dwStyle, UINT nID);
29 void Update (
const IncrementalParagraphInfo& pf);
30 void Update (
const PARAFORMAT& pf);
31 void Update (CSize sizePaper,
const CRect& rectMargins);
40 RulerItem (UINT nBitmapID = 0);
42 virtual BOOL HitTestPix (CPoint pt)
44 return GetHitRectPix ().PtInRect (pt);
46 virtual void Draw (CDC& dc);
47 virtual void SetHorzPosTwips (
int nXPos);
48 virtual void TrackHorzPosTwips (
int nXPos, BOOL bOnRuler = TRUE);
49 virtual void SetVertPos (
int nYPos)
53 virtual void SetAlignment (
int nAlign)
55 m_nAlignment = nAlign;
57 virtual void SetRuler (RulerBar* pRuler)
61 virtual void SetBounds (
int nMin,
int nMax)
79 int GetHorzPosTwips ()
84 CRect GetHitRectPix ();
85 void DrawFocusLine ();
86 void SetTrack (BOOL b);
93 BOOL LoadMaskedBitmap (LPCTSTR lpszResourceName);
106 class CComboRulerItem :
public RulerItem {
108 CComboRulerItem (UINT nBitmapID1, UINT nBitmapID2, RulerItem& item);
109 virtual BOOL HitTestPix (CPoint pt);
110 virtual void Draw (CDC& dc);
111 virtual void SetHorzPosTwips (
int nXPos);
112 virtual void TrackHorzPosTwips (
int nXPos, BOOL bOnRuler = TRUE);
113 virtual void SetVertPos (
int nYPos);
114 virtual void SetAlignment (
int nAlign);
115 virtual void SetRuler (RulerBar* pRuler);
116 virtual void SetBounds (
int nMin,
int nMax);
121 RulerItem m_secondary;
126 class CTabRulerItem :
public RulerItem {
130 SetAlignment (TA_LEFT);
132 virtual void Draw (CDC& dc)
134 if (GetHorzPosTwips () != 0)
135 RulerItem::Draw (dc);
137 virtual void TrackHorzPosTwips (
int nXPos, BOOL bOnRuler = TRUE);
138 virtual BOOL HitTestPix (CPoint pt)
140 return (GetHorzPosTwips () != 0) ? RulerItem::HitTestPix (pt) : FALSE;
145 BOOL m_bDeferInProgress;
148 RulerItem* m_pSelItem;
150 CSize GetBaseUnits ();
151 CComboRulerItem m_leftmargin;
153 RulerItem m_rightmargin;
155 CTabRulerItem m_pTabItems[MAX_TAB_STOPS];
160 return m_sizePaper.cx - m_rectMargin.left - m_rectMargin.right;
168 CPen penBtnHighLight;
180 virtual void DoPaint (CDC* pDC);
181 virtual CSize CalcFixedLayout (BOOL bStretch, BOOL bHorz);
182 void ClientToRuler (CPoint& pt)
184 pt.Offset (-m_cxLeftBorder + m_nScroll, -m_cyTopBorder);
186 void ClientToRuler (CRect& rect)
188 rect.OffsetRect (-m_cxLeftBorder + m_nScroll, -m_cyTopBorder);
190 void RulerToClient (CPoint& pt)
192 pt.Offset (m_cxLeftBorder - m_nScroll, m_cyTopBorder);
194 void RulerToClient (CRect& rect)
196 rect.OffsetRect (m_cxLeftBorder - m_nScroll, m_cyTopBorder);
199 int XTwipsToClient (
int nT)
201 return MulDiv (nT, m_logx, 1440) + m_cxLeftBorder - m_nScroll;
203 int XClientToTwips (
int nC)
205 return MulDiv (nC - m_cxLeftBorder + m_nScroll, 1440, m_logx);
208 int XTwipsToRuler (
int nT)
210 return MulDiv (nT, m_logx, 1440);
212 int XRulerToTwips (
int nR)
214 return MulDiv (nR, 1440, m_logx);
217 int XRulerToClient (
int nR)
219 return nR + m_cxLeftBorder - m_nScroll;
221 int XClientToRuler (
int nC)
223 return nC - m_cxLeftBorder + m_nScroll;
227 virtual void OnUpdateCmdUI (CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
228 void CreateGDIObjects ();
229 void DrawFace (CDC& dc);
230 void DrawTickMarks (CDC& dC);
231 void DrawNumbers (CDC& dc,
int nInc,
int nTPU);
232 void DrawDiv (CDC& dc,
int nInc,
int nLargeDiv,
int nLength);
233 void DrawTabs (CDC& dc);
234 void FillInParaFormat (IncrementalParagraphInfo& pf);
236 void SetMarginBounds ();
237 RulerItem* GetFreeTab ();
238 LedItView* GetView ();
240 CTabRulerItem* GetHitTabPix (CPoint pt);
241 afx_msg
void OnLButtonDown (UINT nFlags, CPoint point);
242 afx_msg
void OnLButtonUp (UINT nFlags, CPoint point);
243 afx_msg
void OnMouseMove (UINT nFlags, CPoint point);
244 afx_msg
void OnSysColorChange ();
245 afx_msg
void OnWindowPosChanging (WINDOWPOS FAR* lpwndpos);
246 afx_msg
void OnShowWindow (BOOL bShow, UINT nStatus);
247 afx_msg
void OnWindowPosChanged (WINDOWPOS FAR* lpwndpos);
248 afx_msg LRESULT OnSizeParent (WPARAM wParam, LPARAM lParam);
249 DECLARE_MESSAGE_MAP ()
251 friend class RulerItem;
259inline
int RulerBar::RulerItem::GetHorzPosPix ()
261 return m_pRuler->XTwipsToRuler (m_nXPosTwips);