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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [configitem.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, 2009 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
// configitem.h :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians, jld
28
// Contact(s):  julians, jld
29
// Date:        2000/09/01
30
// Version:     $Id: configitem.h,v 1.4 2001/04/09 12:51:34 julians Exp $
31
// Purpose:
32
// Description: Header file for ecConfigItem, which describes a config item
33
//              from this tool's perspective. Note that this duplicates
34
//              some of the CDL data structures in order to be able to test the
35
//              UI independently; we may eliminate some of the duplication later.
36
// Requires:
37
// Provides:
38
// See also:
39
// Known bugs:
40
// Usage:
41
//
42
//####DESCRIPTIONEND####
43
//
44
//===========================================================================
45
 
46
#ifndef _ECOS_CONFIGITEM_H_
47
#define _ECOS_CONFIGITEM_H_
48
 
49
#ifdef __GNUG__
50
#pragma interface "configitem.h"
51
#endif
52
 
53
#include "wx/variant.h"
54
#include "wx/treectrl.h"
55
#include "wx/spinctrl.h"
56
 
57
#include "filename.h"
58
#include "cdl.hxx"
59
 
60
/*
61
 * ecConfigType
62
 * The type of item
63
 */
64
 
65
enum ecConfigType
66
{
67
    ecConfigTypeNone,
68
    ecContainer,
69
    ecPackage,
70
    ecComponent,
71
    ecOption
72
};
73
 
74
/*
75
 * ecOptionFlavor
76
 * The flavor of the option
77
 */
78
 
79
enum ecOptionFlavor
80
{
81
    ecFlavorNone,
82
    ecFlavorBool,
83
    ecFlavorBoolData,
84
    ecFlavorData
85
};
86
 
87
/*
88
 * ecOptionType
89
 * The type of option, if this is an option
90
 */
91
 
92
enum ecOptionType
93
{
94
    ecOptionTypeNone,
95
    ecDouble,
96
    ecLong,
97
    ecBool,
98
    ecString,
99
    ecEnumerated
100
};
101
 
102
/*
103
 * ecUIHint
104
 * What kind of control to use
105
 */
106
 
107
enum ecUIHint
108
{
109
    ecHintNone,
110
    ecHintCheck,
111
    ecHintRadio
112
};
113
 
114
/*
115
 * Get string from where?
116
 */
117
 
118
enum ecWhereType
119
{
120
    ecInMacro = 0,
121
    ecInName,
122
    ecInDesc,
123
    ecInCurrentValue,
124
    ecInDefaultValue
125
};
126
 
127
/*
128
 * ecConfigItem
129
 * Represents a node in the configuration hierarchy.
130
 * For every ecConfigItem, there is also an ecTreeItemData
131
 * that points to it.
132
 */
133
class ecConfigTreeCtrl;
134
class ecConfigItem: public wxObject
135
{
136
DECLARE_CLASS(ecConfigItem)
137
    friend class ecConfigToolDoc;
138
 
139
public:
140
    // active: whether greyed out or not
141
    // enabled: only if this is a Bool or BoolData: whether enabled/disabled (checked/unchecked)
142
    ecConfigItem(ecConfigItem* parent, const wxString& name, ecConfigType ctype = ecConfigTypeNone,
143
        ecOptionFlavor flavor = ecFlavorNone, ecOptionType otype = ecOptionTypeNone,
144
        bool active = TRUE, bool enabled = TRUE, bool modifiable = TRUE, ecUIHint hint = ecHintNone);
145
    ecConfigItem(ecConfigItem* parent, CdlUserVisible vitem);
146
    ~ecConfigItem();
147
 
148
//// Accessors
149
    void SetParent(ecConfigItem* parent) { m_parent = parent; }
150
    ecConfigItem* GetParent() const { return m_parent; }
151
 
152
    void SetName(const wxString& name) { m_name = name; }
153
    const wxString& GetName() const { return m_name; }
154
 
155
    void SetMacro(const wxString& name) { m_macro = name; }
156
    const wxString& GetMacro() const { return m_macro; }
157
 
158
    void SetDescription(const wxString& descr) { m_strDescr = descr; }
159
    const wxString& GetDescription() const { return m_strDescr; }
160
 
161
    void SetConfigType(ecConfigType ctype) { m_configType = ctype; }
162
    ecConfigType GetConfigType() const { return m_configType; }
163
 
164
    void SetOptionType(ecOptionType otype) { m_optionType = otype; }
165
    ecOptionType GetOptionType() const { return m_optionType; }
166
 
167
    void SetOptionFlavor(ecOptionFlavor flavor) { m_optionFlavor = flavor; }
168
    ecOptionFlavor GetOptionFlavor() const { return m_optionFlavor; }
169
 
170
    void SetValue(const wxVariant& value) { m_value = value; }
171
    wxVariant& GetValue() { return m_value; }
172
 
173
    // Only appropriate if Bool or BoolData. Otherwise, assume always enabled.
174
    void SetEnabled(bool enabled) { m_enabled = enabled; }
175
    bool GetEnabled() const { return m_enabled; }
176
 
177
    // Whether value and icon greyed out or not
178
    void SetModifiable(bool modifiable) { m_modifiable = modifiable; }
179
    bool GetModifiable() const { return m_modifiable; }
180
 
181
    // Whether tree item text greyed out or not
182
    void SetActive(bool active) { m_active = active; }
183
    bool GetActive() const { return m_active; }
184
 
185
    // UI hint
186
    void SetUIHint(ecUIHint hint) { m_hint = hint; }
187
    ecUIHint GetUIHint() const { return m_hint; }
188
 
189
    // Gets the value to display (often an empty string)
190
    wxString GetDisplayValue() const ;
191
 
192
    wxTreeItemId GetTreeItem() const { return m_treeItem; };
193
    void SetTreeItem(wxTreeItemId id) { m_treeItem = id; };
194
 
195
    CdlUserVisible GetCdlItem() const { return m_CdlItem; }
196
    void SetCdlItem(CdlUserVisible cdlItem) { m_CdlItem = cdlItem; }
197
 
198
    wxString GetItemNameOrMacro() const;
199
 
200
        bool IsPackage () const { return NULL!=dynamic_cast<CdlPackage> (GetCdlItem()); }
201
 
202
//// Operations
203
    // Sets the text and icon for this item
204
    bool UpdateTreeItem(ecConfigTreeCtrl& treeCtrl);
205
 
206
    // Handle a left click on the icon: e.g. (un)check the option
207
    void OnIconLeftDown(ecConfigTreeCtrl& treeCtrl);
208
 
209
    // Can we start editing this item?
210
    bool CanEdit() const;
211
 
212
    // Creates an edit window. It will be positioned by the caller.
213
    wxWindow* CreateEditWindow(wxWindow* parent);
214
 
215
    // Transfers data between item and window
216
    bool TransferDataToWindow(wxWindow* window);
217
    bool TransferDataFromWindow(wxWindow* window);
218
 
219
    // Convert from Cdl to internal representation
220
    bool ConvertFromCdl();
221
 
222
    // Bump by specified amount, or toggle if a boolean value
223
    bool BumpItem(int nInc);
224
 
225
//// TAKEN FROM MFC VERSION
226
 
227
    const ecFileName GetFilename () const;
228
    CdlPackage GetOwnerPackage() const { return GetCdlItem()?(dynamic_cast<CdlPackage> (GetCdlItem()->get_owner ())):NULL; }
229
    bool ChangeVersion (const wxString &strVersion);
230
    CdlValuable GetCdlValuable() const { return dynamic_cast<CdlValuable> (GetCdlItem()); }
231
    bool Unload();
232
    wxString GetURL () const;
233
 
234
    bool HasRadio () const;
235
    ecConfigItem *FirstRadio() const;
236
 
237
    ecConfigItem *FirstChild() const;
238
    ecConfigItem *NextSibling() const;
239
 
240
    bool HasModifiedChildren() const;
241
    bool IsEnabled() const;
242
    bool IsActive() const; // Added JACS
243
    bool IsModifiable() const;
244
 
245
    bool Modified() const;
246
 
247
    void DumpItem();
248
 
249
    ecConfigItem * NextRadio() const;
250
 
251
    bool IsDescendantOf (ecConfigItem *pAncestor);
252
 
253
    bool ViewURL();
254
    bool ViewHeader();
255
 
256
    bool HasBool () const;
257
 
258
    long DefaultValue() const;
259
    long Value() const;
260
    const wxString StringValue (CdlValueSource source = CdlValueSource_Current) const;
261
    const wxString StringValue(ecWhereType where) const;
262
    const double DoubleValue (CdlValueSource source = CdlValueSource_Current) const;
263
    const wxString StringDefaultValue() const { return StringValue (CdlValueSource_Default); }
264
    const double DoubleDefaultValue () const { return DoubleValue (CdlValueSource_Default); }
265
    int  EvalEnumStrings (wxArrayString &arEnumStrings) const;
266
 
267
    // Convert a string representation of 'where' (e.g. "Macro names") to
268
    // ecWhereType
269
    static ecWhereType WhereStringToType(const wxString& whereString);
270
 
271
    // Convert a type representation of 'where' to a string
272
    static wxString WhereTypeToString(ecWhereType whereType);
273
 
274
protected:
275
 
276
    bool SetValue (const wxString& value, CdlTransaction transaction=NULL);
277
    bool SetValue (double dValue, CdlTransaction transaction=NULL);
278
    bool SetValue (long nValue, CdlTransaction transaction=NULL);
279
    bool SetEnabled (bool bEnabled, CdlTransaction transaction=NULL);
280
 
281
protected:
282
    wxString            m_name;
283
    wxString            m_macro;
284
    bool                m_enabled;
285
    bool                m_active;
286
    bool                m_modifiable;
287
    ecConfigType        m_configType;
288
    ecOptionType        m_optionType;
289
    ecOptionFlavor      m_optionFlavor;
290
    ecUIHint            m_hint;
291
    wxVariant           m_value;
292
    ecConfigItem*       m_parent;
293
    wxTreeItemId        m_treeItem;
294
    CdlUserVisible      m_CdlItem;
295
    wxString            m_strDescr; // Description
296
};
297
 
298
 
299
//// TODO: put these in separate file
300
 
301
/*
302
 * ecTextEditorCtrl
303
 * A specialised wxTextCtrl, for editing string config values
304
 */
305
 
306
class ecTextEditorCtrl: public wxTextCtrl
307
{
308
DECLARE_CLASS(ecTextEditorCtrl)
309
public:
310
// Ctor(s)
311
    ecTextEditorCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
312
        long style = 0);
313
 
314
//// Event handlers
315
 
316
    void OnEnter(wxCommandEvent& event);
317
    void OnKillFocus(wxFocusEvent& event);
318
    void OnLeftDClick(wxMouseEvent& event);
319
 
320
DECLARE_EVENT_TABLE()
321
 
322
private:
323
};
324
 
