OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [configtree.h] - Blame information for rev 502

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by the Free
10
// Software Foundation; either version 2 of the License, or (at your option)
11
// any later version.
12
//
13
// This program is distributed in the hope that it will be useful, but WITHOUT
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16
// more details.
17
//
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc.,
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//
24
//####COPYRIGHTEND####
25
// configtree.h :
26
//
27
//===========================================================================
28
//#####DESCRIPTIONBEGIN####
29
//
30
// Author(s):   julians
31
// Contact(s):  julians
32
// Date:        2000/08/24
33
// Version:     $Id: configtree.h,v 1.1.1.1 2004-02-14 13:28:49 phoenix Exp $
34
// Purpose:
35
// Description: Header file for ecConfigTreeCtrl
36
// Requires:
37
// Provides:
38
// See also:
39
// Known bugs:
40
// Usage:
41
//
42
//####DESCRIPTIONEND####
43
//
44
//===========================================================================
45
 
46
#ifndef _ECOS_CONFIGTREE_H_
47
#define _ECOS_CONFIGTREE_H_
48
 
49
#ifdef __GNUG__
50
#pragma interface "configtree.h"
51
#endif
52
 
53
#include "wx/wx.h"
54
#include "splittree.h"
55
#include "configitem.h"
56
 
57
#define wxMAX_ICON_STATES 4
58
 
59
/*
60
 
61
The idea behind wxIconStateInfo, wxIconStateInfoDB
62
is to associate multiple state icons with items in tree controls
63
(and potentially other controls).
64
 
65
So instead of having to remember a lot of image list ids,
66
you have a named state info object which contains up to 4 different states
67
(identified by the integers 0 - 3). Each of these states can
68
be in a further 2 sub-states - enabled or disabled.
69
 
70
wxIconStateDB holds a list of these state info objects
71
and has a convenient API. For example, the following adds
72
icons for a checkbox item that can be: on/enabled, off/enabled,
73
on/disabled,off/disabled.
74
 
75
    m_iconDB.AddInfo("Checkbox", wxICON(checked), 0, TRUE);
76
    m_iconDB.AddInfo("Checkbox", wxICON(checked_dis), 0, FALSE);
77
    m_iconDB.AddInfo("Checkbox", wxICON(unchecked), 1, TRUE);
78
    m_iconDB.AddInfo("Checkbox", wxICON(unchecked_dis), 1, FALSE);
79
 
80
When you update the item image in response to (e.g.) user interaction,
81
you can say something like this:
82
 
83
    int iconId = m_iconDB.GetIconId("Checkbox", 0, FALSE);
84
 
85
    treeCtrl.SetItemImage(itemId, iconId, wxTreeItemIcon_Normal);
86
    treeCtrl.SetItemImage(itemId, iconId, wxTreeItemIcon_Selected);
87
 
88
See configitem.cpp for further examples.
89
 
90
These two classes are prefixed 'wx' because they are generic and may
91
be used elsewhere.
92
 
93
 */
94
 
95
/*
96
 * wxIconStateInfo
97
 * Stores information about the visual state of an item in a tree control
98
 */
99
 
100
class wxIconStateInfo: public wxObject
101
{
102
public:
103
    wxIconStateInfo(const wxString& name);
104
 
105
    // How many states? (Each state
106
    //  has enabled/disabled state)
107
    // Max (say) 4 states, each with
108
    // enabled/disabled
109
    int GetStateCount() const { return m_maxStates; };
110
 
111
    void SetStateCount(int count) { m_maxStates; }
112
    int GetIconId(int state, bool enabled = TRUE) const;
113
    void SetIconId(int state, bool enabled, int iconId);
114
 
115
    const wxString& GetName() const { return m_name; }
116
 
117
protected:
118
    int             m_maxStates;
119
    int             m_states[wxMAX_ICON_STATES * 2]; // Enabled/disabled
120
    wxString        m_name; // Name of icon, e.g. "Package"
121
};
122
 
123
/*
124
 * wxIconStateInfoDb
125
 * Contains a list of wxIconStateInfos
126
 */
127
 
128
class wxIconStateInfoDB: public wxList
129
{
130
public:
131
    wxIconStateInfoDB(wxImageList* imageList = NULL);
132
 
133
    void AppendInfo(wxIconStateInfo* info);
134
 
135
    // Easy way of initialising both the image list and the
136
    // info db. It will generate image ids itself while appending the icon.
137
    // 'state' is an integer from 0 up to the max allowed, representing a different
138
    // state. There may be only one, or (for a checkbox) there may be two.
139
    // A folder that can be open or closed would have two states.
140
    // Enabled/disabled is taken as a special case.
141
    bool AddInfo(const wxString& name, const wxIcon& icon, int state, bool enabled);
142
 
143
    wxIconStateInfo* FindInfo(const wxString& name) const;
144
 
145
    int GetIconId(const wxString& name, int state, bool enabled = TRUE) const;
146
    bool SetIconId(const wxString& name, int state, bool enabled, int iconId) ;
147
 
148
    void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
149
    wxImageList* GetImageList() const { return m_imageList; }
150
 
151
protected:
152
    wxImageList*    m_imageList;
153
};
154
 
155
/*
156
 * ecTreeItemData
157
 * This holds an association between the tree control item
158
 * and the ecConfigItem.
159
 */
160
 
