2001-07-24 11:27:12 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2002-01-21 17:34:42 -05:00
|
|
|
// Name: toolwnd.h
|
|
|
|
// Purpose: wxToolWindow, cbMiniButton, cbCloseBox, cbCollapseBox,
|
|
|
|
// cbDockBox, cbFloatedBarWindow class declarations.
|
2001-07-24 11:27:12 -04:00
|
|
|
// Author: Aleksandras Gluchovas
|
|
|
|
// Modified by:
|
|
|
|
// Created: 06/09/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Aleksandras Gluchovas
|
2002-01-21 17:34:42 -05:00
|
|
|
// Licence: wxWindows licence
|
2001-07-24 11:27:12 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __TOOLWND_G__
|
|
|
|
#define __TOOLWND_G__
|
|
|
|
|
|
|
|
#include "wx/frame.h"
|
|
|
|
#include "wx/dynarray.h"
|
2002-12-04 09:11:26 -05:00
|
|
|
#include "wx/fl/fldefs.h"
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
// fixed settings
|
|
|
|
|
|
|
|
#define BTN_BOX_HEIGHT 12
|
|
|
|
#define BTN_BOX_WIDTH 12
|
2005-02-10 11:35:12 -05:00
|
|
|
#define BTN_X_WEIGHT 2
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2003-07-08 16:47:17 -04:00
|
|
|
class WXDLLIMPEXP_FL cbMiniButton;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
typedef cbMiniButton* cbMinitButtonPtrT;
|
|
|
|
|
2003-10-25 04:52:23 -04:00
|
|
|
WXFL_DEFINE_ARRAY_PTR( cbMinitButtonPtrT, cbMiniButtonArrayT );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
A tool window is a special kind of frame that paints its own title, and
|
|
|
|
can be used to implement small floating windows.
|
|
|
|
*/
|
|
|
|
|
2003-07-08 16:47:17 -04:00
|
|
|
class WXDLLIMPEXP_FL wxToolWindow : public wxFrame
|
2001-07-24 11:27:12 -04:00
|
|
|
{
|
2002-01-21 17:34:42 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS( wxToolWindow )
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
public: /** protected really, accessed only by serializers **/
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
cbMiniButtonArrayT mButtons;
|
|
|
|
wxWindow* mpClientWnd;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
wxFont mTitleFont;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
int mTitleHeight;
|
|
|
|
int mClntHorizGap;
|
|
|
|
int mClntVertGap;
|
|
|
|
int mWndVertGap;
|
|
|
|
int mWndHorizGap;
|
|
|
|
int mButtonGap;
|
|
|
|
int mInTitleMargin;
|
|
|
|
int mHintBorder;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
bool mResizeStarted;
|
|
|
|
bool mRealTimeUpdatesOn;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
int mMTolerance;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
int mCursorType;
|
|
|
|
bool mMouseCaptured;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// drag&drop state variables
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
wxPoint mDragOrigin;
|
|
|
|
wxRect mInitialRect;
|
|
|
|
wxRect mPrevHintRect;
|
|
|
|
wxScreenDC* mpScrDc;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
protected:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Maps client coordinates to screen coordinates.
|
|
|
|
void GetScrWindowRect( wxRect& r );
|
|
|
|
|
|
|
|
// Gets the mouse position in screen coordinates.
|
|
|
|
void GetScrMousePos ( wxMouseEvent& event, wxPoint& pos );
|
|
|
|
|
|
|
|
// Sets the hint cursor.
|
|
|
|
void SetHintCursor ( int type );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Calculate resized rectangle.
|
|
|
|
void CalcResizedRect( wxRect& rect, wxPoint& delta, const wxSize& minDim );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Helper function.
|
|
|
|
void AdjustRectPos( const wxRect& original, const wxSize& newDim, wxRect& newRect );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Helper function.
|
|
|
|
wxSize GetMinimalWndDim();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Draws the hint rectangle.
|
|
|
|
void DrawHintRect( const wxRect& r );
|
|
|
|
|
|
|
|
// Tests if the mouse position is in this window.
|
|
|
|
int HitTestWindow( wxMouseEvent& event );
|
|
|
|
|
|
|
|
// Lays out the buttons.
|
|
|
|
void LayoutMiniButtons();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Default constructor.
|
|
|
|
wxToolWindow();
|
|
|
|
|
|
|
|
// Destructor.
|
|
|
|
~wxToolWindow();
|
|
|
|
|
|
|
|
// Sets the client for this tool window.
|
|
|
|
void SetClient( wxWindow* pWnd );
|
|
|
|
|
|
|
|
// Returns the client window.
|
|
|
|
wxWindow* GetClient();
|
|
|
|
|
|
|
|
// Sets the title font.
|
|
|
|
void SetTitleFont( wxFont& font );
|
|
|
|
|
|
|
|
// Adds a button. Buttons are added in right-to-left order.
|
|
|
|
void AddMiniButton( cbMiniButton* pBtn );
|
|
|
|
|
|
|
|
// Responds to a paint event.
|
|
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
|
|
|
|
// Responds to a mouse move event.
|
|
|
|
void OnMotion( wxMouseEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Responds to a mouse left down event.
|
|
|
|
void OnLeftDown( wxMouseEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Responds to a mouse left up event.
|
|
|
|
void OnLeftUp( wxMouseEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Responds to a size event.
|
|
|
|
void OnSize( wxSizeEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Responds to an erase background event.
|
|
|
|
void OnEraseBackground( wxEraseEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Returns the preferred size for the window.
|
|
|
|
virtual wxSize GetPreferredSize( const wxSize& given );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Called when a mini button is clicked.
|
|
|
|
// By default, does nothing.
|
2004-01-29 18:11:29 -05:00
|
|
|
virtual void OnMiniButtonClicked( int WXUNUSED(btnIdx) ) {}
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Handles clicking on the title. By default, does nothing.
|
2004-01-29 18:11:29 -05:00
|
|
|
virtual bool HandleTitleClick( wxMouseEvent& WXUNUSED(event) ) { return false; }
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// FIXME:: the code below should be moved to a separate file
|
|
|
|
|
|
|
|
#include "wx/fl/controlbar.h"
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
|
|
|
|
titlebar.
|
|
|
|
*/
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
class cbMiniButton : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
wxPoint mPos;
|
|
|
|
wxSize mDim;
|
|
|
|
bool mVisible;
|
|
|
|
bool mEnabled;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
wxFrameLayout* mpLayout;
|
|
|
|
cbDockPane* mpPane;
|
|
|
|
cbPluginBase* mpPlugin;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
wxWindow* mpWnd;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
bool mWasClicked;
|
|
|
|
bool mDragStarted;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
bool mPressed;
|
2001-07-24 11:27:12 -04:00
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Default constructor.
|
|
|
|
cbMiniButton();
|
|
|
|
|
|
|
|
// Set the position of the button.
|
|
|
|
void SetPos( const wxPoint& pos );
|
|
|
|
|
2004-06-07 12:02:23 -04:00
|
|
|
// Returns true if the given position was over the button.
|
2002-01-21 17:34:42 -05:00
|
|
|
bool HitTest( const wxPoint& pos );
|
|
|
|
|
|
|
|
// Responds to a left down event.
|
|
|
|
void OnLeftDown( const wxPoint& pos );
|
|
|
|
|
|
|
|
// Responds to a left up event.
|
|
|
|
void OnLeftUp( const wxPoint& pos );
|
|
|
|
|
|
|
|
// Responds to a mouse move event.
|
|
|
|
void OnMotion( const wxPoint& pos );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Refreshes the button.
|
|
|
|
void Refresh();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Draws the button. Override this to implement
|
|
|
|
// the desired appearance.
|
|
|
|
virtual void Draw( wxDC& dc );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2004-06-07 12:02:23 -04:00
|
|
|
// Returns true if the button was clicked.
|
2002-01-21 17:34:42 -05:00
|
|
|
bool WasClicked();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Reset the button.
|
|
|
|
void Reset();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Enable or disable the button.
|
|
|
|
void Enable( bool enable ) { mEnabled = enable; }
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2004-06-07 12:02:23 -04:00
|
|
|
// Returns true if this button is pressed.
|
2002-01-21 17:34:42 -05:00
|
|
|
bool IsPressed() { return mPressed; }
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
cbCloseBox is a window close button, used in a wxToolWindow titlebar.
|
|
|
|
*/
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2003-07-08 16:47:17 -04:00
|
|
|
class WXDLLIMPEXP_FL cbCloseBox : public cbMiniButton
|
2001-07-24 11:27:12 -04:00
|
|
|
{
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Draws the close button appearance.
|
|
|
|
virtual void Draw( wxDC& dc );
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
|
|
|
|
*/
|
|
|
|
|
2003-07-08 16:47:17 -04:00
|
|
|
class WXDLLIMPEXP_FL cbCollapseBox : public cbMiniButton
|
2001-07-24 11:27:12 -04:00
|
|
|
{
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
bool mIsAtLeft;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Draws the collapse button appearance.
|
|
|
|
virtual void Draw( wxDC& dc );
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
cbDockBox is a window dock button, used in a wxToolWindow titlebar.
|
|
|
|
*/
|
|
|
|
|
2003-07-08 16:47:17 -04:00
|
|
|
class WXDLLIMPEXP_FL cbDockBox : public cbMiniButton
|
2001-07-24 11:27:12 -04:00
|
|
|
{
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Draws the dock button appearance.
|
|
|
|
virtual void Draw( wxDC& dc );
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
cbFloatedBarWindow is a kind of wxToolWindow,
|
|
|
|
implementing floating toolbars.
|
|
|
|
*/
|
|
|
|
|
2003-07-08 16:47:17 -04:00
|
|
|
class WXDLLIMPEXP_FL cbFloatedBarWindow : public wxToolWindow
|
2001-07-24 11:27:12 -04:00
|
|
|
{
|
2002-01-21 17:34:42 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow )
|
2001-07-24 11:27:12 -04:00
|
|
|
protected:
|
2002-01-21 17:34:42 -05:00
|
|
|
cbBarInfo* mpBar;
|
|
|
|
wxFrameLayout* mpLayout;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
friend class cbFloatedBarWindowSerializer;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Default constructor.
|
|
|
|
cbFloatedBarWindow();
|
|
|
|
|
|
|
|
// Sets the bar information for this window.
|
|
|
|
void SetBar( cbBarInfo* pBar );
|
|
|
|
|
|
|
|
// Sets the layout for this window.
|
|
|
|
void SetLayout( wxFrameLayout* pLayout );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Returns the bar information for this window.
|
|
|
|
cbBarInfo* GetBar();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Position the floating window. The given coordinates
|
|
|
|
// are those of the bar itself; the floated container window's
|
|
|
|
// position and size are ajusted accordingly.
|
|
|
|
void PositionFloatedWnd( int scrX, int scrY,
|
|
|
|
int width, int height );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Overridden function returning the preferred size.
|
|
|
|
virtual wxSize GetPreferredSize( const wxSize& given );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Overridden function responding to mouse clicks on mini-buttons.
|
|
|
|
virtual void OnMiniButtonClicked( int btnIdx );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Overridden function responding to mouse button clicks on the titlebar.
|
|
|
|
virtual bool HandleTitleClick( wxMouseEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Responds to double-click mouse events.
|
|
|
|
void OnDblClick( wxMouseEvent& event );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __TOOLWND_G__ */
|
|
|
|
|
|
|
|
|