18#include <owl/glyphbtn.rh>
20#if defined(__BORLANDC__)
102 const TColor& fromColor,
int width,
int height)
113 hMemDC.
BitBlt(0, 0, width, height, srcDC, 0, 0, SRCCOPY);
123 dc.
BitBlt(0, 0, width, height, srcDC, 0, 0, SRCCOPY);
166 int X,
int Y,
int W,
int H,
TBtnType type,
167 bool isDefault,
TModule* module)
169 TButton(parent, id, text, X, Y, W, H, isDefault, module)
184 int X,
int Y,
int W,
int H,
189 :
TButton(parent, id, text, X, Y, W, H, isDefault, module)
206 TButton(parent, resourceId, module)
224 xGlyph = yGlyph = -1;
250 ResIdUp = IDB_BORBTNII_OK;
255 ResIdUp = IDB_BORBTNII_CANCEL;
258 ResIdUp = IDB_BORBTNII_NO;
261 ResIdUp = IDB_BORBTNII_HELP;
264 ResIdUp = IDB_BORBTNII_APPLY;
267 ResIdUp = IDB_BORBTNII_BROWSE;
270 ResIdUp = IDB_BORBTNII_REVERT;
273 ResIdUp = IDB_BORBTNII_ADD;
276 ResIdUp = IDB_BORBTNII_DEL;
279 ResIdUp = IDB_BORBTNII_EDIT;
282 ResIdUp = IDB_BORBTNII_KEY;
285 ResIdUp = IDB_BORBTNII_SETUP;
333 case WM_GETDLGCODE: {
334 uint32 btnStyle = ButtonStyle(GetWindowLong(hwnd, GWL_STYLE));
335 if (btnStyle == BS_DEFPUSHBUTTON)
336 return DLGC_BUTTON|DLGC_DEFPUSHBUTTON;
338 return DLGC_BUTTON|DLGC_UNDEFPUSHBUTTON;
341 return DefWindowProc(hwnd, msg, wParam, lParam);
354 if (::GetClassInfo(0,
_T(
"BUTTON"), &wndClass)) {
361 wndClass.style = CS_HREDRAW|CS_VREDRAW|CS_PARENTDC;
362 wndClass.hbrBackground = HBRUSH(COLOR_BTNFACE+1);
385 if (ButtonStyle(
GetStyle()) == BS_DEFPUSHBUTTON)
414 CelArray->Replace(0, *bitmap);
425 CelArray->Replace(1, *bitmap);
436 CelArray->Replace(2, *bitmap);
449 bitmap:
new TBitmap(*bitmap)),3);
473 const auto createBitmap = [](
const TIcon& icon,
TColor bkgndColor)
478 const auto faceBrush =
TBrush{bkgndColor};
480 const auto r =
TRect{{0, 0}, bmp.Size()};
481 dc.
MaskBlt(r, dc, r.
TopLeft(), i.Mask, r.TopLeft(), MAKEROP4(PATCOPY, SRCCOPY));
498 PRECONDITION(!hBitmap || ::GetObjectType(hBitmap) == OBJ_BITMAP);
524 CelArray->Add(*cell);
525 CelArray->Add(*cell);
526 CelArray->Add(*cell);
599 return BtnFont ? HFONT(*BtnFont) : HFONT(0);
609 BtnFont =
new TFont(hFont);
622 return DLGC_BUTTON|DLGC_DEFPUSHBUTTON;
624 return DLGC_BUTTON|DLGC_UNDEFPUSHBUTTON;
678 if (modKeys & MK_LBUTTON &&
GetCapture() == *
this) {
685 else if (IsThemed() && rect.
Contains(point))
836 b->TWindow::SetStyle(bs | other);
843 uint32 newBtnStyle = ButtonStyle(
static_cast<uint32>(param1));
849 if (newBtnStyle == BS_PUSHBUTTON && btnStyle != BS_PUSHBUTTON)
853 Local::SetButtonStyle(
this, newBtnStyle);
857 else if (newBtnStyle == BS_DEFPUSHBUTTON && btnStyle != BS_DEFPUSHBUTTON)
861 Local::SetButtonStyle(
this, newBtnStyle);
866#if defined(__DEBUG) || defined(__TRACE) || defined(__WARN)
867 if (newBtnStyle != BS_PUSHBUTTON && newBtnStyle != BS_DEFPUSHBUTTON)
868 TRACEX(OwlControl, 0,
"BmSetStyle: Invalid style specified");
966 const bool isThemed = IsThemed();
992 TSize cell = CelArray->CelSize();
993 glyphRect.
Set(0, 0, cell.cx, cell.cy);
1015 const TFont& f = BtnFont ? *BtnFont : *tmpFnt;
1019 text =
new tchar[len+1];
1021 textRect.
Set(0, 0, rect.
Width() - glyphRect.
Width(), SHRT_MAX);
1024 dc.
DrawText(&text[0], len, textRect, DT_WORDBREAK|DT_CALCRECT);
1037 if (!glyphRect.
IsNull() && index != 1)
1045 if (!glyphRect.
IsNull()) {
1051 TRect srcRect(CelArray->CelRect(index));
1052 TUIFace face(rect, *CelArray);
1055 const bool pressed =
false;
1056 face.
Paint(dc, srcRect, dstPt, state, pressed,
false);
1062 CelArray->BitBlt(index, dc, glyphRect.left, glyphRect.top);
1065 if (!textRect.
IsNull()) {
1069 DT_WORDBREAK|DT_VCENTER|DT_CENTER).Paint(dc, textRect.
TopLeft(),
1075 dc.
DrawText(&text[0], len, textRect, DT_WORDBREAK|DT_VCENTER|DT_CENTER);
1086 if (isThemed || textRect.
IsNull())
1094 if (len && (BtnFont || tmpFnt))
1117 if (!textRect.
IsNull() && xText >= 0 && yText >= 0)
1118 textRect.
Offset(xText, yText);
1119 if (!glyphRect.
IsNull() && xGlyph >= 0 && yGlyph >= 0)
1120 glyphRect.
Offset(xGlyph, yGlyph);
1128 TRect& centerRect = textRect.
IsNull() ? glyphRect : textRect;
1130 centerRect.
Offset(faceRect.left, faceRect.top);
1134 centerRect.right = faceRect.right;
1138 centerRect.bottom = faceRect.bottom;
1146 glyphRect.
Offset(faceRect.left, faceRect.top);
1147 textRect.
Offset(faceRect.left, faceRect.top);
1163 tDelta = hspace >= 0 ? gDelta + glyphRect.
Width() + hspace/3 :
1164 gDelta + glyphRect.
Width();
1169 tDelta = hspace >= 0 ? gDelta + glyphRect.
Width() + hspace/2 :
1170 gDelta + glyphRect.
Width();
1176 gDelta = hspace >= 0 ? tDelta + textRect.
Width() + hspace/3 :
1177 tDelta + textRect.
Width();
1182 gDelta = hspace >= 0 ? textRect.
Width() + hspace/3 : textRect.
Width();
1190 tDelta = vspace >= 0 ? gDelta + glyphRect.
Height() + vspace/3 :
1191 gDelta + glyphRect.
Height();
1196 tDelta = vspace >= 0 ? gDelta + glyphRect.
Height() + vspace/2 :
1197 gDelta + glyphRect.
Height();
1203 gDelta = vspace >= 0 ? tDelta + textRect.
Height() + vspace/3 :
1204 tDelta + textRect.
Height();
1209 gDelta = vspace >= 0 ? textRect.
Height() + vspace/3 : textRect.
Height();
1242 glyphRect.
Offset(gx+gDelta, gy);
1243 textRect.
Offset(tDelta, 0);
1252 gx += (faceRect.
Width() - glyphRect.
Width())/2;
1265 glyphRect.
Offset(gx, gy+gDelta);
1266 textRect.
Offset(0, tDelta);
1278 if (style != LayStyle) {
1292 if (x != xText || y != yText) {
1307 if (x != xGlyph || y != yGlyph) {
1323 TRect focusRect = faceRect;
1338 Paint(dc,
false, rect);
Definition of a bitmap Cel array class.
#define PRECONDITION(condition)
#define DIAG_DECLARE_GROUP(group)
#define TRACEX(group, level, message)
Pointer to an array of type T.
TBitmap is the GDI bitmap class derived from TGdiObject.
TSize Size() const
The width and height of the bitmap in pixels.
int Width() const
Returns the width of this bitmap using GDI's GetObject.
TBitmap(HBITMAP handle, TAutoDelete autoDelete=NoAutoDelete)
Construct an alias TBitmap for an existing bitmap handle.
int Height() const
Returns the height of this bitmap using GDI's GetObject.
The GDI Brush class is derived from TGdiObject.
static void MapColor(TDC &dc, TDC &srcDC, const TColor &toColor, const TColor &fromColor, int width, int height)
Helper routine used to map the face color of the underlying bitmap.
TBtnBitmap(HINSTANCE hInstance, TResId resId, const TColor &faceColor=TColor::LtGray)
Loads the specified bitmap and updates the face color, if necessary.
void UpdateFaceColor()
Updates the face color of the associated bitmap to the current system setting.
TColor FaceColor
Current face color of bitmap.
TCelArray(TBitmap *bmp, int numCels, TSize celSize=TSize(), TPoint offset=TPoint(), int numRows=1, TAutoDelete=AutoDelete)
Constructs a TCelArray from a bitmap by slicing the bitmap into a horizontal array of cels of a speci...
A device context class derived from TWindowDC, TClientDC provides access to the client area owned by ...
Class wrapper for management of color values.
static const TColor SysBtnText
The symbolic system color value for the text on buttons.
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
static const TColor LtGray
Static TColor object with fixed Value set by RGB(192, 192, 192).
static const TColor Sys3dShadow
The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges f...
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
TDC is the root class for GDI DC wrappers.
void RestoreBitmap()
Restores the original GDI bitmap object into this DC.
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
bool FillRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Fills the given rectangle on this DC using the specified brush.
void RestorePen()
Restores the original GDI pen object to this DC.
bool DrawFocusRect(int x1, int y1, int x2, int y2)
Draws the given rectangle on this DC in the style used to indicate focus.
virtual TColor SetBkColor(const TColor &color)
Sets the current background color of this DC to the given color value or the nearest available.
bool Rectangle(int x1, int y1, int x2, int y2)
Draws and fills a rectangle of the given size on this DC with the current pen and brush objects.
void RestoreBrush()
Restores the original GDI brush object to this DC.
virtual void RestoreFont()
Restores the original GDI font object to this DC.
virtual void SelectStockObject(int index)
Selects into the DC a predefined stock pen, brush, font, or palette.
bool BitBlt(int dstX, int dstY, int w, int h, const TDC &srcDC, int srcX, int srcY, uint32 rop=SRCCOPY)
Performs a bit-block transfer from srcDc (the given source DC) to this DC (the destination DC).
virtual TColor SetTextColor(const TColor &color)
Sets the current text color of this DC to the given color value.
int SetBkMode(int mode)
Sets the background mode to the given mode argument, which can be either OPAQUE or TRANSPARENT.
bool MaskBlt(const TRect &dst, const TDC &srcDC, const TPoint &src, const TBitmap &maskBm, const TPoint &maskPos, uint32 rop=SRCCOPY)
Copies a bitmap from the given source DC to this DC.
int DrawText(const tstring &str, int count, const TRect &, uint16 format=0)
Overload for const TRect& For obvious reasons, this overload does not support the DT_CALCRECT format ...
TDefaultGuiFont(TSystemFontId=sfiLegacyDefault)
Create a wrapper for the given system font.
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
TFont(HFONT handle, TAutoDelete autoDelete=NoAutoDelete)
TFont encapsulates an HFONT.
bool IsGDIObject() const
Returns true if this represents a real GDI object.
TIcon, derived from TGdiObject, represents the GDI object icon class.
auto GetInfo() const -> TInfo
Retrieves information about this icon.
A device context (DC) class derived from TCreatedDC, TMemoryDC provides access to a memory DC.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
A DC class that wraps begin and end paint calls for use in an WM_PAINT response function.
PAINTSTRUCT Ps
The paint structure associated with this TPaintDC object.
TPen is derived from TGdiObject.
TPoint is a support class, derived from tagPOINT.
Smart pointer to a single object. Provides member access operator ->.
TRect is a mathematical class derived from tagRect.
int Height() const
Returns the height of this rectangle (bottom - top).
bool IsNull() const
Returns true if left, right, top, and bottom are all 0; otherwise, returns false.
void Set(int _left, int _top, int _right, int _bottom)
Repositions and resizes this rectangle to the given values.
TRect & Offset(int dx, int dy)
Changes this rectangle so its corners are offset by the given delta values.
TRect InflatedBy(int dx, int dy) const
Returns a rectangle inflated by the given delta arguments.
TRect & Inflate(int dx, int dy)
Inflates a rectangle inflated by the given delta arguments.
const TPoint & TopLeft() const
Returns the upperleft point.
int Width() const
Returns the width of this rectangle (right - left).
bool Contains(const TPoint &point) const
Returns true if the given point lies within this rectangle; otherwise, it returns false.
The tagSIZE struct is defined as.
static TThemeModule & GetInstance()
Returns the module instance.
TModuleProc0< BOOL > IsAppThemed
Encapsulates a themed part.
void DrawTransparentBackground(HWND control, HDC, const TRect &dest)
Paints the background of the themed part, properly composited with the parent background.
Assists in drawing borders of many styles.
TRect GetClientRect() const
Calculates the rectangle within the border.
void Paint(TDC &dc) const
Paints this UIBorder object onto a given device context.
@ ButtonDn
Button in down position.
@ ButtonUp
Button in up position.
TUIFace assists in painting UI elements in various states.
TState
Enumeration describing the state of the bitmap to be drawn.
@ Disabled
Disabled or Unavailable state (embossed 3d no color).
TUIFace(const TRect &faceRect, const TBitmap &bm, const TColor &bgndColor=TColor::Sys3dFace, const TColor &fillColor=TColor::Sys3dFace)
Initializes the button face with a bitmap.
void Paint(TDC &dc, const TPoint &dstPt, TState state, bool pressed, bool fillFace=true)
Paint the face of a button onto a DC.
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
HWND GetParentH() const
Return the handle of the parent.
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
HWND SetCapture()
Sets the mouse capture to the current window.
static HWND GetCapture()
Returns the handle of the window that has captured the mouse.
virtual void GetWindowClass(WNDCLASS &wndClass)
Redefined by derived classes, GetWindowClass fills the supplied MS-Windows registration class structu...
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
virtual auto GetWindowClassName() -> TWindowClassName
TWindow * GetParentO() const
Return the OWL's parent for this window.
static void ReleaseCapture()
Releases the mouse capture from this window.
TModule * GetModule() const
Returns a pointer to the module object.
int GetWindowText(TCHAR *str, int maxCount) const
Copies the window's title into a buffer pointed to by string.
bool TrackMouseEvent(uint flags=TME_HOVER|TME_LEAVE, int hoverTime=HOVER_DEFAULT)
Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount ...
uint32 GetStyle() const
Gets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
int GetDlgCtrlID() const
Returns the ID of the control.
void SendNotification(int id, int notifyCode, HWND hCtl, TMsgId=WM_COMMAND)
Repacks a command message (msg) so that a child window (hCtl) can send a message to its parent regard...
void EvSysColorChange()
Respond to WM_SYSCOLORCHANGE by broadcasting it to all children.
HFONT GetWindowFont()
Gets the font the control uses to draw text.
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
void GetClientRect(TRect &rect) const
Gets the coordinates of the window's client area and then copies them into the object referred to by ...
HWND THandle
TWindow encapsulates an HWND.
virtual void Invalidate(bool erase=true)
Invalidates (mark for painting) the entire client area of a window.
HWND GetHandle() const
Returns the handle of the window.
int GetWindowTextLength() const
Returns the length, in characters, of the specified window's title.
Definition of windowing system color classes.
Definition of classes for CommonControl encapsulation.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition of abstract GDI object class and derived classes.
Definition of class TGlyphButton.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Object Windows Library (OWLNext Core).
const int BUTTONSTATE_PUSHED
const int FaceToFocusRectDelta
const int BUTTONSTATE_FOCUS
const uint32 BUTTONSTYLE_MASK
LPARAM TParam2
Second parameter type.
const int BUTTONSTATE_HOT
auto GetCommCtrlVersion() -> DWORD
Returns the version number of the Common Control library (ComCtl32.dll).
WPARAM TParam1
First parameter type.
LRESULT CALLBACK BButtonProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
LRESULT TResult
Result type.
TModule & GetGlobalModule()
EV_MESSAGE(BM_SETSTYLE, BMSetStyle)
Definition of TSystem, a system information provider class.
Microsoft UxTheme Library Encapsulation.
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.