X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/af49c4b8a2d3553e733e71c7dd3911881f4c1a2a..bc448be3417555aa4bb57499b114d73b4036f9bb:/include/wx/generic/tabg.h diff --git a/include/wx/generic/tabg.h b/include/wx/generic/tabg.h index b71a4e902b..2666ffd601 100644 --- a/include/wx/generic/tabg.h +++ b/include/wx/generic/tabg.h @@ -5,36 +5,34 @@ // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __TABGH_G__ #define __TABGH_G__ -#if defined(__GNUG__) && !defined(__APPLE__) -#pragma interface "tabg.h" -#endif - #define WXTAB_VERSION 1.1 -#include "wx/hash.h" +#include "wx/hashmap.h" #include "wx/string.h" #include "wx/dialog.h" +#include "wx/panel.h" +#include "wx/list.h" -class WXDLLEXPORT wxTabView; +class WXDLLIMPEXP_FWD_CORE wxTabView; /* * A wxTabControl is the internal and visual representation * of the tab. */ -class WXDLLEXPORT wxTabControl: public wxObject +class WXDLLIMPEXP_CORE wxTabControl: public wxObject { DECLARE_DYNAMIC_CLASS(wxTabControl) public: wxTabControl(wxTabView *v = (wxTabView *) NULL); - ~wxTabControl(void); + virtual ~wxTabControl(void); virtual void OnDraw(wxDC& dc, bool lastInRow); void SetLabel(const wxString& str) { m_controlLabel = str; } @@ -83,38 +81,39 @@ protected: * are 3 layers in the MS Word Options dialog. */ -class WXDLLEXPORT wxTabLayer: public wxList +class WXDLLIMPEXP_CORE wxTabLayer: public wxList { - DECLARE_DYNAMIC_CLASS(wxTabLayer) }; /* * The wxTabView controls and draws the tabbed object */ +WX_DECLARE_LIST(wxTabLayer, wxTabLayerList); + #define wxTAB_STYLE_DRAW_BOX 1 // Draws 3D boxes round tab layers #define wxTAB_STYLE_COLOUR_INTERIOR 2 // Colours interior of tabs, otherwise draws outline -class WXDLLEXPORT wxTabView: public wxObject +class WXDLLIMPEXP_CORE wxTabView: public wxObject { DECLARE_DYNAMIC_CLASS(wxTabView) public: wxTabView(long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); - ~wxTabView(); + virtual ~wxTabView(); - inline int GetNumberOfLayers() const { return m_layers.Number(); } - inline wxList& GetLayers() { return m_layers; } + inline int GetNumberOfLayers() const { return m_layers.GetCount(); } + inline wxTabLayerList& GetLayers() { return m_layers; } inline void SetWindow(wxWindow* wnd) { m_window = wnd; } inline wxWindow* GetWindow(void) const { return m_window; } - + // Automatically positions tabs wxTabControl *AddTab(int id, const wxString& label, wxTabControl *existingTab = (wxTabControl *) NULL); // Remove the tab without deleting the window bool RemoveTab(int id); - - void ClearTabs(bool deleteTabs = TRUE); + + void ClearTabs(bool deleteTabs = true); bool SetTabText(int id, const wxString& label); wxString GetTabText(int id) const; @@ -124,14 +123,14 @@ public: // Draw all tabs virtual void Draw(wxDC& dc); - - // Process mouse event, return FALSE if we didn't process it + + // Process mouse event, return false if we didn't process it virtual bool OnEvent(wxMouseEvent& event); // Called when a tab is activated virtual void OnTabActivate(int activateId, int deactivateId); // Allows vetoing - virtual bool OnTabPreActivate(int WXUNUSED(activateId), int WXUNUSED(deactivateId) ) { return TRUE; }; + virtual bool OnTabPreActivate(int WXUNUSED(activateId), int WXUNUSED(deactivateId) ) { return true; }; // Allows use of application-supplied wxTabControl classes. virtual wxTabControl *OnCreateTabControl(void) { return new wxTabControl(this); } @@ -140,26 +139,26 @@ public: void SetShadowColour(const wxColour& col); void SetBackgroundColour(const wxColour& col); inline void SetTextColour(const wxColour& col) { m_textColour = col; } - + inline wxColour GetHighlightColour(void) const { return m_highlightColour; } inline wxColour GetShadowColour(void) const { return m_shadowColour; } inline wxColour GetBackgroundColour(void) const { return m_backgroundColour; } inline wxColour GetTextColour(void) const { return m_textColour; } - inline wxPen *GetHighlightPen(void) const { return m_highlightPen; } - inline wxPen *GetShadowPen(void) const { return m_shadowPen; } - inline wxPen *GetBackgroundPen(void) const { return m_backgroundPen; } - inline wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; } - + inline const wxPen *GetHighlightPen(void) const { return m_highlightPen; } + inline const wxPen *GetShadowPen(void) const { return m_shadowPen; } + inline const wxPen *GetBackgroundPen(void) const { return m_backgroundPen; } + inline const wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; } + inline void SetViewRect(const wxRect& rect) { m_tabViewRect = rect; } inline wxRect GetViewRect(void) const { return m_tabViewRect; } - + // Calculate tab width to fit to view, and optionally adjust the view // to fit the tabs exactly. - int CalculateTabWidth(int noTabs, bool adjustView = FALSE); + int CalculateTabWidth(int noTabs, bool adjustView = false); inline void SetTabStyle(long style) { m_tabStyle = style; } inline long GetTabStyle(void) const { return m_tabStyle; } - + inline void SetTabSize(int w, int h) { m_tabWidth = w; m_tabHeight = h; } inline int GetTabWidth(void) const { return m_tabWidth; } inline int GetTabHeight(void) const { return m_tabHeight; } @@ -169,35 +168,35 @@ public: // Returns the total height of the tabs component -- this may be several // times the height of a tab, if there are several tab layers (rows). int GetTotalTabHeight(); - + inline int GetTopMargin(void) const { return m_topMargin; } inline void SetTopMargin(int margin) { m_topMargin = margin; } - - void SetTabSelection(int sel, bool activateTool = TRUE); + + void SetTabSelection(int sel, bool activateTool = true); inline int GetTabSelection() const { return m_tabSelection; } - + // Find tab control for id wxTabControl *FindTabControlForId(int id) const ; // Find tab control for layer, position (starting from zero) wxTabControl *FindTabControlForPosition(int layer, int position) const ; - + inline int GetHorizontalTabOffset() const { return m_tabHorizontalOffset; } inline int GetHorizontalTabSpacing() const { return m_tabHorizontalSpacing; } inline void SetHorizontalTabOffset(int sp) { m_tabHorizontalOffset = sp; } inline void SetHorizontalTabSpacing(int sp) { m_tabHorizontalSpacing = sp; } - + inline void SetVerticalTabTextSpacing(int s) { m_tabVerticalTextSpacing = s; } inline int GetVerticalTabTextSpacing() const { return m_tabVerticalTextSpacing; } - + inline wxFont *GetTabFont() const { return (wxFont*) & m_tabFont; } inline void SetTabFont(const wxFont& f) { m_tabFont = f; } inline wxFont *GetSelectedTabFont() const { return (wxFont*) & m_tabSelectedFont; } inline void SetSelectedTabFont(const wxFont& f) { m_tabSelectedFont = f; } // Find the node and the column at which this control is positioned. - wxNode *FindTabNodeAndColumn(wxTabControl *control, int *col) const ; - + wxList::compatibility_iterator FindTabNodeAndColumn(wxTabControl *control, int *col) const ; + // Do the necessary to change to this tab virtual bool ChangeTab(wxTabControl *control); @@ -209,8 +208,8 @@ public: protected: // List of layers, from front to back. - wxList m_layers; - + wxTabLayerList m_layers; + // Selected tab int m_tabSelection; @@ -222,13 +221,13 @@ protected: // Usual tab width int m_tabWidth; - + // Space between tabs int m_tabHorizontalSpacing; - + // Space between top of normal tab and text int m_tabVerticalTextSpacing; - + // Horizontal offset of each tab row above the first int m_tabHorizontalOffset; @@ -239,7 +238,7 @@ protected: // The position and size of the view above which the tabs are placed. // I.e., the internal client area of the sheet. wxRect m_tabViewRect; - + // Bitlist of styles long m_tabStyle; @@ -248,16 +247,16 @@ protected: wxColour m_shadowColour; wxColour m_backgroundColour; wxColour m_textColour; - + // Pen and brush cache - wxPen* m_highlightPen; - wxPen* m_shadowPen; - wxPen* m_backgroundPen; - wxBrush* m_backgroundBrush; - + const wxPen* m_highlightPen; + const wxPen* m_shadowPen; + const wxPen* m_backgroundPen; + const wxBrush* m_backgroundBrush; + wxFont m_tabFont; wxFont m_tabSelectedFont; - + int m_noTabs; wxWindow* m_window; @@ -266,85 +265,94 @@ protected: /* * A dialog box class that is tab-friendly */ - -class WXDLLEXPORT wxTabbedDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxTabbedDialog) - -public: - wxTabbedDialog(wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxDialogNameStr); - ~wxTabbedDialog(void); - - inline wxTabView *GetTabView() const { return m_tabView; } - inline void SetTabView(wxTabView *v) { m_tabView = v; } +class WXDLLIMPEXP_CORE wxTabbedDialog : public wxDialog +{ + DECLARE_DYNAMIC_CLASS(wxTabbedDialog) - void OnCloseWindow(wxCloseEvent& event); - void OnMouseEvent(wxMouseEvent& event); - void OnPaint(wxPaintEvent& event); +public: + wxTabbedDialog(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long windowStyle = wxDEFAULT_DIALOG_STYLE, + const wxString& name = wxDialogNameStr); + virtual ~wxTabbedDialog(); + + wxTabView *GetTabView() const { return m_tabView; } + void SetTabView(wxTabView *v) { m_tabView = v; } + + void OnCloseWindow(wxCloseEvent& event); + void OnMouseEvent(wxMouseEvent& event); + void OnPaint(wxPaintEvent& event); protected: - wxTabView* m_tabView; - -DECLARE_EVENT_TABLE() + wxTabView* m_tabView; + +private: + DECLARE_EVENT_TABLE() }; /* * A panel class that is tab-friendly */ -class WXDLLEXPORT wxTabbedPanel: public wxPanel +class WXDLLIMPEXP_CORE wxTabbedPanel : public wxPanel { -DECLARE_DYNAMIC_CLASS(wxTabbedPanel) - + DECLARE_DYNAMIC_CLASS(wxTabbedPanel) + public: + wxTabbedPanel(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long windowStyle = 0, + const wxString& name = wxPanelNameStr); + virtual ~wxTabbedPanel(); + + wxTabView *GetTabView() const { return m_tabView; } + void SetTabView(wxTabView *v) { m_tabView = v; } - wxTabbedPanel(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long windowStyle = 0, const wxString& name = wxPanelNameStr); - ~wxTabbedPanel(void); - - inline wxTabView *GetTabView() const { return m_tabView; } - inline void SetTabView(wxTabView *v) { m_tabView = v; } - - void OnMouseEvent(wxMouseEvent& event); - void OnPaint(wxPaintEvent& event); + void OnMouseEvent(wxMouseEvent& event); + void OnPaint(wxPaintEvent& event); protected: - wxTabView* m_tabView; - -DECLARE_EVENT_TABLE() + wxTabView* m_tabView; + +private: + DECLARE_EVENT_TABLE() }; -class WXDLLEXPORT wxPanelTabView: public wxTabView +WX_DECLARE_HASH_MAP(int, wxWindow*, wxIntegerHash, wxIntegerEqual, + wxIntToWindowHashMap); + +class WXDLLIMPEXP_CORE wxPanelTabView : public wxTabView { -DECLARE_DYNAMIC_CLASS(wxPanelTabView) + DECLARE_DYNAMIC_CLASS(wxPanelTabView) + public: - wxPanelTabView(wxPanel *pan, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); - ~wxPanelTabView(void); + wxPanelTabView(wxPanel *pan, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); + virtual ~wxPanelTabView(void); - // Called when a tab is activated - virtual void OnTabActivate(int activateId, int deactivateId); + // Called when a tab is activated + virtual void OnTabActivate(int activateId, int deactivateId); + + // Specific to this class + void AddTabWindow(int id, wxWindow *window); + wxWindow *GetTabWindow(int id) const ; + void ClearWindows(bool deleteWindows = true); + wxWindow *GetCurrentWindow() const { return m_currentWindow; } - // Specific to this class - void AddTabWindow(int id, wxWindow *window); - wxWindow *GetTabWindow(int id) const ; - void ClearWindows(bool deleteWindows = TRUE); - inline wxWindow *GetCurrentWindow() const { return m_currentWindow; } - - void ShowWindowForTab(int id); - inline wxList& GetWindows() const { return (wxList&) m_tabWindows; } + void ShowWindowForTab(int id); + // wxList& GetWindows() const { return (wxList&) m_tabWindows; } protected: - // List of panels, one for each tab. Indexed - // by tab ID. - wxList m_tabWindows; - wxWindow* m_currentWindow; - wxPanel* m_panel; + // List of panels, one for each tab. Indexed + // by tab ID. + wxIntToWindowHashMap m_tabWindows; + wxWindow* m_currentWindow; + wxPanel* m_panel; }; #endif