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__
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "toolwnd.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/frame.h"
|
|
|
|
#include "wx/dynarray.h"
|
|
|
|
|
|
|
|
// fixed settings
|
|
|
|
|
|
|
|
#define BTN_BOX_HEIGHT 12
|
|
|
|
#define BTN_BOX_WIDTH 12
|
|
|
|
#define BTN_X_WIEGHT 2
|
|
|
|
|
|
|
|
class cbMiniButton;
|
|
|
|
|
|
|
|
typedef cbMiniButton* cbMinitButtonPtrT;
|
|
|
|
|
|
|
|
WX_DEFINE_ARRAY( cbMinitButtonPtrT, cbMiniButtonArrayT );
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
class wxToolWindow : public wxFrame
|
|
|
|
{
|
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.
|
|
|
|
virtual void OnMiniButtonClicked( int 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.
|
|
|
|
virtual bool HandleTitleClick( wxMouseEvent& 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 );
|
|
|
|
|
|
|
|
// Returns TRUE if the given position was over the button.
|
|
|
|
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
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Returns TRUE if the button was clicked.
|
|
|
|
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
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Returns TRUE if this button is pressed.
|
|
|
|
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
|
|
|
|
|
|
|
class cbCloseBox : public cbMiniButton
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
class cbCollapseBox : public cbMiniButton
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
class cbDockBox : public cbMiniButton
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
class cbFloatedBarWindow : public wxToolWindow
|
|
|
|
{
|
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__ */
|
|
|
|
|
|
|
|
|