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
)
121 sm_propertyWindow
->Raise();
125 int width
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
;
126 int height
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
;
127 int x
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
;
128 int y
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
;
130 wxPropertySheet
*propSheet
= new wxPropertySheet
;
132 wxStringList propNames
;
133 GetPropertyNames(propNames
);
135 wxNode
*node
= propNames
.First();
138 wxString
name((char *)node
->Data());
139 wxProperty
*prop
= GetProperty(name
);
142 propSheet
->AddProperty(prop
);
147 // Reset 'modified' flags for all property values
148 propSheet
->SetAllModified(FALSE
);
150 wxResourcePropertyListView
*view
= new wxResourcePropertyListView(this, NULL
,
151 wxPROP_BUTTON_OK
| wxPROP_BUTTON_CANCEL
|
152 wxPROP_BUTTON_CHECK_CROSS
|wxPROP_DYNAMIC_VALUE_FIELD
|wxPROP_PULLDOWN
|wxPROP_SHOWVALUES
);
154 wxDialogEditorPropertyListFrame
*propWin
= new wxDialogEditorPropertyListFrame(view
,
155 wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title
, wxPoint(x
, y
),
156 wxSize(width
, height
), wxDEFAULT_FRAME_STYLE
);
157 sm_propertyWindow
= propWin
;
159 propWin
->m_registry
.RegisterValidator((wxString
)"real", new wxRealListValidator
);
160 propWin
->m_registry
.RegisterValidator((wxString
)"string", new wxStringListValidator
);
161 propWin
->m_registry
.RegisterValidator((wxString
)"integer", new wxIntegerListValidator
);
162 propWin
->m_registry
.RegisterValidator((wxString
)"bool", new wxBoolListValidator
);
163 propWin
->m_registry
.RegisterValidator((wxString
)"filename", new wxFilenameListValidator
);
164 propWin
->m_registry
.RegisterValidator((wxString
)"stringlist", new wxListOfStringsListValidator
);
165 propWin
->m_registry
.RegisterValidator((wxString
)"window_id", new wxResourceSymbolValidator
);
167 propWin
->m_propInfo
= this;
168 propWin
->m_propSheet
= propSheet
;
170 // view->propertyWindow = propWin;
171 view
->AddRegistry(&(propWin
->m_registry
));
173 propWin
->Initialize();
174 view
->ShowView(propSheet
, propWin
->GetPropertyPanel());
181 * wxWindowPropertyInfo
184 wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
)
186 propertyWindow
= win
;
187 propertyResource
= res
;
190 wxWindowPropertyInfo::~wxWindowPropertyInfo(void)
194 wxProperty
*wxWindowPropertyInfo::GetFontProperty(wxString
& name
, wxFont
*font
)
199 if (name
.Contains("Points"))
200 return new wxProperty(name
, (long)font
->GetPointSize(), "integer", new wxIntegerListValidator(1, 100));
201 else if (name
.Contains("Family"))
202 return new wxProperty(name
, font
->GetFamilyString(), "string",
203 new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN",
205 else if (name
.Contains("Style"))
206 return new wxProperty(name
, font
->GetStyleString(), "string",
207 new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL
)));
208 else if (name
.Contains("Weight"))
209 return new wxProperty(name
, font
->GetWeightString(), "string",
210 new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL
)));
211 else if (name
.Contains("Underlined"))
212 return new wxProperty(name
, (bool)font
->GetUnderlined(), "bool");
217 wxFont
*wxWindowPropertyInfo::SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*font
)
220 int fontFamily
= wxMODERN
;
221 int fontStyle
= wxNORMAL
;
222 int fontWeight
= wxNORMAL
;
223 bool fontUnderlined
= FALSE
;
225 if (name
.Contains("Points"))
227 pointSize
= (int)property
->GetValue().IntegerValue();
228 if (font
&& (pointSize
== font
->GetPointSize()))
229 return NULL
; // No change
231 else if (font
) pointSize
= font
->GetPointSize();
233 if (name
.Contains("Family"))
235 wxString val
= property
->GetValue().StringValue();
236 fontFamily
= wxStringToFontFamily(val
);
238 if (font
&& (fontFamily
== font
->GetFamily()))
239 return NULL
; // No change
241 else if (font
) fontFamily
= font
->GetFamily();
243 if (name
.Contains("Style"))
245 wxString val
= property
->GetValue().StringValue();
246 fontStyle
= wxStringToFontStyle(val
);
248 if (font
&& (fontStyle
== font
->GetStyle()))
249 return NULL
; // No change
251 else if (font
) fontStyle
= font
->GetStyle();
252 if (name
.Contains("Weight"))
254 wxString val
= property
->GetValue().StringValue();
255 fontWeight
= wxStringToFontWeight(val
);
257 if (font
&& (fontWeight
== font
->GetWeight()))
258 return NULL
; // No change
260 else if (font
) fontWeight
= font
->GetWeight();
262 if (name
.Contains("Underlined"))
264 fontUnderlined
= property
->GetValue().BoolValue();
266 if (font
&& (fontUnderlined
== font
->GetUnderlined()))
267 return NULL
; // No change
269 else if (font
) fontUnderlined
= font
->GetUnderlined();
271 wxFont
*newFont
= wxTheFontList
->FindOrCreateFont(pointSize
, fontFamily
, fontStyle
, fontWeight
, fontUnderlined
);
280 wxProperty
*wxWindowPropertyInfo::GetProperty(wxString
& name
)
282 wxFont
*font
= propertyWindow
->GetFont();
283 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
284 name
== "fontUnderlined")
285 return GetFontProperty(name
, font
);
286 else if (name
== "name")
287 return new wxProperty("name", propertyWindow
->GetName(), "string");
288 else if (name
== "title")
289 return new wxProperty("title", propertyWindow
->GetTitle(), "string");
290 else if (name
== "x")
293 propertyWindow
->GetPosition(&x
, &y
);
294 return new wxProperty("x", (long)x
, "integer");
296 else if (name
== "y")
299 propertyWindow
->GetPosition(&x
, &y
);
300 return new wxProperty("y", (long)y
, "integer");
302 else if (name
== "width")
305 propertyWindow
->GetSize(&width
, &height
);
306 return new wxProperty("width", (long)width
, "integer");
308 else if (name
== "height")
311 propertyWindow
->GetSize(&width
, &height
);
312 return new wxProperty("height", (long)height
, "integer");
314 else if (name
== "id")
316 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
319 int id
= resource
->GetId();
321 idStr
.Printf("%d", id
);
322 wxString symbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id
);
325 // symbolName is now e.g. "ID_PANEL21=105"
326 return new wxProperty("id", symbolName
, "window_id");
331 else if (name
== "border")
334 if (propertyWindow
->GetWindowStyleFlag() & wxSIMPLE_BORDER
)
335 border
= "wxSIMPLE_BORDER";
336 else if (propertyWindow
->GetWindowStyleFlag() & wxRAISED_BORDER
)
337 border
= "wxRAISED_BORDER";
338 else if (propertyWindow
->GetWindowStyleFlag() & wxSUNKEN_BORDER
)
339 border
= "wxSUNKEN_BORDER";
340 else if (propertyWindow
->GetWindowStyleFlag() & wxDOUBLE_BORDER
)
341 border
= "wxDOUBLE_BORDER";
342 else if (propertyWindow
->GetWindowStyleFlag() & wxSTATIC_BORDER
)
343 border
= "wxSTATIC_BORDER";
345 border
= "wxNO_BORDER";
347 return new wxProperty("border", border
, "string",
348 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
349 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL
)));
355 bool wxWindowPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
357 wxFont
*font
= propertyWindow
->GetFont();
358 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
360 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
362 propertyWindow
->SetFont(newFont
);
365 else if (name
== "name")
367 // Remove old name from resource table, if it's there.
368 wxItemResource
*oldResource
= (wxItemResource
*)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(propertyWindow
->GetName());
371 // It's a top-level resource
372 propertyWindow
->SetName(property
->GetValue().StringValue());
373 oldResource
->SetName(property
->GetValue().StringValue());
374 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(propertyWindow
->GetName(), oldResource
);
378 // It's a child of something; just set the name of the resource and the window.
379 propertyWindow
->SetName(property
->GetValue().StringValue());
380 propertyResource
->SetName(property
->GetValue().StringValue());
382 // Refresh the resource manager list, because the name changed.
383 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
386 else if (name
== "title")
388 propertyWindow
->SetTitle(property
->GetValue().StringValue());
391 else if (name
== "x")
394 propertyWindow
->GetPosition(&x
, &y
);
395 int newX
= (int)property
->GetValue().IntegerValue();
397 propertyWindow
->Move(newX
, y
);
400 else if (name
== "y")
403 propertyWindow
->GetPosition(&x
, &y
);
404 int newY
= (int)property
->GetValue().IntegerValue();
406 propertyWindow
->Move(x
, newY
);
409 else if (name
== "width")
412 propertyWindow
->GetSize(&width
, &height
);
413 int newWidth
= (int)property
->GetValue().IntegerValue();
414 if (width
!= newWidth
)
416 propertyWindow
->SetSize(newWidth
, height
);
418 if (propertyWindow->IsKindOf(CLASSINFO(wxPanel)) && !propertyWindow->IsKindOf(CLASSINFO(wxDialog)))
420 propertyWindow->GetParent()->SetClientSize(newWidth, height);
426 else if (name
== "height")
429 propertyWindow
->GetSize(&width
, &height
);
430 int newHeight
= (int)property
->GetValue().IntegerValue();
431 if (height
!= newHeight
)
433 propertyWindow
->SetSize(width
, newHeight
);
435 if (propertyWindow->IsKindOf(CLASSINFO(wxPanel)) && !propertyWindow->IsKindOf(CLASSINFO(wxDialog)))
437 propertyWindow->GetParent()->SetClientSize(width, newHeight);
443 else if (name
== "id")
445 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
448 wxString value
= property
->GetValue().StringValue();
450 wxString strName
= value
.Before('=');
451 wxString strId
= value
.After('=');
452 int id
= atoi(strId
);
454 wxString oldSymbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource
->GetId());
455 int oldSymbolId
= resource
->GetId();
459 // If we change the id for an existing symbol, we need to:
460 // 1) Check if there are any other resources currently using the original id.
461 // If so, will need to change their id to the new id.
462 // 2) Remove the old symbol, add the new symbol.
463 // In this check, we don't have to do this, but we need to do it in SetProperty.
465 if (strName
== oldSymbolName
&& id
!= oldSymbolId
)
467 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
469 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
470 // because ids are unique and changing one resource's id must change all identical ones.
471 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId
, id
);
473 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
474 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
477 // If we change the name but not the id, we'll just need to remove and
478 // re-add the symbol/id pair.
479 if (strName
!= oldSymbolName
&& id
== oldSymbolId
)
481 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
483 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
485 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
487 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
491 // What if we're changing both the name and the id?
492 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
493 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
495 if (strName
!= oldSymbolName
&& id
!= oldSymbolId
)
497 // Remove old symbol if it's not being used
498 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource
, oldSymbolId
) &&
499 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
))
501 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
504 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
506 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
517 else if (name
== "border")
519 long borderStyle
= wxNO_BORDER
;
520 wxString val
= property
->GetValue().StringValue();
522 if (val
== "wxSIMPLE_BORDER")
523 borderStyle
= wxSIMPLE_BORDER
;
524 else if (val
== "wxRAISED_BORDER")
525 borderStyle
= wxRAISED_BORDER
;
526 else if (val
== "wxSUNKEN_BORDER")
527 borderStyle
= wxSUNKEN_BORDER
;
528 else if (val
== "wxDOUBLE_BORDER")
529 borderStyle
= wxDOUBLE_BORDER
;
530 else if (val
== "wxSTATIC_BORDER")
531 borderStyle
= wxSTATIC_BORDER
;
533 borderStyle
= wxNO_BORDER
;
535 SetWindowStyle(propertyWindow
, wxSIMPLE_BORDER
, FALSE
);
536 SetWindowStyle(propertyWindow
, wxRAISED_BORDER
, FALSE
);
537 SetWindowStyle(propertyWindow
, wxSUNKEN_BORDER
, FALSE
);
538 SetWindowStyle(propertyWindow
, wxDOUBLE_BORDER
, FALSE
);
539 SetWindowStyle(propertyWindow
, wxSTATIC_BORDER
, FALSE
);
540 SetWindowStyle(propertyWindow
, wxNO_BORDER
, FALSE
);
542 SetWindowStyle(propertyWindow
, borderStyle
, TRUE
);
544 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
545 resource
->SetStyle(propertyWindow
->GetWindowStyleFlag());
552 void wxWindowPropertyInfo::GetPropertyNames(wxStringList
& names
)
561 if (!propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
563 names
.Add("fontPoints");
564 names
.Add("fontFamily");
565 names
.Add("fontStyle");
566 names
.Add("fontWeight");
567 names
.Add("fontUnderlined");
571 // Fill in the wxItemResource members to mirror the current window settings
572 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource
*resource
)
574 // resource->SetType(propertyWindow->GetClassInfo()->GetClassName());
576 // resource->SetStyle(propertyWindow->GetWindowStyleFlag());
577 wxString
str(propertyWindow
->GetName());
578 resource
->SetName(WXSTRINGCAST str
);
580 propertyWindow
->GetSize(&w
, &h
);
582 propertyWindow
->GetPosition(&x
, &y
);
583 resource
->SetSize(x
, y
, w
, h
);
587 // Set the window style
588 void wxWindowPropertyInfo::SetWindowStyle(wxWindow
* win
, long style
, bool set
)
593 if ((win
->GetWindowStyleFlag() & style
) == style
)
597 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() - style
);
604 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() | style
);
613 wxProperty
*wxItemPropertyInfo::GetProperty(wxString
& name
)
615 wxControl
*itemWindow
= (wxControl
*)propertyWindow
;
616 wxFont
*font
= itemWindow
->GetFont();
618 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
619 name
== "fontUnderlined")
620 return GetFontProperty(name
, font
);
621 else if (name
== "label" && itemWindow
->GetLabel())
622 return new wxProperty("label", propertyWindow
->GetLabel(), "string");
624 return wxWindowPropertyInfo::GetProperty(name
);
627 bool wxItemPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
629 wxControl
*itemWindow
= (wxControl
*)propertyWindow
;
630 wxFont
*font
= itemWindow
->GetFont();
632 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
634 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
636 itemWindow
->SetLabelFont(newFont
);
639 else if (name
== "label")
641 itemWindow
->SetLabel(property
->GetValue().StringValue());
645 return wxWindowPropertyInfo::SetProperty(name
, property
);
648 void wxItemPropertyInfo::GetPropertyNames(wxStringList
& names
)
650 wxWindowPropertyInfo::GetPropertyNames(names
);
652 names
.Add("fontPoints");
653 names
.Add("fontFamily");
654 names
.Add("fontStyle");
655 names
.Add("fontWeight");
656 names
.Add("fontUnderlined");
659 bool wxItemPropertyInfo::InstantiateResource(wxItemResource
*resource
)
661 wxWindowPropertyInfo::InstantiateResource(resource
);
663 wxControl
*item
= (wxControl
*)propertyWindow
;
664 wxString
str(item
->GetLabel());
665 resource
->SetTitle(WXSTRINGCAST str
);
666 if (item
->GetFont() && item
->GetFont()->Ok())
667 resource
->SetFont(wxTheFontList
->FindOrCreateFont(item
->GetFont()->GetPointSize(),
668 item
->GetFont()->GetFamily(), item
->GetFont()->GetStyle(), item
->GetFont()->GetWeight(),
669 item
->GetFont()->GetUnderlined(), item
->GetFont()->GetFaceName()));
677 wxProperty
*wxButtonPropertyInfo::GetProperty(wxString
& name
)
679 wxButton
*button
= (wxButton
*)propertyWindow
;
680 return wxItemPropertyInfo::GetProperty(name
);
683 bool wxButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
685 wxButton
*button
= (wxButton
*)propertyWindow
;
686 return wxItemPropertyInfo::SetProperty(name
, property
);
689 void wxButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
691 wxItemPropertyInfo::GetPropertyNames(names
);
695 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
697 return wxItemPropertyInfo::InstantiateResource(resource
);
704 wxProperty
*wxBitmapButtonPropertyInfo::GetProperty(wxString
& name
)
706 wxBitmapButton
*button
= (wxBitmapButton
*)propertyWindow
;
709 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
710 wxString
str("none.bmp");
714 char *filename
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
718 return new wxProperty("label", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
721 return wxButtonPropertyInfo::GetProperty(name
);
724 bool wxBitmapButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
726 wxBitmapButton
*button
= (wxBitmapButton
*)propertyWindow
;
729 char *s
= property
->GetValue().StringValue();
730 if (s
&& wxFileExists(s
))
733 wxBitmap
*bitmap
= new wxBitmap(s
, wxBITMAP_TYPE_BMP
);
742 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
745 wxString
oldResource(resource
->GetValue4());
746 char *resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s
);
747 resource
->SetValue4(resName
);
749 if (!oldResource
.IsNull())
750 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(WXSTRINGCAST oldResource
);
753 button
->SetLabel(bitmap
);
761 return wxButtonPropertyInfo::SetProperty(name
, property
);
764 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
766 // names.Add("label");
767 wxButtonPropertyInfo::GetPropertyNames(names
);
770 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
772 return wxItemPropertyInfo::InstantiateResource(resource
);
779 wxProperty
*wxStaticTextPropertyInfo::GetProperty(wxString
& name
)
781 wxStaticText
*message
= (wxStaticText
*)propertyWindow
;
782 return wxItemPropertyInfo::GetProperty(name
);
785 bool wxStaticTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
787 wxStaticText
*message
= (wxStaticText
*)propertyWindow
;
788 return wxItemPropertyInfo::SetProperty(name
, property
);
791 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
793 wxItemPropertyInfo::GetPropertyNames(names
);
797 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
799 return wxItemPropertyInfo::InstantiateResource(resource
);
806 wxProperty
*wxStaticBitmapPropertyInfo::GetProperty(wxString
& name
)
808 wxStaticBitmap
*message
= (wxStaticBitmap
*)propertyWindow
;
811 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
812 wxString
str("none.bmp");
816 char *filename
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
820 return new wxProperty("label", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
823 return wxItemPropertyInfo::GetProperty(name
);
826 bool wxStaticBitmapPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
828 wxStaticBitmap
*message
= (wxStaticBitmap
*)propertyWindow
;
831 char *s
= property
->GetValue().StringValue();
832 if (s
&& wxFileExists(s
))
836 wxBitmap
*bitmap
= new wxBitmap(s
, wxBITMAP_TYPE_BMP
);
845 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
848 wxString
oldResource(resource
->GetValue4());
849 char *resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s
);
850 resource
->SetValue4(resName
);
852 if (!oldResource
.IsNull())
853 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(WXSTRINGCAST oldResource
);
856 message
->SetBitmap(bitmap
);
864 return wxItemPropertyInfo::SetProperty(name
, property
);
867 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList
& names
)
869 wxItemPropertyInfo::GetPropertyNames(names
);
873 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource
*resource
)
875 return wxItemPropertyInfo::InstantiateResource(resource
);
882 wxProperty
*wxTextPropertyInfo::GetProperty(wxString
& name
)
884 wxTextCtrl
*text
= (wxTextCtrl
*)propertyWindow
;
886 return new wxProperty("value", text
->GetValue(), "string");
887 else if (name
== "password")
889 bool isPassword
= ((text
->GetWindowStyleFlag() & wxTE_PASSWORD
) == wxTE_PASSWORD
);
890 return new wxProperty("password", isPassword
, "bool");
892 else if (name
== "readonly")
894 bool isReadOnly
= ((text
->GetWindowStyleFlag() & wxTE_READONLY
) == wxTE_READONLY
);
895 return new wxProperty("readonly", isReadOnly
, "bool");
898 return wxItemPropertyInfo::GetProperty(name
);
901 bool wxTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
903 wxTextCtrl
*text
= (wxTextCtrl
*)propertyWindow
;
906 text
->SetValue(property
->GetValue().StringValue());
909 else if (name
== "password")
911 long flag
= text
->GetWindowStyleFlag();
912 if (property
->GetValue().BoolValue())
914 if ((flag
& wxTE_PASSWORD
) != wxTE_PASSWORD
)
915 flag
|= wxTE_PASSWORD
;
919 if ((flag
& wxTE_PASSWORD
) == wxTE_PASSWORD
)
920 flag
-= wxTE_PASSWORD
;
922 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
923 resource
->SetStyle(flag
);
925 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
928 else if (name
== "readonly")
930 long flag
= text
->GetWindowStyleFlag();
931 if (property
->GetValue().BoolValue())
933 if ((flag
& wxTE_READONLY
) != wxTE_READONLY
)
934 flag
|= wxTE_READONLY
;
938 if ((flag
& wxTE_READONLY
) == wxTE_READONLY
)
939 flag
-= wxTE_READONLY
;
941 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
942 resource
->SetStyle(flag
);
944 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
948 return wxItemPropertyInfo::SetProperty(name
, property
);
951 void wxTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
953 wxItemPropertyInfo::GetPropertyNames(names
);
955 names
.Add("readonly");
956 names
.Add("password");
959 bool wxTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
961 wxTextCtrl
*text
= (wxTextCtrl
*)propertyWindow
;
962 wxString
str(text
->GetValue());
963 resource
->SetValue4(WXSTRINGCAST str
);
965 return wxItemPropertyInfo::InstantiateResource(resource
);
972 wxProperty
*wxListBoxPropertyInfo::GetProperty(wxString
& name
)
974 wxListBox
*listBox
= (wxListBox
*)propertyWindow
;
975 if (name
== "values")
977 wxStringList
*stringList
= new wxStringList
;
979 for (i
= 0; i
< listBox
->Number(); i
++)
980 stringList
->Add(listBox
->GetString(i
));
982 return new wxProperty(name
, stringList
, "stringlist");
984 else if (name
== "multiple")
987 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
991 char *mult
= "wxSINGLE";
993 switch (resource
->GetValue1())
996 mult
= "wxLB_MULTIPLE";
999 mult
= "wxLB_EXTENDED";
1003 mult
= "wxLB_SINGLE";
1006 return new wxProperty("multiple", mult
, "string",
1007 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1011 return wxItemPropertyInfo::GetProperty(name
);
1014 bool wxListBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1016 wxListBox
*listBox
= (wxListBox
*)propertyWindow
;
1017 if (name
== "values")
1020 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1023 char *s
= expr
->StringValue();
1026 expr
= expr
->GetNext();
1030 else if (name
== "multiple")
1032 int mult
= wxLB_SINGLE
;
1033 wxString
str(property
->GetValue().StringValue());
1034 if (str
== "wxLB_MULTIPLE")
1035 mult
= wxLB_MULTIPLE
;
1036 else if (str
== "wxLB_EXTENDED")
1037 mult
= wxLB_EXTENDED
;
1040 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1042 resource
->SetValue1(mult
);
1043 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox
, this);
1047 return wxItemPropertyInfo::SetProperty(name
, property
);
1050 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1052 wxItemPropertyInfo::GetPropertyNames(names
);
1053 names
.Add("values");
1054 names
.Add("multiple");
1057 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1059 wxListBox
*lbox
= (wxListBox
*)propertyWindow
;
1060 // This will be set for the wxItemResource on reading or in SetProperty
1061 // resource->SetValue1(lbox->GetSelectionMode());
1063 if (lbox
->Number() == 0)
1064 resource
->SetStringValues(NULL
);
1067 wxStringList
*slist
= new wxStringList
;
1069 for (i
= 0; i
< lbox
->Number(); i
++)
1070 slist
->Add(lbox
->GetString(i
));
1072 resource
->SetStringValues(slist
);
1074 return wxItemPropertyInfo::InstantiateResource(resource
);
1081 wxProperty
*wxChoicePropertyInfo::GetProperty(wxString
& name
)
1083 wxChoice
*choice
= (wxChoice
*)propertyWindow
;
1084 if (name
== "values")
1086 wxStringList
*stringList
= new wxStringList
;
1088 for (i
= 0; i
< choice
->Number(); i
++)
1089 stringList
->Add(choice
->GetString(i
));
1091 return new wxProperty(name
, stringList
, "stringlist");
1094 return wxItemPropertyInfo::GetProperty(name
);
1097 bool wxChoicePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1099 wxChoice
*choice
= (wxChoice
*)propertyWindow
;
1100 if (name
== "values")
1103 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1106 char *s
= expr
->StringValue();
1109 expr
= expr
->GetNext();
1111 if (choice
->Number() > 0)
1112 choice
->SetSelection(0);
1116 return wxItemPropertyInfo::SetProperty(name
, property
);
1119 void wxChoicePropertyInfo::GetPropertyNames(wxStringList
& names
)
1121 wxItemPropertyInfo::GetPropertyNames(names
);
1122 names
.Add("values");
1125 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1127 wxChoice
*choice
= (wxChoice
*)propertyWindow
;
1129 if (choice
->Number() == 0)
1130 resource
->SetStringValues(NULL
);
1133 wxStringList
*slist
= new wxStringList
;
1135 for (i
= 0; i
< choice
->Number(); i
++)
1136 slist
->Add(choice
->GetString(i
));
1138 resource
->SetStringValues(slist
);
1140 return wxItemPropertyInfo::InstantiateResource(resource
);
1147 wxProperty
*wxComboBoxPropertyInfo::GetProperty(wxString
& name
)
1149 wxComboBox
*choice
= (wxComboBox
*)propertyWindow
;
1150 if (name
== "values")
1152 wxStringList
*stringList
= new wxStringList
;
1154 for (i
= 0; i
< choice
->Number(); i
++)
1155 stringList
->Add(choice
->GetString(i
));
1157 return new wxProperty(name
, stringList
, "stringlist");
1159 else if (name
== "sort")
1161 bool sort
= ((propertyWindow
->GetWindowStyleFlag() & wxCB_SORT
) == wxCB_SORT
);
1162 return new wxProperty(name
, sort
, "bool");
1164 else if (name
== "style")
1166 wxString
styleStr("dropdown");
1167 if (propertyWindow
->GetWindowStyleFlag() & wxCB_SIMPLE
)
1168 styleStr
= "simple";
1169 else if (propertyWindow
->GetWindowStyleFlag() & wxCB_READONLY
)
1170 styleStr
= "readonly";
1172 styleStr
= "dropdown";
1174 return new wxProperty(name
, styleStr
, "string",
1175 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1179 return wxItemPropertyInfo::GetProperty(name
);
1182 bool wxComboBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1184 wxComboBox
*choice
= (wxComboBox
*)propertyWindow
;
1185 if (name
== "values")
1188 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1191 char *s
= expr
->StringValue();
1194 expr
= expr
->GetNext();
1196 if (choice
->Number() > 0)
1197 choice
->SetSelection(0);
1200 else if (name
== "sort")
1202 SetWindowStyle(propertyWindow
, wxCB_SORT
, property
->GetValue().BoolValue());
1204 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
1205 resource
->SetStyle(propertyWindow
->GetWindowStyleFlag());
1207 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow
, this);
1210 else if (name
== "style")
1212 SetWindowStyle(propertyWindow
, wxCB_SIMPLE
, FALSE
);
1213 SetWindowStyle(propertyWindow
, wxCB_DROPDOWN
, FALSE
);
1214 SetWindowStyle(propertyWindow
, wxCB_READONLY
, FALSE
);
1216 wxString
styleStr(property
->GetValue().StringValue());
1217 if (styleStr
== "simple")
1218 SetWindowStyle(propertyWindow
, wxCB_SIMPLE
, TRUE
);
1219 else if (styleStr
== "dropdown")
1220 SetWindowStyle(propertyWindow
, wxCB_DROPDOWN
, TRUE
);
1221 else if (styleStr
== "readonly")
1222 SetWindowStyle(propertyWindow
, wxCB_READONLY
, TRUE
);
1225 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
1226 resource
->SetStyle(propertyWindow
->GetWindowStyleFlag());
1228 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow
, this);
1233 return wxItemPropertyInfo::SetProperty(name
, property
);
1236 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1238 wxItemPropertyInfo::GetPropertyNames(names
);
1239 names
.Add("values");
1244 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1246 wxComboBox
*choice
= (wxComboBox
*)propertyWindow
;
1248 if (choice
->Number() == 0)
1249 resource
->SetStringValues(NULL
);
1252 wxStringList
*slist
= new wxStringList
;
1254 for (i
= 0; i
< choice
->Number(); i
++)
1255 slist
->Add(choice
->GetString(i
));
1257 resource
->SetStringValues(slist
);
1259 return wxItemPropertyInfo::InstantiateResource(resource
);
1266 wxProperty
*wxRadioBoxPropertyInfo::GetProperty(wxString
& name
)
1268 wxRadioBox
*radioBox
= (wxRadioBox
*)propertyWindow
;
1269 if (name
== "numberRowsOrCols")
1271 return new wxProperty("numberRowsOrCols", (long)radioBox
->GetNumberOfRowsOrCols(), "integer");
1273 if (name
== "orientation")
1276 if (propertyWindow
->GetWindowStyleFlag() & wxRA_HORIZONTAL
)
1277 orient
= "wxRA_HORIZONTAL";
1279 orient
= "wxRA_VERTICAL";
1281 return new wxProperty("orientation", orient
, "string",
1282 new wxStringListValidator(new wxStringList("wxRA_HORIZONTAL", "wxRA_VERTICAL",
1285 else if (name
== "values")
1287 wxStringList
*stringList
= new wxStringList
;
1289 for (i
= 0; i
< radioBox
->Number(); i
++)
1290 stringList
->Add(radioBox
->GetString(i
));
1292 return new wxProperty(name
, stringList
, "stringlist");
1294 return wxItemPropertyInfo::GetProperty(name
);
1297 bool wxRadioBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1299 wxRadioBox
*radioBox
= (wxRadioBox
*)propertyWindow
;
1300 if (name
== "numberRowsOrCols")
1302 radioBox
->SetNumberOfRowsOrCols((int)property
->GetValue().IntegerValue());
1303 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1306 else if (name
== "orientation")
1308 long windowStyle
= radioBox
->GetWindowStyleFlag();
1309 wxString
val(property
->GetValue().StringValue());
1310 if (val
== "wxRA_HORIZONTAL")
1312 if (windowStyle
& wxRA_VERTICAL
)
1313 windowStyle
-= wxRA_VERTICAL
;
1314 windowStyle
|= wxRA_HORIZONTAL
;
1318 if (windowStyle
& wxRA_HORIZONTAL
)
1319 windowStyle
-= wxRA_HORIZONTAL
;
1320 windowStyle
|= wxRA_VERTICAL
;
1322 radioBox
->SetWindowStyleFlag(windowStyle
);
1323 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox
);
1324 resource
->SetStyle(windowStyle
);
1326 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1329 else if (name
== "values")
1331 // Set property into *resource*, not wxRadioBox, and then recreate
1332 // the wxRadioBox. This is because we can't dynamically set the strings
1334 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow
);
1338 wxStringList
*stringList
= resource
->GetStringValues();
1341 stringList
= new wxStringList
;
1342 resource
->SetStringValues(stringList
);
1344 stringList
->Clear();
1346 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1349 char *s
= expr
->StringValue();
1352 expr
= expr
->GetNext();
1354 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1357 return wxItemPropertyInfo::SetProperty(name
, property
);
1360 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1362 wxItemPropertyInfo::GetPropertyNames(names
);
1364 names
.Add("values");
1365 names
.Add("orientation");
1366 names
.Add("numberRowsOrCols");
1369 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1371 wxRadioBox
*rbox
= (wxRadioBox
*)propertyWindow
;
1372 // Take strings from resource instead
1375 if (rbox->Number() == 0)
1376 resource->SetStringValues(NULL);
1379 wxStringList *slist = new wxStringList;
1381 for (i = 0; i < rbox->Number(); i++)
1382 slist->Add(rbox->GetString(i));
1384 resource->SetStringValues(slist);
1387 resource
->SetValue1(rbox
->GetNumberOfRowsOrCols());
1388 return wxItemPropertyInfo::InstantiateResource(resource
);
1395 wxProperty
*wxGroupBoxPropertyInfo::GetProperty(wxString
& name
)
1397 wxStaticBox
*groupBox
= (wxStaticBox
*)propertyWindow
;
1398 return wxItemPropertyInfo::GetProperty(name
);
1401 bool wxGroupBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1403 return wxItemPropertyInfo::SetProperty(name
, property
);
1406 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1408 wxItemPropertyInfo::GetPropertyNames(names
);
1412 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1414 wxStaticBox
*gbox
= (wxStaticBox
*)propertyWindow
;
1415 return wxItemPropertyInfo::InstantiateResource(resource
);
1422 wxProperty
*wxCheckBoxPropertyInfo::GetProperty(wxString
& name
)
1424 wxCheckBox
*checkBox
= (wxCheckBox
*)propertyWindow
;
1425 if (name
== "value")
1426 return new wxProperty("value", checkBox
->GetValue(), "bool");
1428 return wxItemPropertyInfo::GetProperty(name
);
1431 bool wxCheckBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1433 wxCheckBox
*checkBox
= (wxCheckBox
*)propertyWindow
;
1434 if (name
== "value")
1436 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1440 return wxItemPropertyInfo::SetProperty(name
, property
);
1443 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1445 wxItemPropertyInfo::GetPropertyNames(names
);
1450 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1452 wxCheckBox
*cbox
= (wxCheckBox
*)propertyWindow
;
1453 resource
->SetValue1(cbox
->GetValue());
1454 return wxItemPropertyInfo::InstantiateResource(resource
);
1461 wxProperty
*wxRadioButtonPropertyInfo::GetProperty(wxString
& name
)
1463 wxRadioButton
*checkBox
= (wxRadioButton
*)propertyWindow
;
1464 if (name
== "value")
1465 return new wxProperty("value", checkBox
->GetValue(), "bool");
1467 return wxItemPropertyInfo::GetProperty(name
);
1470 bool wxRadioButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1472 wxRadioButton
*checkBox
= (wxRadioButton
*)propertyWindow
;
1473 if (name
== "value")
1475 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1479 return wxItemPropertyInfo::SetProperty(name
, property
);
1482 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
1484 wxItemPropertyInfo::GetPropertyNames(names
);
1489 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1491 wxRadioButton
*cbox
= (wxRadioButton
*)propertyWindow
;
1492 resource
->SetValue1(cbox
->GetValue());
1493 return wxItemPropertyInfo::InstantiateResource(resource
);
1500 wxProperty
*wxSliderPropertyInfo::GetProperty(wxString
& name
)
1502 wxSlider
*slider
= (wxSlider
*)propertyWindow
;
1503 if (name
== "value")
1504 return new wxProperty("value", (long)slider
->GetValue(), "integer");
1505 else if (name
== "orientation")
1508 if (propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1509 pos
= "wxHORIZONTAL";
1513 return new wxProperty("orientation", pos
, "string",
1514 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1517 else if (name
== "minValue")
1518 return new wxProperty("minValue", (long)slider
->GetMin(), "integer");
1519 else if (name
== "maxValue")
1520 return new wxProperty("maxValue", (long)slider
->GetMax(), "integer");
1522 return wxItemPropertyInfo::GetProperty(name
);
1525 bool wxSliderPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1527 wxSlider
*slider
= (wxSlider
*)propertyWindow
;
1528 if (name
== "value")
1530 slider
->SetValue((int)property
->GetValue().IntegerValue());
1533 else if (name
== "orientation")
1535 long windowStyle
= slider
->GetWindowStyleFlag();
1536 long oldWindowStyle
= windowStyle
;
1537 wxString
val(property
->GetValue().StringValue());
1538 if (val
== "wxHORIZONTAL")
1540 if (windowStyle
& wxVERTICAL
)
1541 windowStyle
-= wxVERTICAL
;
1542 windowStyle
|= wxHORIZONTAL
;
1546 if (windowStyle
& wxHORIZONTAL
)
1547 windowStyle
-= wxHORIZONTAL
;
1548 windowStyle
|= wxVERTICAL
;
1551 if (oldWindowStyle
== windowStyle
)
1554 slider
->SetWindowStyleFlag(windowStyle
);
1556 // If the window style has changed, we swap the width and height parameters.
1558 slider
->GetSize(&w
, &h
);
1560 slider
= (wxSlider
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider
, this);
1561 slider
->SetSize(-1, -1, h
, w
);
1565 else if (name
== "minValue")
1567 slider
->SetRange((int)property
->GetValue().IntegerValue(), slider
->GetMax());
1570 else if (name
== "maxValue")
1572 slider
->SetRange(slider
->GetMin(), (int)property
->GetValue().IntegerValue());
1576 return wxItemPropertyInfo::SetProperty(name
, property
);
1579 void wxSliderPropertyInfo::GetPropertyNames(wxStringList
& names
)
1581 wxItemPropertyInfo::GetPropertyNames(names
);
1583 names
.Add("orientation");
1584 names
.Add("minValue");
1585 names
.Add("maxValue");
1588 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1590 wxSlider
*slider
= (wxSlider
*)propertyWindow
;
1591 resource
->SetValue1(slider
->GetValue());
1592 resource
->SetValue2(slider
->GetMin());
1593 resource
->SetValue3(slider
->GetMax());
1594 return wxItemPropertyInfo::InstantiateResource(resource
);
1601 wxProperty
*wxGaugePropertyInfo::GetProperty(wxString
& name
)
1603 wxGauge
*gauge
= (wxGauge
*)propertyWindow
;
1604 if (name
== "value")
1605 return new wxProperty("value", (long)gauge
->GetValue(), "integer");
1606 else if (name
== "maxValue")
1607 return new wxProperty("maxValue", (long)gauge
->GetRange(), "integer");
1609 return wxItemPropertyInfo::GetProperty(name
);
1612 bool wxGaugePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1614 wxGauge
*gauge
= (wxGauge
*)propertyWindow
;
1615 if (name
== "value")
1617 gauge
->SetValue((int)property
->GetValue().IntegerValue());
1620 else if (name
== "maxValue")
1622 gauge
->SetRange((int)property
->GetValue().IntegerValue());
1626 return wxItemPropertyInfo::SetProperty(name
, property
);
1629 void wxGaugePropertyInfo::GetPropertyNames(wxStringList
& names
)
1631 wxItemPropertyInfo::GetPropertyNames(names
);
1633 names
.Add("maxValue");
1636 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1638 wxGauge
*gauge
= (wxGauge
*)propertyWindow
;
1639 resource
->SetValue1(gauge
->GetValue());
1640 resource
->SetValue2(gauge
->GetRange());
1641 return wxItemPropertyInfo::InstantiateResource(resource
);
1648 wxProperty
*wxScrollBarPropertyInfo::GetProperty(wxString
& name
)
1650 wxScrollBar
*scrollBar
= (wxScrollBar
*)propertyWindow
;
1651 if (name
== "value")
1652 return new wxProperty("value", (long)scrollBar
->GetValue(), "integer");
1653 else if (name
== "orientation")
1656 if (propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1657 pos
= "wxHORIZONTAL";
1661 return new wxProperty("orientation", pos
, "string",
1662 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1665 else if (name
== "pageSize")
1667 int viewStart
, pageLength
, objectLength
, viewLength
;
1668 scrollBar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1670 return new wxProperty("pageSize", (long)pageLength
, "integer");
1672 else if (name
== "viewLength")
1674 int viewStart
, pageLength
, objectLength
, viewLength
;
1675 scrollBar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1677 return new wxProperty("viewLength", (long)viewLength
, "integer");
1679 else if (name
== "objectLength")
1681 int viewStart
, pageLength
, objectLength
, viewLength
;
1682 scrollBar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1684 return new wxProperty("objectLength", (long)objectLength
, "integer");
1687 return wxItemPropertyInfo::GetProperty(name
);
1690 bool wxScrollBarPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1692 wxScrollBar
*scrollBar
= (wxScrollBar
*)propertyWindow
;
1693 if (name
== "value")
1695 scrollBar
->SetValue((int)property
->GetValue().IntegerValue());
1698 else if (name
== "orientation")
1700 long windowStyle
= scrollBar
->GetWindowStyleFlag();
1701 long oldWindowStyle
= windowStyle
;
1702 wxString
val(property
->GetValue().StringValue());
1703 if (val
== "wxHORIZONTAL")
1705 if (windowStyle
& wxVERTICAL
)
1706 windowStyle
-= wxVERTICAL
;
1707 windowStyle
|= wxHORIZONTAL
;
1711 if (windowStyle
& wxHORIZONTAL
)
1712 windowStyle
-= wxHORIZONTAL
;
1713 windowStyle
|= wxVERTICAL
;
1716 if (oldWindowStyle
== windowStyle
)
1719 scrollBar
->SetWindowStyleFlag(windowStyle
);
1721 // If the window style has changed, we swap the width and height parameters.
1723 scrollBar
->GetSize(&w
, &h
);
1725 scrollBar
= (wxScrollBar
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar
, this);
1726 scrollBar
->SetSize(-1, -1, h
, w
);
1730 else if (name
== "pageSize")
1732 scrollBar
->SetPageSize((int)property
->GetValue().IntegerValue());
1735 else if (name
== "viewLength")
1737 scrollBar
->SetViewLength((int)property
->GetValue().IntegerValue());
1740 else if (name
== "objectLength")
1742 scrollBar
->SetObjectLength((int)property
->GetValue().IntegerValue());
1746 return wxItemPropertyInfo::SetProperty(name
, property
);
1749 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList
& names
)
1751 wxItemPropertyInfo::GetPropertyNames(names
);
1752 names
.Add("orientation");
1754 names
.Add("pageSize");
1755 names
.Add("viewLength");
1756 names
.Add("objectLength");
1758 // Remove some properties we don't inherit
1759 names
.Delete("fontPoints");
1760 names
.Delete("fontFamily");
1761 names
.Delete("fontStyle");
1762 names
.Delete("fontWeight");
1763 names
.Delete("fontUnderlined");
1766 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1768 wxScrollBar
*sbar
= (wxScrollBar
*)propertyWindow
;
1770 resource
->SetValue1(sbar
->GetValue());
1772 int viewStart
, pageLength
, objectLength
, viewLength
;
1773 sbar
->GetValues(&viewStart
, &viewLength
, &objectLength
, &pageLength
);
1775 resource
->SetValue2(pageLength
);
1776 resource
->SetValue3(objectLength
);
1777 resource
->SetValue5(viewLength
);
1779 return wxItemPropertyInfo::InstantiateResource(resource
);
1786 wxProperty
*wxPanelPropertyInfo::GetProperty(wxString
& name
)
1788 wxPanel
*panelWindow
= (wxPanel
*)propertyWindow
;
1789 wxFont
*labelFont
= panelWindow
->GetLabelFont();
1790 wxFont
*buttonFont
= panelWindow
->GetButtonFont();
1792 if (name
== "labelFontPoints" || name
== "labelFontFamily" || name
== "labelFontStyle" || name
== "labelFontWeight" ||
1793 name
== "labelFontUnderlined")
1794 return GetFontProperty(name
, labelFont
);
1795 else if (name
== "buttonFontPoints" || name
== "buttonFontFamily" || name
== "buttonFontStyle" || name
== "buttonFontWeight" ||
1796 name
== "buttonFontUnderlined")
1797 return GetFontProperty(name
, buttonFont
);
1798 else if (name
== "no3D")
1801 if (panelWindow
->GetWindowStyleFlag() & wxNO_3D
)
1804 userColours
= FALSE
;
1806 return new wxProperty(name
, (bool)userColours
, "bool");
1808 else if (name
== "backgroundColour")
1810 wxColour
col(panelWindow
->GetBackgroundColour());
1812 wxDecToHex(col
.Red(), buf
);
1813 wxDecToHex(col
.Green(), buf
+2);
1814 wxDecToHex(col
.Blue(), buf
+4);
1816 return new wxProperty(name
, buf
, "string", new wxColourListValidator
);
1818 else if (name
== "title")
1820 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1822 return new wxProperty(name
, resource
->GetTitle(), "string");
1824 return new wxProperty(name
, "Could not get title", "string");
1826 else if (name
== "caption")
1828 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxCAPTION
) == wxCAPTION
),
1831 else if (name
== "systemMenu")
1833 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxSYSTEM_MENU
) == wxSYSTEM_MENU
),
1836 else if (name
== "thickFrame")
1838 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxTHICK_FRAME
) == wxTHICK_FRAME
),
1842 return wxWindowPropertyInfo::GetProperty(name
);
1845 bool wxPanelPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1847 wxPanel
*panelWindow
= (wxPanel
*)propertyWindow
;
1848 wxFont
*labelFont
= panelWindow
->GetLabelFont();
1849 wxFont
*buttonFont
= panelWindow
->GetButtonFont();
1851 if (labelFont
&& (name
== "labelFontPoints" || name
== "labelFontFamily" || name
== "labelFontStyle" || name
== "labelFontWeight" || name
== "labelFontUnderlined" ))
1853 wxFont
*newFont
= SetFontProperty(name
, property
, labelFont
);
1855 panelWindow
->SetLabelFont(newFont
);
1858 else if (buttonFont
&& (name
== "buttonFontPoints" || name
== "buttonFontFamily" || name
== "buttonFontStyle" || name
== "buttonFontWeight" || name
== "buttonFontUnderlined" ))
1860 wxFont
*newFont
= SetFontProperty(name
, property
, buttonFont
);
1862 panelWindow
->SetButtonFont(newFont
);
1865 else if (name
== "no3D")
1867 bool userColours
= property
->GetValue().BoolValue();
1868 long flag
= panelWindow
->GetWindowStyleFlag();
1872 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) != wxNO_3D
)
1873 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() | wxNO_3D
);
1877 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) == wxNO_3D
)
1878 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() - wxNO_3D
);
1880 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1881 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1883 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
1886 else if (name
== "backgroundColour")
1888 char *hex
= property
->GetValue().StringValue();
1889 int r
= wxHexToDec(hex
);
1890 int g
= wxHexToDec(hex
+2);
1891 int b
= wxHexToDec(hex
+4);
1893 wxColour
col(r
,g
,b
);
1894 panelWindow
->SetBackgroundColour(col
);
1895 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
1898 else if (name
== "title")
1900 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1903 resource
->SetTitle(property
->GetValue().StringValue());
1909 else if (name
== "caption")
1911 SetWindowStyle(panelWindow
, wxCAPTION
, property
->GetValue().BoolValue());
1913 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1914 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1917 else if (name
== "thickFrame")
1919 SetWindowStyle(panelWindow
, wxTHICK_FRAME
, property
->GetValue().BoolValue());
1921 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1922 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1925 else if (name
== "systemMenu")
1927 SetWindowStyle(panelWindow
, wxSYSTEM_MENU
, property
->GetValue().BoolValue());
1929 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1930 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
1934 return wxWindowPropertyInfo::SetProperty(name
, property
);
1937 void wxPanelPropertyInfo::GetPropertyNames(wxStringList
& names
)
1939 wxWindowPropertyInfo::GetPropertyNames(names
);
1943 names
.Add("backgroundColour");
1944 names
.Add("caption");
1945 names
.Add("systemMenu");
1946 names
.Add("thickFrame");
1949 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1951 wxPanel
*panel
= (wxPanel
*)propertyWindow
;
1952 if (panel
->GetFont())
1953 resource
->SetFont(wxTheFontList
->FindOrCreateFont(panel
->GetFont()->GetPointSize(),
1954 panel
->GetFont()->GetFamily(), panel
->GetFont()->GetStyle(), panel
->GetFont()->GetWeight(),
1955 panel
->GetFont()->GetUnderlined(), panel
->GetFont()->GetFaceName()));
1957 resource
->SetBackgroundColour(new wxColour(panel
->GetBackgroundColour()));
1959 return wxWindowPropertyInfo::InstantiateResource(resource
);
1967 wxProperty
*wxDialogPropertyInfo::GetProperty(wxString
& name
)
1969 wxDialog
*dialogWindow
= (wxDialog
*)propertyWindow
;
1970 if (name
== "modal")
1972 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
1976 bool modal
= (resource
->GetValue1() != 0);
1977 return new wxProperty(name
, modal
, "bool");
1980 return wxPanelPropertyInfo::GetProperty(name
);
1983 bool wxDialogPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1985 wxDialog
*dialogWindow
= (wxDialog
*)propertyWindow
;
1987 if (name
== "modal")
1989 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
1993 resource
->SetValue1(property
->GetValue().BoolValue());
1997 return wxPanelPropertyInfo::SetProperty(name
, property
);
2000 void wxDialogPropertyInfo::GetPropertyNames(wxStringList
& names
)
2002 wxPanelPropertyInfo::GetPropertyNames(names
);
2007 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2009 wxDialog
*dialog
= (wxDialog
*)propertyWindow
;
2010 wxString
str(dialog
->GetTitle());
2011 resource
->SetTitle(WXSTRINGCAST str
);
2013 return wxPanelPropertyInfo::InstantiateResource(resource
);
2021 int wxStringToFontWeight(wxString
& val
)
2023 if (val
== "wxBOLD") return wxBOLD
;
2024 else if (val
== "wxLIGHT") return wxLIGHT
;
2025 else return wxNORMAL
;
2028 int wxStringToFontStyle(wxString
& val
)
2030 if (val
== "wxITALIC") return wxITALIC
;
2031 else if (val
== "wxSLANT") return wxSLANT
;
2032 else return wxNORMAL
;
2035 int wxStringToFontFamily(wxString
& val
)
2037 if (val
== "wxDECORATIVE") return wxDECORATIVE
;
2038 else if (val
== "wxROMAN") return wxROMAN
;
2039 else if (val
== "wxSCRIPT") return wxSCRIPT
;
2040 else if (val
== "wxMODERN") return wxMODERN
;
2041 else if (val
== "wxTELETYPE") return wxTELETYPE
;
2042 else return wxSWISS
;
2046 /// Resource symbol validator
2048 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator
, wxPropertyListValidator
)
2050 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags
):
2051 wxPropertyListValidator(flags
)
2055 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2059 bool wxResourceSymbolValidator::OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2064 // Called when TICK is pressed or focus is lost or view wants to update
2065 // the property list.
2066 // Does the transferance from the property editing area to the property itself
2067 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2069 if (!view
->GetValueText())
2071 wxString
value(view
->GetValueText()->GetValue());
2072 property
->GetValue() = value
;
2076 // Called when TICK is pressed or focus is lost or view wants to update
2077 // the property list.
2078 // Does the transferance from the property editing area to the property itself
2079 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2081 if (!view
->GetValueText())
2083 wxString
str(property
->GetValue().GetStringRepresentation());
2084 view
->GetValueText()->SetValue(str
);
2088 // Called when the property is double clicked. Extra functionality can be provided,
2089 // cycling through possible values.
2090 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2092 if (!view
->GetValueText())
2094 OnEdit(property
, view
, parentWindow
);
2098 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2100 if (view
->GetConfirmButton())
2101 view
->GetConfirmButton()->Enable(TRUE
);
2102 if (view
->GetCancelButton())
2103 view
->GetCancelButton()->Enable(TRUE
);
2104 if (view
->GetEditButton())
2105 view
->GetEditButton()->Enable(TRUE
);
2106 if (view
->GetValueText())
2107 view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
);
2111 void wxResourceSymbolValidator::OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2113 if (!view
->GetValueText())
2116 wxResourceSymbolDialog
* dialog
= new wxResourceSymbolDialog(parentWindow
, -1, "Edit Symbol");
2118 // Split name/id pair e.g. "IDC_TEXT=123"
2119 wxString
value(property
->GetValue().StringValue());
2121 wxString strName
= value
.Before('=');
2122 wxString strId
= value
.After('=');
2124 dialog
->SetSymbol(strName
);
2125 dialog
->SetId(atoi(strId
));
2129 if (dialog
->ShowModal() == wxID_OK
)
2131 wxString
symbolName(dialog
->GetSymbol());
2132 long id
= dialog
->GetId();
2136 str
.Printf("%d", id
);
2137 property
->GetValue() = symbolName
+ wxString("=") + str
;
2139 view
->DisplayProperty(property
);
2140 view
->UpdatePropertyDisplayInList(property
);
2141 view
->OnPropertyChanged(property
);
2145 BEGIN_EVENT_TABLE(wxResourceSymbolDialog
, wxDialog
)
2146 EVT_BUTTON(wxID_OK
, wxResourceSymbolDialog::OnOK
)
2147 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnComboBoxSelect
)
2148 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnSymbolNameUpdate
)
2151 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
2152 const wxSize
& size
, long style
):
2153 wxDialog(parent
, id
, title
, pos
, size
, style
)
2158 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x
, y
));
2162 m_nameCtrl
= new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX
, "",
2163 wxPoint(x
, y
), wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
|wxCB_SORT
);
2168 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x
, y
));
2172 m_idCtrl
= new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL
, "",
2173 wxPoint(x
, y
), wxSize(200, -1));
2177 (void) new wxButton(this, wxID_OK
, "OK", wxPoint(x
, y
), wxSize(80, -1));
2180 (void) new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(x
, y
), wxSize(80, -1));
2186 void wxResourceSymbolDialog::Init()
2189 defaultId
.Printf("%ld", m_symbolId
);
2191 m_nameCtrl
->SetValue(m_symbolName
);
2192 m_idCtrl
->SetValue(defaultId
);
2194 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl
);
2197 void wxResourceSymbolDialog::OnOK(wxCommandEvent
& event
)
2201 wxDialog::OnOK(event
);
2205 bool wxResourceSymbolDialog::CheckValues()
2207 wxString
nameStr(m_nameCtrl
->GetValue());
2208 wxString
idStr(m_idCtrl
->GetValue());
2209 int id
= atoi(idStr
);
2213 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2218 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2221 if (nameStr
.Contains(" "))
2223 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2226 if (nameStr
.Contains("="))
2228 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2231 if (nameStr
.IsNumber())
2233 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2236 // TODO: other checks on the name syntax.
2238 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr
))
2240 // If we change the id for an existing symbol, we need to:
2241 // 1) Check if there are any other resources currently using the original id.
2242 // If so, will need to change their id to the new id, in SetProperty.
2243 // 2) Remove the old symbol, add the new symbol.
2244 // In this check, we don't have to do this, but we need to do it in SetProperty.
2246 if (nameStr
== GetSymbol() && id
!= GetId())
2248 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2252 // If we change the name but not the id... we'll just need to remove and
2253 // re-add the symbol/id pair, in SetProperty.
2254 if (nameStr
!= GetSymbol() && id
== GetId())
2258 // What if we're changing both the name and the id?
2259 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2260 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2262 if (nameStr
!= GetSymbol() && id
!= GetId())
2264 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr
, id
))
2266 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2267 "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2280 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent
& event
)
2282 wxString
str(m_nameCtrl
->GetStringSelection());
2283 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2285 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2287 str2
.Printf("%d", id
);
2288 m_idCtrl
->SetValue(str2
);
2289 m_idCtrl
->Enable(FALSE
);
2293 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2295 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2297 str2
.Printf("%d", id
);
2298 m_idCtrl
->SetValue(str2
);
2300 m_idCtrl
->Enable(TRUE
);
2304 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent
& event
)
2306 wxString
str(m_nameCtrl
->GetValue());
2307 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2309 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2311 str2
.Printf("%d", id
);
2312 m_idCtrl
->SetValue(str2
);
2313 m_idCtrl
->Enable(FALSE
);
2317 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2319 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2321 str2
.Printf("%d", id
);
2322 m_idCtrl
->SetValue(str2
);
2324 m_idCtrl
->Enable(TRUE
);