Subclass button controls to paint pictures left to the labels. More...
#include <window.h>
Public Types | |
typedef OwnerdrawnButton | super |
Public Member Functions | |
PictureButton (HWND hwnd, HICON hIcon, HBRUSH hbrush=GetSysColorBrush(COLOR_BTNFACE), bool flat=false) | |
PictureButton (HWND hparent, int id, HICON hIcon, HBRUSH hbrush=GetSysColorBrush(COLOR_BTNFACE), bool flat=false) | |
PictureButton (HWND hwnd, HBITMAP hBmp, HBRUSH hbrush=GetSysColorBrush(COLOR_BTNFACE), bool flat=false) | |
PictureButton (HWND hparent, int id, HBITMAP hBmp, HBRUSH hbrush=GetSysColorBrush(COLOR_BTNFACE), bool flat=false) | |
Protected Member Functions | |
virtual void | DrawItem (LPDRAWITEMSTRUCT dis) |
Protected Attributes | |
HICON | _hIcon |
HBITMAP | _hBmp |
HBRUSH | _hBrush |
int | _cx |
int | _cy |
bool | _flat |
Subclass button controls to paint pictures left to the labels.
The buttons should have set the style bit BS_OWNERDRAW. The owning window should use the OwnerDrawParent template to route owner draw messages to the buttons.
Definition at line 716 of file window.h.
typedef OwnerdrawnButton PictureButton::super |
Reimplemented from OwnerdrawnButton.
Reimplemented in StartButton.
PictureButton::PictureButton | ( | HWND | hwnd, |
HICON | hIcon, | ||
HBRUSH | hbrush = GetSysColorBrush(COLOR_BTNFACE) , |
||
bool | flat = false |
||
) | [inline] |
PictureButton::PictureButton | ( | HWND | hparent, |
int | id, | ||
HICON | hIcon, | ||
HBRUSH | hbrush = GetSysColorBrush(COLOR_BTNFACE) , |
||
bool | flat = false |
||
) | [inline] |
PictureButton::PictureButton | ( | HWND | hwnd, |
HBITMAP | hBmp, | ||
HBRUSH | hbrush = GetSysColorBrush(COLOR_BTNFACE) , |
||
bool | flat = false |
||
) | [inline] |
PictureButton::PictureButton | ( | HWND | hparent, |
int | id, | ||
HBITMAP | hBmp, | ||
HBRUSH | hbrush = GetSysColorBrush(COLOR_BTNFACE) , |
||
bool | flat = false |
||
) | [inline] |
void PictureButton::DrawItem | ( | LPDRAWITEMSTRUCT | dis ) | [protected, virtual] |
Implements OwnerdrawnButton.
Definition at line 960 of file window.cpp.
References _cx, _cy, _flat, _hBmp, _hBrush, _hIcon, WindowHandle::_hwnd, BUFFER_LEN, and DrawGrayText().
{ UINT state = DFCS_BUTTONPUSH; int style = GetWindowStyle(_hwnd); if (dis->itemState & ODS_DISABLED) state |= DFCS_INACTIVE; POINT imagePos; RECT textRect; int dt_flags; if (style & BS_BOTTOM) { // align horizontal centered, vertical floating imagePos.x = (dis->rcItem.left + dis->rcItem.right - _cx) / 2; imagePos.y = dis->rcItem.top + 3; textRect.left = dis->rcItem.left + 2; textRect.top = dis->rcItem.top + _cy + 4; textRect.right = dis->rcItem.right - 4; textRect.bottom = dis->rcItem.bottom - 4; dt_flags = DT_SINGLELINE|DT_CENTER|DT_VCENTER; } else { // horizontal floating, vertical centered imagePos.x = dis->rcItem.left + 3; imagePos.y = (dis->rcItem.top + dis->rcItem.bottom - _cy)/2; textRect.left = dis->rcItem.left + _cx + 4; textRect.top = dis->rcItem.top + 2; textRect.right = dis->rcItem.right - 4; textRect.bottom = dis->rcItem.bottom - 4; dt_flags = DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/; } if (dis->itemState & ODS_SELECTED) { state |= DFCS_PUSHED; ++imagePos.x; ++imagePos.y; ++textRect.left; ++textRect.top; ++textRect.right; ++textRect.bottom; } if (_flat) { FillRect(dis->hDC, &dis->rcItem, _hBrush); if (style & BS_FLAT) // Only with BS_FLAT set, there will be drawn a frame without highlight. DrawEdge(dis->hDC, &dis->rcItem, EDGE_RAISED, BF_RECT|BF_FLAT); } else DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, state); if (_hIcon) DrawIconEx(dis->hDC, imagePos.x, imagePos.y, _hIcon, _cx, _cy, 0, _hBrush, DI_NORMAL); else { MemCanvas mem_dc; BitmapSelection sel(mem_dc, _hBmp); BitBlt(dis->hDC, imagePos.x, imagePos.y, _cx, _cy, mem_dc, 0, 0, SRCCOPY); } TCHAR title[BUFFER_LEN]; GetWindowText(_hwnd, title, BUFFER_LEN); BkMode bk_mode(dis->hDC, TRANSPARENT); if (dis->itemState & (ODS_DISABLED|ODS_GRAYED)) DrawGrayText(dis->hDC, &textRect, title, dt_flags); else { TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNTEXT)); DrawText(dis->hDC, title, -1, &textRect, dt_flags); } if (dis->itemState & ODS_FOCUS) { RECT rect = { dis->rcItem.left+3, dis->rcItem.top+3, dis->rcItem.right-dis->rcItem.left-4, dis->rcItem.bottom-dis->rcItem.top-4 }; if (dis->itemState & ODS_SELECTED) { ++rect.left; ++rect.top; ++rect.right; ++rect.bottom; } DrawFocusRect(dis->hDC, &rect); } }
int PictureButton::_cx [protected] |
Definition at line 759 of file window.h.
Referenced by DrawItem(), and PictureButton().
int PictureButton::_cy [protected] |
Definition at line 760 of file window.h.
Referenced by DrawItem(), and PictureButton().
bool PictureButton::_flat [protected] |
Definition at line 762 of file window.h.
Referenced by DrawItem().
HBITMAP PictureButton::_hBmp [protected] |
Definition at line 756 of file window.h.
Referenced by DrawItem().
HBRUSH PictureButton::_hBrush [protected] |
Definition at line 757 of file window.h.
Referenced by DrawItem().
HICON PictureButton::_hIcon [protected] |
Definition at line 755 of file window.h.
Referenced by DrawItem().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |