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