Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
FormatToolbar.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5#ifndef __FormatToolbar_h__
6#define __FormatToolbar_h__ 1
7
8#include "Stroika/Foundation/StroikaPreComp.h"
9
10#if qStroika_Foundation_Common_Platform_Windows
11#include <afxext.h>
12#endif
13
14#include "Stroika/Frameworks/Led/GDI.h"
15
16#include "LedItConfig.h"
17
18#if qStroika_Foundation_Common_Platform_Windows
19// abstract callback API
20class FormatToolbarOwner {
21public:
22 virtual IncrementalFontSpecification GetCurFont () const = 0;
23 virtual void SetCurFont (const IncrementalFontSpecification& fsp) = 0;
24};
25
26class FormatToolbar : public CToolBar {
27public:
28 FormatToolbar (FormatToolbarOwner& owner);
29
30private:
31 FormatToolbarOwner& fOwner;
32
33public:
34 nonvirtual void PositionCombos ();
35 nonvirtual void SyncToView ();
36
37public:
38 class LocalComboBox : public CComboBox {
39 public:
40 static int m_nFontHeight;
41 int m_nLimitText;
42 nonvirtual BOOL HasFocus ()
43 {
44 HWND hWnd = ::GetFocus ();
45 return (hWnd == m_hWnd || ::IsChild (m_hWnd, hWnd));
46 }
47 nonvirtual void GetTheText (CString& str);
48 nonvirtual void SetTheText (LPCTSTR lpszText, BOOL bMatchExact = FALSE);
49
50 nonvirtual BOOL LimitText (int nMaxChars);
51
52 public:
53 virtual BOOL PreTranslateMessage (MSG* pMsg);
54 afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct);
55 DECLARE_MESSAGE_MAP ()
56 };
57
58 class FontComboBox : public LocalComboBox {
59 public:
60 FontComboBox ();
61
62 CBitmap m_bmFontType;
63
64 nonvirtual void EnumFontFamiliesEx ();
65 nonvirtual void MatchFont (LPCTSTR lpszName);
66
67 static BOOL CALLBACK AFX_EXPORT CheckIsTrueTypeEnumFamCallback (ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType, LPVOID pThis);
68
69 virtual void DrawItem (LPDRAWITEMSTRUCT lpDIS) override;
70 virtual void MeasureItem (LPMEASUREITEMSTRUCT lpMIS) override;
71 virtual int CompareItem (LPCOMPAREITEMSTRUCT lpCIS) override;
72 DECLARE_MESSAGE_MAP ()
73 };
74
75 class SizeComboBox : public LocalComboBox {
76 public:
77 SizeComboBox ();
78 int m_nLogVert;
79 int m_nTwipsLast;
80
81 public:
82 nonvirtual void EnumFontSizes (CDC& dc, LPCTSTR pFontName);
83 static BOOL FAR PASCAL EnumSizeCallBack (LOGFONT FAR* lplf, LPNEWTEXTMETRIC lpntm, int FontType, LPVOID lpv);
84 nonvirtual void TwipsToPointString (LPTSTR lpszBuf, int nTwips);
85 nonvirtual void SetTwipSize (int nSize);
86 nonvirtual int GetTwipSize ();
87 nonvirtual void InsertSize (int nSize);
88 };
89
90public:
91 CSize m_szBaseUnits;
92 FontComboBox m_comboFontName;
93 SizeComboBox m_comboFontSize;
94
95public:
96 void NotifyOwner (UINT nCode);
97
98protected:
99 virtual void OnUpdateCmdUI (CFrameWnd* pTarget, BOOL bDisableIfNoHndler) override;
100
101 afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct);
102 afx_msg void OnFontNameKillFocus ();
103 afx_msg void OnFontSizeKillFocus ();
104 afx_msg void OnFontSizeDropDown ();
105 afx_msg void OnComboCloseUp ();
106 afx_msg void OnComboSetFocus ();
107 DECLARE_MESSAGE_MAP ()
108};
109#endif
110
111#endif /*__FormatToolbar_h__*/