~ubuntu-dev/wxwidgets2.6/upstream-debian

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/////////////////////////////////////////////////////////////////////////////
// Name:        dyntbar.h
// Purpose:     wxDynamicToolBar header
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     ??/10/98
// RCS-ID:      $Id: dyntbar.h,v 1.16 2004/07/20 10:08:27 ABX Exp $
// Copyright:   (c) Aleksandras Gluchovas
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef __DYNTBAR_G__
#define __DYNTBAR_G__

#if defined(__GNUG__) && !defined(__APPLE__)
    #pragma interface "dyntbar.h"
#endif

#include "wx/tbarbase.h"
#include "wx/dynarray.h"
#include "wx/fl/fldefs.h"

/*
Tool layout item.
*/

class WXDLLIMPEXP_FL wxToolLayoutItem : public wxObject
{
    DECLARE_DYNAMIC_CLASS(wxToolLayoutItem)

public:
    wxRect    mRect;
    bool      mIsSeparator;
};

class WXDLLIMPEXP_FL wxDynToolInfo;

typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
typedef wxDynToolInfo*    wxDynToolInfoPtrT;

WXFL_DEFINE_ARRAY_PTR( wxToolLayoutItemPtrT, wxLayoutItemArrayT  );
WXFL_DEFINE_ARRAY_PTR( wxDynToolInfoPtrT,    wxDynToolInfoArrayT );

/*
This is a base class for layout algorithm implementations.
*/

class WXDLLIMPEXP_FL LayoutManagerBase
{
public:
        // Constructor.
    virtual void Layout( const wxSize&       parentDim,
                         wxSize&             resultingDim,
                         wxLayoutItemArrayT& items,
                         int                 horizGap,
                         int                 vertGap   ) = 0;

        // Destructor.
    virtual ~LayoutManagerBase() {}
};

/*
BagLayout lays out items in left-to-right order from
top to bottom.
*/

class WXDLLIMPEXP_FL BagLayout : public LayoutManagerBase
{
public:
        // Constructor.
    virtual void Layout( const wxSize&       parentDim, 
                         wxSize&             resultingDim,
                         wxLayoutItemArrayT& items,
                         int                 horizGap,
                         int                 vertGap   );
};

/*
This class holds dynamic toolbar item information.
*/

class WXDLLIMPEXP_FL wxDynToolInfo : public wxToolLayoutItem
{
    DECLARE_DYNAMIC_CLASS(wxDynToolInfo)

public:
    wxWindow* mpToolWnd;
    int       mIndex;
    wxSize    mRealSize;
};

// Layout orientations for tools

#define LO_HORIZONTAL    0
#define LO_VERTICAL      1
#define LO_FIT_TO_WINDOW 2

/*
wxDynamicToolBar manages containment and layout of tool windows.
*/

class WXDLLIMPEXP_FL wxDynamicToolBar : public wxToolBarBase
{
protected:
    friend class wxDynamicToolBarSerializer;

    wxDynToolInfoArrayT mTools;
    LayoutManagerBase*  mpLayoutMan;

protected:
        // Internal function for sizing tool windows.
    virtual void SizeToolWindows();

public: /* public properties */

    int                mSepartorSize; // default: 8
    int                mVertGap;      // default: 0
    int                mHorizGap;      // default: 0

public:
        // Default constructor.

    wxDynamicToolBar();

        // Constructor: see the documentation for wxToolBar for details.

    wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
                 const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
                 const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);

        // Destructor.

    ~wxDynamicToolBar(void);

        // Creation function: see the documentation for wxToolBar for details.

    bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
                const long style = wxNO_BORDER, const int orientation = wxVERTICAL, const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);

        // Adds a tool. See the documentation for wxToolBar for details.

    virtual void AddTool( int toolIndex, 
                              wxWindow* pToolWindow,
                              const wxSize& size = wxDefaultSize );

        // Adds a tool. See the documentation for wxToolBar for details.

    virtual void AddTool( int toolIndex,
                              const wxString& imageFileName,
                              wxBitmapType imageFileType = wxBITMAP_TYPE_BMP,
                              const wxString& labelText = wxT(""), bool alignTextRight = false,
                              bool isFlat = true );
        // Adds a tool. See the documentation for wxToolBar for details.

    virtual void AddTool( int toolIndex, wxBitmap labelBmp,
                              const wxString& labelText = wxT(""), bool alignTextRight = false,
                              bool isFlat = true );

        // Unhide method from parent.

    virtual wxToolBarToolBase *AddTool (wxToolBarToolBase *tool)
                              { return wxToolBarBase::AddTool(tool); };

    // Method from wxToolBarBase (for compatibility), only
    // the first two arguments are valid.
    // See the documentation for wxToolBar for details.

    virtual wxToolBarToolBase *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
               const bool toggle = false, const long xPos = wxDefaultCoord, const long yPos = wxDefaultCoord, wxObject *clientData = NULL,
               const wxString& helpString1 = wxT(""), const wxString& helpString2 = wxT(""));

        // Adds a separator. See the documentation for wxToolBar for details.

    virtual void AddSeparator( wxWindow* pSepartorWnd );

        // Unhide method from parent.

    virtual wxToolBarToolBase *AddSeparator()
                              { return wxToolBarBase::AddSeparator(); };

        // Returns tool information for the given tool index.

    wxDynToolInfo* GetToolInfo( int toolIndex );

        // Removes the given tool. Misspelt in order not to clash with a similar function
        // in the base class.

    void RemveTool( int toolIndex );

        // Draws a separator. The default implementation draws a shaded line.

    virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );

        // Performs layout. See definitions of orientation types.

    virtual bool Layout();

        // Returns the preferred dimension, taking the given dimension and a reference to the result.

    virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );

        // Creates the default layout (BagLayout).

    virtual LayoutManagerBase* CreateDefaultLayout() { return new BagLayout(); }

        // Sets the layout for this toolbar.

    virtual void SetLayout( LayoutManagerBase* pLayout );

        // Enables or disables the given tool.

    virtual void EnableTool(int toolIndex, bool enable = true);

        // Responds to size events, calling Layout.

    void OnSize( wxSizeEvent& event );

        // Responds to paint events, drawing separators.

    void OnPaint( wxPaintEvent& event );

        // Responds to background erase events. Currently does nothing.

    void OnEraseBackground( wxEraseEvent& event );

        // Overriden from wxToolBarBase; does nothing.

    virtual bool Realize(void);

        // Finds a tool for the given position.

    virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
                                                   wxCoord y) const;

        // Inserts a tool at the given position.

    virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);

        // Deletes a tool. The tool is still in m_tools list when this function is called, and it will
        // only be deleted from it if it succeeds.

    virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);

        // Called when the tools enabled flag changes.

    virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);

        // Called when the tool is toggled.

    virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);

        // Called when the tools 'can be toggled' flag changes.

    virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);

        // Creates a toolbar tool.

    virtual wxToolBarToolBase *CreateTool(int id,
                                          const wxString& label,
                                          const wxBitmap& bmpNormal,
                                          const wxBitmap& bmpDisabled,
                                          wxItemKind kind,
                                          wxObject *clientData,
                                          const wxString& shortHelp,
                                          const wxString& longHelp);

        // Creates a toolbar tool.

    virtual wxToolBarToolBase *CreateTool(wxControl *control);

private:
    DECLARE_EVENT_TABLE()
    DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
};

#endif /* __DYNTBAR_G__ */