]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/framelayout/src/dyntbar.h
reduce flicker in header window when deleting items and let space select items even...
[wxWidgets.git] / utils / framelayout / src / dyntbar.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: ??/10/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __DYNTBAR_G__
13#define __DYNTBAR_G__
14
15#include "wx/tbarbase.h"
16#include "wx/dynarray.h"
17
18// layout item
19
20class wxToolLayoutItem : public wxObject
21{
22public:
23 wxRect mRect;
24 bool mIsSeparator;
25};
26
27class wxDynToolInfo;
28
29typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
30typedef wxDynToolInfo* wxDynToolInfoPtrT;
31
32
33WX_DEFINE_ARRAY( wxToolLayoutItemPtrT, wxLayoutItemArrayT );
34WX_DEFINE_ARRAY( wxDynToolInfoPtrT, wxDynToolInfoArrayT );
35
36// base class for layouting algorithm implementations
37
38class LayoutManagerBase
39{
40public:
41 virtual void Layout( const wxSize& parentDim,
42 wxSize& resultingDim,
43 wxLayoutItemArrayT& items,
44 int horizGap,
45 int vertGap ) = 0;
46
47 virtual ~LayoutManagerBase() {}
48};
49
50// layouts items in left-to-right order from
51// top towards bottom
52
53class BagLayout : public LayoutManagerBase
54{
55public:
56 virtual void Layout( const wxSize& parentDim,
57 wxSize& resultingDim,
58 wxLayoutItemArrayT& items,
59 int horizGap,
60 int vertGap );
61};
62
63class wxDynToolInfo : public wxToolLayoutItem
64{
65 DECLARE_DYNAMIC_CLASS(wxDynToolInfo)
66
67public:
68 wxWindow* mpToolWnd;
69 int mIndex;
70 wxSize mRealSize;
71};
72
73// layouting orientations for tools
74
75#define LO_HORIZONTAL 0
76#define LO_VERTICAL 1
77#define LO_FIT_TO_WINDOW 2
78
79// class manages containment and layouting of tool-windows
80
81class wxDynamicToolBar : public wxToolBarBase
82{
83 DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
84protected:
85
86 friend class wxDynamicToolBarSerializer;
87
88 wxDynToolInfoArrayT mTools;
89 LayoutManagerBase* mpLayoutMan;
90
91protected:
92 virtual void SizeToolWindows();
93
94public: /* public properties */
95
96 int mSepartorSize; // default: 8
97 int mVertGap; // default: 0
98 int mHorizGap; // default: 0
99
100public:
101 wxDynamicToolBar();
102
103 wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
104 const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
105 const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
106
107 ~wxDynamicToolBar(void);
108
109 bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
110 const long style = wxNO_BORDER, const int orientation = wxVERTICAL, const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
111
112 // overridables
113
114 virtual void AddTool( int toolIndex,
115 wxWindow* pToolWindow,
116 const wxSize& size = wxDefaultSize );
117
118 virtual void AddTool( int toolIndex,
119 const wxString& imageFileName,
120 int imageFileType = wxBITMAP_TYPE_BMP,
121 const wxString& labelText = "", bool alignTextRight = FALSE,
122 bool isFlat = TRUE );
123 virtual void AddTool( int toolIndex, wxBitmap labelBmp,
124 const wxString& labelText = "", bool alignTextRight = FALSE,
125 bool isFlat = TRUE );
126
127 // method from wxToolBarBase (for compatibility), only
128 // first two arguments are valid
129
130 virtual wxToolBarTool *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
131 const bool toggle = FALSE, const long xPos = -1, const long yPos = -1, wxObject *clientData = NULL,
132 const wxString& helpString1 = "", const wxString& helpString2 = "");
133
134 virtual void AddSeparator( wxWindow* pSepartorWnd = NULL );
135
136 wxDynToolInfo* GetToolInfo( int toolIndex );
137
138 void RemveTool( int toolIndex );
139
140 // the default implementation draws shaded line
141 virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );
142
143 // see definitions of orientation types
144 virtual bool Layout();
145
146 virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );
147
148 virtual LayoutManagerBase* CreateDefaulLayout() { return new BagLayout(); }
149
150 virtual void SetLayout( LayoutManagerBase* pLayout );
151
152 virtual void EnableTool(const int toolIndex, const bool enable = TRUE);
153
154 // event handlers
155
156 void OnSize( wxSizeEvent& event );
157 void OnPaint( wxPaintEvent& event );
158 void OnEraseBackground( wxEraseEvent& event );
159
160 // overriden from wxToolBarBase
161
162 virtual bool Realize(void);
163
164 DECLARE_EVENT_TABLE()
165};
166
167#endif