]>
git.saurik.com Git - wxWidgets.git/blob - src/common/bmpbtncmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/bmpbtncmn.cpp
3 // Purpose: wxBitmapButton common code
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/bmpbuttn.h"
25 #include "wx/dcmemory.h"
29 #include "wx/artprov.h"
30 #include "wx/renderer.h"
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 wxDEFINE_FLAGS( wxBitmapButtonStyle
)
37 wxBEGIN_FLAGS( wxBitmapButtonStyle
)
38 // new style border flags, we put them first to
39 // use them for streaming out
40 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
41 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
42 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
43 wxFLAGS_MEMBER(wxBORDER_RAISED
)
44 wxFLAGS_MEMBER(wxBORDER_STATIC
)
45 wxFLAGS_MEMBER(wxBORDER_NONE
)
47 // old style border flags
48 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
49 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
50 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
51 wxFLAGS_MEMBER(wxRAISED_BORDER
)
52 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
53 wxFLAGS_MEMBER(wxBORDER
)
55 // standard window styles
56 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
57 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
58 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
59 wxFLAGS_MEMBER(wxWANTS_CHARS
)
60 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
61 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
62 wxFLAGS_MEMBER(wxVSCROLL
)
63 wxFLAGS_MEMBER(wxHSCROLL
)
65 wxFLAGS_MEMBER(wxBU_AUTODRAW
)
66 wxFLAGS_MEMBER(wxBU_LEFT
)
67 wxFLAGS_MEMBER(wxBU_RIGHT
)
68 wxFLAGS_MEMBER(wxBU_TOP
)
69 wxFLAGS_MEMBER(wxBU_BOTTOM
)
70 wxEND_FLAGS( wxBitmapButtonStyle
)
72 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxBitmapButton
, wxButton
, "wx/bmpbuttn.h")
74 wxBEGIN_PROPERTIES_TABLE(wxBitmapButton
)
75 wxPROPERTY_FLAGS( WindowStyle
, wxBitmapButtonStyle
, long, \
76 SetWindowStyleFlag
, GetWindowStyleFlag
, \
77 wxEMPTY_PARAMETER_VALUE
, 0 /*flags*/, wxT("Helpstring"), \
78 wxT("group")) // style
79 wxEND_PROPERTIES_TABLE()
81 wxEMPTY_HANDLERS_TABLE(wxBitmapButton
)
83 wxCONSTRUCTOR_5( wxBitmapButton
, wxWindow
*, Parent
, wxWindowID
, Id
, \
84 wxBitmap
, Bitmap
, wxPoint
, Position
, wxSize
, Size
)
89 long "style" , wxBU_AUTODRAW
99 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
102 GetCloseButtonBitmap(wxWindow
*win
,
104 const wxColour
& colBg
,
109 dc
.SetBackground(colBg
);
111 wxRendererNative::Get().
112 DrawTitleBarBitmap(win
, dc
, size
, wxTITLEBAR_BUTTON_CLOSE
, flags
);
116 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
118 } // anonymous namespace
122 wxBitmapButtonBase::NewCloseButton(wxWindow
* parent
, wxWindowID winid
)
124 wxCHECK_MSG( parent
, NULL
, wxS("Must have a valid parent") );
126 const wxColour colBg
= parent
->GetBackgroundColour();
128 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
129 const wxSize sizeBmp
= wxArtProvider::GetSizeHint(wxART_BUTTON
);
130 wxBitmap bmp
= GetCloseButtonBitmap(parent
, sizeBmp
, colBg
);
131 #else // !wxHAS_DRAW_TITLE_BAR_BITMAP
132 wxBitmap bmp
= wxArtProvider::GetBitmap(wxART_CLOSE
, wxART_BUTTON
);
133 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
135 wxBitmapButton
* const button
= new wxBitmapButton
145 #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
146 button
->SetBitmapPressed(
147 GetCloseButtonBitmap(parent
, sizeBmp
, colBg
, wxCONTROL_PRESSED
));
149 button
->SetBitmapCurrent(
150 GetCloseButtonBitmap(parent
, sizeBmp
, colBg
, wxCONTROL_CURRENT
));
151 #endif // wxHAS_DRAW_TITLE_BAR_BITMAP
153 // The button should blend with its parent background.
154 button
->SetBackgroundColour(colBg
);
159 #endif // wxUSE_BMPBUTTON