OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [configtree.h] - Blame information for rev 790

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

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

powered by: WebSVN 2.1.0

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