OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
theme.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// OWLNext
3//
4/// \file
5/// Microsoft UxTheme Library Encapsulation
6//----------------------------------------------------------------------------
7
8#if !defined(OWL_THEME_H)
9#define OWL_THEME_H
10
11#include <owl/private/defs.h>
12#if defined(BI_HAS_PRAGMA_ONCE)
13# pragma once
14#endif
15
16#include <owl/module.h>
17
18#include <uxtheme.h>
19#include <vssym32.h>
20
21namespace owl {
22
23
24//
25/// This singleton encapsulates the "uxtheme.dll" module.
26//
27class _OWLCLASS TThemeModule : public TModule
28{
29public:
30
31 /// Returns the module instance.
32 /// Exceptions are thrown if the module cannot be loaded.
33 //
34 static TThemeModule& GetInstance();
35
36 // API functors - dynamically linked functions
37 // General
38 //
39 TModuleProc1 <HRESULT, HTHEME> CloseThemeData;
40 TModuleProc3 <HRESULT, HWND, HDC, const RECT*> DrawThemeParentBackground;
41 TModuleProc2 <HRESULT, HWND, DWORD> EnableThemeDialogTexture;
42 TModuleProc1 <HRESULT, BOOL> EnableTheming;
43 TModuleProc6 <HRESULT, LPWSTR, int, LPWSTR, int, LPWSTR, int> GetCurrentThemeName;
44 TModuleProc0 <DWORD> GetThemeAppProperties;
45 TModuleProc4 <HRESULT, LPCWSTR, LPCWSTR, LPWSTR, int> GetThemeDocumentationProperty;
46 TModuleProc1 <HTHEME, HWND> GetWindowTheme;
47 TModuleProc0 <BOOL> IsAppThemed;
48 TModuleProc0 <BOOL> IsThemeActive;
49 TModuleProc1 <BOOL, HWND> IsThemeDialogTextureEnabled;
50 TModuleProc2 <HTHEME, HWND, LPCWSTR> OpenThemeData;
51 TModuleProcV1 <DWORD> SetThemeAppProperties;
52 TModuleProc3 <HRESULT, HWND, LPCWSTR, LPCWSTR> SetWindowTheme;
53
54 // API functors (continued)
55 // Theme sys properties
56 //
57 TModuleProc2 <BOOL, HTHEME, int> GetThemeSysBool;
58 TModuleProc2 <COLORREF, HTHEME, int> GetThemeSysColor;
59 TModuleProc2 <HBRUSH, HTHEME, int> GetThemeSysColorBrush;
60 TModuleProc3 <HRESULT, HTHEME, int, LOGFONT*> GetThemeSysFont;
61 TModuleProc3 <HRESULT, HTHEME, int, int*> GetThemeSysInt;
62 TModuleProc2 <int, HTHEME, int> GetThemeSysSize;
63 TModuleProc4 <HRESULT, HTHEME, int, LPWSTR, int> GetThemeSysString;
64
65 // API functors (continued)
66 // Theme parts
67 //
68 TModuleProc6 <HRESULT, HTHEME, HDC, int, int, const RECT*, const RECT*> DrawThemeBackground;
69 TModuleProc8 <HRESULT, HTHEME, HDC, int, int, const RECT*, UINT, UINT, RECT*> DrawThemeEdge;
70 TModuleProc7 <HRESULT, HTHEME, HDC, int, int, const RECT*, HIMAGELIST, int> DrawThemeIcon;
71 TModuleProc9 <HRESULT, HTHEME, HDC, int, int, LPCWSTR, int, DWORD, DWORD, const RECT*> DrawThemeText;
72 TModuleProc6 <HRESULT, HTHEME, HDC, int, int, const RECT*, RECT*> GetThemeBackgroundContentRect;
73 TModuleProc6 <HRESULT, HTHEME, HDC, int, int, const RECT*, RECT*> GetThemeBackgroundExtent;
74 TModuleProc6 <HRESULT, HTHEME, HDC, int, int, const RECT*, HRGN*> GetThemeBackgroundRegion;
75 TModuleProc5 <HRESULT, HTHEME, int, int, int, BOOL*> GetThemeBool;
76 TModuleProc5 <HRESULT, HTHEME, int, int, int, COLORREF*> GetThemeColor;
77 TModuleProc5 <HRESULT, HTHEME, int, int, int, int*> GetThemeEnumValue;
78 TModuleProc6 <HRESULT, HTHEME, int, int, int, LPWSTR, int> GetThemeFilename;
79 TModuleProc6 <HRESULT, HTHEME, HDC, int, int, int, LOGFONT*> GetThemeFont;
80 TModuleProc5 <HRESULT, HTHEME, int, int, int, int*> GetThemeInt;
81 TModuleProc5 <HRESULT, HTHEME, int, int, int, INTLIST*> GetThemeIntList;
82 TModuleProc7 <HRESULT, HTHEME, HDC, int, int, int, RECT*, MARGINS*> GetThemeMargins;
83 TModuleProc6 <HRESULT, HTHEME, HDC, int, int, int, int*> GetThemeMetric;
84 TModuleProc7 <HRESULT, HTHEME, HDC, int, int, RECT*, THEMESIZE, SIZE*> GetThemePartSize;
85 TModuleProc5 <HRESULT, HTHEME, int, int, int, POINT*> GetThemePosition;
86 TModuleProc5 <HRESULT, HTHEME, int, int, int, PROPERTYORIGIN*> GetThemePropertyOrigin;
87 TModuleProc5 <HRESULT, HTHEME, int, int, int, RECT*> GetThemeRect;
88 TModuleProc6 <HRESULT, HTHEME, int, int, int, LPWSTR, int> GetThemeString;
89 TModuleProc9 <HRESULT, HTHEME, HDC, int, int, LPCWSTR, int, DWORD, const RECT*, RECT*> GetThemeTextExtent;
90 TModuleProc5 <HRESULT, HTHEME, HDC, int, int, TEXTMETRIC*> GetThemeTextMetrics;
91 TModuleProc9 <HRESULT, HTHEME, HDC, int, int, DWORD, const RECT*, HRGN, POINT, WORD*> HitTestThemeBackground;
92 TModuleProc3 <BOOL, HTHEME, int, int> IsThemeBackgroundPartiallyTransparent;
93 TModuleProc3 <BOOL, HTHEME, int, int> IsThemePartDefined;
94
95private:
96 TThemeModule();
97};
98
99//
100/// Encapsulates a theme handle.
101/// TODO: Add appropriate member functions from the module API.
102//
104{
105public:
106 TTheme(HWND, LPCWSTR cls);
107 virtual ~TTheme();
108
109 // Accessors
110 //
111 HTHEME GetHandle() {return m_handle;}
112 operator HTHEME() {return m_handle;}
113
114private:
115 HTHEME m_handle;
116};
117
118//
119/// Encapsulates a themed part.
120//
122{
123public:
124 TThemePart(HWND, LPCWSTR cls, int part, int state);
125
126 // Accessors and mutators
127 //
128 int GetPart() const {return m_part;}
129 int GetState() const {return m_state;}
130 void SetState(int state) {m_state = state;}
131
132 // UxTheme interface
133 // TODO: Complete the interface.
134 //
135 void DrawBackground(HDC, const TRect& dest);
136 void DrawBackground(HDC, const TRect& dest, const TRect& clip);
137 bool IsBackgroundPartiallyTransparent();
138
139 void DrawTransparentBackground(HWND control, HDC, const TRect& dest);
140
141private:
142 int m_part;
143 int m_state;
144};
145
146//
147// Exception class
148//
149class _OWLCLASS TXTheme : public TXOwl
150{
151public:
152 HRESULT result;
153
154 TXTheme(const tstring& = tstring(), HRESULT = 0);
155
156 TXTheme* Clone();
157 void Throw();
158
159 static void Raise(const tstring& name = tstring(), HRESULT = 0);
160};
161
162
163} // OWL namespace
164
165
166#endif // OWL_THEME_H
167
168
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
HTHEME GetHandle()
Definition theme.h:111
TTheme(HWND, LPCWSTR cls)
Constructs a theme handler.
Definition theme.cpp:141
TModuleProc6< HRESULT, HTHEME, HDC, int, int, int, LOGFONT * > GetThemeFont
Definition theme.h:79
TModuleProc2< BOOL, HTHEME, int > GetThemeSysBool
Definition theme.h:57
TModuleProc2< HTHEME, HWND, LPCWSTR > OpenThemeData
Definition theme.h:50
TModuleProc2< int, HTHEME, int > GetThemeSysSize
Definition theme.h:62
TModuleProc6< HRESULT, HTHEME, int, int, int, LPWSTR, int > GetThemeFilename
Definition theme.h:78
TModuleProc2< HRESULT, HWND, DWORD > EnableThemeDialogTexture
Definition theme.h:41
TModuleProc5< HRESULT, HTHEME, int, int, int, int * > GetThemeEnumValue
Definition theme.h:77
TModuleProc3< BOOL, HTHEME, int, int > IsThemePartDefined
Definition theme.h:93
TModuleProc5< HRESULT, HTHEME, int, int, int, INTLIST * > GetThemeIntList
Definition theme.h:81
TModuleProc4< HRESULT, HTHEME, int, LPWSTR, int > GetThemeSysString
Definition theme.h:63
TModuleProc9< HRESULT, HTHEME, HDC, int, int, DWORD, const RECT *, HRGN, POINT, WORD * > HitTestThemeBackground
Definition theme.h:91
TModuleProc5< HRESULT, HTHEME, HDC, int, int, TEXTMETRIC * > GetThemeTextMetrics
Definition theme.h:90
TModuleProc6< HRESULT, HTHEME, HDC, int, int, const RECT *, const RECT * > DrawThemeBackground
Definition theme.h:68
TModuleProc1< HRESULT, BOOL > EnableTheming
Definition theme.h:42
TModuleProc2< HBRUSH, HTHEME, int > GetThemeSysColorBrush
Definition theme.h:59
TModuleProc7< HRESULT, HTHEME, HDC, int, int, RECT *, THEMESIZE, SIZE * > GetThemePartSize
Definition theme.h:84
TModuleProc6< HRESULT, HTHEME, int, int, int, LPWSTR, int > GetThemeString
Definition theme.h:88
TModuleProc5< HRESULT, HTHEME, int, int, int, PROPERTYORIGIN * > GetThemePropertyOrigin
Definition theme.h:86
TModuleProc7< HRESULT, HTHEME, HDC, int, int, const RECT *, HIMAGELIST, int > DrawThemeIcon
Definition theme.h:70
TModuleProc3< HRESULT, HTHEME, int, int * > GetThemeSysInt
Definition theme.h:61
TModuleProc3< HRESULT, HWND, LPCWSTR, LPCWSTR > SetWindowTheme
Definition theme.h:52
TModuleProc0< BOOL > IsThemeActive
Definition theme.h:48
TModuleProc6< HRESULT, HTHEME, HDC, int, int, const RECT *, RECT * > GetThemeBackgroundContentRect
Definition theme.h:72
TModuleProc5< HRESULT, HTHEME, int, int, int, RECT * > GetThemeRect
Definition theme.h:87
TModuleProc6< HRESULT, LPWSTR, int, LPWSTR, int, LPWSTR, int > GetCurrentThemeName
Definition theme.h:43
TModuleProcV1< DWORD > SetThemeAppProperties
Definition theme.h:51
TModuleProc0< DWORD > GetThemeAppProperties
Definition theme.h:44
TModuleProc6< HRESULT, HTHEME, HDC, int, int, const RECT *, HRGN * > GetThemeBackgroundRegion
Definition theme.h:74
TModuleProc9< HRESULT, HTHEME, HDC, int, int, LPCWSTR, int, DWORD, DWORD, const RECT * > DrawThemeText
Definition theme.h:71
TModuleProc9< HRESULT, HTHEME, HDC, int, int, LPCWSTR, int, DWORD, const RECT *, RECT * > GetThemeTextExtent
Definition theme.h:89
TModuleProc7< HRESULT, HTHEME, HDC, int, int, int, RECT *, MARGINS * > GetThemeMargins
Definition theme.h:82
TModuleProc6< HRESULT, HTHEME, HDC, int, int, int, int * > GetThemeMetric
Definition theme.h:83
TModuleProc1< BOOL, HWND > IsThemeDialogTextureEnabled
Definition theme.h:49
TModuleProc8< HRESULT, HTHEME, HDC, int, int, const RECT *, UINT, UINT, RECT * > DrawThemeEdge
Definition theme.h:69
TModuleProc5< HRESULT, HTHEME, int, int, int, POINT * > GetThemePosition
Definition theme.h:85
TModuleProc5< HRESULT, HTHEME, int, int, int, COLORREF * > GetThemeColor
Definition theme.h:76
TModuleProc5< HRESULT, HTHEME, int, int, int, BOOL * > GetThemeBool
Definition theme.h:75
TModuleProc2< COLORREF, HTHEME, int > GetThemeSysColor
Definition theme.h:58
TModuleProc3< BOOL, HTHEME, int, int > IsThemeBackgroundPartiallyTransparent
Definition theme.h:92
static TThemeModule & GetInstance()
Returns the module instance.
Definition theme.cpp:91
TModuleProc4< HRESULT, LPCWSTR, LPCWSTR, LPWSTR, int > GetThemeDocumentationProperty
Definition theme.h:45
TModuleProc5< HRESULT, HTHEME, int, int, int, int * > GetThemeInt
Definition theme.h:80
TModuleProc0< BOOL > IsAppThemed
Definition theme.h:47
TModuleProc1< HRESULT, HTHEME > CloseThemeData
Definition theme.h:39
TModuleProc3< HRESULT, HWND, HDC, const RECT * > DrawThemeParentBackground
Definition theme.h:40
TModuleProc1< HTHEME, HWND > GetWindowTheme
Definition theme.h:46
TModuleProc3< HRESULT, HTHEME, int, LOGFONT * > GetThemeSysFont
Definition theme.h:60
TModuleProc6< HRESULT, HTHEME, HDC, int, int, const RECT *, RECT * > GetThemeBackgroundExtent
Definition theme.h:73
int GetState() const
Definition theme.h:129
void SetState(int state)
Definition theme.h:130
int GetPart() const
Definition theme.h:128
TThemePart(HWND, LPCWSTR cls, int part, int state)
Constructs a theme part handler.
Definition theme.cpp:159
HRESULT result
Definition theme.h:152
void Throw()
Throws the exception.
Definition theme.cpp:235
TXTheme * Clone()
Creates a copy of the exception.
Definition theme.cpp:226
static void Raise(const tstring &name=tstring(), HRESULT=0)
Throws the exception.
Definition theme.cpp:244
TXTheme(const tstring &=tstring(), HRESULT=0)
Creates a theme exception.
Definition theme.cpp:216
TXOwl(const tstring &msg, uint resId=0)
An OWL exception with a given message for displaying and an unsigned Id that can be used for identifi...
Definition except.cpp:123
TModule(const tstring &name, bool shouldLoad=true, bool mustLoad=true, bool addToList=true)
Constructs a TModule object that is used as an alias for a DLL.
Definition module.cpp:308
Definition of class TModule.
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
#define _OWLCLASS
Definition defs.h:338