git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3345 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
		
			
				
	
	
		
			263 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			263 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/////////////////////////////////////////////////////////////////////////////
 | 
						|
// Name:        No names yet.
 | 
						|
// Purpose:     Contrib. demo
 | 
						|
// Author:      Aleksandras Gluchovas
 | 
						|
// Modified by:
 | 
						|
// Created:     07/09/98
 | 
						|
// RCS-ID:      $Id$
 | 
						|
// Copyright:   (c) Aleksandras Gluchovas
 | 
						|
// Licence:   	wxWindows license
 | 
						|
/////////////////////////////////////////////////////////////////////////////
 | 
						|
 | 
						|
#ifndef __CONTROLAREA_G__
 | 
						|
#define __CONTROLAREA_G__
 | 
						|
 | 
						|
#ifdef __GNUG__
 | 
						|
#pragma interface "controlarea.h"
 | 
						|
#endif
 | 
						|
 | 
						|
#include "wx/defs.h"
 | 
						|
#include "wx/window.h"
 | 
						|
#include "wx/string.h"
 | 
						|
 | 
						|
#define WXCONTROLAREA_VERSION      1.0
 | 
						|
 | 
						|
// layout types for title bars of the tabs
 | 
						|
// (are selected up by evaluating the available free space )
 | 
						|
 | 
						|
class twTabInfo; // forward decl.
 | 
						|
 | 
						|
#define wxTITLE_IMG_AND_TEXT 0
 | 
						|
#define wxTITLE_IMG_ONLY     1
 | 
						|
#define wxTITLE_BORDER_ONLY  2
 | 
						|
 | 
						|
/*
 | 
						|
 * class manages and decorates contained "tab"-windows. 
 | 
						|
 * Draws decorations similar to those in "Project Workplace"
 | 
						|
 * of Microsoft Developer Studio 4.xx 
 | 
						|
 */
 | 
						|
 | 
						|