161
class ecConfigItem;
162
class ecTreeItemData : public wxTreeItemData
163
{
164
public:
165
    ecTreeItemData(ecConfigItem* item) : m_configItem(item) { }
166
    ~ecTreeItemData() { if (m_configItem) delete m_configItem; }
167
 
168
    ecConfigItem *GetConfigItem() const { return m_configItem; }
169
    void SetConfigItem(ecConfigItem *item) { m_configItem = item; }
170
 
171
private:
172
    ecConfigItem*   m_configItem;
173
};
174
 
175
 
176
/*
177
 * ecConfigTreeCtrl
178
 * This control represents the configuration hierarchy.
179
 * It's derived from wxRemotelyScrolledTreeCtrl because we want
180
 * to synchronize the tree scrolling with the value window scrolling,
181
 * and have the scrollbar on the right-hand-side of the value window
182
 * (not the tree control).
183
 */
184
 
185
class ecValueWindow;
186
class ecConfigTreeCtrl: public wxRemotelyScrolledTreeCtrl
187
{
188
    DECLARE_CLASS(ecConfigTreeCtrl)
189
public:
190
    ecConfigTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
191
        const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
192
    ~ecConfigTreeCtrl();
193
 
194
//// Event handlers    
195
    void OnPaint(wxPaintEvent& event);
196
    void OnMouseEvent(wxMouseEvent& event);
197
    void OnSelChanged(wxTreeEvent& event);
198
    void OnCollapseExpand(wxTreeEvent& event);
199
    void OnHelp(wxHelpEvent& event);
200
    void OnKeyDown(wxKeyEvent& event);
201
 
202
//// Accessors
203
    wxIconStateInfoDB& GetIconDB() { return m_iconDB; }
204
    wxMenu* GetPropertiesMenu() const { return m_propertiesMenu; }
205
 
206
//// Operations
207
    void LoadIcons();
208
 
209
protected:
210
    wxImageList*        m_imageList;
211
    wxIconStateInfoDB   m_iconDB;
212
    wxMenu*             m_propertiesMenu;
213
 
214
    DECLARE_EVENT_TABLE()
215
};
216
 
217
/*
218
 * ecValueWindow
219
 * This window represents the values associated with the configuration tree.
220
 * It scrolls synchronously with the tree control.
221
 */
222
 
223
class ecValueWindow: public wxTreeCompanionWindow
224
{
225
public:
226
    ecValueWindow(wxWindow* parent, wxWindowID id = -1,
227
        const wxPoint& pos = wxDefaultPosition,
228
        const wxSize& sz = wxDefaultSize,
229
        long style = 0);
230
 
231
    //// Overrides
232
    virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
233
 
234
    //// Events
235
    void OnPaint(wxPaintEvent& event);
236
    void OnMouseEvent(wxMouseEvent& event);
237
    void OnScroll(wxScrollWinEvent& event);
238
    void OnExpand(wxTreeEvent& event);
239
 
240
    //// Accessors
241
    wxWindow* GetEditWindow() const { return m_editWindow; }
242
 
243
    //// Operations
244
 
245
    bool BeginEditing(ecConfigItem* item);
246
    bool EndEditing();
247
    void PositionEditWindow();
248
    wxRect GetItemRect(ecConfigItem* item);
249
 
250
    ecConfigItem*   GetCurrentConfigItem() const { return m_configItem; }
251
 
252
    //// Data members
253
protected:
254
    wxWindow*       m_editWindow; // Edit control
255
    ecConfigItem*   m_configItem; // Item being edited
256
 
257
    DECLARE_EVENT_TABLE()
258
    DECLARE_CLASS(ecValueWindow)
259
};
260
 
261
/*
262
 * ecSplitterScrolledWindow
263
 * This window holds the tree and value windows.
264
 * We derive a new class mainly to intercept popup menu commands from both child windows
265
 * without resorting to placing their handlers in the main frame.
266
 */
267
 
268
class ecSplitterScrolledWindow: public wxSplitterScrolledWindow
269
{
270
public:
271
    ecSplitterScrolledWindow(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
272
        const wxSize& sz = wxDefaultSize, long style = wxVSCROLL):
273
        wxSplitterScrolledWindow(parent, id, pt, sz, style)
274
    {
275
    }
276
 
277
//// Event handlers
278
    void OnWhatsThis(wxCommandEvent& event);
279
    void OnProperties(wxCommandEvent& event);
280
    void OnRestoreDefaults(wxCommandEvent& event);
281
    void OnVisitDoc(wxCommandEvent& event);
282
    void OnViewHeader(wxCommandEvent& event);
283
    void OnUnloadPackage(wxCommandEvent& event);
284
 
285
    void OnUpdateRestoreDefaults(wxUpdateUIEvent& event);
286
    void OnUpdateVisitDoc(wxUpdateUIEvent& event);
287
    void OnUpdateViewHeader(wxUpdateUIEvent& event);
288
    void OnUpdateUnloadPackage(wxUpdateUIEvent& event);
289
 
290
//// Helpers
291
    void RestoreDefault(wxTreeItemId h, bool bRecurse = FALSE, bool bTopLevel = TRUE);
292
    bool IsChanged(wxTreeItemId h, bool bRecurse);
293
protected:
294
    DECLARE_EVENT_TABLE()
295
};
296
 
297
 
298
#endif
299
// _ECOS_CONFIGTREE_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.