4cbc57f086
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
195 lines
5.9 KiB
C++
195 lines
5.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: newbmpbtn.h
|
|
// Purpose: wxNewBitmapButton header.
|
|
// Author: Aleksandras Gluchovas
|
|
// Modified by:
|
|
// Created: ??/09/98
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) Aleksandras Gluchovas
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef __NEWBMPBTN_G__
|
|
#define __NEWBMPBTN_G__
|
|
|
|
#ifdef __GNUG__
|
|
#pragma interface "newbmpbtn.h"
|
|
#endif
|
|
|
|
#include "wx/button.h"
|
|
#include "wx/string.h"
|
|
|
|
// button label-text alignment types
|
|
|
|
#define NB_ALIGN_TEXT_RIGHT 0
|
|
#define NB_ALIGN_TEXT_BOTTOM 1
|
|
#define NB_NO_TEXT 2
|
|
#define NB_NO_IMAGE 3
|
|
|
|
// classes declared in this header file
|
|
|
|
class wxNewBitmapButton;
|
|
class wxBorderLessBitmapButton;
|
|
|
|
/*
|
|
This is an alternative class to wxBitmapButton. It is used
|
|
in the implementation of dynamic toolbars.
|
|
*/
|
|
|
|
class wxNewBitmapButton: public wxPanel
|
|
{
|
|
DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
|
|
|
|
protected:
|
|
|
|
friend class wxNewBitmapButtonSerializer;
|
|
|
|
int mTextToLabelGap;
|
|
int mMarginX;
|
|
int mMarginY;
|
|
int mTextAlignment;
|
|
bool mIsSticky;
|
|
bool mIsFlat;
|
|
|
|
wxString mLabelText;
|
|
wxString mImageFileName;
|
|
wxBitmapType mImageFileType;
|
|
|
|
wxBitmap mDepressedBmp; // source image for rendering
|
|
// labels for particular state
|
|
|
|
wxBitmap mFocusedBmp; // may not be always present -
|
|
// only if mHasFocusedBmp is TRUE
|
|
|
|
wxBitmap* mpDepressedImg;
|
|
wxBitmap* mpPressedImg;
|
|
wxBitmap* mpDisabledImg;
|
|
wxBitmap* mpFocusedImg;
|
|
|
|
// button state variables;
|
|
bool mDragStarted;
|
|
bool mIsPressed;
|
|
bool mIsInFocus;
|
|
bool mPrevPressedState;
|
|
bool mPrevInFocusState;
|
|
|
|
bool mHasFocusedBmp;
|
|
|
|
// 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;
|
|
|
|
bool mIsCreated;
|
|
int mSizeIsSet;
|
|
|
|
protected:
|
|
|
|
// 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 );
|
|
|
|
// Returns TRUE if the given point is in the window.
|
|
bool IsInWindow( int x, int y );
|
|
|
|
public:
|
|
|
|
// Constructor.
|
|
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,
|
|
const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP,
|
|
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
|
|
);
|
|
|
|
// 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 = "" );
|
|
|
|
// Sets the text alignment and margins.
|
|
virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
|
|
int marginX = 2,
|
|
int marginY = 2,
|
|
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();
|
|
|
|
// Responds to a left mouse button down event.
|
|
void OnLButtonDown( wxMouseEvent& event );
|
|
|
|
// Responds to a left mouse button up event.
|
|
void OnLButtonUp( wxMouseEvent& event );
|
|
|
|
// Responds to a mouse move event.
|
|
void OnMouseMove( wxMouseEvent& event );
|
|
|
|
// Responds to a size event.
|
|
void OnSize( wxSizeEvent& event );
|
|
|
|
// Responds to a paint event.
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
// Responds to an erase background event.
|
|
void OnEraseBackground( wxEraseEvent& event );
|
|
|
|
// Responds to a kill focus event.
|
|
void OnKillFocus( wxFocusEvent& event );
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
};
|
|
|
|
#endif /* __NEWBMPBTN_G__ */
|
|
|