Mercurial > foo_out_sdl
comparison foosdk/sdk/libPPUI/Controls.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #pragma once | |
| 2 | |
| 3 #pragma comment(lib, "uxtheme.lib") | |
| 4 | |
| 5 #include "wtl-pp.h" | |
| 6 #include "win32_op.h" | |
| 7 | |
| 8 // Separator-in-dialog tool: subclass a static control on init | |
| 9 class CStaticSeparator : public CWindowImpl<CStaticSeparator, CStatic> { | |
| 10 public: | |
| 11 CStaticSeparator() {} | |
| 12 BEGIN_MSG_MAP_EX(CSeparator) | |
| 13 MSG_WM_PAINT(OnPaint) | |
| 14 MSG_WM_SETTEXT(OnSetText) | |
| 15 END_MSG_MAP() | |
| 16 private: | |
| 17 int OnSetText(LPCTSTR) { | |
| 18 Invalidate(); | |
| 19 SetMsgHandled(FALSE); | |
| 20 return 0; | |
| 21 } | |
| 22 void OnPaint(CDCHandle); | |
| 23 }; | |
| 24 | |
| 25 // CWindowRegistered with font & text functionality, for creating custom text label classes | |
| 26 template<typename TClass> | |
| 27 class CTextControl : public CWindowRegisteredT<TClass> { | |
| 28 public: | |
| 29 BEGIN_MSG_MAP_EX(CTextControl) | |
| 30 MSG_WM_SETFONT(OnSetFont) | |
| 31 MSG_WM_GETFONT(OnGetFont) | |
| 32 MSG_WM_SETTEXT(OnSetText) | |
| 33 CHAIN_MSG_MAP(__super) | |
| 34 END_MSG_MAP() | |
| 35 private: | |
| 36 HFONT OnGetFont() { | |
| 37 return m_font; | |
| 38 } | |
| 39 void OnSetFont(HFONT font, BOOL bRedraw) { | |
| 40 m_font = font; | |
| 41 if (bRedraw) this->Invalidate(); | |
| 42 } | |
| 43 int OnSetText(LPCTSTR) { | |
| 44 this->Invalidate();this->SetMsgHandled(FALSE); return 0; | |
| 45 } | |
| 46 CFontHandle m_font; | |
| 47 }; | |
| 48 | |
| 49 // CStaticThemed BROKEN WITH DARK MODE, DO NOT USE | |
| 50 // CStaticMainInstruction = use 1.5x scaled font for non subclassed static instead | |
| 51 #if 0 | |
| 52 // Static control subclass with override for theme part used for rendering | |
| 53 class CStaticThemed : public CWindowImpl<CStaticThemed, CStatic> { | |
| 54 public: | |
| 55 CStaticThemed() : m_id(), m_fallback() {} | |
| 56 BEGIN_MSG_MAP_EX(CStaticThemed) | |
| 57 MSG_WM_PAINT(OnPaint) | |
| 58 MSG_WM_THEMECHANGED(OnThemeChanged) | |
| 59 MSG_WM_SETTEXT(OnSetText) | |
| 60 END_MSG_MAP() | |
| 61 | |
| 62 void SetThemePart(int id) {m_id = id; if (m_hWnd != NULL) Invalidate();} | |
| 63 private: | |
| 64 int OnSetText(LPCTSTR) { | |
| 65 Invalidate(); | |
| 66 SetMsgHandled(FALSE); | |
| 67 return 0; | |
| 68 } | |
| 69 void OnThemeChanged() { | |
| 70 m_theme.Release(); | |
| 71 m_fallback = false; | |
| 72 } | |
| 73 void OnPaint(CDCHandle); | |
| 74 int m_id; | |
| 75 CTheme m_theme; | |
| 76 bool m_fallback; | |
| 77 }; | |
| 78 | |
| 79 class CStaticMainInstruction : public CStaticThemed { | |
| 80 public: | |
| 81 CStaticMainInstruction(); | |
| 82 }; | |
| 83 #endif | |
| 84 | |
| 85 | |
| 86 class CSeparator : public CTextControl<CSeparator> { | |
| 87 public: | |
| 88 BEGIN_MSG_MAP_EX(CSeparator) | |
| 89 MSG_WM_PAINT(OnPaint) | |
| 90 MSG_WM_ENABLE(OnEnable) | |
| 91 CHAIN_MSG_MAP(__super) | |
| 92 END_MSG_MAP() | |
| 93 | |
| 94 static const TCHAR * GetClassName() { | |
| 95 return _T("foobar2000:separator"); | |
| 96 } | |
| 97 private: | |
| 98 void OnEnable(BOOL) { | |
| 99 Invalidate(); | |
| 100 } | |
| 101 void OnPaint(CDCHandle dc); | |
| 102 }; | |
| 103 |
