1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Window properties
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "winprop.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
32 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
35 #include <strstream.h>
45 // Causes immediate feedback.
46 void wxResourcePropertyListView::OnPropertyChanged(wxProperty
*property
)
48 // Sets the value of the property back into the actual object,
49 // IF the property value was modified.
50 if (property
->GetValue().GetModified())
52 propertyInfo
->SetProperty(property
->GetName(), property
);
53 property
->GetValue().SetModified(FALSE
);
57 bool wxResourcePropertyListView::OnClose(void)
60 GetManagedWindow()->GetSize(& w
, & h
);
61 GetManagedWindow()->GetPosition(& x
, & y
);
63 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
= w
;
64 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
= h
;
65 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
= x
;
66 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
= y
;
68 return wxPropertyListView::OnClose();
71 wxWindow
*wxPropertyInfo::sm_propertyWindow
;
74 * wxDialogEditorPropertyListDialog
78 wxDialogEditorPropertyListDialog::wxDialogEditorPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title,
79 const wxPoint& pos, const wxSize& size,
80 long style, const wxString& name):
81 wxPropertyListDialog(v, parent, title, pos, size, style, name)
87 wxDialogEditorPropertyListDialog::~wxDialogEditorPropertyListDialog()
91 wxPropertyInfo::sm_propertyWindow = NULL;
95 wxDialogEditorPropertyListFrame::wxDialogEditorPropertyListFrame(wxPropertyListView
*v
, wxFrame
*parent
, const wxString
& title
,
96 const wxPoint
& pos
, const wxSize
& size
,
97 long style
, const wxString
& name
):
98 wxPropertyListFrame(v
, parent
, title
, pos
, size
, style
, name
)
104 wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
108 wxPropertyInfo::sm_propertyWindow
= NULL
;
115 // Edit the information represented by this object, whatever that
117 bool wxPropertyInfo::Edit(wxWindow
*parent
, const wxString
& title
)
119 if (sm_propertyWindow
)
122 int width
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
;
123 int height
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
;
124 int x
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
;
125 int y
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
;
127 wxPropertySheet
*propSheet
= new wxPropertySheet
;
129 wxStringList propNames
;
130 GetPropertyNames(propNames
);
132 wxNode
*node
= propNames
.First();
135 wxString
name((char *)node
->Data());
136 wxProperty
*prop
= GetProperty(name
);
139 propSheet
->AddProperty(prop
);
144 // Reset 'modified' flags for all property values
145 propSheet
->SetAllModified(FALSE
);
147 wxResourcePropertyListView
*view
= new wxResourcePropertyListView(this, NULL
,
148 wxPROP_BUTTON_OK
| wxPROP_BUTTON_CANCEL
|
149 wxPROP_BUTTON_CHECK_CROSS
|wxPROP_DYNAMIC_VALUE_FIELD
|wxPROP_PULLDOWN
|wxPROP_SHOWVALUES
);
151 wxDialogEditorPropertyListFrame
*propWin
= new wxDialogEditorPropertyListFrame(view
,
152 wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title
, wxPoint(x
, y
),
153 wxSize(width
, height
), wxDEFAULT_FRAME_STYLE
);
154 sm_propertyWindow
= propWin
;
156 propWin
->m_registry
.RegisterValidator((wxString
)"real", new wxRealListValidator
);
157 propWin
->m_registry
.RegisterValidator((wxString
)"string", new wxStringListValidator
);
158 propWin
->m_registry
.RegisterValidator((wxString
)"integer", new wxIntegerListValidator
);
159 propWin
->m_registry
.RegisterValidator((wxString
)"bool", new wxBoolListValidator
);
160 propWin
->m_registry
.RegisterValidator((wxString
)"filename", new wxFilenameListValidator
);
161 propWin
->m_registry
.RegisterValidator((wxString
)"stringlist", new wxListOfStringsListValidator
);
162 propWin
->m_registry
.RegisterValidator((wxString
)"window_id", new wxResourceSymbolValidator
);
164 propWin
->m_propInfo
= this;
165 propWin
->m_propSheet
= propSheet
;
167 // view->propertyWindow = propWin;
168 view
->AddRegistry(&(propWin
->m_registry
));
170 propWin
->Initialize();
171 view
->ShowView(propSheet
, propWin
->GetPropertyPanel());
178 * wxWindowPropertyInfo
181 wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
)
183 propertyWindow
= win
;
184 propertyResource
= res
;
187 wxWindowPropertyInfo::~wxWindowPropertyInfo(void)
191 wxProperty
*wxWindowPropertyInfo::GetFontProperty(wxString
& name
, wxFont
*font
)
196 if (name
.Contains("Points"))
197 return new wxProperty(name
, (long)font
->GetPointSize(), "integer", new wxIntegerListValidator(1, 100));
198 else if (name
.Contains("Family"))
199 return new wxProperty(name
, font
->GetFamilyString(), "string",
200 new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN",
202 else if (name
.Contains("Style"))
203 return new wxProperty(name
, font
->GetStyleString(), "string",
204 new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL
)));
205 else if (name
.Contains("Weight"))
206 return new wxProperty(name
, font
->GetWeightString(), "string",
207 new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL
)));
208 else if (name
.Contains("Underlined"))
209 return new wxProperty(name
, (bool)font
->GetUnderlined(), "bool");
214 wxFont
*wxWindowPropertyInfo::SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*font
)
217 int fontFamily
= wxMODERN
;
218 int fontStyle
= wxNORMAL
;
219 int fontWeight
= wxNORMAL
;
220 bool fontUnderlined
= FALSE
;
222 if (name
.Contains("Points"))
224 pointSize
= (int)property
->GetValue().IntegerValue();
225 if (font
&& (pointSize
== font
->GetPointSize()))
226 return NULL
; // No change
228 else if (font
) pointSize
= font
->GetPointSize();
230 if (name
.Contains("Family"))
232 wxString val
= property
->GetValue().StringValue();
233 fontFamily
= wxStringToFontFamily(val
);
235 if (font
&& (fontFamily
== font
->GetFamily()))
236 return NULL
; // No change
238 else if (font
) fontFamily
= font
->GetFamily();
240 if (name
.Contains("Style"))
242 wxString val
= property
->GetValue().StringValue();
243 fontStyle
= wxStringToFontStyle(val
);
245 if (font
&& (fontStyle
== font
->GetStyle()))
246 return NULL
; // No change
248 else if (font
) fontStyle
= font
->GetStyle();
249 if (name
.Contains("Weight"))
251 wxString val
= property
->GetValue().StringValue();
252 fontWeight
= wxStringToFontWeight(val
);
254 if (font
&& (fontWeight
== font
->GetWeight()))
255 return NULL
; // No change
257 else if (font
) fontWeight
= font
->GetWeight();
259 if (name
.Contains("Underlined"))
261 fontUnderlined
= property
->GetValue().BoolValue();
263 if (font
&& (fontUnderlined
== font
->GetUnderlined()))
264 return NULL
; // No change
266 else if (font
) fontUnderlined
= font
->GetUnderlined();
268 wxFont
*newFont
= wxTheFontList
->FindOrCreateFont(pointSize
, fontFamily
, fontStyle
, fontWeight
, fontUnderlined
);
277 wxProperty
*wxWindowPropertyInfo::GetProperty(wxString
& name
)
279 wxFont
*font
= propertyWindow
->GetFont();
280 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
281 name
== "fontUnderlined")
282 return GetFontProperty(name
, font
);
283 else if (name
== "name")
284 return new wxProperty("name", propertyWindow
->GetName(), "string");
285 else if (name
== "title")
286 return new wxProperty("title", propertyWindow
->GetTitle(), "string");
287 else if (name
== "x")
290 propertyWindow
->GetPosition(&x
, &y
);
291 return new wxProperty("x", (long)x
, "integer");
293 else if (name
== "y")
296 propertyWindow
->GetPosition(&x
, &y
);
297 return new wxProperty("y", (long)y
, "integer");
299 else if (name
== "width")
302 propertyWindow
->GetSize(&width
, &height
);
303 return new wxProperty("width", (long)width
, "integer");
305 else if (name
== "height")
308 propertyWindow
->GetSize(&width
, &height
);
309 return new wxProperty("height", (long)height
, "integer");
311 else if (name
== "id")
313 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
316 int id
= resource
->GetId();
318 idStr
.Printf("%d", id
);
319 wxString symbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id
);
322 // symbolName is now e.g. "ID_PANEL21=105"
323 return new wxProperty("id", symbolName
, "window_id");
328 else if (name
== "border")
331 if (propertyWindow
->GetWindowStyleFlag() & wxSIMPLE_BORDER
)
332 border
= "wxSIMPLE_BORDER";
333 else if (propertyWindow
->GetWindowStyleFlag() & wxRAISED_BORDER
)
334 border
= "wxRAISED_BORDER";
335 else if (propertyWindow
->GetWindowStyleFlag() & wxSUNKEN_BORDER
)
336 border
= "wxSUNKEN_BORDER";
337 else if (propertyWindow
->GetWindowStyleFlag() & wxDOUBLE_BORDER
)
338 border
= "wxDOUBLE_BORDER";
339 else if (propertyWindow
->GetWindowStyleFlag() & wxSTATIC_BORDER
)
340 border
= "wxSTATIC_BORDER";
342 border
= "wxNO_BORDER";
344 return new wxProperty("border", border
, "string",
345 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
346 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL
)));
352 bool wxWindowPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
354 wxFont
*font
= propertyWindow
->GetFont();
355 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
357 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
359 propertyWindow
->SetFont(newFont
);
362 else if (name
== "name")
364 // Remove old name from resource table, if it's there.
365 wxItemResource
*oldResource
= (wxItemResource
*)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(propertyWindow
->GetName());
368 // It's a top-level resource
369 propertyWindow
->SetName(property
->GetValue().StringValue());
370 oldResource
->SetName(property
->GetValue().StringValue());
371 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(propertyWindow
->GetName(), oldResource
);
375 // It's a child of something; just set the name of the resource and the window.
376 propertyWindow
->SetName(property
->GetValue().StringValue());
377 propertyResource
->SetName(property
->GetValue().StringValue());
379 // Refresh the resource manager list, because the name changed.
380 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
383 else if (name
== "title")
385 propertyWindow
->SetTitle(property
->GetValue().StringValue());
388 else if (name
== "x")
391 propertyWindow
->GetPosition(&x
, &y
);
392 int newX
= (int)property
->GetValue().IntegerValue();
394 propertyWindow
->Move(newX
, y
);
397 else if (name
== "y")
400 propertyWindow
->GetPosition(&x
, &y
);
401 int newY
= (int)property
->GetValue().IntegerValue();
403 propertyWindow
->Move(x
, newY
);
406 else if (name
== "width")
409 propertyWindow
->GetSize(&width
, &height
);
410 int newWidth
= (int)property
->GetValue().IntegerValue();
411 if (width
!= newWidth
)
413 propertyWindow
->SetSize(newWidth
, height
);
415 if (propertyWindow->IsKindOf(CLASSINFO(wxPanel)) && !propertyWindow->IsKindOf(CLASSINFO(wxDialog)))
417 propertyWindow->GetParent()->SetClientSize(newWidth, height);
423 else if (name
== "height")
426 propertyWindow
->GetSize(&width
, &height
);
427 int newHeight
= (int)property
->GetValue().IntegerValue();
428 if (height
!= newHeight
)
430 propertyWindow
->SetSize(width
, newHeight
);
432 if (propertyWindow->IsKindOf(CLASSINFO(wxPanel)) && !propertyWindow->IsKindOf(CLASSINFO(wxDialog)))
434 propertyWindow->GetParent()->SetClientSize(width, newHeight);
440 else if (name
== "id")
442 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
445 wxString value
= property
->GetValue().StringValue();
447 wxString strName
= value
.Before('=');
448 wxString strId
= value
.After('=');
449 int id
= atoi(strId
);
451 wxString oldSymbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource
->GetId());
452 int oldSymbolId
= resource
->GetId();
456 // If we change the id for an existing symbol, we need to:
457 // 1) Check if there are any other resources currently using the original id.
458 // If so, will need to change their id to the new id.
459 // 2) Remove the old symbol, add the new symbol.
460 // In this check, we don't have to do this, but we need to do it in SetProperty.
462 if (strName
== oldSymbolName
&& id
!= oldSymbolId
)
464 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
466 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
467 // because ids are unique and changing one resource's id must change all identical ones.
468 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId
, id
);
470 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
471 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
474 // If we change the name but not the id, we'll just need to remove and
475 // re-add the symbol/id pair.
476 if (strName
!= oldSymbolName
&& id
== oldSymbolId
)
478 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
480 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
482 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
484 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
488 // What if we're changing both the name and the id?
489 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
490 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
492 if (strName
!= oldSymbolName
&& id
!= oldSymbolId
)
494 // Remove old symbol if it's not being used
495 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource
, oldSymbolId
) &&
496 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
))
498 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
501 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
503 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
514 else if (name
== "border")
516 long borderStyle
= wxNO_BORDER
;
517 wxString val
= property
->GetValue().StringValue();
519 if (val
== "wxSIMPLE_BORDER")
520 borderStyle
= wxSIMPLE_BORDER
;
521 else if (val
== "wxRAISED_BORDER")
522 borderStyle
= wxRAISED_BORDER
;
523 else if (val
== "wxSUNKEN_BORDER")
524 borderStyle
= wxSUNKEN_BORDER
;
525 else if (val
== "wxDOUBLE_BORDER")
526 borderStyle
= wxDOUBLE_BORDER
;
527 else if (val
== "wxSTATIC_BORDER")
528 borderStyle
= wxSTATIC_BORDER
;
530 borderStyle
= wxNO_BORDER
;
532 SetWindowStyle(propertyWindow
, wxSIMPLE_BORDER
, FALSE
);
533 SetWindowStyle(propertyWindow
, wxRAISED_BORDER
, FALSE
);
534 SetWindowStyle(propertyWindow
, wxSUNKEN_BORDER
, FALSE
);
535 SetWindowStyle(propertyWindow
, wxDOUBLE_BORDER
, FALSE
);
536 SetWindowStyle(propertyWindow
, wxSTATIC_BORDER
, FALSE
);
537 SetWindowStyle(propertyWindow
, wxNO_BORDER
, FALSE
);
539 SetWindowStyle(propertyWindow
, borderStyle
, TRUE
);
541 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
542 resource
->SetStyle(propertyWindow
->GetWindowStyleFlag());
549 void wxWindowPropertyInfo::GetPropertyNames(wxStringList
& names
)
558 if (!propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
560 names
.Add("fontPoints");
561 names
.Add("fontFamily");
562 names
.Add("fontStyle");
563 names
.Add("fontWeight");
564 names
.Add("fontUnderlined");
568 // Fill in the wxItemResource members to mirror the current window settings
569 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource
*resource
)
571 // resource->SetType(propertyWindow->GetClassInfo()->GetClassName());
573 // resource->SetStyle(propertyWindow->GetWindowStyleFlag());
574 wxString
str(propertyWindow
->GetName());
575 resource
->SetName(WXSTRINGCAST str
);
577 propertyWindow
->GetSize(&w
, &h
);
579 propertyWindow
->GetPosition(&x
, &y
);
580 resource
->SetSize(x
, y
, w
, h
);
584 // Set the window style
585 void wxWindowPropertyInfo::SetWindowStyle(wxWindow
* win
, long style
, bool set
)
590 if ((win
->GetWindowStyleFlag() & style
) == style
)
594 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() - style
);
601 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() | style
);
610 wxProperty
*wxItemPropertyInfo::GetProperty(wxString
& name
)
612 wxControl
*itemWindow
= (wxControl
*)propertyWindow
;
613 wxFont
*font
= itemWindow
->GetFont();
615 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
616 name
== "fontUnderlined")
617 return GetFontProperty(name
, font
);
618 else if (name
== "label" && itemWindow
->GetLabel())
619 return new wxProperty("label", propertyWindow
->GetLabel(), "string");
621 return wxWindowPropertyInfo::GetProperty(name
);
624 bool wxItemPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
626 wxControl
*itemWindow
= (wxControl
*)propertyWindow
;
627 wxFont
*font
= itemWindow
->GetFont();
629 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
631 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
633 itemWindow
->SetLabelFont(newFont
);
636 else if (name
== "label")
638 itemWindow
->SetLabel(property
->GetValue().StringValue());
642 return wxWindowPropertyInfo::SetProperty(name
, property
);
645 void wxItemPropertyInfo::GetPropertyNames(wxStringList
& names
)
647 wxWindowPropertyInfo::GetPropertyNames(names
);
649 names
.Add("fontPoints");
650 names
.Add("fontFamily");
651 names
.Add("fontStyle");
652 names
.Add("fontWeight");
653 names
.Add("fontUnderlined");
656 bool wxItemPropertyInfo::InstantiateResource(wxItemResource
*resource
)
658 wxWindowPropertyInfo::InstantiateResource(resource
);
660 wxControl
*item
= (wxControl
*)propertyWindow
;
661 wxString
str(item
->GetLabel());
662 resource
->SetTitle(WXSTRINGCAST str
);
663 if (item
->GetFont() && item
->GetFont()->Ok())
664 resource
->SetFont(wxTheFontList
->FindOrCreateFont(item
->GetFont()->GetPointSize(),
665 item
->GetFont()->GetFamily(), item
->GetFont()->GetStyle(), item
->GetFont()->GetWeight(),
666 item
->GetFont()->GetUnderlined(), item
->GetFont()->GetFaceName()));
674 wxProperty
*wxButtonPropertyInfo::GetProperty(wxString
& name
)
676 wxButton
*button
= (wxButton
*)propertyWindow
;
677 return wxItemPropertyInfo::GetProperty(name
);
680 bool wxButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
682 wxButton
*button
= (wxButton
*)propertyWindow
;
683 return wxItemPropertyInfo::SetProperty(name
, property
);
686 void wxButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
688 wxItemPropertyInfo::GetPropertyNames(names
);
692 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
694 return wxItemPropertyInfo::InstantiateResource(resource
);
701 wxProperty
*wxBitmapButtonPropertyInfo::GetProperty(wxString
& name
)
703 wxBitmapButton
*button
= (wxBitmapButton
*)propertyWindow
;
706 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
707 wxString
str("none.bmp");
711 char *filename
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
715 return new wxProperty("label", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
718 return wxButtonPropertyInfo::GetProperty(name
);
721 bool wxBitmapButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
723 wxBitmapButton
*button
= (wxBitmapButton
*)propertyWindow
;
726 char *s
= property
->GetValue().StringValue();
727 if (s
&& wxFileExists(s
))
730 wxBitmap
*bitmap
= new wxBitmap(s
, wxBITMAP_TYPE_BMP
);
739 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
742 wxString
oldResource(resource
->GetValue4());
743 char *resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s
);
744 resource
->SetValue4(resName
);
746 if (!oldResource
.IsNull())
747 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(WXSTRINGCAST oldResource
);
750 button
->SetLabel(bitmap
);
758 return wxButtonPropertyInfo::SetProperty(name
, property
);
761 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
763 // names.Add("label");
764 wxButtonPropertyInfo::GetPropertyNames(names
);
767 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
769 return wxItemPropertyInfo::InstantiateResource(resource
);
776 wxProperty
*wxStaticTextPropertyInfo::GetProperty(wxString
& name
)
778 wxStaticText
*message
= (wxStaticText
*)propertyWindow
;
779 return wxItemPropertyInfo::GetProperty(name
);
782 bool wxStaticTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
784 wxStaticText
*message
= (wxStaticText
*)propertyWindow
;
785 return wxItemPropertyInfo::SetProperty(name
, property
);
788 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
790 wxItemPropertyInfo::GetPropertyNames(names
);
794 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
796 return wxItemPropertyInfo::InstantiateResource(resource
);
803 wxProperty
*wxStaticBitmapPropertyInfo::GetProperty(wxString
& name
)
805 wxStaticBitmap
*message
= (wxStaticBitmap
*)propertyWindow
;
808 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
809 wxString
str("none.bmp");
813 char *filename
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
817 return new wxProperty("label", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
820 return wxItemPropertyInfo::GetProperty(name
);
823 bool wxStaticBitmapPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
825 wxStaticBitmap
*message
= (wxStaticBitmap
*)propertyWindow
;
828 char *s
= property
->GetValue().StringValue();
829 if (s
&& wxFileExists(s
))
833 wxBitmap
*bitmap
= new wxBitmap(s
, wxBITMAP_TYPE_BMP
);
842 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
845 wxString
oldResource(resource
->GetValue4());
846 char *resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s
);
847 resource
->SetValue4(resName
);
849 if (!oldResource
.IsNull())
850 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(WXSTRINGCAST oldResource
);
853 message
->SetBitmap(bitmap
);
861 return wxItemPropertyInfo::SetProperty(name
, property
);
864 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList
& names
)
866 wxItemPropertyInfo::GetPropertyNames(names
);
870 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource
*resource
)
872 return wxItemPropertyInfo::InstantiateResource(resource
);
879 wxProperty
*wxTextPropertyInfo::GetProperty(wxString
& name
)
881 wxTextCtrl
*text
= (wxTextCtrl
*)propertyWindow
;
883 return new wxProperty("value", text
->GetValue(), "string");
884 else if (name
== "password")
886 bool isPassword
= ((text
->GetWindowStyleFlag() & wxTE_PASSWORD
) == wxTE_PASSWORD
);
887 return new wxProperty("password", isPassword
, "bool");
889 else if (name
== "readonly")
891 bool isReadOnly
= ((text
->GetWindowStyleFlag() & wxTE_READONLY
) == wxTE_READONLY
);
892 return new wxProperty("readonly", isReadOnly
, "bool");
895 return wxItemPropertyInfo::GetProperty(name
);
898 bool wxTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
900 wxTextCtrl
*text
= (wxTextCtrl
*)propertyWindow
;
903 text
->SetValue(property
->GetValue().StringValue());
906 else if (name
== "password")
908 long flag
= text
->GetWindowStyleFlag();
909 if (property
->GetValue().BoolValue())
911 if ((flag
& wxTE_PASSWORD
) != wxTE_PASSWORD
)
912 flag
|= wxTE_PASSWORD
;
916 if ((flag
& wxTE_PASSWORD
) == wxTE_PASSWORD
)
917 flag
-= wxTE_PASSWORD
;
919 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
920 resource
->SetStyle(flag
);
922 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
925 else if (name
== "readonly")
927 long flag
= text
->GetWindowStyleFlag();
928 if (property
->GetValue().BoolValue())
930 if ((flag
& wxTE_READONLY
) != wxTE_READONLY
)
931 flag
|= wxTE_READONLY
;
935 if ((flag
& wxTE_READONLY
) == wxTE_READONLY
)
936 flag
-= wxTE_READONLY
;
938 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
939 resource
->SetStyle(flag
);
941 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
945 return wxItemPropertyInfo::SetProperty(name
, property
);
948 void wxTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
950 wxItemPropertyInfo::GetPropertyNames(names
);
952 names
.Add("readonly");
953 names
.Add("password");
956 bool wxTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
958 wxTextCtrl
*text
= (wxTextCtrl
*)propertyWindow
;
959 wxString
str(text
->GetValue());
960 resource
->SetValue4(WXSTRINGCAST str
);
962 return wxItemPropertyInfo::InstantiateResource(resource
);
969 wxProperty
*wxListBoxPropertyInfo::GetProperty(wxString
& name
)
971 wxListBox
*listBox
= (wxListBox
*)propertyWindow
;
972 if (name
== "values")
974 wxStringList
*stringList
= new wxStringList
;
976 for (i
= 0; i
< listBox
->Number(); i
++)
977 stringList
->Add(listBox
->GetString(i
));
979 return new wxProperty(name
, stringList
, "stringlist");
981 else if (name
== "multiple")
984 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
988 char *mult
= "wxSINGLE";
990 switch (resource
->GetValue1())
993 mult
= "wxLB_MULTIPLE";
996 mult
= "wxLB_EXTENDED";
1000 mult
= "wxLB_SINGLE";
1003 return new wxProperty("multiple", mult
, "string",
1004 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1008 return wxItemPropertyInfo::GetProperty(name
);
1011 bool wxListBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1013 wxListBox
*listBox
= (wxListBox
*)propertyWindow
;
1014 if (name
== "values")
1017 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1020 char *s
= expr
->StringValue();
1023 expr
= expr
->GetNext();
1027 else if (name
== "multiple")
1029 int mult
= wxLB_SINGLE
;
1030 wxString
str(property
->GetValue().StringValue());
1031 if (str
== "wxLB_MULTIPLE")
1032 mult
= wxLB_MULTIPLE
;
1033 else if (str
== "wxLB_EXTENDED")
1034 mult
= wxLB_EXTENDED
;
1037 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1039 resource
->SetValue1(mult
);
1040 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox
, this);
1044 return wxItemPropertyInfo::SetProperty(name
, property
);
1047 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1049 wxItemPropertyInfo::GetPropertyNames(names
);
1050 names
.Add("values");
1051 names
.Add("multiple");
1054 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1056 wxListBox
*lbox
= (wxListBox
*)propertyWindow
;
1057 // This will be set for the wxItemResource on reading or in SetProperty
1058 // resource->SetValue1(lbox->GetSelectionMode());
1060 if (lbox
->Number() == 0)
1061 resource
->SetStringValues(NULL
);
1064 wxStringList
*slist
= new wxStringList
;
1066 for (i
= 0; i
< lbox
->Number(); i
++)
1067 slist
->Add(lbox
->GetString(i
));
1069 resource
->SetStringValues(slist
);
1071 return wxItemPropertyInfo::InstantiateResource(resource
);
1078 wxProperty
*wxChoicePropertyInfo::GetProperty(wxString
& name
)
1080 wxChoice
*choice
= (wxChoice
*)propertyWindow
;
1081 if (name
== "values")
1083 wxStringList
*stringList
= new wxStringList
;
1085 for (i
= 0; i
< choice
->Number(); i
++)
1086 stringList
->Add(choice
->GetString(i
));
1088 return new wxProperty(name
, stringList
, "stringlist");
1091 return wxItemPropertyInfo::GetProperty(name
);
1094 bool wxChoicePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1096 wxChoice
*choice
= (wxChoice
*)propertyWindow
;
1097 if (name
== "values")
1100 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1103 char *s
= expr
->StringValue();
1106 expr
= expr
->GetNext();
1108 if (choice
->Number() > 0)
1109 choice
->SetSelection(0);
1113 return wxItemPropertyInfo::SetProperty(name
, property
);
1116 void wxChoicePropertyInfo::GetPropertyNames(wxStringList
& names
)
1118 wxItemPropertyInfo::GetPropertyNames(names
);
1119 names
.Add("values");
1122 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1124 wxChoice
*choice
= (wxChoice
*)propertyWindow
;
1126 if (choice
->Number() == 0)
1127 resource
->SetStringValues(NULL
);
1130 wxStringList
*slist
= new wxStringList
;
1132 for (i
= 0; i
< choice
->Number(); i
++)
1133 slist
->Add(choice
->GetString(i
));
1135 resource
->SetStringValues(slist
);
1137 return wxItemPropertyInfo::InstantiateResource(resource
);
1144 wxProperty
*wxComboBoxPropertyInfo::GetProperty(wxString
& name
)
1146 wxComboBox
*choice
= (wxComboBox
*)propertyWindow
;
1147 if (name
== "values")
1149 wxStringList
*stringList
= new wxStringList
;
1151 for (i
= 0; i
< choice
->Number(); i
++)
1152 stringList
->Add(choice
->GetString(i
));
1154 return new wxProperty(name
, stringList
, "stringlist");
1156 else if (name
== "sort")
1158 bool sort
= ((propertyWindow
->GetWindowStyleFlag() & wxCB_SORT
) == wxCB_SORT
);
1159 return new wxProperty(name
, sort
, "bool");
1161 else if (name
== "style")
1163 wxString
styleStr("dropdown");
1164 if (propertyWindow
->GetWindowStyleFlag() & wxCB_SIMPLE
)
1165 styleStr
= "simple";
1166 else if (propertyWindow
->GetWindowStyleFlag() & wxCB_READONLY
)
1167 styleStr
= "readonly";
1169 styleStr
= "dropdown";
1171 return new wxProperty(name
, styleStr
, "string",
1172 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1176 return wxItemPropertyInfo::GetProperty(name
);
1179 bool wxComboBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1181 wxComboBox
*choice
= (wxComboBox
*)propertyWindow
;
1182 if (name
== "values")
1185 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1188 char *s
= expr
->StringValue();
1191 expr
= expr
->GetNext();
1193 if (choice
->Number() > 0)
1194 choice
->SetSelection(0);
1197 else if (name
== "sort")
1199 SetWindowStyle(propertyWindow
, wxCB_SORT
, property
->GetValue().BoolValue());
1201 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
1202 resource
->SetStyle(propertyWindow
->GetWindowStyleFlag());
1204 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow
, this);
1207 else if (name
== "style")
1209 SetWindowStyle(propertyWindow
, wxCB_SIMPLE
, FALSE
);
1210 SetWindowStyle(propertyWindow
, wxCB_DROPDOWN
, FALSE
);
1211 SetWindowStyle(propertyWindow
, wxCB_READONLY
, FALSE
);
1213 wxString
styleStr(property
->GetValue().StringValue());
1214 if (styleStr
== "simple")
1215 SetWindowStyle(propertyWindow
, wxCB_SIMPLE
, TRUE
);
1216 else if (styleStr
== "dropdown")
1217 SetWindowStyle(propertyWindow
, wxCB_DROPDOWN
, TRUE
);
1218 else if (styleStr
== "readonly")
1219 SetWindowStyle(propertyWindow
, wxCB_READONLY
, TRUE
);
1222 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
1223 resource
->SetStyle(propertyWindow
->GetWindowStyleFlag());
1225 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow
, this);
1230 return wxItemPropertyInfo::SetProperty(name
, property
);
1233 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1235 wxItemPropertyInfo::GetPropertyNames(names
);
1236 names
.Add("values");
1241 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1243 wxComboBox
*choice
= (wxComboBox
*)propertyWindow
;
1245 if (choice
->Number() == 0)
1246 resource
->SetStringValues(NULL
);
1249 wxStringList
*slist
= new wxStringList
;
1251 for (i
= 0; i
< choice
->Number(); i
++)
1252 slist
->Add(choice
->GetString(i
));
1254 resource
->SetStringValues(slist
);
1256 return wxItemPropertyInfo::InstantiateResource(resource
);
1263 wxProperty
*wxRadioBoxPropertyInfo::GetProperty(wxString
& name
)
1265 wxRadioBox
*radioBox
= (wxRadioBox
*)propertyWindow
;
1266 if (name
== "numberRowsOrCols")
1268 return new wxProperty("numberRowsOrCols", (long)radioBox
->GetNumberOfRowsOrCols(), "integer");
1270 if (name
== "orientation")
1273 if (propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1274 pos
= "wxHORIZONTAL";
1278 return new wxProperty("orientation", pos
, "string",
1279 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1282 else if (name
== "values")
1284 wxStringList
*stringList
= new wxStringList
;
1286 for (i
= 0; i
< radioBox
->Number(); i
++)
1287 stringList
->Add(radioBox
->GetString(i
));
1289 return new wxProperty(name
, stringList
, "stringlist");
1291 return wxItemPropertyInfo::GetProperty(name
);
1294 bool wxRadioBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1296 wxRadioBox
*radioBox
= (wxRadioBox
*)propertyWindow
;
1297 if (name
== "numberRowsOrCols")
1299 radioBox
->SetNumberOfRowsOrCols((int)property
->GetValue().IntegerValue());
1300 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1303 else if (name
== "orientation")
1305 long windowStyle
= radioBox
->GetWindowStyleFlag();
1306 wxString
val(property
->GetValue().StringValue());
1307 if (val
== "wxHORIZONTAL")
1309 if (windowStyle
& wxVERTICAL
)
1310 windowStyle
-= wxVERTICAL
;
1311 windowStyle
|= wxHORIZONTAL
;
1315 if (windowStyle
& wxHORIZONTAL
)
1316 windowStyle
-= wxHORIZONTAL
;
1317 windowStyle
|= wxVERTICAL
;
1319 radioBox
->SetWindowStyleFlag(windowStyle
);
1321 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1324 else if (name
== "values")
1326 // Set property into *resource*, not wxRadioBox, and then recreate
1327 // the wxRadioBox. This is because we can't dynamically set the strings
1329 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
1333 wxStringList
*stringList
= resource
->GetStringValues();
1336 stringList
= new wxStringList
;
1337 resource
->SetStringValues(stringList
);
1339 stringList
->Clear();
1341 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1344 char *s
= expr
->StringValue();
1347 expr
= expr
->GetNext();
1349 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1352 return wxItemPropertyInfo::SetProperty(name
, property
);
1355 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1357 wxItemPropertyInfo::GetPropertyNames(names
);
1359 names
.Add("values");
1360 names
.Add("orientation");
1361 names
.Add("numberRowsOrCols");
1364 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1366 wxRadioBox
*rbox
= (wxRadioBox
*)propertyWindow
;
1367 // Take strings from resource instead
1370 if (rbox->Number() == 0)
1371 resource->SetStringValues(NULL);
1374 wxStringList *slist = new wxStringList;
1376 for (i = 0; i < rbox->Number(); i++)
1377 slist->Add(rbox->GetString(i));
1379 resource->SetStringValues(slist);
1382 resource
->SetValue1(rbox
->GetNumberOfRowsOrCols());
1383 return wxItemPropertyInfo::InstantiateResource(resource
);
1390 wxProperty
*wxGroupBoxPropertyInfo::GetProperty(wxString
& name
)
1392 wxStaticBox
*groupBox
= (wxStaticBox
*)propertyWindow
;
1393 return wxItemPropertyInfo::GetProperty(name
);
1396 bool wxGroupBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1398 return wxItemPropertyInfo::SetProperty(name
, property
);
1401 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1403 wxItemPropertyInfo::GetPropertyNames(names
);
1407 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1409 wxStaticBox
*gbox
= (wxStaticBox
*)propertyWindow
;
1410 return wxItemPropertyInfo::InstantiateResource(resource
);
1417 wxProperty
*wxCheckBoxPropertyInfo::GetProperty(wxString
& name
)
1419 wxCheckBox
*checkBox
= (wxCheckBox
*)propertyWindow
;
1420 if (name
== "value")
1421 return new wxProperty("value", checkBox
->GetValue(), "bool");
1423 return wxItemPropertyInfo::GetProperty(name
);
1426 bool wxCheckBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1428 wxCheckBox
*checkBox
= (wxCheckBox
*)propertyWindow
;
1429 if (name
== "value")
1431 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1435 return wxItemPropertyInfo::SetProperty(name
, property
);
1438 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1440 wxItemPropertyInfo::GetPropertyNames(names
);
1445 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1447 wxCheckBox
*cbox
= (wxCheckBox
*)propertyWindow
;
1448 resource
->SetValue1(cbox
->GetValue());
1449 return wxItemPropertyInfo::InstantiateResource(resource
);
1456 wxProperty
*wxRadioButtonPropertyInfo::GetProperty(wxString
& name
)
1458 wxRadioButton
*checkBox
= (wxRadioButton
*)propertyWindow
;
1459 if (name
== "value")
1460 return new wxProperty("value", checkBox
->GetValue(), "bool");
1462 return wxItemPropertyInfo::GetProperty(name
);
1465 bool wxRadioButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1467 wxRadioButton
*checkBox
= (wxRadioButton
*)propertyWindow
;
1468 if (name
== "value")
1470 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1474 return wxItemPropertyInfo::SetProperty(name
, property
);
1477 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
1479 wxItemPropertyInfo::GetPropertyNames(names
);
1484 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1486 wxRadioButton
*cbox
= (wxRadioButton
*)propertyWindow
;
1487 resource
->SetValue1(cbox
->GetValue());
1488 return wxItemPropertyInfo::InstantiateResource(resource
);
1495 wxProperty
*wxSliderPropertyInfo::GetProperty(wxString
& name
)
1497 wxSlider
*slider
= (wxSlider
*)propertyWindow
;
1498 if (name
== "value")
1499 return new wxProperty("value", (long)slider
->GetValue(), "integer");
1500 else if (name
== "orientation")
1503 if (propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1504 pos
= "wxHORIZONTAL";
1508 return new wxProperty("orientation", pos
, "string",
1509 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1512 else if (name
== "minValue")
1513 return new wxProperty("minValue", (long)slider
->GetMin(), "integer");
1514 else if (name
== "maxValue")
1515 return new wxProperty("maxValue", (long)slider
->GetMax(), "integer");
1517 return wxItemPropertyInfo::GetProperty(name
);
1520 bool wxSliderPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1522 wxSlider
*slider
= (wxSlider
*)propertyWindow
;
1523 if (name
== "value")
1525 slider
->SetValue((int)property
->GetValue().IntegerValue());
1528 else if (name
== "orientation")
1530 long windowStyle
= slider
->GetWindowStyleFlag();
1531 long oldWindowStyle
= windowStyle
;
1532 wxString
val(property
->GetValue().StringValue());
1533 if (val
== "wxHORIZONTAL")
1535 if (windowStyle
& wxVERTICAL
)
1536 windowStyle
-= wxVERTICAL
;
1537 windowStyle
|= wxHORIZONTAL
;
1541 if (windowStyle
& wxHORIZONTAL
)
1542 windowStyle
-= wxHORIZONTAL
;
1543 windowStyle
|= wxVERTICAL
;
1546 if (oldWindowStyle
== windowStyle
)
1549 slider
->SetWindowStyleFlag(windowStyle
);
1551 // If the window style has changed, we swap the width and height parameters.
1553 slider
->GetSize(&w
, &h
);
1555 slider
= (wxSlider
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider
, this);
1556 slider
->SetSize(-1, -1, h
, w
);
1560 else if (name
== "minValue")
1562 slider
->SetRange((int)property
->GetValue().IntegerValue(), slider
->GetMax());
1565 else if (name
== "maxValue")
1567 slider
->SetRange(slider
->GetMin(), (int)property
->GetValue().IntegerValue());
1571 return wxItemPropertyInfo::SetProperty(name
, property
);
1574 void wxSliderPropertyInfo::GetPropertyNames(wxStringList
& names
)
1576 wxItemPropertyInfo::GetPropertyNames(names
);
1578 names
.Add("orientation");
1579 names
.Add("minValue");
1580 names
.Add("maxValue");
1583 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1585 wxSlider
*slider
= (wxSlider
*)propertyWindow
;
1586 resource
->SetValue1(slider
->GetValue());
1587 resource
->SetValue2(slider
->GetMin());
1588 resource
->SetValue3(slider
->GetMax());
1589 return wxItemPropertyInfo::InstantiateResource(resource
);
1596 wxProperty
*wxGaugePropertyInfo::GetProperty(wxString
& name
)
1598 wxGauge
*gauge
= (wxGauge
*)propertyWindow
;
1599 if (name
== "value")
1600 return new wxProperty("value", (long)gauge
->GetValue(), "integer");
1601 else if (name
== "maxValue")
1602 return new wxProperty("maxValue", (long)gauge
->GetRange(), "integer");
1604 return wxItemPropertyInfo::GetProperty(name
);
1607 bool wxGaugePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1609 wxGauge
*gauge
= (wxGauge
*)propertyWindow
;
1610 if (name
== "value")
1612 gauge
->SetValue((int)property
->GetValue().IntegerValue());
1615 else if (name
== "maxValue")
1617 gauge
->SetRange((int)property
->GetValue().IntegerValue());
1621 return wxItemPropertyInfo::SetProperty(name
, property
);
1624 void wxGaugePropertyInfo::GetPropertyNames(wxStringList
& names
)
1626 wxItemPropertyInfo::GetPropertyNames(names
);
1628 names
.Add("maxValue");
1631 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1633 wxGauge
*gauge
= (wxGauge
*)propertyWindow
;
1634 resource
->SetValue1(gauge
->GetValue());
1635 resource
->SetValue2(gauge
->GetRange());
1636 return wxItemPropertyInfo::InstantiateResource(resource
);
1643 wxProperty
*wxScrollBarPropertyInfo::GetProperty(wxString
& name
)
1645 wxScrollBar
*scrollBar
= (wxScrollBar
*)propertyWindow
;
1646 if (name
== "value")
1647 return new wxProperty("value", (long)scrollBar
->GetValue(), "integer");
1648 else if (name
== "orientation")
1651 if (propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1652 pos
= "wxHORIZONTAL";
1656 return new wxProperty("orientation", pos
, "string",
1657 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1660 else if (name
== "pageSize")
1662 int viewStart
, pageLength
, objectLength
, viewLength
;
1663 scrollBar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1665 return new wxProperty("pageSize", (long)pageLength
, "integer");
1667 else if (name
== "viewLength")
1669 int viewStart
, pageLength
, objectLength
, viewLength
;
1670 scrollBar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1672 return new wxProperty("viewLength", (long)viewLength
, "integer");
1674 else if (name
== "objectLength")
1676 int viewStart
, pageLength
, objectLength
, viewLength
;
1677 scrollBar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1679 return new wxProperty("objectLength", (long)objectLength
, "integer");
1682 return wxItemPropertyInfo::GetProperty(name
);
1685 bool wxScrollBarPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1687 wxScrollBar
*scrollBar
= (wxScrollBar
*)propertyWindow
;
1688 if (name
== "value")
1690 scrollBar
->SetValue((int)property
->GetValue().IntegerValue());
1693 else if (name
== "orientation")
1695 long windowStyle
= scrollBar
->GetWindowStyleFlag();
1696 long oldWindowStyle
= windowStyle
;
1697 wxString
val(property
->GetValue().StringValue());
1698 if (val
== "wxHORIZONTAL")
1700 if (windowStyle
& wxVERTICAL
)
1701 windowStyle
-= wxVERTICAL
;
1702 windowStyle
|= wxHORIZONTAL
;
1706 if (windowStyle
& wxHORIZONTAL
)
1707 windowStyle
-= wxHORIZONTAL
;
1708 windowStyle
|= wxVERTICAL
;
1711 if (oldWindowStyle
== windowStyle
)
1714 scrollBar
->SetWindowStyleFlag(windowStyle
);
1716 // If the window style has changed, we swap the width and height parameters.
1718 scrollBar
->GetSize(&w
, &h
);
1720 scrollBar
= (wxScrollBar
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar
, this);
1721 scrollBar
->SetSize(-1, -1, h
, w
);
1725 else if (name
== "pageSize")
1727 scrollBar
->SetPageSize((int)property
->GetValue().IntegerValue());
1730 else if (name
== "viewLength")
1732 scrollBar
->SetViewLength((int)property
->GetValue().IntegerValue());
1735 else if (name
== "objectLength")
1737 scrollBar
->SetObjectLength((int)property
->GetValue().IntegerValue());
1741 return wxItemPropertyInfo::SetProperty(name
, property
);
1744 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList
& names
)
1746 wxItemPropertyInfo::GetPropertyNames(names
);
1747 names
.Add("orientation");
1749 names
.Add("pageSize");
1750 names
.Add("viewLength");
1751 names
.Add("objectLength");
1753 // Remove some properties we don't inherit
1754 names
.Delete("fontPoints");
1755 names
.Delete("fontFamily");
1756 names
.Delete("fontStyle");
1757 names
.Delete("fontWeight");
1758 names
.Delete("fontUnderlined");
1761 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1763 wxScrollBar
*sbar
= (wxScrollBar
*)propertyWindow
;
1765 resource
->SetValue1(sbar
->GetValue());
1767 int viewStart
, pageLength
, objectLength
, viewLength
;
1768 sbar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1770 resource
->SetValue2(pageLength
);
1771 resource
->SetValue3(objectLength
);
1772 resource
->SetValue5(viewLength
);
1774 return wxItemPropertyInfo::InstantiateResource(resource
);
1781 wxProperty
*wxPanelPropertyInfo::GetProperty(wxString
& name
)
1783 wxPanel
*panelWindow
= (wxPanel
*)propertyWindow
;
1784 wxFont
*labelFont
= panelWindow
->GetLabelFont();
1785 wxFont
*buttonFont
= panelWindow
->GetButtonFont();
1787 if (name
== "labelFontPoints" || name
== "labelFontFamily" || name
== "labelFontStyle" || name
== "labelFontWeight" ||
1788 name
== "labelFontUnderlined")
1789 return GetFontProperty(name
, labelFont
);
1790 else if (name
== "buttonFontPoints" || name
== "buttonFontFamily" || name
== "buttonFontStyle" || name
== "buttonFontWeight" ||
1791 name
== "buttonFontUnderlined")
1792 return GetFontProperty(name
, buttonFont
);
1793 else if (name
== "no3D")
1796 if (panelWindow
->GetWindowStyleFlag() & wxNO_3D
)
1799 userColours
= FALSE
;
1801 return new wxProperty(name
, (bool)userColours
, "bool");
1803 else if (name
== "backgroundColour")
1805 wxColour
col(panelWindow
->GetBackgroundColour());
1807 wxDecToHex(col
.Red(), buf
);
1808 wxDecToHex(col
.Green(), buf
+2);
1809 wxDecToHex(col
.Blue(), buf
+4);
1811 return new wxProperty(name
, buf
, "string", new wxColourListValidator
);
1813 else if (name
== "title")
1815 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1817 return new wxProperty(name
, resource
->GetTitle(), "string");
1819 return new wxProperty(name
, "Could not get title", "string");
1821 else if (name
== "caption")
1823 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxCAPTION
) == wxCAPTION
),
1826 else if (name
== "systemMenu")
1828 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxSYSTEM_MENU
) == wxSYSTEM_MENU
),
1831 else if (name
== "thickFrame")
1833 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxTHICK_FRAME
) == wxTHICK_FRAME
),
1837 return wxWindowPropertyInfo::GetProperty(name
);
1840 bool wxPanelPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1842 wxPanel
*panelWindow
= (wxPanel
*)propertyWindow
;
1843 wxFont
*labelFont
= panelWindow
->GetLabelFont();
1844 wxFont
*buttonFont
= panelWindow
->GetButtonFont();
1846 if (labelFont
&& (name
== "labelFontPoints" || name
== "labelFontFamily" || name
== "labelFontStyle" || name
== "labelFontWeight" || name
== "labelFontUnderlined" ))
1848 wxFont
*newFont
= SetFontProperty(name
, property
, labelFont
);
1850 panelWindow
->SetLabelFont(newFont
);
1853 else if (buttonFont
&& (name
== "buttonFontPoints" || name
== "buttonFontFamily" || name
== "buttonFontStyle" || name
== "buttonFontWeight" || name
== "buttonFontUnderlined" ))
1855 wxFont
*newFont
= SetFontProperty(name
, property
, buttonFont
);
1857 panelWindow
->SetButtonFont(newFont
);
1860 else if (name
== "no3D")
1862 bool userColours
= property
->GetValue().BoolValue();
1863 long flag
= panelWindow
->GetWindowStyleFlag();
1867 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) != wxNO_3D
)
1868 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() | wxNO_3D
);
1872 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) == wxNO_3D
)
1873 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() - wxNO_3D
);
1875 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1876 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1878 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
1881 else if (name
== "backgroundColour")
1883 char *hex
= property
->GetValue().StringValue();
1884 int r
= wxHexToDec(hex
);
1885 int g
= wxHexToDec(hex
+2);
1886 int b
= wxHexToDec(hex
+4);
1888 wxColour
col(r
,g
,b
);
1889 panelWindow
->SetBackgroundColour(col
);
1890 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
1893 else if (name
== "title")
1895 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1898 resource
->SetTitle(property
->GetValue().StringValue());
1904 else if (name
== "caption")
1906 SetWindowStyle(panelWindow
, wxCAPTION
, property
->GetValue().BoolValue());
1908 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1909 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1912 else if (name
== "thickFrame")
1914 SetWindowStyle(panelWindow
, wxTHICK_FRAME
, property
->GetValue().BoolValue());
1916 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1917 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1920 else if (name
== "systemMenu")
1922 SetWindowStyle(panelWindow
, wxSYSTEM_MENU
, property
->GetValue().BoolValue());
1924 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1925 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1929 return wxWindowPropertyInfo::SetProperty(name
, property
);
1932 void wxPanelPropertyInfo::GetPropertyNames(wxStringList
& names
)
1934 wxWindowPropertyInfo::GetPropertyNames(names
);
1938 names
.Add("backgroundColour");
1939 names
.Add("caption");
1940 names
.Add("systemMenu");
1941 names
.Add("thickFrame");
1944 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1946 wxPanel
*panel
= (wxPanel
*)propertyWindow
;
1947 if (panel
->GetFont())
1948 resource
->SetFont(wxTheFontList
->FindOrCreateFont(panel
->GetFont()->GetPointSize(),
1949 panel
->GetFont()->GetFamily(), panel
->GetFont()->GetStyle(), panel
->GetFont()->GetWeight(),
1950 panel
->GetFont()->GetUnderlined(), panel
->GetFont()->GetFaceName()));
1952 resource
->SetBackgroundColour(new wxColour(panel
->GetBackgroundColour()));
1954 return wxWindowPropertyInfo::InstantiateResource(resource
);
1962 wxProperty
*wxDialogPropertyInfo::GetProperty(wxString
& name
)
1964 wxDialog
*dialogWindow
= (wxDialog
*)propertyWindow
;
1965 if (name
== "modal")
1967 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
1971 bool modal
= (resource
->GetValue1() != 0);
1972 return new wxProperty(name
, modal
, "bool");
1975 return wxPanelPropertyInfo::GetProperty(name
);
1978 bool wxDialogPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1980 wxDialog
*dialogWindow
= (wxDialog
*)propertyWindow
;
1982 if (name
== "modal")
1984 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
1988 resource
->SetValue1(property
->GetValue().BoolValue());
1992 return wxPanelPropertyInfo::SetProperty(name
, property
);
1995 void wxDialogPropertyInfo::GetPropertyNames(wxStringList
& names
)
1997 wxPanelPropertyInfo::GetPropertyNames(names
);
2002 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2004 wxDialog
*dialog
= (wxDialog
*)propertyWindow
;
2005 wxString
str(dialog
->GetTitle());
2006 resource
->SetTitle(WXSTRINGCAST str
);
2008 return wxPanelPropertyInfo::InstantiateResource(resource
);
2016 int wxStringToFontWeight(wxString
& val
)
2018 if (val
== "wxBOLD") return wxBOLD
;
2019 else if (val
== "wxLIGHT") return wxLIGHT
;
2020 else return wxNORMAL
;
2023 int wxStringToFontStyle(wxString
& val
)
2025 if (val
== "wxITALIC") return wxITALIC
;
2026 else if (val
== "wxSLANT") return wxSLANT
;
2027 else return wxNORMAL
;
2030 int wxStringToFontFamily(wxString
& val
)
2032 if (val
== "wxDECORATIVE") return wxDECORATIVE
;
2033 else if (val
== "wxROMAN") return wxROMAN
;
2034 else if (val
== "wxSCRIPT") return wxSCRIPT
;
2035 else if (val
== "wxMODERN") return wxMODERN
;
2036 else if (val
== "wxTELETYPE") return wxTELETYPE
;
2037 else return wxSWISS
;
2041 /// Resource symbol validator
2043 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator
, wxPropertyListValidator
)
2045 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags
):
2046 wxPropertyListValidator(flags
)
2050 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2054 bool wxResourceSymbolValidator::OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2059 // Called when TICK is pressed or focus is lost or view wants to update
2060 // the property list.
2061 // Does the transferance from the property editing area to the property itself
2062 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2064 if (!view
->GetValueText())
2066 wxString
value(view
->GetValueText()->GetValue());
2067 property
->GetValue() = value
;
2071 // Called when TICK is pressed or focus is lost or view wants to update
2072 // the property list.
2073 // Does the transferance from the property editing area to the property itself
2074 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2076 if (!view
->GetValueText())
2078 wxString
str(property
->GetValue().GetStringRepresentation());
2079 view
->GetValueText()->SetValue(str
);
2083 // Called when the property is double clicked. Extra functionality can be provided,
2084 // cycling through possible values.
2085 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2087 if (!view
->GetValueText())
2089 OnEdit(property
, view
, parentWindow
);
2093 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2095 if (view
->GetConfirmButton())
2096 view
->GetConfirmButton()->Enable(TRUE
);
2097 if (view
->GetCancelButton())
2098 view
->GetCancelButton()->Enable(TRUE
);
2099 if (view
->GetEditButton())
2100 view
->GetEditButton()->Enable(TRUE
);
2101 if (view
->GetValueText())
2102 view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
);
2106 void wxResourceSymbolValidator::OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2108 if (!view
->GetValueText())
2111 wxResourceSymbolDialog
* dialog
= new wxResourceSymbolDialog(parentWindow
, -1, "Edit Symbol");
2113 // Split name/id pair e.g. "IDC_TEXT=123"
2114 wxString
value(property
->GetValue().StringValue());
2116 wxString strName
= value
.Before('=');
2117 wxString strId
= value
.After('=');
2119 dialog
->SetSymbol(strName
);
2120 dialog
->SetId(atoi(strId
));
2124 if (dialog
->ShowModal() == wxID_OK
)
2126 wxString
symbolName(dialog
->GetSymbol());
2127 long id
= dialog
->GetId();
2131 str
.Printf("%d", id
);
2132 property
->GetValue() = symbolName
+ wxString("=") + str
;
2134 view
->DisplayProperty(property
);
2135 view
->UpdatePropertyDisplayInList(property
);
2136 view
->OnPropertyChanged(property
);
2140 BEGIN_EVENT_TABLE(wxResourceSymbolDialog
, wxDialog
)
2141 EVT_BUTTON(wxID_OK
, wxResourceSymbolDialog::OnOK
)
2142 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnComboBoxSelect
)
2143 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnSymbolNameUpdate
)
2146 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
2147 const wxSize
& size
, long style
):
2148 wxDialog(parent
, id
, title
, pos
, size
, style
)
2153 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x
, y
));
2157 m_nameCtrl
= new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX
, "",
2158 wxPoint(x
, y
), wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
|wxCB_SORT
);
2163 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x
, y
));
2167 m_idCtrl
= new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL
, "",
2168 wxPoint(x
, y
), wxSize(200, -1));
2172 (void) new wxButton(this, wxID_OK
, "OK", wxPoint(x
, y
), wxSize(80, -1));
2175 (void) new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(x
, y
), wxSize(80, -1));
2181 void wxResourceSymbolDialog::Init()
2184 defaultId
.Printf("%ld", m_symbolId
);
2186 m_nameCtrl
->SetValue(m_symbolName
);
2187 m_idCtrl
->SetValue(defaultId
);
2189 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl
);
2192 void wxResourceSymbolDialog::OnOK(wxCommandEvent
& event
)
2196 wxDialog::OnOK(event
);
2200 bool wxResourceSymbolDialog::CheckValues()
2202 wxString
nameStr(m_nameCtrl
->GetValue());
2203 wxString
idStr(m_idCtrl
->GetValue());
2204 int id
= atoi(idStr
);
2208 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2213 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2216 if (nameStr
.Contains(" "))
2218 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2221 if (nameStr
.Contains("="))
2223 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2226 if (nameStr
.IsNumber())
2228 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2231 // TODO: other checks on the name syntax.
2233 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr
))
2235 // If we change the id for an existing symbol, we need to:
2236 // 1) Check if there are any other resources currently using the original id.
2237 // If so, will need to change their id to the new id, in SetProperty.
2238 // 2) Remove the old symbol, add the new symbol.
2239 // In this check, we don't have to do this, but we need to do it in SetProperty.
2241 if (nameStr
== GetSymbol() && id
!= GetId())
2243 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2247 // If we change the name but not the id... we'll just need to remove and
2248 // re-add the symbol/id pair, in SetProperty.
2249 if (nameStr
!= GetSymbol() && id
== GetId())
2253 // What if we're changing both the name and the id?
2254 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2255 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2257 if (nameStr
!= GetSymbol() && id
!= GetId())
2259 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr
, id
))
2261 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2262 "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2275 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent
& event
)
2277 wxString
str(m_nameCtrl
->GetStringSelection());
2278 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2280 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2282 str2
.Printf("%d", id
);
2283 m_idCtrl
->SetValue(str2
);
2284 m_idCtrl
->Enable(FALSE
);
2288 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2290 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2292 str2
.Printf("%d", id
);
2293 m_idCtrl
->SetValue(str2
);
2295 m_idCtrl
->Enable(TRUE
);
2299 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent
& event
)
2301 wxString
str(m_nameCtrl
->GetValue());
2302 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2304 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2306 str2
.Printf("%d", id
);
2307 m_idCtrl
->SetValue(str2
);
2308 m_idCtrl
->Enable(FALSE
);
2312 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2314 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2316 str2
.Printf("%d", id
);
2317 m_idCtrl
->SetValue(str2
);
2319 m_idCtrl
->Enable(TRUE
);