]>
git.saurik.com Git - wxWidgets.git/blob - src/common/bmpbtncmn.cpp
8760c70c09850f407e3d875264ac5e4034d5e85f
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/bmpbtncmn.cpp
3 // Purpose: wxBitmapButton common code
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
20 #include "wx/bmpbuttn.h"
24 #include "wx/dcmemory.h"
28 #include "wx/artprov.h"
29 #include "wx/renderer.h"
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 wxDEFINE_FLAGS( wxBitmapButtonStyle
)
36 wxBEGIN_FLAGS( wxBitmapButtonStyle
)
37 // new style border flags, we put them first to
38 // use them for streaming out
39 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
40 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
41 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
42 wxFLAGS_MEMBER(wxBORDER_RAISED
)
43 wxFLAGS_MEMBER(wxBORDER_STATIC
)
44 wxFLAGS_MEMBER(wxBORDER_NONE
)
46 // old style border flags
47 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
48 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
49 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
50 wxFLAGS_MEMBER(wxRAISED_BORDER
)
51 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
52 wxFLAGS_MEMBER(wxBORDER
)
54 // standard window styles
55 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
56 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
57 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
58 wxFLAGS_MEMBER(wxWANTS_CHARS
)
59 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
60 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
61 wxFLAGS_MEMBER(wxVSCROLL
)
62 wxFLAGS_MEMBER(wxHSCROLL
)
64 wxFLAGS_MEMBER(wxBU_AUTODRAW
)
65 wxFLAGS_MEMBER(wxBU_LEFT
)
66 wxFLAGS_MEMBER(wxBU_RIGHT
)
67 wxFLAGS_MEMBER(wxBU_TOP
)
68 wxFLAGS_MEMBER(wxBU_BOTTOM
)
69 wxEND_FLAGS( wxBitmapButtonStyle
)
71 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxBitmapButton
, wxButton
, "wx/bmpbuttn.h")
73 wxBEGIN_PROPERTIES_TABLE(wxBitmapButton
)
74 wxPROPERTY_FLAGS( WindowStyle
, wxBitmapButtonStyle
, long, \
75 SetWindowStyleFlag
, GetWindowStyleFlag
, \
76 wxEMPTY_PARAMETER_VALUE
, 0 /*flags*/, wxT("Helpstring"), \
77 wxT("group")) // style
78 wxEND_PROPERTIES_TABLE()
80 wxEMPTY_HANDLERS_TABLE(wxBitmapButton
)
82 wxCONSTRUCTOR_5( wxBitmapButton
, wxWindow
*, Parent
, wxWindowID
, Id
, \
83 wxBitmap
, Bitmap
, wxPoint
, Position
, wxSize
, Size
)
88 long "style" , wxBU_AUTODRAW
98 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
101 GetCloseButtonBitmap(wxWindow
*win
,
103 const wxColour
& colBg
,
108 dc
.SetBackground(colBg
);
110 wxRendererNative::Get().
111 DrawTitleBarBitmap(win
, dc
, size
, wxTITLEBAR_BUTTON_CLOSE
, flags
);
115 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
117 } // anonymous namespace
121 wxBitmapButtonBase::NewCloseButton(wxWindow
* parent
, wxWindowID winid
)
123 wxCHECK_MSG( parent
, NULL
, wxS("Must have a valid parent") );
125 const wxColour colBg
= parent
->GetBackgroundColour();
127 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
128 const wxSize sizeBmp
= wxArtProvider::GetSizeHint(wxART_BUTTON
);
129 wxBitmap bmp
= GetCloseButtonBitmap(parent
, sizeBmp
, colBg
);
130 #else // !wxHAS_DRAW_TITLE_BAR_BITMAP
131 wxBitmap bmp
= wxArtProvider::GetBitmap(wxART_CLOSE
, wxART_BUTTON
);
132 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
134 wxBitmapButton
* const button
= new wxBitmapButton
144 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
145 button
->SetBitmapPressed(
146 GetCloseButtonBitmap(parent
, sizeBmp
, colBg
, wxCONTROL_PRESSED
));
148 button
->SetBitmapCurrent(
149 GetCloseButtonBitmap(parent
, sizeBmp
, colBg
, wxCONTROL_CURRENT
));
150 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
152 // The button should blend with its parent background.
153 button
->SetBackgroundColour(colBg
);
158 #endif // wxUSE_BMPBUTTON