2000-01-28 10:25:32 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2001-05-28 08:10:04 -04:00
|
|
|
// Name: tabpgwin.h
|
2000-01-28 10:25:32 -05:00
|
|
|
// Purpose: Contrib. demo
|
|
|
|
// Author: Aleksandras Gluchovas
|
2001-02-12 14:23:44 -05:00
|
|
|
// Modified by: 19990908 : mj
|
2000-01-28 10:25:32 -05:00
|
|
|
// 19990909 :
|
|
|
|
// - rename to tabpgwin
|
|
|
|
// - restruction of Variable declaration
|
|
|
|
// - to prevent Warnings under MingGW32
|
2001-02-12 14:23:44 -05:00
|
|
|
// Modified by: 19990909 : mj
|
2004-06-01 14:27:09 -04:00
|
|
|
// - mNoVertScroll true = no / false = Original Code
|
2001-02-01 15:24:44 -05:00
|
|
|
// the Original Code Paints a Vertical Scroll in wxPagedWindow
|
2004-06-01 14:27:09 -04:00
|
|
|
// which is not needed in this Version. Use true for this.
|
2000-01-28 10:25:32 -05:00
|
|
|
// Created: 07/09/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Aleksandras Gluchovas
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-28 08:10:04 -04:00
|
|
|
#ifndef __TABPGWIN_G__
|
|
|
|
#define __TABPGWIN_G__
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
#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;
|
|
|
|
void HideInactiveTabs( bool andRepaint );
|
|
|
|
|
|
|
|
// overrride,to provide different font for tab-labels
|
|
|
|
|
|
|
|
virtual wxFont GetLabelingFont();
|
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// FOR NOW:: scrollbars are actually related to wxPagedWindow
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
wxScrollBar* mpTabScroll;
|
|
|
|
wxScrollBar* mpHorizScroll;
|
|
|
|
wxScrollBar* mpVertScroll;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
// public properties (invoke ReclaclLayout(true) to apply changes)
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
wxPen mWhitePen; // default: RGB(255,255,255)
|
|
|
|
wxPen mGrayPen; // default: RGB(192,192,192)
|
|
|
|
wxPen mDarkPen; // default: RGB(128,128,128)
|
|
|
|
wxPen mBlackPen; // default: RGB( 0, 0, 0)
|
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
size_t mActiveTab;
|
2000-01-28 10:25:32 -05:00
|
|
|
int mTitleHeight;
|
|
|
|
int mLayoutType;
|
|
|
|
|
|
|
|
// notifications (can be handled by derivatives)
|
|
|
|
|
2004-04-06 09:19:42 -04:00
|
|
|
virtual void OnTabAdded( twTabInfo* WXUNUSED(pInfo) ) {}
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2001-07-22 10:09:23 -04:00
|
|
|
virtual void AddTab( wxWindow* pContent, // contained window
|
|
|
|
wxString tabText, // tab label
|
2004-01-11 17:08:25 -05:00
|
|
|
wxString imageFileName = _T(""), // if "", only text label is displayed
|
2001-07-22 10:09:23 -04:00
|
|
|
wxBitmapType imageType = wxBITMAP_TYPE_BMP );
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
// 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,
|
2004-10-05 11:38:40 -04:00
|
|
|
wxBitmap* pImage );
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
virtual void RecalcLayout( bool andRepaint = true );
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
// 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
|
|
|
|
*/
|
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
class wxPagedWindow : public wxTabbedWindow
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS( wxPagedWindow )
|
2000-01-28 10:25:32 -05:00
|
|
|
// the protected: public: changes prevents Warnings in gcc
|
|
|
|
protected:
|
|
|
|
bool mScrollEventInProgress;
|
|
|
|
public:
|
|
|
|
int mTabTrianGap;
|
|
|
|
wxBrush mWhiteBrush;
|
|
|
|
wxBrush mGrayBrush;
|
|
|
|
int mCurentRowOfs;
|
|
|
|
int mAdjustableTitleRowLen; // setup by dragging mini-sash
|
|
|
|
// with the mosue pointer
|
|
|
|
protected:
|
|
|
|
// drag&drop state variables
|
|
|
|
bool mIsDragged;
|
|
|
|
int mDagOrigin;
|
|
|
|
bool mCursorChanged;
|
|
|
|
wxCursor mResizeCursor;
|
|
|
|
wxCursor mNormalCursor;
|
|
|
|
int mOriginalTitleRowLen;
|
|
|
|
|
|
|
|
public:
|
|
|
|
int mTitleRowStart;
|
|
|
|
int mResizeNailGap;
|
|
|
|
int mTitleRowLen; // actual title row length
|
2004-06-01 14:27:09 -04:00
|
|
|
int mNoVertScroll; // No Vertical Scroll true/false
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
2001-02-01 15:24:44 -05:00
|
|
|
wxPagedWindow();
|
2004-10-05 11:38:40 -04:00
|
|
|
~wxPagedWindow(){};
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
virtual void RecalcLayout( bool andRepaint = true );
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
// 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();
|
2004-10-05 11:38:40 -04:00
|
|
|
~twTabInfo(){};
|
2000-01-28 10:25:32 -05:00
|
|
|
|
|
|
|
int ImgWidth();
|
|
|
|
int ImgHeight();
|
|
|
|
int ImageToTxtGap( int prefGap );
|
|
|
|
|
|
|
|
bool HasImg();
|
|
|
|
wxBitmap& GetImg();
|
|
|
|
// bool HasText();
|
|
|
|
unsigned int HasText();
|
|
|
|
wxString& GetText();
|
|
|
|
wxWindow& GetContent();
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxWindow* mpContent;
|
|
|
|
wxBitmap mBitMap;
|
|
|
|
|
|
|
|
wxString mText;
|
|
|
|
wxSize mDims;
|
|
|
|
|
|
|
|
// used for serialization
|
|
|
|
wxString mImageFile;
|
|
|
|
long mImageType;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|