325
/*
326
 * ecDoubleEditorCtrl
327
 * A specialised wxTextCtrl, for editing double config values
328
 */
329
 
330
class ecDoubleEditorCtrl: public wxTextCtrl
331
{
332
DECLARE_CLASS(ecDoubleEditorCtrl)
333
public:
334
// Ctor(s)
335
    ecDoubleEditorCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
336
        long style = 0);
337
 
338
//// Event handlers
339
 
340
    void OnEnter(wxCommandEvent& event);
341
    void OnKillFocus(wxFocusEvent& event);
342
 
343
DECLARE_EVENT_TABLE()
344
};
345
 
346
/*
347
 * ecIntegerEditorCtrl
348
 * A specialised wxSpinCtrl, for editing integer config values
349
 */
350
 
351
class ecIntegerEditorCtrl: public wxSpinCtrl
352
{
353
DECLARE_CLASS(ecIntegerEditorCtrl)
354
public:
355
// Ctor(s)
356
    ecIntegerEditorCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
357
        long style = 0);
358
 
359
//// Event handlers
360
 
361
    void OnEnter(wxCommandEvent& event);
362
    void OnKillFocus(wxFocusEvent& event);
363
 
364
DECLARE_EVENT_TABLE()
365
};
366
 
367
/*
368
 * ecEnumEditorCtrl
369
 * A specialised wxChoice, for editing enumerated config values
370
 */
