]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/winprop.cpp
7eabff426073b7944d084c34907fb118727d61f2
[wxWidgets.git] / utils / dialoged / src / winprop.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: winprop.cpp
3 // Purpose: Window properties
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "winprop.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include <ctype.h>
28 #include <stdlib.h>
29 #include <math.h>
30 #include <string.h>
31
32 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
33 #include <strstrea.h>
34 #else
35 #include <strstream.h>
36 #endif
37
38 #ifdef __WXMSW__
39 #include <windows.h>
40 #endif
41
42 #include "reseditr.h"
43 #include "winprop.h"
44
45 // Causes immediate feedback.
46 void wxResourcePropertyListView::OnPropertyChanged(wxProperty *property)
47 {
48 // Sets the value of the property back into the actual object,
49 // IF the property value was modified.
50 if (property->GetValue().GetModified())
51 {
52 m_propertyInfo->SetProperty(property->GetName(), property);
53 property->GetValue().SetModified(FALSE);
54 wxResourceManager::GetCurrentResourceManager()->Modify(TRUE);
55 }
56 }
57
58 bool wxResourcePropertyListView::OnClose(void)
59 {
60 int w, h, x, y;
61 GetManagedWindow()->GetSize(& w, & h);
62 GetManagedWindow()->GetPosition(& x, & y);
63
64 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width = w;
65 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height = h;
66 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x = x;
67 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y = y;
68
69 return wxPropertyListView::OnClose();
70 }
71
72 wxWindow *wxPropertyInfo::sm_propertyWindow;
73
74 /*
75 * wxDialogEditorPropertyListDialog
76 */
77
78 /*
79 wxDialogEditorPropertyListDialog::wxDialogEditorPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title,
80 const wxPoint& pos, const wxSize& size,
81 long style, const wxString& name):
82 wxPropertyListDialog(v, parent, title, pos, size, style, name)
83 {
84 m_propSheet = NULL;
85 m_propInfo = NULL;
86 }
87
88 wxDialogEditorPropertyListDialog::~wxDialogEditorPropertyListDialog()
89 {
90 delete m_propSheet;
91 delete m_propInfo;
92 wxPropertyInfo::sm_propertyWindow = NULL;
93 }
94 */
95
96 wxDialogEditorPropertyListFrame::wxDialogEditorPropertyListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title,
97 const wxPoint& pos, const wxSize& size,
98 long style, const wxString& name):
99 wxPropertyListFrame(v, parent, title, pos, size, style, name)
100 {
101 m_propSheet = NULL;
102 m_propInfo = NULL;
103 }
104
105 wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
106 {
107 delete m_propSheet;
108 delete m_propInfo;
109 wxPropertyInfo::sm_propertyWindow = NULL;
110 }
111
112 /*
113 * wxPropertyInfo
114 */
115
116 // Edit the information represented by this object, whatever that
117 // might be.
118 bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title)
119 {
120 if (sm_propertyWindow)
121 {
122 sm_propertyWindow->Raise();
123 return TRUE;
124 }
125
126 int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width;
127 int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height;
128 int x = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x;
129 int y = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y;
130
131 wxPropertySheet *propSheet = new wxPropertySheet;
132
133 wxStringList propNames;
134 GetPropertyNames(propNames);
135
136 wxNode *node = propNames.First();
137 while (node)
138 {
139 wxString name((char *)node->Data());
140 wxProperty *prop = GetProperty(name);
141 if (prop)
142 {
143 propSheet->AddProperty(prop);
144 }
145 node = node->Next();
146 }
147
148 // Reset 'modified' flags for all property values
149 propSheet->SetAllModified(FALSE);
150
151 wxResourcePropertyListView *view = new wxResourcePropertyListView(this, NULL,
152 wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL |
153 wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES);
154
155 wxDialogEditorPropertyListFrame *propWin = new wxDialogEditorPropertyListFrame(view,
156 wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title, wxPoint(x, y),
157 wxSize(width, height), wxDEFAULT_FRAME_STYLE);
158 sm_propertyWindow = propWin;
159
160 propWin->m_registry.RegisterValidator(wxString("real"), new wxRealListValidator);
161 propWin->m_registry.RegisterValidator(wxString("string"), new wxStringListValidator);
162 propWin->m_registry.RegisterValidator(wxString("integer"), new wxIntegerListValidator);
163 propWin->m_registry.RegisterValidator(wxString("bool"), new wxBoolListValidator);
164 propWin->m_registry.RegisterValidator(wxString("filename"), new wxFilenameListValidator);
165 propWin->m_registry.RegisterValidator(wxString("stringlist"), new wxListOfStringsListValidator);
166 propWin->m_registry.RegisterValidator(wxString("window_id"), new wxResourceSymbolValidator);
167
168 propWin->m_propInfo = this;
169 propWin->m_propSheet = propSheet;
170
171 // view->m_propertyWindow = propWin;
172 view->AddRegistry(&(propWin->m_registry));
173
174 propWin->Initialize();
175 view->ShowView(propSheet, propWin->GetPropertyPanel());
176
177 propWin->Show(TRUE);
178 return TRUE;
179 }
180
181 /*
182 * wxWindowPropertyInfo
183 */
184
185 wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow *win, wxItemResource *res)
186 {
187 m_propertyWindow = win;
188 m_propertyResource = res;
189 }
190
191 wxWindowPropertyInfo::~wxWindowPropertyInfo(void)
192 {
193 }
194
195 wxProperty *wxWindowPropertyInfo::GetFontProperty(wxString& name, wxFont *font)
196 {
197 if (!font)
198 return NULL;
199
200 if (name.Contains("Points"))
201 return new wxProperty(name, (long)font->GetPointSize(), "integer", new wxIntegerListValidator(1, 100));
202 else if (name.Contains("Family"))
203 return new wxProperty(name, font->GetFamilyString(), "string",
204 new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN",
205 NULL)));
206 else if (name.Contains("Style"))
207 return new wxProperty(name, font->GetStyleString(), "string",
208 new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL)));
209 else if (name.Contains("Weight"))
210 return new wxProperty(name, font->GetWeightString(), "string",
211 new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL)));
212 else if (name.Contains("Underlined"))
213 return new wxProperty(name, (bool)font->GetUnderlined(), "bool");
214 else
215 return NULL;
216 }
217
218 wxFont *wxWindowPropertyInfo::SetFontProperty(wxString& name, wxProperty *property, wxFont *font)
219 {
220 int pointSize = 12;
221 int fontFamily = wxMODERN;
222 int fontStyle = wxNORMAL;
223 int fontWeight = wxNORMAL;
224 bool fontUnderlined = FALSE;
225
226 if (name.Contains("Points"))
227 {
228 pointSize = (int)property->GetValue().IntegerValue();
229 if (font && (pointSize == font->GetPointSize()))
230 return NULL; // No change
231 }
232 else if (font) pointSize = font->GetPointSize();
233
234 if (name.Contains("Family"))
235 {
236 wxString val = property->GetValue().StringValue();
237 fontFamily = wxStringToFontFamily(val);
238
239 if (font && (fontFamily == font->GetFamily()))
240 return NULL; // No change
241 }
242 else if (font) fontFamily = font->GetFamily();
243
244 if (name.Contains("Style"))
245 {
246 wxString val = property->GetValue().StringValue();
247 fontStyle = wxStringToFontStyle(val);
248
249 if (font && (fontStyle == font->GetStyle()))
250 return NULL; // No change
251 }
252 else if (font) fontStyle = font->GetStyle();
253 if (name.Contains("Weight"))
254 {
255 wxString val = property->GetValue().StringValue();
256 fontWeight = wxStringToFontWeight(val);
257
258 if (font && (fontWeight == font->GetWeight()))
259 return NULL; // No change
260 }
261 else if (font) fontWeight = font->GetWeight();
262
263 if (name.Contains("Underlined"))
264 {
265 fontUnderlined = property->GetValue().BoolValue();
266
267 if (font && (fontUnderlined == font->GetUnderlined()))
268 return NULL; // No change
269 }
270 else if (font) fontUnderlined = font->GetUnderlined();
271
272 wxFont *newFont = wxTheFontList->FindOrCreateFont(pointSize, fontFamily, fontStyle, fontWeight, fontUnderlined);
273 if (newFont)
274 {
275 return newFont;
276 }
277 else
278 return NULL;
279 }
280
281 wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name)
282 {
283 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
284
285 wxFont *font = m_propertyWindow->GetFont();
286 if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" ||
287 name == "fontUnderlined")
288 return GetFontProperty(name, font);
289 else if (name == "name")
290 return new wxProperty("name", m_propertyWindow->GetName(), "string");
291 else if (name == "title")
292 return new wxProperty("title", m_propertyWindow->GetTitle(), "string");
293 else if (name == "x")
294 {
295 return new wxProperty("x", (long)resource->GetX(), "integer");
296 }
297 else if (name == "y")
298 {
299 return new wxProperty("y", (long)resource->GetY(), "integer");
300 }
301 else if (name == "width")
302 {
303 return new wxProperty("width", (long)resource->GetWidth(), "integer");
304 }
305 else if (name == "height")
306 {
307 return new wxProperty("width", (long)resource->GetHeight(), "integer");
308 }
309 else if (name == "id")
310 {
311 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
312 if (resource)
313 {
314 int id = resource->GetId();
315 wxString idStr;
316 idStr.Printf("%d", id);
317 wxString symbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id);
318 symbolName += "=";
319 symbolName += idStr;
320 // symbolName is now e.g. "ID_PANEL21=105"
321 return new wxProperty("id", symbolName, "window_id");
322 }
323 else
324 return NULL;
325 }
326 else if (name == "border")
327 {
328 wxString border("");
329 if (m_propertyWindow->GetWindowStyleFlag() & wxSIMPLE_BORDER)
330 border = "wxSIMPLE_BORDER";
331 else if (m_propertyWindow->GetWindowStyleFlag() & wxRAISED_BORDER)
332 border = "wxRAISED_BORDER";
333 else if (m_propertyWindow->GetWindowStyleFlag() & wxSUNKEN_BORDER)
334 border = "wxSUNKEN_BORDER";
335 else if (m_propertyWindow->GetWindowStyleFlag() & wxDOUBLE_BORDER)
336 border = "wxDOUBLE_BORDER";
337 else if (m_propertyWindow->GetWindowStyleFlag() & wxSTATIC_BORDER)
338 border = "wxSTATIC_BORDER";
339 else
340 border = "wxNO_BORDER";
341
342 return new wxProperty("border", border, "string",
343 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
344 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL)));
345 }
346 else
347 return NULL;
348 }
349
350 bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property)
351 {
352 wxFont *font = m_propertyWindow->GetFont();
353 if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" ))
354 {
355 wxFont *newFont = SetFontProperty(name, property, font);
356 if (newFont)
357 m_propertyWindow->SetFont(newFont);
358 return TRUE;
359 }
360 else if (name == "name")
361 {
362 // Remove old name from resource table, if it's there.
363 wxItemResource *oldResource = (wxItemResource *)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow->GetName());
364 if (oldResource)
365 {
366 // It's a top-level resource
367 m_propertyWindow->SetName(property->GetValue().StringValue());
368 oldResource->SetName(property->GetValue().StringValue());
369 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow->GetName(), oldResource);
370 }
371 else
372 {
373 // It's a child of something; just set the name of the resource and the window.
374 m_propertyWindow->SetName(property->GetValue().StringValue());
375 m_propertyResource->SetName(property->GetValue().StringValue());
376 }
377 // Refresh the resource manager list, because the name changed.
378 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
379 return TRUE;
380 }
381 else if (name == "title")
382 {
383 m_propertyWindow->SetTitle(property->GetValue().StringValue());
384 return TRUE;
385 }
386 else if (name == "x")
387 {
388 int x, y;
389 m_propertyWindow->GetPosition(&x, &y);
390 int newX = (int)property->GetValue().IntegerValue();
391
392 // We need to convert to pixels if this is not a dialog or panel, but
393 // the parent resource specifies dialog units.
394 if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
395 {
396 wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
397 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
398 {
399 wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(newX, y));
400 newX = pt.x;
401 }
402 }
403 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
404 {
405 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
406 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
407 {
408 wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(newX, y));
409 newX = pt.x;
410 }
411 }
412
413 if (x != newX)
414 m_propertyWindow->Move(newX, y);
415 return TRUE;
416 }
417 else if (name == "y")
418 {
419 int x, y;
420 m_propertyWindow->GetPosition(&x, &y);
421 int newY = (int)property->GetValue().IntegerValue();
422
423 // We need to convert to pixels if this is not a dialog or panel, but
424 // the parent resource specifies dialog units.
425 if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
426 {
427 wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
428 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
429 {
430 wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(x, newY));
431 newY = pt.y;
432 }
433 }
434 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
435 {
436 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
437 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
438 {
439 wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(x, newY));
440 newY = pt.y;
441 }
442 }
443
444 if (y != newY)
445 m_propertyWindow->Move(x, newY);
446 return TRUE;
447 }
448 else if (name == "width")
449 {
450 int width, height;
451 m_propertyWindow->GetSize(&width, &height);
452 int newWidth = (int)property->GetValue().IntegerValue();
453
454 // We need to convert to pixels if this is not a dialog or panel, but
455 // the parent resource specifies dialog units.
456 if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
457 {
458 wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
459 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
460 {
461 wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(newWidth, height));
462 newWidth = sz.x;
463 }
464 }
465 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
466 {
467 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
468 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
469 {
470 wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(newWidth, height));
471 newWidth = sz.x;
472 }
473 }
474
475 if (width != newWidth)
476 {
477 m_propertyWindow->SetSize(newWidth, height);
478 }
479 return TRUE;
480 }
481 else if (name == "height")
482 {
483 int width, height;
484 m_propertyWindow->GetSize(&width, &height);
485 int newHeight = (int)property->GetValue().IntegerValue();
486
487 // We need to convert to pixels if this is not a dialog or panel, but
488 // the parent resource specifies dialog units.
489 if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
490 {
491 wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
492 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
493 {
494 wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(width, newHeight));
495 newHeight = sz.y;
496 }
497 }
498 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
499 {
500 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
501 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
502 {
503 wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(width, newHeight));
504 newHeight = sz.y;
505 }
506 }
507
508 if (height != newHeight)
509 {
510 m_propertyWindow->SetSize(width, newHeight);
511 }
512 return TRUE;
513 }
514 else if (name == "id")
515 {
516 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
517 if (resource)
518 {
519 wxString value = property->GetValue().StringValue();
520
521 wxString strName = value.Before('=');
522 wxString strId = value.After('=');
523 int id = atoi(strId);
524
525 wxString oldSymbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource->GetId());
526 int oldSymbolId = resource->GetId();
527
528 if (strName != "")
529 {
530 // If we change the id for an existing symbol, we need to:
531 // 1) Check if there are any other resources currently using the original id.
532 // If so, will need to change their id to the new id.
533 // 2) Remove the old symbol, add the new symbol.
534 // In this check, we don't have to do this, but we need to do it in SetProperty.
535
536 if (strName == oldSymbolName && id != oldSymbolId)
537 {
538 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) );
539
540 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
541 // because ids are unique and changing one resource's id must change all identical ones.
542 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId, id);
543
544 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
545 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
546 }
547
548 // If we change the name but not the id, we'll just need to remove and
549 // re-add the symbol/id pair.
550 if (strName != oldSymbolName && id == oldSymbolId)
551 {
552 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) );
553
554 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
555
556 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName))
557 {
558 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
559 }
560 }
561
562 // What if we're changing both the name and the id?
563 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
564 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
565
566 if (strName != oldSymbolName && id != oldSymbolId)
567 {
568 // Remove old symbol if it's not being used
569 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource, oldSymbolId) &&
570 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName))
571 {
572 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
573 }
574
575 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName))
576 {
577 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
578 }
579 }
580 resource->SetId(id);
581 }
582
583 return TRUE;
584 }
585 else
586 return FALSE;
587 }
588 else if (name == "border")
589 {
590 long borderStyle = wxNO_BORDER;
591 wxString val = property->GetValue().StringValue();
592
593 if (val == "wxSIMPLE_BORDER")
594 borderStyle = wxSIMPLE_BORDER;
595 else if (val == "wxRAISED_BORDER")
596 borderStyle = wxRAISED_BORDER;
597 else if (val == "wxSUNKEN_BORDER")
598 borderStyle = wxSUNKEN_BORDER;
599 else if (val == "wxDOUBLE_BORDER")
600 borderStyle = wxDOUBLE_BORDER;
601 else if (val == "wxSTATIC_BORDER")
602 borderStyle = wxSTATIC_BORDER;
603 else
604 borderStyle = wxNO_BORDER;
605
606 SetWindowStyle(m_propertyWindow, wxSIMPLE_BORDER, FALSE);
607 SetWindowStyle(m_propertyWindow, wxRAISED_BORDER, FALSE);
608 SetWindowStyle(m_propertyWindow, wxSUNKEN_BORDER, FALSE);
609 SetWindowStyle(m_propertyWindow, wxDOUBLE_BORDER, FALSE);
610 SetWindowStyle(m_propertyWindow, wxSTATIC_BORDER, FALSE);
611 SetWindowStyle(m_propertyWindow, wxNO_BORDER, FALSE);
612
613 SetWindowStyle(m_propertyWindow, borderStyle, TRUE);
614
615 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
616 resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
617 return TRUE;
618 }
619 else
620 return FALSE;
621 }
622
623 void wxWindowPropertyInfo::GetPropertyNames(wxStringList& names)
624 {
625 names.Add("id");
626 names.Add("name");
627 names.Add("x");
628 names.Add("y");
629 names.Add("width");
630 names.Add("height");
631 names.Add("border");
632 if (!m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
633 {
634 names.Add("fontPoints");
635 names.Add("fontFamily");
636 names.Add("fontStyle");
637 names.Add("fontWeight");
638 names.Add("fontUnderlined");
639 }
640 }
641
642 // Fill in the wxItemResource members to mirror the current window settings
643 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource)
644 {
645 // resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName());
646
647 // resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
648 wxString str(m_propertyWindow->GetName());
649 resource->SetName(str);
650
651 #if 0
652 int x, y, w, h;
653
654 if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
655 m_propertyWindow->GetClientSize(&w, &h);
656 else
657 m_propertyWindow->GetSize(&w, &h);
658
659 m_propertyWindow->GetPosition(&x, &y);
660
661 // We need to convert to dialog units if this is not a dialog or panel, but
662 // the parent resource specifies dialog units.
663 if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
664 {
665 wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
666 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
667 {
668 wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y));
669 x = pt.x; y = pt.y;
670 wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h));
671 w = sz.x; h = sz.y;
672 }
673 }
674 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
675 {
676 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
677 {
678 wxPoint pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(x, y));
679 x = pt.x; y = pt.y;
680 wxSize sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(w, h));
681 w = sz.x; h = sz.y;
682 }
683 }
684
685 resource->SetSize(x, y, w, h);
686 #endif
687
688 return TRUE;
689 }
690
691 // Set the window style
692 void wxWindowPropertyInfo::SetWindowStyle(wxWindow* win, long style, bool set)
693 {
694 if (style == 0)
695 return;
696
697 if ((win->GetWindowStyleFlag() & style) == style)
698 {
699 if (!set)
700 {
701 win->SetWindowStyleFlag(win->GetWindowStyleFlag() - style);
702 }
703 }
704 else
705 {
706 if (set)
707 {
708 win->SetWindowStyleFlag(win->GetWindowStyleFlag() | style);
709 }
710 }
711 }
712
713 /*
714 * Controls
715 */
716
717 wxProperty *wxItemPropertyInfo::GetProperty(wxString& name)
718 {
719 wxControl *itemWindow = (wxControl *)m_propertyWindow;
720 wxFont *font = itemWindow->GetFont();
721
722 if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" ||
723 name == "fontUnderlined")
724 return GetFontProperty(name, font);
725 else if (name == "label" && itemWindow->GetLabel())
726 return new wxProperty("label", m_propertyWindow->GetLabel(), "string");
727 else
728 return wxWindowPropertyInfo::GetProperty(name);
729 }
730
731 bool wxItemPropertyInfo::SetProperty(wxString& name, wxProperty *property)
732 {
733 wxControl *itemWindow = (wxControl *)m_propertyWindow;
734 wxFont *font = itemWindow->GetFont();
735
736 if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" ))
737 {
738 wxFont *newFont = SetFontProperty(name, property, font);
739 if (newFont)
740 itemWindow->SetLabelFont(newFont);
741 return TRUE;
742 }
743 else if (name == "label")
744 {
745 itemWindow->SetLabel(property->GetValue().StringValue());
746 return TRUE;
747 }
748 else
749 return wxWindowPropertyInfo::SetProperty(name, property);
750 }
751
752 void wxItemPropertyInfo::GetPropertyNames(wxStringList& names)
753 {
754 wxWindowPropertyInfo::GetPropertyNames(names);
755
756 names.Add("fontPoints");
757 names.Add("fontFamily");
758 names.Add("fontStyle");
759 names.Add("fontWeight");
760 names.Add("fontUnderlined");
761 }
762
763 bool wxItemPropertyInfo::InstantiateResource(wxItemResource *resource)
764 {
765 wxWindowPropertyInfo::InstantiateResource(resource);
766
767 wxControl *item = (wxControl *)m_propertyWindow;
768 wxString str(item->GetLabel());
769 resource->SetTitle(str);
770 if (item->GetFont() && item->GetFont()->Ok())
771 resource->SetFont(wxTheFontList->FindOrCreateFont(item->GetFont()->GetPointSize(),
772 item->GetFont()->GetFamily(), item->GetFont()->GetStyle(), item->GetFont()->GetWeight(),
773 item->GetFont()->GetUnderlined(), item->GetFont()->GetFaceName()));
774 return TRUE;
775 }
776
777 /*
778 * Button
779 */
780
781 wxProperty *wxButtonPropertyInfo::GetProperty(wxString& name)
782 {
783 return wxItemPropertyInfo::GetProperty(name);
784 }
785
786 bool wxButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property)
787 {
788 return wxItemPropertyInfo::SetProperty(name, property);
789 }
790
791 void wxButtonPropertyInfo::GetPropertyNames(wxStringList& names)
792 {
793 wxItemPropertyInfo::GetPropertyNames(names);
794 names.Add("label");
795 }
796
797 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource *resource)
798 {
799 return wxItemPropertyInfo::InstantiateResource(resource);
800 }
801
802 /*
803 * wxBitmapButton
804 */
805
806 wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name)
807 {
808 wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow;
809 if (name == "label")
810 {
811 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button);
812 wxString str("none.bmp");
813
814 if (resource)
815 {
816 str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource);
817 }
818 return new wxProperty("label", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
819 }
820 else
821 return wxButtonPropertyInfo::GetProperty(name);
822 }
823
824 bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property)
825 {
826 wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow;
827 if (name == "label")
828 {
829 char *s = property->GetValue().StringValue();
830 if (s && wxFileExists(s))
831 {
832 s = copystring(s);
833 wxBitmap *bitmap = new wxBitmap(s, wxBITMAP_TYPE_BMP);
834 if (!bitmap->Ok())
835 {
836 delete bitmap;
837 delete[] s;
838 return FALSE;
839 }
840 else
841 {
842 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button);
843 if (resource)
844 {
845 wxString oldResource(resource->GetValue4());
846 wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s);
847 resource->SetValue4(resName);
848
849 if (!oldResource.IsNull())
850 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource);
851 }
852
853 button->SetLabel(bitmap);
854 delete[] s;
855 return TRUE;
856 }
857 }
858 return FALSE;
859 }
860 else
861 return wxButtonPropertyInfo::SetProperty(name, property);
862 }
863
864 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList& names)
865 {
866 // names.Add("label");
867 wxButtonPropertyInfo::GetPropertyNames(names);
868 }
869
870 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource *resource)
871 {
872 return wxItemPropertyInfo::InstantiateResource(resource);
873 }
874
875 /*
876 * wxStaticText
877 */
878
879 wxProperty *wxStaticTextPropertyInfo::GetProperty(wxString& name)
880 {
881 return wxItemPropertyInfo::GetProperty(name);
882 }
883
884 bool wxStaticTextPropertyInfo::SetProperty(wxString& name, wxProperty *property)
885 {
886 return wxItemPropertyInfo::SetProperty(name, property);
887 }
888
889 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList& names)
890 {
891 wxItemPropertyInfo::GetPropertyNames(names);
892 names.Add("label");
893 }
894
895 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource *resource)
896 {
897 return wxItemPropertyInfo::InstantiateResource(resource);
898 }
899
900 /*
901 * wxStaticBitmap
902 */
903
904 wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name)
905 {
906 wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow;
907 if (name == "label")
908 {
909 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message);
910 wxString str("none.bmp");
911
912 if (resource)
913 {
914 str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource);
915 }
916 return new wxProperty("label", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
917 }
918 else
919 return wxItemPropertyInfo::GetProperty(name);
920 }
921
922 bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *property)
923 {
924 wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow;
925 if (name == "label")
926 {
927 char *s = property->GetValue().StringValue();
928 if (s && wxFileExists(s))
929 {
930 s = copystring(s);
931
932 wxBitmap *bitmap = new wxBitmap(s, wxBITMAP_TYPE_BMP);
933 if (!bitmap->Ok())
934 {
935 delete bitmap;
936 delete[] s;
937 return FALSE;
938 }
939 else
940 {
941 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message);
942 if (resource)
943 {
944 wxString oldResource(resource->GetValue4());
945 wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s);
946 resource->SetValue4(resName);
947
948 if (!oldResource.IsNull())
949 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource);
950 }
951
952 message->SetBitmap(bitmap);
953 delete[] s;
954 return TRUE;
955 }
956 }
957 return FALSE;
958 }
959 else
960 return wxItemPropertyInfo::SetProperty(name, property);
961 }
962
963 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList& names)
964 {
965 wxItemPropertyInfo::GetPropertyNames(names);
966 names.Add("label");
967 }
968
969 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource *resource)
970 {
971 return wxItemPropertyInfo::InstantiateResource(resource);
972 }
973
974 /*
975 * Text item
976 */
977
978 wxProperty *wxTextPropertyInfo::GetProperty(wxString& name)
979 {
980 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
981 if (name == "value")
982 return new wxProperty("value", text->GetValue(), "string");
983 else if (name == "password")
984 {
985 bool isPassword = ((text->GetWindowStyleFlag() & wxTE_PASSWORD) == wxTE_PASSWORD);
986 return new wxProperty("password", isPassword, "bool");
987 }
988 else if (name == "readonly")
989 {
990 bool isReadOnly = ((text->GetWindowStyleFlag() & wxTE_READONLY) == wxTE_READONLY);
991 return new wxProperty("readonly", isReadOnly, "bool");
992 }
993 else
994 return wxItemPropertyInfo::GetProperty(name);
995 }
996
997 bool wxTextPropertyInfo::SetProperty(wxString& name, wxProperty *property)
998 {
999 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
1000 if (name == "value")
1001 {
1002 text->SetValue(property->GetValue().StringValue());
1003 return TRUE;
1004 }
1005 else if (name == "password")
1006 {
1007 long flag = text->GetWindowStyleFlag();
1008 if (property->GetValue().BoolValue())
1009 {
1010 if ((flag & wxTE_PASSWORD) != wxTE_PASSWORD)
1011 flag |= wxTE_PASSWORD;
1012 }
1013 else
1014 {
1015 if ((flag & wxTE_PASSWORD) == wxTE_PASSWORD)
1016 flag -= wxTE_PASSWORD;
1017 }
1018 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text);
1019 resource->SetStyle(flag);
1020
1021 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this);
1022 return TRUE;
1023 }
1024 else if (name == "readonly")
1025 {
1026 long flag = text->GetWindowStyleFlag();
1027 if (property->GetValue().BoolValue())
1028 {
1029 if ((flag & wxTE_READONLY) != wxTE_READONLY)
1030 flag |= wxTE_READONLY;
1031 }
1032 else
1033 {
1034 if ((flag & wxTE_READONLY) == wxTE_READONLY)
1035 flag -= wxTE_READONLY;
1036 }
1037 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text);
1038 resource->SetStyle(flag);
1039
1040 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this);
1041 return TRUE;
1042 }
1043 else
1044 return wxItemPropertyInfo::SetProperty(name, property);
1045 }
1046
1047 void wxTextPropertyInfo::GetPropertyNames(wxStringList& names)
1048 {
1049 wxItemPropertyInfo::GetPropertyNames(names);
1050 names.Add("value");
1051 names.Add("readonly");
1052 names.Add("password");
1053 }
1054
1055 bool wxTextPropertyInfo::InstantiateResource(wxItemResource *resource)
1056 {
1057 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
1058 wxString str(text->GetValue());
1059 resource->SetValue4(str);
1060
1061 return wxItemPropertyInfo::InstantiateResource(resource);
1062 }
1063
1064 /*
1065 * Listbox item
1066 */
1067
1068 wxProperty *wxListBoxPropertyInfo::GetProperty(wxString& name)
1069 {
1070 wxListBox *listBox = (wxListBox *)m_propertyWindow;
1071 if (name == "values")
1072 {
1073 wxStringList *stringList = new wxStringList;
1074 int i;
1075 for (i = 0; i < listBox->Number(); i++)
1076 stringList->Add(listBox->GetString(i));
1077
1078 return new wxProperty(name, stringList, "stringlist");
1079 }
1080 else if (name == "multiple")
1081 {
1082 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox);
1083 if (!resource)
1084 return NULL;
1085
1086 char *mult = "wxSINGLE";
1087
1088 switch (resource->GetValue1())
1089 {
1090 case wxLB_MULTIPLE:
1091 mult = "wxLB_MULTIPLE";
1092 break;
1093 case wxLB_EXTENDED:
1094 mult = "wxLB_EXTENDED";
1095 break;
1096 default:
1097 case wxLB_SINGLE:
1098 mult = "wxLB_SINGLE";
1099 break;
1100 }
1101 return new wxProperty("multiple", mult, "string",
1102 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1103 NULL)));
1104 }
1105 else
1106 return wxItemPropertyInfo::GetProperty(name);
1107 }
1108
1109 bool wxListBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1110 {
1111 wxListBox *listBox = (wxListBox *)m_propertyWindow;
1112 if (name == "values")
1113 {
1114 listBox->Clear();
1115 wxPropertyValue *expr = property->GetValue().GetFirst();
1116 while (expr)
1117 {
1118 char *s = expr->StringValue();
1119 if (s)
1120 listBox->Append(s);
1121 expr = expr->GetNext();
1122 }
1123 return TRUE;
1124 }
1125 else if (name == "multiple")
1126 {
1127 int mult = wxLB_SINGLE;
1128 wxString str(property->GetValue().StringValue());
1129 if (str == "wxLB_MULTIPLE")
1130 mult = wxLB_MULTIPLE;
1131 else if (str == "wxLB_EXTENDED")
1132 mult = wxLB_EXTENDED;
1133 else
1134 mult = wxLB_SINGLE;
1135 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox);
1136 if (resource)
1137 resource->SetValue1(mult);
1138 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this);
1139 return TRUE;
1140 }
1141 else
1142 return wxItemPropertyInfo::SetProperty(name, property);
1143 }
1144
1145 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList& names)
1146 {
1147 wxItemPropertyInfo::GetPropertyNames(names);
1148 names.Add("values");
1149 names.Add("multiple");
1150 }
1151
1152 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
1153 {
1154 wxListBox *lbox = (wxListBox *)m_propertyWindow;
1155 // This will be set for the wxItemResource on reading or in SetProperty
1156 // resource->SetValue1(lbox->GetSelectionMode());
1157 int i;
1158 if (lbox->Number() == 0)
1159 resource->SetStringValues(NULL);
1160 else
1161 {
1162 wxStringList slist;
1163
1164 for (i = 0; i < lbox->Number(); i++)
1165 slist.Add(lbox->GetString(i));
1166
1167 resource->SetStringValues(slist);
1168 }
1169 return wxItemPropertyInfo::InstantiateResource(resource);
1170 }
1171
1172 /*
1173 * Choice item
1174 */
1175
1176 wxProperty *wxChoicePropertyInfo::GetProperty(wxString& name)
1177 {
1178 wxChoice *choice = (wxChoice *)m_propertyWindow;
1179 if (name == "values")
1180 {
1181 wxStringList* stringList = new wxStringList;
1182 int i;
1183 for (i = 0; i < choice->Number(); i++)
1184 stringList->Add(choice->GetString(i));
1185
1186 return new wxProperty(name, stringList, "stringlist");
1187 }
1188 else
1189 return wxItemPropertyInfo::GetProperty(name);
1190 }
1191
1192 bool wxChoicePropertyInfo::SetProperty(wxString& name, wxProperty *property)
1193 {
1194 wxChoice *choice = (wxChoice *)m_propertyWindow;
1195 if (name == "values")
1196 {
1197 choice->Clear();
1198 wxPropertyValue *expr = property->GetValue().GetFirst();
1199 while (expr)
1200 {
1201 char *s = expr->StringValue();
1202 if (s)
1203 choice->Append(s);
1204 expr = expr->GetNext();
1205 }
1206 if (choice->Number() > 0)
1207 choice->SetSelection(0);
1208 return TRUE;
1209 }
1210 else
1211 return wxItemPropertyInfo::SetProperty(name, property);
1212 }
1213
1214 void wxChoicePropertyInfo::GetPropertyNames(wxStringList& names)
1215 {
1216 wxItemPropertyInfo::GetPropertyNames(names);
1217 names.Add("values");
1218 }
1219
1220 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource *resource)
1221 {
1222 wxChoice *choice = (wxChoice *)m_propertyWindow;
1223 int i;
1224 if (choice->Number() == 0)
1225 resource->SetStringValues(NULL);
1226 else
1227 {
1228 wxStringList slist;
1229
1230 for (i = 0; i < choice->Number(); i++)
1231 slist.Add(choice->GetString(i));
1232
1233 resource->SetStringValues(slist);
1234 }
1235 return wxItemPropertyInfo::InstantiateResource(resource);
1236 }
1237
1238 /*
1239 * Choice item
1240 */
1241
1242 wxProperty *wxComboBoxPropertyInfo::GetProperty(wxString& name)
1243 {
1244 wxComboBox *choice = (wxComboBox *)m_propertyWindow;
1245 if (name == "values")
1246 {
1247 wxStringList *stringList = new wxStringList;
1248 int i;
1249 for (i = 0; i < choice->Number(); i++)
1250 stringList->Add(choice->GetString(i));
1251
1252 return new wxProperty(name, stringList, "stringlist");
1253 }
1254 else if (name == "sort")
1255 {
1256 bool sort = ((m_propertyWindow->GetWindowStyleFlag() & wxCB_SORT) == wxCB_SORT);
1257 return new wxProperty(name, sort, "bool");
1258 }
1259 else if (name == "style")
1260 {
1261 wxString styleStr("dropdown");
1262 if (m_propertyWindow->GetWindowStyleFlag() & wxCB_SIMPLE)
1263 styleStr = "simple";
1264 else if (m_propertyWindow->GetWindowStyleFlag() & wxCB_READONLY)
1265 styleStr = "readonly";
1266 else
1267 styleStr = "dropdown";
1268
1269 return new wxProperty(name, styleStr, "string",
1270 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1271 NULL)));
1272 }
1273 else
1274 return wxItemPropertyInfo::GetProperty(name);
1275 }
1276
1277 bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1278 {
1279 wxComboBox *choice = (wxComboBox *)m_propertyWindow;
1280 if (name == "values")
1281 {
1282 choice->Clear();
1283 wxPropertyValue *expr = property->GetValue().GetFirst();
1284 while (expr)
1285 {
1286 char *s = expr->StringValue();
1287 if (s)
1288 choice->Append(s);
1289 expr = expr->GetNext();
1290 }
1291 if (choice->Number() > 0)
1292 choice->SetSelection(0);
1293 return TRUE;
1294 }
1295 else if (name == "sort")
1296 {
1297 SetWindowStyle(m_propertyWindow, wxCB_SORT, property->GetValue().BoolValue());
1298
1299 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
1300 resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
1301
1302 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this);
1303 return TRUE;
1304 }
1305 else if (name == "style")
1306 {
1307 SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, FALSE);
1308 SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, FALSE);
1309 SetWindowStyle(m_propertyWindow, wxCB_READONLY, FALSE);
1310
1311 wxString styleStr(property->GetValue().StringValue());
1312 if (styleStr == "simple")
1313 SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, TRUE);
1314 else if (styleStr == "dropdown")
1315 SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, TRUE);
1316 else if (styleStr == "readonly")
1317 SetWindowStyle(m_propertyWindow, wxCB_READONLY, TRUE);
1318
1319 // Necesary?
1320 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
1321 resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
1322
1323 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this);
1324
1325 return TRUE;
1326 }
1327 else
1328 return wxItemPropertyInfo::SetProperty(name, property);
1329 }
1330
1331 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList& names)
1332 {
1333 wxItemPropertyInfo::GetPropertyNames(names);
1334 names.Add("values");
1335 names.Add("style");
1336 names.Add("sort");
1337 }
1338
1339 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
1340 {
1341 wxComboBox *choice = (wxComboBox *)m_propertyWindow;
1342 int i;
1343 if (choice->Number() == 0)
1344 resource->SetStringValues(NULL);
1345 else
1346 {
1347 wxStringList slist;
1348
1349 for (i = 0; i < choice->Number(); i++)
1350 slist.Add(choice->GetString(i));
1351
1352 resource->SetStringValues(slist);
1353 }
1354 return wxItemPropertyInfo::InstantiateResource(resource);
1355 }
1356
1357 /*
1358 * Radiobox item
1359 */
1360
1361 wxProperty *wxRadioBoxPropertyInfo::GetProperty(wxString& name)
1362 {
1363 wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow;
1364 if (name == "numberRowsOrCols")
1365 {
1366 return new wxProperty("numberRowsOrCols", (long)radioBox->GetNumberOfRowsOrCols(), "integer");
1367 }
1368 if (name == "orientation")
1369 {
1370 wxString orient;
1371 if (m_propertyWindow->GetWindowStyleFlag() & wxRA_HORIZONTAL)
1372 orient = "wxRA_HORIZONTAL";
1373 else
1374 orient = "wxRA_VERTICAL";
1375
1376 return new wxProperty("orientation", orient, "string",
1377 new wxStringListValidator(new wxStringList("wxRA_HORIZONTAL", "wxRA_VERTICAL",
1378 NULL)));
1379 }
1380 else if (name == "values")
1381 {
1382 wxStringList *stringList = new wxStringList;
1383 int i;
1384 for (i = 0; i < radioBox->Number(); i++)
1385 stringList->Add(radioBox->GetString(i));
1386
1387 return new wxProperty(name, stringList, "stringlist");
1388 }
1389 return wxItemPropertyInfo::GetProperty(name);
1390 }
1391
1392 bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1393 {
1394 wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow;
1395 if (name == "numberRowsOrCols")
1396 {
1397 radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue());
1398 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
1399 return TRUE;
1400 }
1401 else if (name == "orientation")
1402 {
1403 long windowStyle = radioBox->GetWindowStyleFlag();
1404 wxString val(property->GetValue().StringValue());
1405 if (val == "wxRA_HORIZONTAL")
1406 {
1407 if (windowStyle & wxRA_VERTICAL)
1408 windowStyle -= wxRA_VERTICAL;
1409 windowStyle |= wxRA_HORIZONTAL;
1410 }
1411 else
1412 {
1413 if (windowStyle & wxRA_HORIZONTAL)
1414 windowStyle -= wxRA_HORIZONTAL;
1415 windowStyle |= wxRA_VERTICAL;
1416 }
1417 radioBox->SetWindowStyleFlag(windowStyle);
1418 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox);
1419 resource->SetStyle(windowStyle);
1420
1421 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
1422 return TRUE;
1423 }
1424 else if (name == "values")
1425 {
1426 // Set property into *resource*, not wxRadioBox, and then recreate
1427 // the wxRadioBox. This is because we can't dynamically set the strings
1428 // of a wxRadioBox.
1429 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
1430 if (!resource)
1431 return FALSE;
1432
1433 wxStringList stringList;
1434 wxPropertyValue *expr = property->GetValue().GetFirst();
1435 while (expr)
1436 {
1437 char *s = expr->StringValue();
1438 if (s)
1439 stringList.Add(s);
1440 expr = expr->GetNext();
1441 }
1442 resource->SetStringValues(stringList);
1443 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
1444 return TRUE;
1445 }
1446 return wxItemPropertyInfo::SetProperty(name, property);
1447 }
1448
1449 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList& names)
1450 {
1451 wxItemPropertyInfo::GetPropertyNames(names);
1452 names.Add("label");
1453 names.Add("values");
1454 names.Add("orientation");
1455 names.Add("numberRowsOrCols");
1456 }
1457
1458 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
1459 {
1460 wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow;
1461 // Take strings from resource instead
1462 /*
1463 int i;
1464 if (rbox->Number() == 0)
1465 resource->SetStringValues(NULL);
1466 else
1467 {
1468 wxStringList *slist = new wxStringList;
1469
1470 for (i = 0; i < rbox->Number(); i++)
1471 slist->Add(rbox->GetString(i));
1472
1473 resource->SetStringValues(slist);
1474 }
1475 */
1476 resource->SetValue1(rbox->GetNumberOfRowsOrCols());
1477 return wxItemPropertyInfo::InstantiateResource(resource);
1478 }
1479
1480 /*
1481 * Groupbox item
1482 */
1483
1484 wxProperty *wxGroupBoxPropertyInfo::GetProperty(wxString& name)
1485 {
1486 return wxItemPropertyInfo::GetProperty(name);
1487 }
1488
1489 bool wxGroupBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1490 {
1491 return wxItemPropertyInfo::SetProperty(name, property);
1492 }
1493
1494 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList& names)
1495 {
1496 wxItemPropertyInfo::GetPropertyNames(names);
1497 names.Add("label");
1498 }
1499
1500 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
1501 {
1502 return wxItemPropertyInfo::InstantiateResource(resource);
1503 }
1504
1505 /*
1506 * Checkbox item
1507 */
1508
1509 wxProperty *wxCheckBoxPropertyInfo::GetProperty(wxString& name)
1510 {
1511 wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
1512 if (name == "value")
1513 return new wxProperty("value", checkBox->GetValue(), "bool");
1514 else
1515 return wxItemPropertyInfo::GetProperty(name);
1516 }
1517
1518 bool wxCheckBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1519 {
1520 wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
1521 if (name == "value")
1522 {
1523 checkBox->SetValue((bool)property->GetValue().BoolValue());
1524 return TRUE;
1525 }
1526 else
1527 return wxItemPropertyInfo::SetProperty(name, property);
1528 }
1529
1530 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList& names)
1531 {
1532 wxItemPropertyInfo::GetPropertyNames(names);
1533 names.Add("label");
1534 names.Add("value");
1535 }
1536
1537 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
1538 {
1539 wxCheckBox *cbox = (wxCheckBox *)m_propertyWindow;
1540 resource->SetValue1(cbox->GetValue());
1541 return wxItemPropertyInfo::InstantiateResource(resource);
1542 }
1543
1544 /*
1545 * Radiobutton item
1546 */
1547
1548 wxProperty *wxRadioButtonPropertyInfo::GetProperty(wxString& name)
1549 {
1550 wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow;
1551 if (name == "value")
1552 return new wxProperty("value", checkBox->GetValue(), "bool");
1553 else
1554 return wxItemPropertyInfo::GetProperty(name);
1555 }
1556
1557 bool wxRadioButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1558 {
1559 wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow;
1560 if (name == "value")
1561 {
1562 checkBox->SetValue((bool)property->GetValue().BoolValue());
1563 return TRUE;
1564 }
1565 else
1566 return wxItemPropertyInfo::SetProperty(name, property);
1567 }
1568
1569 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList& names)
1570 {
1571 wxItemPropertyInfo::GetPropertyNames(names);
1572 names.Add("label");
1573 names.Add("value");
1574 }
1575
1576 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource *resource)
1577 {
1578 wxRadioButton *cbox = (wxRadioButton *)m_propertyWindow;
1579 resource->SetValue1(cbox->GetValue());
1580 return wxItemPropertyInfo::InstantiateResource(resource);
1581 }
1582
1583 /*
1584 * Slider item
1585 */
1586
1587 wxProperty *wxSliderPropertyInfo::GetProperty(wxString& name)
1588 {
1589 wxSlider *slider = (wxSlider *)m_propertyWindow;
1590 if (name == "value")
1591 return new wxProperty("value", (long)slider->GetValue(), "integer");
1592 else if (name == "orientation")
1593 {
1594 char *pos = NULL;
1595 if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL)
1596 pos = "wxHORIZONTAL";
1597 else
1598 pos = "wxVERTICAL";
1599
1600 return new wxProperty("orientation", pos, "string",
1601 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1602 NULL)));
1603 }
1604 else if (name == "minValue")
1605 return new wxProperty("minValue", (long)slider->GetMin(), "integer");
1606 else if (name == "maxValue")
1607 return new wxProperty("maxValue", (long)slider->GetMax(), "integer");
1608 else
1609 return wxItemPropertyInfo::GetProperty(name);
1610 }
1611
1612 bool wxSliderPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1613 {
1614 wxSlider *slider = (wxSlider *)m_propertyWindow;
1615 if (name == "value")
1616 {
1617 slider->SetValue((int)property->GetValue().IntegerValue());
1618 return TRUE;
1619 }
1620 else if (name == "orientation")
1621 {
1622 long windowStyle = slider->GetWindowStyleFlag();
1623 long oldWindowStyle = windowStyle;
1624 wxString val(property->GetValue().StringValue());
1625 if (val == "wxHORIZONTAL")
1626 {
1627 if (windowStyle & wxVERTICAL)
1628 windowStyle -= wxVERTICAL;
1629 windowStyle |= wxHORIZONTAL;
1630 }
1631 else
1632 {
1633 if (windowStyle & wxHORIZONTAL)
1634 windowStyle -= wxHORIZONTAL;
1635 windowStyle |= wxVERTICAL;
1636 }
1637
1638 if (oldWindowStyle == windowStyle)
1639 return TRUE;
1640
1641 slider->SetWindowStyleFlag(windowStyle);
1642
1643 // If the window style has changed, we swap the width and height parameters.
1644 int w, h;
1645 slider->GetSize(&w, &h);
1646
1647 slider = (wxSlider *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider, this);
1648 slider->SetSize(-1, -1, h, w);
1649
1650 return TRUE;
1651 }
1652 else if (name == "minValue")
1653 {
1654 slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax());
1655 return TRUE;
1656 }
1657 else if (name == "maxValue")
1658 {
1659 slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue());
1660 return TRUE;
1661 }
1662 else
1663 return wxItemPropertyInfo::SetProperty(name, property);
1664 }
1665
1666 void wxSliderPropertyInfo::GetPropertyNames(wxStringList& names)
1667 {
1668 wxItemPropertyInfo::GetPropertyNames(names);
1669 names.Add("value");
1670 names.Add("orientation");
1671 names.Add("minValue");
1672 names.Add("maxValue");
1673 }
1674
1675 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource)
1676 {
1677 wxSlider *slider = (wxSlider *)m_propertyWindow;
1678 resource->SetValue1(slider->GetValue());
1679 resource->SetValue2(slider->GetMin());
1680 resource->SetValue3(slider->GetMax());
1681 return wxItemPropertyInfo::InstantiateResource(resource);
1682 }
1683
1684 /*
1685 * Gauge item
1686 */
1687
1688 wxProperty *wxGaugePropertyInfo::GetProperty(wxString& name)
1689 {
1690 wxGauge *gauge = (wxGauge *)m_propertyWindow;
1691 if (name == "value")
1692 return new wxProperty("value", (long)gauge->GetValue(), "integer");
1693 else if (name == "maxValue")
1694 return new wxProperty("maxValue", (long)gauge->GetRange(), "integer");
1695 else
1696 return wxItemPropertyInfo::GetProperty(name);
1697 }
1698
1699 bool wxGaugePropertyInfo::SetProperty(wxString& name, wxProperty *property)
1700 {
1701 wxGauge *gauge = (wxGauge *)m_propertyWindow;
1702 if (name == "value")
1703 {
1704 gauge->SetValue((int)property->GetValue().IntegerValue());
1705 return TRUE;
1706 }
1707 else if (name == "maxValue")
1708 {
1709 gauge->SetRange((int)property->GetValue().IntegerValue());
1710 return TRUE;
1711 }
1712 else
1713 return wxItemPropertyInfo::SetProperty(name, property);
1714 }
1715
1716 void wxGaugePropertyInfo::GetPropertyNames(wxStringList& names)
1717 {
1718 wxItemPropertyInfo::GetPropertyNames(names);
1719 names.Add("value");
1720 names.Add("maxValue");
1721 }
1722
1723 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource)
1724 {
1725 wxGauge *gauge = (wxGauge *)m_propertyWindow;
1726 resource->SetValue1(gauge->GetValue());
1727 resource->SetValue2(gauge->GetRange());
1728 return wxItemPropertyInfo::InstantiateResource(resource);
1729 }
1730
1731 /*
1732 * Scrollbar item
1733 */
1734
1735 wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name)
1736 {
1737 wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow;
1738 if (name == "value")
1739 return new wxProperty("value", (long)scrollBar->GetValue(), "integer");
1740 else if (name == "orientation")
1741 {
1742 char *pos = NULL;
1743 if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL)
1744 pos = "wxHORIZONTAL";
1745 else
1746 pos = "wxVERTICAL";
1747
1748 return new wxProperty("orientation", pos, "string",
1749 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1750 NULL)));
1751 }
1752 else if (name == "pageSize")
1753 {
1754 int viewStart, pageLength, objectLength, viewLength;
1755 scrollBar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength);
1756
1757 return new wxProperty("pageSize", (long)pageLength, "integer");
1758 }
1759 else if (name == "viewLength")
1760 {
1761 int viewStart, pageLength, objectLength, viewLength;
1762 scrollBar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength);
1763
1764 return new wxProperty("viewLength", (long)viewLength, "integer");
1765 }
1766 else if (name == "objectLength")
1767 {
1768 int viewStart, pageLength, objectLength, viewLength;
1769 scrollBar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength);
1770
1771 return new wxProperty("objectLength", (long)objectLength, "integer");
1772 }
1773 else
1774 return wxItemPropertyInfo::GetProperty(name);
1775 }
1776
1777 bool wxScrollBarPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1778 {
1779 wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow;
1780 if (name == "value")
1781 {
1782 scrollBar->SetValue((int)property->GetValue().IntegerValue());
1783 return TRUE;
1784 }
1785 else if (name == "orientation")
1786 {
1787 long windowStyle = scrollBar->GetWindowStyleFlag();
1788 long oldWindowStyle = windowStyle;
1789 wxString val(property->GetValue().StringValue());
1790 if (val == "wxHORIZONTAL")
1791 {
1792 if (windowStyle & wxVERTICAL)
1793 windowStyle -= wxVERTICAL;
1794 windowStyle |= wxHORIZONTAL;
1795 }
1796 else
1797 {
1798 if (windowStyle & wxHORIZONTAL)
1799 windowStyle -= wxHORIZONTAL;
1800 windowStyle |= wxVERTICAL;
1801 }
1802
1803 if (oldWindowStyle == windowStyle)
1804 return TRUE;
1805
1806 scrollBar->SetWindowStyleFlag(windowStyle);
1807
1808 // If the window style has changed, we swap the width and height parameters.
1809 int w, h;
1810 scrollBar->GetSize(&w, &h);
1811
1812 scrollBar = (wxScrollBar *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar, this);
1813 scrollBar->SetSize(-1, -1, h, w);
1814
1815 return TRUE;
1816 }
1817 else if (name == "pageSize")
1818 {
1819 scrollBar->SetPageSize((int)property->GetValue().IntegerValue());
1820 return TRUE;
1821 }
1822 else if (name == "viewLength")
1823 {
1824 scrollBar->SetViewLength((int)property->GetValue().IntegerValue());
1825 return TRUE;
1826 }
1827 else if (name == "objectLength")
1828 {
1829 scrollBar->SetObjectLength((int)property->GetValue().IntegerValue());
1830 return TRUE;
1831 }
1832 else
1833 return wxItemPropertyInfo::SetProperty(name, property);
1834 }
1835
1836 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList& names)
1837 {
1838 wxItemPropertyInfo::GetPropertyNames(names);
1839 names.Add("orientation");
1840 names.Add("value");
1841 names.Add("pageSize");
1842 names.Add("viewLength");
1843 names.Add("objectLength");
1844
1845 // Remove some properties we don't inherit
1846 names.Delete("fontPoints");
1847 names.Delete("fontFamily");
1848 names.Delete("fontStyle");
1849 names.Delete("fontWeight");
1850 names.Delete("fontUnderlined");
1851 }
1852
1853 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource)
1854 {
1855 wxScrollBar *sbar = (wxScrollBar *)m_propertyWindow;
1856
1857 resource->SetValue1(sbar->GetValue());
1858
1859 int viewStart, pageLength, objectLength, viewLength;
1860 sbar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength);
1861
1862 resource->SetValue2(pageLength);
1863 resource->SetValue3(objectLength);
1864 resource->SetValue5(viewLength);
1865
1866 return wxItemPropertyInfo::InstantiateResource(resource);
1867 }
1868
1869 /*
1870 * Panels
1871 */
1872
1873 wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name)
1874 {
1875 wxPanel *panelWindow = (wxPanel *)m_propertyWindow;
1876 wxFont *labelFont = panelWindow->GetLabelFont();
1877 wxFont *buttonFont = panelWindow->GetButtonFont();
1878
1879 if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" ||
1880 name == "labelFontUnderlined")
1881 return GetFontProperty(name, labelFont);
1882 else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" ||
1883 name == "buttonFontUnderlined")
1884 return GetFontProperty(name, buttonFont);
1885 else if (name == "no3D")
1886 {
1887 bool userColours;
1888 if (panelWindow->GetWindowStyleFlag() & wxNO_3D)
1889 userColours = TRUE;
1890 else
1891 userColours = FALSE;
1892
1893 return new wxProperty(name, (bool)userColours, "bool");
1894 }
1895 else if (name == "backgroundColour")
1896 {
1897 wxColour col(panelWindow->GetBackgroundColour());
1898 char buf[7];
1899 wxDecToHex(col.Red(), buf);
1900 wxDecToHex(col.Green(), buf+2);
1901 wxDecToHex(col.Blue(), buf+4);
1902
1903 return new wxProperty(name, buf, "string", new wxColourListValidator);
1904 }
1905 else if (name == "title")
1906 {
1907 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
1908 if (resource)
1909 return new wxProperty(name, resource->GetTitle(), "string");
1910 else
1911 return new wxProperty(name, "Could not get title", "string");
1912 }
1913 else if (name == "caption")
1914 {
1915 return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxCAPTION) == wxCAPTION),
1916 "bool");
1917 }
1918 else if (name == "systemMenu")
1919 {
1920 return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxSYSTEM_MENU) == wxSYSTEM_MENU),
1921 "bool");
1922 }
1923 else if (name == "thickFrame")
1924 {
1925 return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxTHICK_FRAME) == wxTHICK_FRAME),
1926 "bool");
1927 }
1928 else if (name == "useSystemDefaults")
1929 {
1930 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
1931 return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) == wxRESOURCE_USE_DEFAULTS),
1932 "bool");
1933 }
1934 else if (name == "useDialogUnits")
1935 {
1936 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
1937 return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == wxRESOURCE_DIALOG_UNITS),
1938 "bool");
1939 }
1940 else
1941 return wxWindowPropertyInfo::GetProperty(name);
1942 }
1943
1944 bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property)
1945 {
1946 wxPanel *panelWindow = (wxPanel *)m_propertyWindow;
1947 wxFont *labelFont = panelWindow->GetLabelFont();
1948 wxFont *buttonFont = panelWindow->GetButtonFont();
1949
1950 if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" ))
1951 {
1952 wxFont *newFont = SetFontProperty(name, property, labelFont);
1953 if (newFont)
1954 panelWindow->SetLabelFont(newFont);
1955 return TRUE;
1956 }
1957 else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" ))
1958 {
1959 wxFont *newFont = SetFontProperty(name, property, buttonFont);
1960 if (newFont)
1961 panelWindow->SetButtonFont(newFont);
1962 return TRUE;
1963 }
1964 else if (name == "no3D")
1965 {
1966 bool userColours = property->GetValue().BoolValue();
1967
1968 if (userColours)
1969 {
1970 if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) != wxNO_3D)
1971 panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() | wxNO_3D);
1972 }
1973 else
1974 {
1975 if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) == wxNO_3D)
1976 panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() - wxNO_3D);
1977 }
1978 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
1979 resource->SetStyle(panelWindow->GetWindowStyleFlag());
1980
1981 panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
1982 return TRUE;
1983 }
1984 else if (name == "backgroundColour")
1985 {
1986 char *hex = property->GetValue().StringValue();
1987 int r = wxHexToDec(hex);
1988 int g = wxHexToDec(hex+2);
1989 int b = wxHexToDec(hex+4);
1990
1991 wxColour col(r,g,b);
1992 panelWindow->SetBackgroundColour(col);
1993 panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
1994 return TRUE;
1995 }
1996 else if (name == "title")
1997 {
1998 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
1999 if (resource)
2000 {
2001 resource->SetTitle(property->GetValue().StringValue());
2002 return TRUE;
2003 }
2004 else
2005 return FALSE;
2006 }
2007 else if (name == "caption")
2008 {
2009 SetWindowStyle(panelWindow, wxCAPTION, property->GetValue().BoolValue());
2010
2011 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
2012 resource->SetStyle(panelWindow->GetWindowStyleFlag());
2013 return TRUE;
2014 }
2015 else if (name == "thickFrame")
2016 {
2017 SetWindowStyle(panelWindow, wxTHICK_FRAME, property->GetValue().BoolValue());
2018
2019 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
2020 resource->SetStyle(panelWindow->GetWindowStyleFlag());
2021 return TRUE;
2022 }
2023 else if (name == "systemMenu")
2024 {
2025 SetWindowStyle(panelWindow, wxSYSTEM_MENU, property->GetValue().BoolValue());
2026
2027 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
2028 resource->SetStyle(panelWindow->GetWindowStyleFlag());
2029 return TRUE;
2030 }
2031 else if (name == "useSystemDefaults")
2032 {
2033 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
2034 bool useDefaults = property->GetValue().BoolValue();
2035 long style = resource->GetResourceStyle();
2036 if (useDefaults)
2037 {
2038 if ((style & wxRESOURCE_USE_DEFAULTS) == 0)
2039 style |= wxRESOURCE_USE_DEFAULTS;
2040 }
2041 else
2042 {
2043 if ((style & wxRESOURCE_USE_DEFAULTS) != 0)
2044 style -= wxRESOURCE_USE_DEFAULTS;
2045 }
2046 resource->SetResourceStyle(style);
2047 panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
2048 return TRUE;
2049 }
2050 else if (name == "useDialogUnits")
2051 {
2052 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
2053 bool useDialogUnits = property->GetValue().BoolValue();
2054 long style = resource->GetResourceStyle();
2055 if (useDialogUnits)
2056 {
2057 if ((style & wxRESOURCE_DIALOG_UNITS) == 0)
2058 {
2059 style |= wxRESOURCE_DIALOG_UNITS;
2060 ConvertDialogUnits(TRUE); // Convert all resources
2061 }
2062 }
2063 else
2064 {
2065 if ((style & wxRESOURCE_DIALOG_UNITS) != 0)
2066 {
2067 style -= wxRESOURCE_DIALOG_UNITS;
2068 ConvertDialogUnits(FALSE); // Convert all resources
2069 }
2070 }
2071 resource->SetResourceStyle(style);
2072 panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
2073 // TODO: need to regenerate the width and height properties else they'll be inconsistent.
2074 return TRUE;
2075 }
2076 else
2077 return wxWindowPropertyInfo::SetProperty(name, property);
2078 }
2079
2080 void wxPanelPropertyInfo::GetPropertyNames(wxStringList& names)
2081 {
2082 wxWindowPropertyInfo::GetPropertyNames(names);
2083
2084 names.Add("title");
2085 names.Add("no3D");
2086 names.Add("backgroundColour");
2087 names.Add("caption");
2088 names.Add("systemMenu");
2089 names.Add("thickFrame");
2090 names.Add("useSystemDefaults");
2091 names.Add("useDialogUnits");
2092 }
2093
2094 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource *resource)
2095 {
2096 wxPanel *panel = (wxPanel *)m_propertyWindow;
2097 if (panel->GetFont() && panel->GetFont()->Ok())
2098 resource->SetFont(wxTheFontList->FindOrCreateFont(panel->GetFont()->GetPointSize(),
2099 panel->GetFont()->GetFamily(), panel->GetFont()->GetStyle(), panel->GetFont()->GetWeight(),
2100 panel->GetFont()->GetUnderlined(), panel->GetFont()->GetFaceName()));
2101
2102 resource->SetBackgroundColour(wxColour(panel->GetBackgroundColour()));
2103
2104 return wxWindowPropertyInfo::InstantiateResource(resource);
2105 }
2106
2107 // Convert this dialog, and its children, to or from dialog units
2108 void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits)
2109 {
2110 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
2111
2112 wxPoint pt;
2113 wxSize sz;
2114 if (toDialogUnits)
2115 {
2116 sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(resource->GetWidth(), resource->GetHeight()));
2117 pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(resource->GetX(), resource->GetY()));
2118 }
2119 else
2120 {
2121 sz = m_propertyWindow->ConvertDialogToPixels(wxSize(resource->GetWidth(), resource->GetHeight()));
2122 pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(resource->GetX(), resource->GetY()));
2123 }
2124 resource->SetSize(pt.x, pt.y, sz.x, sz.y);
2125
2126 wxNode* node = m_propertyWindow->GetChildren()->First();
2127 while (node)
2128 {
2129 wxWindow* child = (wxWindow*) node->Data();
2130 if (child->IsKindOf(CLASSINFO(wxControl)))
2131 {
2132 resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(child);
2133 if (toDialogUnits)
2134 {
2135 sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(resource->GetWidth(), resource->GetHeight()));
2136 pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(resource->GetX(), resource->GetY()));
2137 }
2138 else
2139 {
2140 sz = m_propertyWindow->ConvertDialogToPixels(wxSize(resource->GetWidth(), resource->GetHeight()));
2141 pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(resource->GetX(), resource->GetY()));
2142 }
2143 resource->SetSize(pt.x, pt.y, sz.x, sz.y);
2144 }
2145 node = node->Next();
2146 }
2147 }
2148
2149 #if 0
2150 /*
2151 * Dialog boxes
2152 */
2153
2154 wxProperty *wxDialogPropertyInfo::GetProperty(wxString& name)
2155 {
2156 wxDialog *dialogWindow = (wxDialog *)m_propertyWindow;
2157 if (name == "modal")
2158 {
2159 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow);
2160 if (!resource)
2161 return NULL;
2162
2163 bool modal = (resource->GetValue1() != 0);
2164 return new wxProperty(name, modal, "bool");
2165 }
2166 else
2167 return wxPanelPropertyInfo::GetProperty(name);
2168 }
2169
2170 bool wxDialogPropertyInfo::SetProperty(wxString& name, wxProperty *property)
2171 {
2172 wxDialog *dialogWindow = (wxDialog *)m_propertyWindow;
2173
2174 if (name == "modal")
2175 {
2176 wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow);
2177 if (!resource)
2178 return FALSE;
2179
2180 resource->SetValue1(property->GetValue().BoolValue());
2181 return TRUE;
2182 }
2183 else
2184 return wxPanelPropertyInfo::SetProperty(name, property);
2185 }
2186
2187 void wxDialogPropertyInfo::GetPropertyNames(wxStringList& names)
2188 {
2189 wxPanelPropertyInfo::GetPropertyNames(names);
2190 names.Add("title");
2191 names.Add("modal");
2192 }
2193
2194 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource *resource)
2195 {
2196 wxDialog *dialog = (wxDialog *)m_propertyWindow;
2197 wxString str(dialog->GetTitle());
2198 resource->SetTitle(str);
2199
2200 return wxPanelPropertyInfo::InstantiateResource(resource);
2201 }
2202 #endif
2203
2204 /*
2205 * Utilities
2206 */
2207
2208 int wxStringToFontWeight(wxString& val)
2209 {
2210 if (val == "wxBOLD") return wxBOLD;
2211 else if (val == "wxLIGHT") return wxLIGHT;
2212 else return wxNORMAL;
2213 }
2214
2215 int wxStringToFontStyle(wxString& val)
2216 {
2217 if (val == "wxITALIC") return wxITALIC;
2218 else if (val == "wxSLANT") return wxSLANT;
2219 else return wxNORMAL;
2220 }
2221
2222 int wxStringToFontFamily(wxString& val)
2223 {
2224 if (val == "wxDECORATIVE") return wxDECORATIVE;
2225 else if (val == "wxROMAN") return wxROMAN;
2226 else if (val == "wxSCRIPT") return wxSCRIPT;
2227 else if (val == "wxMODERN") return wxMODERN;
2228 else if (val == "wxTELETYPE") return wxTELETYPE;
2229 else return wxSWISS;
2230 }
2231
2232 ///
2233 /// Resource symbol validator
2234 ///
2235 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator, wxPropertyListValidator)
2236
2237 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags):
2238 wxPropertyListValidator(flags)
2239 {
2240 }
2241
2242 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2243 {
2244 }
2245
2246 bool wxResourceSymbolValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow))
2247 {
2248 return TRUE;
2249 }
2250
2251 // Called when TICK is pressed or focus is lost or view wants to update
2252 // the property list.
2253 // Does the transferance from the property editing area to the property itself
2254 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
2255 {
2256 if (!view->GetValueText())
2257 return FALSE;
2258 wxString value(view->GetValueText()->GetValue());
2259 property->GetValue() = value ;
2260 return TRUE;
2261 }
2262
2263 // Called when TICK is pressed or focus is lost or view wants to update
2264 // the property list.
2265 // Does the transferance from the property editing area to the property itself
2266 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
2267 {
2268 if (!view->GetValueText())
2269 return FALSE;
2270 wxString str(property->GetValue().GetStringRepresentation());
2271 view->GetValueText()->SetValue(str);
2272 return TRUE;
2273 }
2274
2275 // Called when the property is double clicked. Extra functionality can be provided,
2276 // cycling through possible values.
2277 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
2278 {
2279 if (!view->GetValueText())
2280 return FALSE;
2281 OnEdit(property, view, parentWindow);
2282 return TRUE;
2283 }
2284
2285 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
2286 {
2287 if (view->GetConfirmButton())
2288 view->GetConfirmButton()->Enable(TRUE);
2289 if (view->GetCancelButton())
2290 view->GetCancelButton()->Enable(TRUE);
2291 if (view->GetEditButton())
2292 view->GetEditButton()->Enable(TRUE);
2293 if (view->GetValueText())
2294 view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING);
2295 return TRUE;
2296 }
2297
2298 void wxResourceSymbolValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
2299 {
2300 if (!view->GetValueText())
2301 return;
2302
2303 wxResourceSymbolDialog* dialog = new wxResourceSymbolDialog(parentWindow, -1, "Edit Symbol");
2304
2305 // Split name/id pair e.g. "IDC_TEXT=123"
2306 wxString value(property->GetValue().StringValue());
2307
2308 wxString strName = value.Before('=');
2309 wxString strId = value.After('=');
2310
2311 dialog->SetSymbol(strName);
2312 dialog->SetId(atoi(strId));
2313
2314 dialog->Init();
2315
2316 if (dialog->ShowModal() == wxID_OK)
2317 {
2318 wxString symbolName(dialog->GetSymbol());
2319 long id = dialog->GetId();
2320 dialog->Destroy();
2321
2322 wxString str;
2323 str.Printf("%d", id);
2324 property->GetValue() = symbolName + wxString("=") + str;
2325
2326 view->DisplayProperty(property);
2327 view->UpdatePropertyDisplayInList(property);
2328 view->OnPropertyChanged(property);
2329 }
2330 }
2331
2332 BEGIN_EVENT_TABLE(wxResourceSymbolDialog, wxDialog)
2333 EVT_BUTTON(wxID_OK, wxResourceSymbolDialog::OnOK)
2334 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnComboBoxSelect)
2335 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnSymbolNameUpdate)
2336 END_EVENT_TABLE()
2337
2338 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos,
2339 const wxSize& size, long style):
2340 wxDialog(parent, id, title, pos, size, style)
2341 {
2342 int x = 5;
2343 int y = 5;
2344
2345 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x, y));
2346
2347 x += 80;
2348
2349 m_nameCtrl = new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX, "",
2350 wxPoint(x, y), wxSize(200, -1), 0, NULL, wxCB_DROPDOWN|wxCB_SORT);
2351
2352 y += 30;
2353 x = 5;
2354
2355 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x, y));
2356
2357 x += 80;
2358
2359 m_idCtrl = new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL, "",
2360 wxPoint(x, y), wxSize(200, -1));
2361
2362 y += 30;
2363 x = 5;
2364 (void) new wxButton(this, wxID_OK, "OK", wxPoint(x, y), wxSize(80, -1));
2365
2366 x += 100;
2367 (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(x, y), wxSize(80, -1));
2368
2369 Fit();
2370 Centre();
2371 }
2372
2373 void wxResourceSymbolDialog::Init()
2374 {
2375 wxString defaultId;
2376 defaultId.Printf("%ld", m_symbolId);
2377
2378 m_nameCtrl->SetValue(m_symbolName);
2379 m_idCtrl->SetValue(defaultId);
2380
2381 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl);
2382 }
2383
2384 void wxResourceSymbolDialog::OnOK(wxCommandEvent& event)
2385 {
2386 if (CheckValues())
2387 {
2388 wxDialog::OnOK(event);
2389 }
2390 }
2391
2392 bool wxResourceSymbolDialog::CheckValues()
2393 {
2394 wxString nameStr(m_nameCtrl->GetValue());
2395 wxString idStr(m_idCtrl->GetValue());
2396 int id = atoi(idStr);
2397
2398 if (id <= 0 )
2399 {
2400 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
2401 return FALSE;
2402 }
2403 if (nameStr == "")
2404 {
2405 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
2406 return FALSE;
2407 }
2408 if (nameStr.Contains(" "))
2409 {
2410 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
2411 return FALSE;
2412 }
2413 if (nameStr.Contains("="))
2414 {
2415 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
2416 return FALSE;
2417 }
2418 if (nameStr.IsNumber())
2419 {
2420 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
2421 return FALSE;
2422 }
2423 // TODO: other checks on the name syntax.
2424
2425 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr))
2426 {
2427 // If we change the id for an existing symbol, we need to:
2428 // 1) Check if there are any other resources currently using the original id.
2429 // If so, will need to change their id to the new id, in SetProperty.
2430 // 2) Remove the old symbol, add the new symbol.
2431 // In this check, we don't have to do this, but we need to do it in SetProperty.
2432
2433 if (nameStr == GetSymbol() && id != GetId())
2434 {
2435 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2436 // in SetProperty.
2437 }
2438
2439 // If we change the name but not the id... we'll just need to remove and
2440 // re-add the symbol/id pair, in SetProperty.
2441 if (nameStr != GetSymbol() && id == GetId())
2442 {
2443 }
2444
2445 // What if we're changing both the name and the id?
2446 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2447 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2448
2449 if (nameStr != GetSymbol() && id != GetId())
2450 {
2451 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr, id))
2452 {
2453 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2454 "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
2455 return FALSE;
2456 }
2457 }
2458
2459 }
2460
2461 SetSymbol(nameStr);
2462 SetId(id);
2463
2464 return TRUE;
2465 }
2466
2467 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent& WXUNUSED(event))
2468 {
2469 wxString str(m_nameCtrl->GetStringSelection());
2470 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str))
2471 {
2472 int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
2473 wxString str2;
2474 str2.Printf("%d", id);
2475 m_idCtrl->SetValue(str2);
2476 m_idCtrl->Enable(FALSE);
2477 }
2478 else
2479 {
2480 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str))
2481 {
2482 int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
2483 wxString str2;
2484 str2.Printf("%d", id);
2485 m_idCtrl->SetValue(str2);
2486 }
2487 m_idCtrl->Enable(TRUE);
2488 }
2489 }
2490
2491 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent& WXUNUSED(event))
2492 {
2493 wxString str(m_nameCtrl->GetValue());
2494 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str))
2495 {
2496 int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
2497 wxString str2;
2498 str2.Printf("%d", id);
2499 m_idCtrl->SetValue(str2);
2500 m_idCtrl->Enable(FALSE);
2501 }
2502 else
2503 {
2504 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str))
2505 {
2506 int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
2507 wxString str2;
2508 str2.Printf("%d", id);
2509 m_idCtrl->SetValue(str2);
2510 }
2511 m_idCtrl->Enable(TRUE);
2512 }
2513 }
2514