OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
flatctrl.cpp
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// ObjectWindows 1998 by Yura Bidus
3//
4// Another implementation of Flat controls.
5// It use ideas from Joseph Parrello, Dieter Windau,and Kirk Stowell
6//
7//
8/// \file
9/// Implementation of classes TFlatComboBox,TFlatEdit, TFlatListBox
10/// Implementation of classes TGadgetComboBox,TGadgetEdit, TGadgetListBox
11//------------------------------------------------------------------------------
12#include <owl/pch.h>
13
14#include <owl/uihelper.h>
15#include <owl/uimetric.h>
16
17#include <owl/flatctrl.h>
18
19namespace owl {
20
22
23
24////////////////////////////////////////////////////////////////////////////////
25//#define TEST
26//
27void
29{
30 if(flat && !IsSet(fpFlatLook)){
33 CHECK(wnd);
34 if(wnd)
35 wnd->Invalidate(false);
36 }
37 else if(!flat && IsSet(fpFlatLook)){
40 CHECK(wnd);
41 if(wnd)
42 wnd->Invalidate(false);
43 }
44}
45
46//
47bool
49{
51 if (idleCount == 0 && wnd && IsFlat() /*&& IsActiveApplicatino()*/){ ///!!!!!!!!!!!!!!!!!!!!!!!!!
53 wnd->GetCursorPos(point);
54 wnd->ScreenToClient(point);
55
56 TRect rect = wnd->GetWindowRect();
57 ::MapWindowPoints(HWND_DESKTOP, *wnd, LPPOINT(&rect), 2);
58
59 if (rect.Contains(point)){
60 if(!IsSet(fpMouseIn)){
62 wnd->Invalidate(false);
63 }
64 }
65 else{
66 if(IsSet(fpMouseIn)) {
68 wnd->Invalidate(false);
69 }
70 }
71 }
72 return false;
73}
74
75//
76void
78{
80 if(!wnd)
81 return;
82
83 if(IsSet(fpMouseIn) && wnd->IsWindowEnabled()){
84 // We draw the "tracked" situation
85#ifdef TEST
87#else
89#endif
90 dc.FrameRect(rect, brush);
91 rect.Inflate(-1, -1);
92 dc.FrameRect(rect, brush);
93 rect.Inflate(-1, -1);
94 dc.FrameRect(rect, brush);
95 rect.Inflate(1, 1);
97 }
98 else{
99 // We draw the "untracked" situation
100#ifdef TEST
103#else
106#endif
107
108 dc.FrameRect(rect,brush);
109 rect.Inflate(-1, -1);
110 dc.FrameRect(rect,brush);
111 rect.Inflate(-1, -1);
112 dc.FrameRect(rect, brush2);
113 }
114}
115
116////////////////////////////////////////////////////////////////////////////////
117//
118// class TFlatComboBox
119// ~~~~~ ~~~~~~~~~~~~~
120//
124
125//
126void
133
134//
135// Intercept WM_PAINT to redirect from TWindow to the underlying control iff
136// this Owl object is just a wrapper for a predefined class.
137//
138void
140{
142
143 if (IsFlat()){
144 TWindowDC dc(GetHandle());
147
148 if(!IsSet(fpMouseIn) || !IsWindowEnabled()){
149 // We draw the "untracked" situation
150 rect.left = rect.right - TUIMetric::CxHThumb;// + 1;
151#ifdef TEST
153#else
155#endif
156 }
157 }
158}
159
160////////////////////////////////////////////////////////////////////////////////
161//
162// class TFlatEdit
163// ~~~~~ ~~~~~~~~~
164//
165
169
170void
176
177//
178// Intercept WM_PAINT to redirect from TWindow to the underlying control iff
179// this Owl object is just a wrapper for a predefined class.
180//
181void
183{
185
186 if (IsFlat())
187 {
188 TWindowDC dc(GetHandle());
190
191 //28.11.2007 Jogy - painting of the was wrong, added some corrections
192 rect.top -= 4;
193 rect.left -= 4;
194 rect.right += 6;
195 rect.bottom += 6;
197 }
198}
199
200////////////////////////////////////////////////////////////////////////////////
201//
202// class TFlatListBox
203// ~~~~~ ~~~~~~~~~~~~
204//
205
209
210void
216
217//
218// Intercept WM_PAINT to redirect from TWindow to the underlying control iff
219// this Owl object is just a wrapper for a predefined class.
220//
221void
223{
225
226 if (IsFlat()){
227
228 TWindowDC dc(GetHandle());
229
233
234 rect.bottom += 6;
235 rect.right += 6;
236 wrect.Offset(3,3);
237
238 bool haveScroll = wrect != rect;
239 if(haveScroll){
240 wrect.bottom -= 1;
241 wrect.right -= 1;
242 }
243
245
246 if((!IsSet(fpMouseIn) || !IsWindowEnabled()) && haveScroll){
247 // We draw the "untracked" situation
248 wrect.left = wrect.right - TUIMetric::CxHThumb;
249
250#ifdef TEST
252#else
254#endif
255 }
256 }
257}
258//------------------------------------------------------------------------------
259//
260bool
262{
264 if(wnd)
265 return ToBool(wnd->GetFlatStyle()&TGadgetWindow::FlatStandard);
266 return false;
267}
268//------------------------------------------------------------------------------
269//
270bool
272{
274 if(wnd)
275 return ToBool(wnd->GetFlatStyle()&TGadgetWindow::FlatStandard);
276 return false;
277}
278//------------------------------------------------------------------------------
279//
280bool
282{
284 if(wnd)
285 return ToBool(wnd->GetFlatStyle()&TGadgetWindow::FlatStandard);
286 return false;
287}
288
289} // OWL namespace
290
291//==============================================================================
292
#define CHECK(condition)
Definition checks.h:239
uint Clear(uint t)
Clear the bits that are enabled in the specified parameter.
Definition bitset.h:188
bool IsSet(uint t) const
Return true of the ON bits of the parameter are currently enabled.
Definition bitset.h:198
uint Set(uint t)
Activate the bits that are enabled in the specified parameter.
Definition bitset.h:179
The GDI Brush class is derived from TGdiObject.
Definition gdiobjec.h:180
static const TColor LtBlue
Static TColor object with fixed Value set by RGB(0, 0, 255).
Definition color.h:311
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
Definition color.h:339
static const TColor LtGreen
Static TColor object with fixed Value set by RGB(0, 255, 0).
Definition color.h:309
static const TColor SysWindow
The symbolic system color value for the background of each window.
Definition color.h:329
static const TColor LtRed
Static TColor object with fixed Value set by RGB(255, 0, 0).
Definition color.h:308
You can use TComboBox to create a combo box or a combo box control in a parent TWindow,...
Definition combobox.h:47
int SetExtendedUI(bool Extended)
Specifies whether the combo box uses the extended user interface or the default user interface.
Definition combobox.h:317
void SetupWindow()
Limits the amount of text that the user can enter in the combo box's edit control to the value of Tex...
Definition combobox.cpp:418
void EvPaint()
Intercept WM_PAINT to redirect from TWindow to the underlying control if this Owl object is just a wr...
Definition control.cpp:159
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
bool FrameRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Draws a border on this DC around the given rectangle, rect, using the given brush,...
Definition dc.h:1781
A TEdit is an interface object that represents an edit control interface element.
Definition edit.h:34
void SetupWindow() override
Definition flatctrl.cpp:127
void SetupWindow() override
Definition flatctrl.cpp:171
void SetupWindow() override
Definition flatctrl.cpp:211
bool IdleAction(long idleCount)
Definition flatctrl.cpp:48
void SetFlatStyle(bool flat=true)
Definition flatctrl.cpp:28
void Paint(TDC &dc, TRect &rect)
Definition flatctrl.cpp:77
virtual bool IsFlat()
Definition flatctrl.h:185
virtual bool IsFlat()
Definition flatctrl.cpp:261
virtual bool IsFlat()
Definition flatctrl.cpp:271
virtual bool IsFlat()
Definition flatctrl.cpp:281
Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a window and lets you dynam...
Definition gadgetwi.h:122
@ FlatStandard
Flat style IE 3.0 - base style.
Definition gadgetwi.h:194
An interface object that represents a corresponding list box element.
Definition listbox.h:43
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
@ SunkenOuter
Sunken outer edge only.
Definition uihelper.h:317
static bool DrawEdge(TDC &dc, const TRect &frame, uint edge, uint flags)
This is a static function that performs the actual drawing of edges for a UIBorder or an external cli...
Definition uiborder.cpp:127
static const TUIMetric CxHThumb
Definition uimetric.h:44
Derived from TDC, TWindowDC is a device context (DC) class that provides access to the entire area ow...
Definition dc.h:588
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
bool IsWindowEnabled() const
Returns true if the window is enabled.
Definition window.h:2161
void SetWindowFont(HFONT font, bool redraw=true)
Sets the font that a control uses to draw text.
Definition window.h:3476
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
void MapWindowPoints(HWND hWndTo, TPoint *pts, int count) const
Maps a set of points in one window to a relative set of points in another window.
Definition window.h:2206
TRect GetClientRect() const
Gets the coordinates of the window's client area (the area in a window you can use for drawing).
Definition window.h:2217
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
Definition window.cpp:2575
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
Another implementation of Flat controls.
void SetupWindow() override
Definition edit.cpp:1000
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
EV_WM_PAINT
Definition control.cpp:28
bool ToBool(const T &t)
Definition defs.h:291
OWL_DIAGINFO
Definition animctrl.cpp:14
END_RESPONSE_TABLE
Definition button.cpp:26
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.
Definition of TUIMetric, a UI metrics provider class.