371
 
372
class ecEnumEditorCtrl: public wxChoice
373
{
374
DECLARE_CLASS(ecEnumEditorCtrl)
375
public:
376
// Ctor(s)
377
    ecEnumEditorCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
378
        long style = 0);
379
 
380
//// Event handlers
381
 
382
    void OnChar(wxKeyEvent& event);
383
    void OnKillFocus(wxFocusEvent& event);
384
 
385
DECLARE_EVENT_TABLE()
386
};
387
 
388
/*
389
 * ecEditStringDialog
390
 * Pops up to make it easier to edit large string values
391
 */
392
 
393
class ecEditStringDialog : public ecDialog
394
{
395
public:
396
// Ctor(s)
397
        ecEditStringDialog(const wxString& initialValue, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
398
        long style = 0);
399
    ~ecEditStringDialog();
400
 
401
//// Event handlers
402
 
403
    void OnOK(wxCommandEvent& event);
404
 
405
//// Operations
406
    void CreateControls(wxWindow* parent);
407
 
408
//// Accessors
409
    wxString GetValue() const { return m_value; }
410
 
411
//// Member variables
412
protected:
413
    DECLARE_EVENT_TABLE()
414
 
415
    wxString    m_value;
416
};
417
 
418
#endif
419
        // _ECOS_CONFIGITEM_H_

powered by: WebSVN 2.1.0

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