X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/52b5ab7edc7296c18f895225efda65db0de62711..e8332ccfe0cf1653b257d46d5c41339e2b2da438:/contrib/include/wx/fl/newbmpbtn.h diff --git a/contrib/include/wx/fl/newbmpbtn.h b/contrib/include/wx/fl/newbmpbtn.h index 1363d73829..09041cb157 100644 --- a/contrib/include/wx/fl/newbmpbtn.h +++ b/contrib/include/wx/fl/newbmpbtn.h @@ -1,25 +1,29 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo +// Name: newbmpbtn.h +// Purpose: wxNewBitmapButton header. // Author: Aleksandras Gluchovas // Modified by: // Created: ??/09/98 // RCS-ID: $Id$ // Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __NEWBMPBTN_G__ #define __NEWBMPBTN_G__ -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "newbmpbtn.h" #endif #include "wx/button.h" #include "wx/string.h" +#include "wx/fl/fldefs.h" -// button lable-text alignment types +// defaults +#define NB_DEFAULT_MARGIN 2 + +// button label-text alignment types #define NB_ALIGN_TEXT_RIGHT 0 #define NB_ALIGN_TEXT_BOTTOM 1 @@ -28,137 +32,183 @@ // classes declared in this header file -class wxNewBitmapButton; -class wxBorderLessBitmapButton; +class WXDLLIMPEXP_FL wxNewBitmapButton; +class WXDLLIMPEXP_FL wxBorderLessBitmapButton; -// alternative class for wxBmpButton +/* +This is an alternative class to wxBitmapButton. It is used +in the implementation of dynamic toolbars. +*/ class wxNewBitmapButton: public wxPanel { - DECLARE_DYNAMIC_CLASS(wxNewBitmapButton) + DECLARE_DYNAMIC_CLASS(wxNewBitmapButton) protected: - friend class wxNewBitmapButtonSerializer; + friend class wxNewBitmapButtonSerializer; - int mTextToLabelGap; - int mMarginX; - int mMarginY; - int mTextAlignment; - bool mIsSticky; - bool mIsFlat; + int mTextToLabelGap; + int mMarginX; + int mMarginY; + int mTextAlignment; + bool mIsSticky; + bool mIsFlat; - wxString mLabelText; - wxString mImageFileName; - wxBitmapType mImageFileType; + wxString mLabelText; + wxString mImageFileName; + wxBitmapType mImageFileType; - wxBitmap mDepressedBmp; // source image for rendering - // labels for particular state + wxBitmap mDepressedBmp; // source image for rendering + // labels for particular state - wxBitmap mFocusedBmp; // may not be always present - - // only if mHasFocusedBmp is TRUE + wxBitmap mFocusedBmp; // may not be always present - + // only if mHasFocusedBmp is true - wxBitmap* mpDepressedImg; - wxBitmap* mpPressedImg; - wxBitmap* mpDisabledImg; - wxBitmap* mpFocusedImg; + wxBitmap* mpDepressedImg; + wxBitmap* mpPressedImg; + wxBitmap* mpDisabledImg; + wxBitmap* mpFocusedImg; - // button state variables; - bool mDragStarted; - bool mIsPressed; - bool mIsInFocus; - bool mPrevPressedState; - bool mPrevInFocusState; + // button state variables; + bool mDragStarted; + bool mIsPressed; + bool mIsInFocus; + bool mIsToggled; - bool mHasFocusedBmp; + bool mHasFocusedBmp; - // type of event which is fired upon depression of this button - int mFiredEventType; + // type of event which is fired upon depression of this button + int mFiredEventType; - // pens for drawing decorations (borders) - wxPen mBlackPen; - wxPen mDarkPen; - wxPen mGrayPen; - wxPen mLightPen; + // pens for drawing decorations (borders) + wxPen mBlackPen; + wxPen mDarkPen; + wxPen mGrayPen; + wxPen mLightPen; - bool mIsCreated; - int mSizeIsSet; + bool mIsCreated; + int mSizeIsSet; protected: - void DestroyLabels(); - // returns the label which match the current button state - virtual wxBitmap* GetStateLabel(); + // Internal function for destroying labels. + void DestroyLabels(); + + // Returns the label that matches the current button state. + virtual wxBitmap* GetStateLabel(); + + // Draws shading on the button. + virtual void DrawShade( int outerLevel, + wxDC& dc, + wxPen& upperLeftSidePen, + wxPen& lowerRightSidePen ); - virtual void DrawShade( int outerLevel, - wxDC& dc, - wxPen& upperLeftSidePen, - wxPen& lowerRightSidePen ); + // Returns true if the given point is in the window. + bool IsInWindow( int x, int y ); - bool IsInWindow( int x,int y ); + virtual void OnIdle(wxIdleEvent& event); + // (EVT_UPDATE_UI handler) + virtual void DoButtonUpdate(); public: - wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap, - const wxString& labelText = "", - int alignText = NB_ALIGN_TEXT_BOTTOM, - bool isFlat = TRUE, - // this is the default type of fired events - int firedEventType = wxEVT_COMMAND_MENU_SELECTED, - int marginX = 2, - int marginY = 2, - int textToLabelGap = 2, - bool isSticky = FALSE - ); - - // use this constructor if buttons have to be persistant - - wxNewBitmapButton( const wxString& bitmapFileName, + // Constructor. + wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap, + const wxString& labelText = wxT(""), + int alignText = NB_ALIGN_TEXT_BOTTOM, + bool isFlat = true, + // this is the default type of fired events + int firedEventType = wxEVT_COMMAND_MENU_SELECTED, + int marginX = NB_DEFAULT_MARGIN, + int marginY = NB_DEFAULT_MARGIN, + int textToLabelGap = 2, + bool isSticky = false + ); + + // Use this constructor if buttons have to be persistant + wxNewBitmapButton( const wxString& bitmapFileName, const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP, - const wxString& labelText = "", + const wxString& labelText = wxT(""), int alignText = NB_ALIGN_TEXT_BOTTOM, - bool isFlat = TRUE, + bool isFlat = true, // this is the default type of fired events int firedEventType = wxEVT_COMMAND_MENU_SELECTED, - int marginX = 2, - int marginY = 2, + int marginX = NB_DEFAULT_MARGIN, + int marginY = NB_DEFAULT_MARGIN, int textToLabelGap = 2, - bool isSticky = FALSE + bool isSticky = false ); - ~wxNewBitmapButton(); + // Destructor. + ~wxNewBitmapButton(); + + // This function should be called after Create. It renders the labels, having + // reloaded the button image if necessary. + virtual void Reshape(); + + // Sets the label and optionally label text. + virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = wxT("") ); + + // Unhide method from parents. + + virtual void SetLabel(const wxString& label) + { wxPanel::SetLabel(label); }; + + // Sets the text alignment and margins. + virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, + int marginX = NB_DEFAULT_MARGIN, + int marginY = NB_DEFAULT_MARGIN, + int textToLabelGap = 2); + + // Draws the decorations. + virtual void DrawDecorations( wxDC& dc ); + + // Draws the label. + virtual void DrawLabel( wxDC& dc ); + + // Renders the label image. + virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, + bool isEnabled = true, + bool isPressed = false); + + // Renders label images. + virtual void RenderLabelImages(); + + // Renders label images. + virtual void RenderAllLabelImages(); + + // Enables/disables button + virtual bool Enable(bool enable); + + // Depress button + virtual bool Toggle(bool enable); + + // Responds to a left mouse button down event. + void OnLButtonDown( wxMouseEvent& event ); + + // Responds to a left mouse button up event. + void OnLButtonUp( wxMouseEvent& event ); - // should be called after Create(); - virtual void Reshape(); + // Responds to mouse enter to window. + void OnMouseEnter( wxMouseEvent& event ); - // overridables - virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" ); - - virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, - int marginX = 2, - int marginY = 2, - int textToLabelGap = 2); + // Responds to mouse leave from window. + void OnMouseLeave( wxMouseEvent& event ); - virtual void DrawDecorations( wxDC& dc ); - virtual void DrawLabel( wxDC& dc ); + // Responds to a size event. + void OnSize( wxSizeEvent& event ); - virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, - bool isEnabled = TRUE, - bool isPressed = FALSE); + // Responds to a paint event. + void OnPaint( wxPaintEvent& event ); - virtual void RenderLabelImages(); - virtual void RenderAllLabelImages(); + // Responds to an erase background event. + void OnEraseBackground( wxEraseEvent& event ); - // event handlers - void OnLButtonDown( wxMouseEvent& event ); - void OnLButtonUp( wxMouseEvent& event ); - void OnMouseMove( wxMouseEvent& event ); - void OnSize( wxSizeEvent& event ); - void OnPaint( wxPaintEvent& event ); - void OnEraseBackground( wxEraseEvent& event ); - void OnKillFocus( wxFocusEvent& event ); + // Responds to a kill focus event. + void OnKillFocus( wxFocusEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; #endif /* __NEWBMPBTN_G__ */