OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
uiborder.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5//----------------------------------------------------------------------------
6#include <owl/pch.h>
7#include <owl/uihelper.h>
8#include <owl/gdiobjec.h>
9
10namespace owl {
11
13
14//
15/// Constructs a UIBorder object given a frame and a high-level style type.
16/// Calculates Edge and modifier flags internally, as needed.
17//
19:
20 Frame(frame)
21{
22 PRECONDITION(style >= 0 && style <= WellSet);
23
24 static struct {
25 uint Edge;
26 uint Flags;
27 }
28 styleMap[] = {
29 {0, 0}, // None
30 {0, 0}, // Plain
31 {RaisedOuter, 0}, // Raised
32 {SunkenOuter, 0}, // Recessed
33 {RaisedOuter | SunkenInner, 0}, // Embossed
34 {SunkenOuter | RaisedInner, 0}, // Grooved
35 {RaisedOuter | RaisedInner, Soft}, // ButtonUp
36 {SunkenOuter | SunkenInner, Soft}, // ButtonDn
37 {RaisedOuter | RaisedInner, 0}, // WndRaised
38 {SunkenOuter | SunkenInner, 0}, // WndRecessed
39 {SunkenOuter | RaisedInner, 0}, // WellSet ???
40 };
41 Edge = styleMap[style].Edge;
42 Flags = styleMap[style].Flags | flags;
43 if (!(Flags & Rect))
44 Flags |= Rect;
45}
46
47//
48/// Constructs a UIBorder object given a frame, edge, and modifier flags.
49//
51:
52 Frame(frame),
53 Edge(edge),
54 Flags(flags)
55{
56 if (!(Flags & Rect))
57 Flags |= Rect;
58}
59
60//
61/// Moves the frame rect by (dx,dy).
62//
63void
65{
66 Frame.Offset(dx, dy);
67}
68
69//
70/// Moves the frame rect to (x,y).
71//
72void
73TUIBorder::MoveTo(int x, int y)
74{
75 Frame.Offset(x-Frame.left, y-Frame.top);
76}
77
78//
79/// Resizes the frame rect to (w,h).
80//
81void
83{
84 Frame.right = Frame.left + w;
85 Frame.top = Frame.top + h;
86}
87
88//
89/// Calculates the outside frame rectangle.
90//
93{
94// return Style == WellSet ? Frame.InflatedBy(1,1) : Frame;
95 return Frame;
96}
97
98//
99/// Calculates the rectangle within the border.
100//
101TRect
103{
104 int count = ((Edge & EdgeOuter) ? 1 : 0) + ((Edge & EdgeInner) ? 1 : 0);
105 return Frame.InflatedBy(-count,-count);
106}
107
108//
109/// Paints this UIBorder object onto a given device context.
110//
111void
113{
114 DrawEdge(dc, Frame, Edge, Flags);
115
116// case WellSet:
117// PaintWT(dc, Frame.InflatedBy(1,1));
118// Paint3H(dc, Frame);
119// PaintWT(dc, Frame.InflatedBy(-1,-1));
120}
121
122//
123/// This is a static function that performs the actual drawing of edges for a
124/// UIBorder or an external client. It uses the system ::DrawEdge if available.
125//
126bool
127TUIBorder::DrawEdge(TDC& dc, const TRect& frame, uint edge, uint flags)
128{
129 bool r = ::DrawEdge(dc, (LPRECT)&frame, edge, flags);
130 CHECK(r || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED); // Assume implemented.
131 return r;
132}
133
134//
135/// Paints a 2-color single pixel-thick frame. Bevel corners get brush color.
136//
137void
138TUIBorder::PaintFrame(TDC& dc, const TRect& fr, uint flags, const TColor& tlColor, const TColor& brColor)
139{
140 if (flags & (Top | Left)) {
142 dc.SelectObject(brsh);
143 if (flags & Top)
144 dc.PatBlt(fr.left, fr.top, fr.Width()-1, 1);
145 if (flags & Left)
146 dc.PatBlt(fr.left, fr.top+1, 1, fr.Height()-2);
147 dc.RestoreBrush();
148 }
149
150 if (flags & (Bottom | Right)) {
152 dc.SelectObject(brsh);
153 if (flags & Bottom)
154 dc.PatBlt(fr.left, fr.bottom-1, fr.Width(), 1);
155 if (flags & Right)
156 dc.PatBlt(fr.right-1, fr.top, 1, fr.Height()-1);
157 dc.RestoreBrush();
158 }
159}
160
161//
162/// Paints a 2-color single pixel-thick frame. Bevel corners get their own color.
163//
164void
165TUIBorder::PaintFrameC(TDC& dc, const TRect& fr, uint flags, const TColor& tlColor, const TColor& brColor, const TColor& bcColor)
166{
167 if (flags & (Top | Left)) {
169 dc.SelectObject(brsh);
170 if (flags & Top) {
171 dc.PatBlt(fr.left, fr.top, fr.Width()-2, 1);
172 dc.SetPixel(fr.right-1, fr.top, bcColor);
173 }
174 if (flags & Left)
175 dc.PatBlt(fr.left, fr.top+1, 1, fr.Height()-2);
176 dc.RestoreBrush();
177 }
178
179 if (flags & (Bottom | Right)) {
181 dc.SelectObject(brsh);
182 if (flags & Bottom) {
183 dc.SetPixel(fr.left, fr.bottom-1, bcColor);
184 dc.PatBlt(fr.left+1, fr.bottom-1, fr.Width(), 1);
185 }
186 if (flags & Right)
187 dc.PatBlt(fr.right-1, fr.top, 1, fr.Height()-1);
188 dc.RestoreBrush();
189 }
190}
191
192#if 0
193//
194//
195//
196void
197TUIBorder::PaintWT(TDC& dc, const TRect& frame)
198{
200}
201
202//
203//
204//
205void
206TUIBorder::Paint3H(TDC& dc, const TRect& frame)
207{
209}
210#endif
211
212} // OWL namespace
213/* ========================================================================== */
214
#define CHECK(condition)
Definition checks.h:239
#define PRECONDITION(condition)
Definition checks.h:227
The GDI Brush class is derived from TGdiObject.
Definition gdiobjec.h:180
Class wrapper for management of color values.
Definition color.h:245
static const TColor Sys3dHilight
The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the ...
Definition color.h:344
static const TColor SysWindowText
The symbolic system color value for text in every window.
Definition color.h:332
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
TColor SetPixel(int x, int y, const TColor &color)
Sets the color of the pixel at the given location to the given color and returns the pixel's previous...
Definition dc.h:2394
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
Definition dc.cpp:113
void RestoreBrush()
Restores the original GDI brush object to this DC.
Definition dc.cpp:233
bool PatBlt(int x, int y, int w, int h, uint32 rop=PATCOPY)
Definition dc.h:2448
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
int Height() const
Returns the height of this rectangle (bottom - top).
Definition geometry.h:1048
TRect & Offset(int dx, int dy)
Changes this rectangle so its corners are offset by the given delta values.
Definition geometry.cpp:114
TRect InflatedBy(int dx, int dy) const
Returns a rectangle inflated by the given delta arguments.
Definition geometry.h:1281
int Width() const
Returns the width of this rectangle (right - left).
Definition geometry.h:1039
TRect GetClientRect() const
Calculates the rectangle within the border.
Definition uiborder.cpp:102
@ Soft
Soft edge look for buttons.
Definition uihelper.h:288
void Size(int w, int h)
Resizes the frame rect to (w,h).
Definition uiborder.cpp:82
static void PaintFrameC(TDC &dc, const TRect &frame, uint flags, const TColor &tlColor, const TColor &brColor, const TColor &bcColor)
Paints a 2-color single pixel-thick frame. Bevel corners get their own color.
Definition uiborder.cpp:165
void Move(int dx, int dy)
Moves the frame rect by (dx,dy).
Definition uiborder.cpp:64
TEdge
Enumeration describing the type of edge to be drawn.
Definition uihelper.h:315
@ EdgeOuter
Mask for outer edge bits.
Definition uihelper.h:320
@ RaisedOuter
Raised outer edge only.
Definition uihelper.h:316
@ RaisedInner
Raised inner edge only.
Definition uihelper.h:318
@ SunkenInner
Sunken inner edge only.
Definition uihelper.h:319
@ SunkenOuter
Sunken outer edge only.
Definition uihelper.h:317
@ EdgeInner
Mask for inner edge bits.
Definition uihelper.h:321
void MoveTo(int x, int y)
Moves the frame rect to (x,y).
Definition uiborder.cpp:73
void Paint(TDC &dc) const
Paints this UIBorder object onto a given device context.
Definition uiborder.cpp:112
TStyle
Enumeration describing hilevel border styles.
Definition uihelper.h:296
@ WellSet
Well option set (auto grows + 1) // !CQ W4 cant do.
Definition uihelper.h:307
static void PaintFrame(TDC &dc, const TRect &frame, uint flags, const TColor &tlColor, const TColor &brColor)
Paints a 2-color single pixel-thick frame. Bevel corners get brush color.
Definition uiborder.cpp:138
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
TRect GetBoundingRect() const
Calculates the outside frame rectangle.
Definition uiborder.cpp:92
TUIBorder(const TRect &frame, TStyle style, uint flags=0)
Constructs a UIBorder object given a frame and a high-level style type.
Definition uiborder.cpp:18
Definition of abstract GDI object class and derived classes.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.