X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2352862a7ee8440fdc2ae65baff31b73e40179d5..2e51fb3041e78ef15506ed746ed5898536be5955:/include/wx/button.h diff --git a/include/wx/button.h b/include/wx/button.h index 5f6da7282a..dfcf6610da 100644 --- a/include/wx/button.h +++ b/include/wx/button.h @@ -43,9 +43,15 @@ // small as possible #define wxBU_EXACTFIT 0x0001 -#include "wx/control.h" +// this flag can be used to disable using the text label in the button: it is +// mostly useful when creating buttons showing bitmap and having stock id as +// without it both the standard label corresponding to the stock id and the +// bitmap would be shown +#define wxBU_NOTEXT 0x0002 + -class WXDLLIMPEXP_FWD_CORE wxBitmap; +#include "wx/bitmap.h" +#include "wx/control.h" extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[]; @@ -100,7 +106,7 @@ public: // set the image position relative to the text, i.e. wxLEFT means that the // image is to the left of the text (this is the default) - virtual void SetBitmapPosition(wxDirection WXUNUSED(dir)) { } + void SetBitmapPosition(wxDirection dir); // make this button the default button in its top level window @@ -131,28 +137,54 @@ public: void SetBitmapSelected(const wxBitmap& bitmap) { SetBitmapPressed(bitmap); } void SetBitmapHover(const wxBitmap& bitmap) { SetBitmapCurrent(bitmap); } -protected: - // choose the default border for this window - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } + // this enum is not part of wx public API, it is public because it is used + // in non wxButton-derived classes internally + // + // also notice that MSW code relies on the values of the enum elements, do + // not change them without revising src/msw/button.cpp enum State { State_Normal, - State_Pressed, // a.k.a. "selected" in public API for some reason State_Current, // a.k.a. hot or "hovering" + State_Pressed, // a.k.a. "selected" in public API for some reason State_Disabled, State_Focused, State_Max }; + // return true if this button shouldn't show the text label, either because + // it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT + bool DontShowLabel() const + { + return HasFlag(wxBU_NOTEXT) || GetLabel().empty(); + } + + // return true if we do show the label + bool ShowsLabel() const + { + return !DontShowLabel(); + } + +protected: + // choose the default border for this window + virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } + virtual wxBitmap DoGetBitmap(State WXUNUSED(which)) const { return wxBitmap(); } virtual void DoSetBitmap(const wxBitmap& WXUNUSED(bitmap), State WXUNUSED(which)) { } + + virtual wxSize DoGetBitmapMargins() const + { return wxSize(0, 0); } + virtual void DoSetBitmapMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { } + virtual void DoSetBitmapPosition(wxDirection WXUNUSED(dir)) + { } + wxDECLARE_NO_COPY_CLASS(wxButtonBase); };