class wxTabbedWindow : public wxPanel
 | 
						|
{
 | 
						|
	DECLARE_DYNAMIC_CLASS( wxTabbedWindow )
 | 
						|
 | 
						|
public:	
 | 
						|
 | 
						|
	friend class wxTabbedWindowSerializer;
 | 
						|
 | 
						|
	wxList mTabs;
 | 
						|
	int    mActiveTab;
 | 
						|
	int    mTitleHeight;
 | 
						|
	int    mLayoutType;
 | 
						|
 | 
						|
	void HideInactiveTabs( bool andRepaint );
 | 
						|
 | 
						|
	// overrride,to provide different font for tab-labels
 | 
						|
 | 
						|
	virtual wxFont GetLabelingFont();
 | 
						|
 | 
						|
	// FOR NOW:: scrollbars are actually related to wxPaggedWindow
 | 
						|
 | 
						|
	wxScrollBar* mpTabScroll;
 | 
						|
	wxScrollBar* mpHorizScroll;
 | 
						|
	wxScrollBar* mpVertScroll;
 | 
						|
 | 
						|
public:
 | 
						|
 | 
						|
	// public properties (invoke ReclaclLayout(TRUE) to apply changes)
 | 
						|
 | 
						|
	wxPen  mWhitePen;        // default: RGB(255,255,255)
 | 
						|
	wxPen  mLightPen;		 // wxSYS_COLOUR_3DHIGHLIGHT
 | 
						|
	wxPen  mGrayPen;         // wxSYS_COLOUR_3DFACE
 | 
						|
	wxPen  mDarkPen;         // wxSYS_COLOUR_3DSHADOW
 | 
						|
	wxPen  mBlackPen;        // default: RGB(  0,  0,  0)
 | 
						|
 | 
						|
	int    mVertGap;         // default: 3
 | 
						|
	int    mHorizGap;        // default: 5
 | 
						|
	int    mTitleVertGap;    // default: 3
 | 
						|
	int    mTitleHorizGap;   // default: 4
 | 
						|
	int    mImageTextGap;    // default: 2
 | 
						|
	int    mFirstTitleGap;   // default: 11
 | 
						|
	int    mBorderOnlyWidth; // default: 8
 | 
						|
 | 
						|
	// notifications (can be handled by derivatives)
 | 
						|
 | 
						|
	virtual void OnTabAdded( twTabInfo* pInfo ) {}
 | 
						|
 | 
						|
	virtual void SizeTabs(int x,int y, int width, int height, bool repant);
 | 
						|
 | 
						|
public:
 | 
						|
	wxTabbedWindow();
 | 
						|
	virtual ~wxTabbedWindow();
 | 
						|
 | 
						|
	// tabs can be also added when the window is 
 | 
						|
	// already displayed - "on the fly"
 | 
						|
 | 
						|
	virtual void AddTab( wxWindow* pContent,           // contained window
 | 
						|
						 wxString  tabText,		       // tab label
 | 
						|
		                 wxString  imageFileName = "", // if "", only text label is displayed
 | 
						|
						 long      imageType     = wxBITMAP_TYPE_BMP );
 | 
						|
 | 
						|
	// NOTE:: if this AddTab(..) overload is called, the 
 | 
						|
	//        image bitmap will not be serialized (if performed),
 | 
						|
	//        use the above method instead, so that images could 
 | 
						|
	//        be restored using the given file names
 | 
						|
 | 
						|
	virtual void AddTab( wxWindow* pContent,
 | 
						|
						 wxString  tabText,
 | 
						|
		                 wxBitmap* pImage = NULL );
 | 
						|
 | 
						|
 | 
						|
	virtual void RemoveTab( int tabNo );
 | 
						|
 | 
						|
	/* misc accessors */
 | 
						|
 | 
						|
	virtual int GetTabCount();
 | 
						|
	virtual wxWindow* GetTab( int tabNo );
 | 
						|
	virtual wxWindow* GetActiveTab();
 | 
						|
	virtual void SetActiveTab( int tabNo );
 | 
						|
 | 
						|
	void DrawShadedRect( int x, int y, int width, int height,
 | 
						|
						 wxPen& upperPen, wxPen& lowerPen, wxDC& dc );
 | 
						|
 | 
						|
	virtual void DrawDecorations( wxDC& dc );
 | 
						|
 | 
						|
	// return -1, if non of the title bars was hitted,
 | 
						|
	// otherwise the index of the hitted tab title bar
 | 
						|
 | 
						|
	virtual int HitTest( const wxPoint& pos );
 | 
						|
 | 
						|
	// should be invoked to redisplay window with changed properties
 | 
						|
 | 
						|
	virtual void RecalcLayout( bool andRepaint = TRUE );
 | 
						|
 | 
						|
	// event handlers
 | 
						|
 | 
						|
	void OnPaint( wxPaintEvent& event );
 | 
						|
	void OnSize ( wxSizeEvent& event );
 | 
						|
 | 
						|
	void OnBkErase( wxEraseEvent& event );
 | 
						|
	void OnLButtonDown( wxMouseEvent& event );
 | 
						|
 | 
						|
	DECLARE_EVENT_TABLE()
 | 
						|
};
 | 
						|
 | 
						|
/*
 | 
						|
 * class manages and decorates contained "sheets" (or pages). 
 | 
						|
 * Draws decorations similar to those in "Output window"
 | 
						|
 * of Microsoft Developer Studio 4.xx 
 | 
						|
 */
 | 
						|
 | 
						|
class wxPaggedWindow : public wxTabbedWindow
 | 
						|
{
 | 
						|
	DECLARE_DYNAMIC_CLASS( wxPaggedWindow )
 | 
						|
protected:
 | 
						|
 | 
						|
	bool         mScrollEventInProgress;
 | 
						|
 | 
						|
	// drag&drop state variables
 | 
						|
 | 
						|
	bool         mIsDragged;
 | 
						|
	int          mDagOrigin;
 | 
						|
	wxCursor     mResizeCursor;
 | 
						|
	wxCursor     mNormalCursor;
 | 
						|
	bool         mCursorChanged;
 | 
						|
	int          mOriginalTitleRowLen;
 | 
						|
 | 
						|
	void DrawPaperBar( twTabInfo& tab, int x, int y, 
 | 
						|
					   wxBrush& brush, wxPen& pen, wxDC& dc );
 | 
						|
 | 
						|
	int GetWholeTabRowLen();
 | 
						|
 | 
						|
	// adjusts scorllbars to fit around tabs
 | 
						|
 | 
						|
	virtual void OnTabAdded( twTabInfo* pInfo );
 | 
						|
 | 
						|
	// sets smaller font for page-labels
 | 
						|
 | 
						|
	virtual wxFont GetLabelingFont();
 | 
						|
 | 
						|
public:
 | 
						|
	int          mTitleRowStart;
 | 
						|
	int          mResizeNailGap;
 | 
						|
	int          mTabTrianGap;  
 | 
						|
	int          mTitleRowLen;	         // actual title row length
 | 
						|
	int          mAdjustableTitleRowLen; // setup by dragging mini-sash 
 | 
						|
	                                     // with the mosue pointer
 | 
						|
	int          mCurentRowOfs;
 | 
						|
 | 
						|
	wxBrush      mGrayBrush;
 | 
						|
	wxBrush      mWhiteBrush;
 | 
						|
 | 
						|
public:
 | 
						|
	wxPaggedWindow();
 | 
						|
	~wxPaggedWindow();
 | 
						|
 | 
						|
	// NOTE:: use public methods of the base class
 | 
						|
	//        to add "pages" to this window
 | 
						|
 | 
						|
	/* misc accessors */
 | 
						|
 | 
						|
	// below two methods should be called after
 | 
						|
	// the tabs were added (AddTab(..)). Set up
 | 
						|
	// these scrollbars to match the needs of the
 | 
						|
	// tabs added into this area
 | 
						|
 | 
						|
	wxScrollBar& GetVerticalScrollBar();
 | 
						|
	wxScrollBar& GetHorizontalScrollBar();
 | 
						|
 | 
						|
	virtual void DrawDecorations( wxDC& dc );
 | 
						|
 | 
						|
	// return -1, if non of the title bars was hitted,
 | 
						|
	// otherwise the index of the hitted tab title bar
 | 
						|
 | 
						|
	virtual int HitTest( const wxPoint& pos );
 | 
						|
 | 
						|
	virtual void RecalcLayout( bool andRepaint = TRUE );
 | 
						|
 | 
						|
	// event handlers
 | 
						|
 | 
						|
	void OnPaint( wxPaintEvent& event );
 | 
						|
	void OnSize ( wxSizeEvent& event );
 | 
						|
	void OnLButtonDown( wxMouseEvent& event );
 | 
						|
	void OnLButtonUp  ( wxMouseEvent& event );
 | 
						|
	void OnMouseMove  ( wxMouseEvent& event );
 | 
						|
	void OnScroll     ( wxScrollEvent& event );
 | 
						|
 | 
						|
	DECLARE_EVENT_TABLE()
 | 
						|
};
 | 
						|
 | 
						|
// helper structure of wxTabbedWindow
 | 
						|
 | 
						|
class twTabInfo : public wxObject
 | 
						|
{
 | 
						|
	DECLARE_DYNAMIC_CLASS( twTabInfo )
 | 
						|
public:
 | 
						|
	twTabInfo();
 | 
						|
	~twTabInfo();
 | 
						|
 | 
						|
	int ImgWidth();
 | 
						|
	int ImgHeight();
 | 
						|
	int ImageToTxtGap( int prefGap );
 | 
						|
 | 
						|
	bool HasImg();
 | 
						|
	wxBitmap& GetImg();
 | 
						|
	bool HasText();
 | 
						|
	wxString& GetText();
 | 
						|
	wxWindow& GetContent();
 | 
						|
 | 
						|
public:
 | 
						|
	wxWindow* mpContent;
 | 
						|
	wxBitmap  mBitMap;  
 | 
						|
 | 
						|
	wxString  mText;
 | 
						|
	wxSize    mDims;
 | 
						|
 | 
						|
	// used for serialization
 | 
						|
	wxString  mImageFile;
 | 
						|
	long      mImageType;
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
#endif
 |