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"
39 // Causes immediate feedback.
40 void wxResourcePropertyListView::OnPropertyChanged(wxProperty
*property
)
42 // Sets the value of the property back into the actual object,
43 // IF the property value was modified.
44 if (property
->GetValue().GetModified())
46 m_propertyInfo
->SetProperty(property
->GetName(), property
);
47 property
->GetValue().SetModified(FALSE
);
48 wxResourceManager::GetCurrentResourceManager()->Modify(TRUE
);
52 bool wxResourcePropertyListView::OnClose(void)
55 GetManagedWindow()->GetSize(& w
, & h
);
56 GetManagedWindow()->GetPosition(& x
, & y
);
58 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
= w
;
59 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
= h
;
60 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
= x
;
61 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
= y
;
63 return wxPropertyListView::OnClose();
66 wxWindow
*wxPropertyInfo::sm_propertyWindow
;
69 * wxDialogEditorPropertyListDialog
73 wxDialogEditorPropertyListDialog::wxDialogEditorPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title,
74 const wxPoint& pos, const wxSize& size,
75 long style, const wxString& name):
76 wxPropertyListDialog(v, parent, title, pos, size, style, name)
82 wxDialogEditorPropertyListDialog::~wxDialogEditorPropertyListDialog()
86 wxPropertyInfo::sm_propertyWindow = NULL;
90 wxDialogEditorPropertyListFrame::wxDialogEditorPropertyListFrame(wxPropertyListView
*v
, wxFrame
*parent
, const wxString
& title
,
91 const wxPoint
& pos
, const wxSize
& size
,
92 long style
, const wxString
& name
):
93 wxPropertyListFrame(v
, parent
, title
, pos
, size
, style
, name
)
99 wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
103 wxPropertyInfo::sm_propertyWindow
= NULL
;
110 // Edit the information represented by this object, whatever that
112 bool wxPropertyInfo::Edit(wxWindow
*WXUNUSED(parent
), const wxString
& title
)
114 if (sm_propertyWindow
)
116 sm_propertyWindow
->Raise();
120 int width
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
;
121 int height
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
;
122 int x
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
;
123 int y
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
;
125 wxPropertySheet
*propSheet
= new wxPropertySheet
;
127 wxStringList propNames
;
128 GetPropertyNames(propNames
);
130 wxNode
*node
= propNames
.First();
133 wxString
name((char *)node
->Data());
134 wxProperty
*prop
= GetProperty(name
);
137 propSheet
->AddProperty(prop
);
142 // Reset 'modified' flags for all property values
143 propSheet
->SetAllModified(FALSE
);
145 wxResourcePropertyListView
*view
= new wxResourcePropertyListView(this, NULL
,
146 wxPROP_BUTTON_OK
| wxPROP_BUTTON_CANCEL
|
147 wxPROP_BUTTON_CHECK_CROSS
|wxPROP_DYNAMIC_VALUE_FIELD
|wxPROP_PULLDOWN
|wxPROP_SHOWVALUES
);
149 wxDialogEditorPropertyListFrame
*propWin
= new wxDialogEditorPropertyListFrame(view
,
150 wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title
, wxPoint(x
, y
),
151 wxSize(width
, height
), wxDEFAULT_FRAME_STYLE
);
152 sm_propertyWindow
= propWin
;
154 propWin
->m_registry
.RegisterValidator(wxString("real"), new wxRealListValidator
);
155 propWin
->m_registry
.RegisterValidator(wxString("string"), new wxStringListValidator
);
156 propWin
->m_registry
.RegisterValidator(wxString("integer"), new wxIntegerListValidator
);
157 propWin
->m_registry
.RegisterValidator(wxString("bool"), new wxBoolListValidator
);
158 propWin
->m_registry
.RegisterValidator(wxString("filename"), new wxFilenameListValidator
);
159 propWin
->m_registry
.RegisterValidator(wxString("stringlist"), new wxListOfStringsListValidator
);
160 propWin
->m_registry
.RegisterValidator(wxString("window_id"), new wxResourceSymbolValidator
);
162 propWin
->m_propInfo
= this;
163 propWin
->m_propSheet
= propSheet
;
165 // view->m_propertyWindow = propWin;
166 view
->AddRegistry(&(propWin
->m_registry
));
168 propWin
->Initialize();
169 view
->ShowView(propSheet
, propWin
->GetPropertyPanel());
173 // Otherwise doesn't show itself
175 wxNoOptimize noOptimize
;
176 propWin
->SetSize(-1, -1, width
, height
);
183 * wxWindowPropertyInfo
186 wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
)
188 m_propertyWindow
= win
;
189 m_propertyResource
= res
;
192 wxWindowPropertyInfo::~wxWindowPropertyInfo(void)
196 wxProperty
*wxWindowPropertyInfo::GetFontProperty(wxString
& name
, wxFont
*font
)
201 if (name
.Contains("Points"))
202 return new wxProperty(name
, (long)font
->GetPointSize(), "integer", new wxIntegerListValidator(1, 100));
203 else if (name
.Contains("Family"))
204 return new wxProperty(name
, font
->GetFamilyString(), "string",
205 new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN",
207 else if (name
.Contains("Style"))
208 return new wxProperty(name
, font
->GetStyleString(), "string",
209 new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL
)));
210 else if (name
.Contains("Weight"))
211 return new wxProperty(name
, font
->GetWeightString(), "string",
212 new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL
)));
213 else if (name
.Contains("Underlined"))
214 return new wxProperty(name
, (bool)font
->GetUnderlined(), "bool");
219 wxFont
*wxWindowPropertyInfo::SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*font
)
222 int fontFamily
= wxMODERN
;
223 int fontStyle
= wxNORMAL
;
224 int fontWeight
= wxNORMAL
;
225 bool fontUnderlined
= FALSE
;
227 if (name
.Contains("Points"))
229 pointSize
= (int)property
->GetValue().IntegerValue();
230 if (font
&& (pointSize
== font
->GetPointSize()))
231 return NULL
; // No change
233 else if (font
) pointSize
= font
->GetPointSize();
235 if (name
.Contains("Family"))
237 wxString val
= property
->GetValue().StringValue();
238 fontFamily
= wxStringToFontFamily(val
);
240 if (font
&& (fontFamily
== font
->GetFamily()))
241 return NULL
; // No change
243 else if (font
) fontFamily
= font
->GetFamily();
245 if (name
.Contains("Style"))
247 wxString val
= property
->GetValue().StringValue();
248 fontStyle
= wxStringToFontStyle(val
);
250 if (font
&& (fontStyle
== font
->GetStyle()))
251 return NULL
; // No change
253 else if (font
) fontStyle
= font
->GetStyle();
254 if (name
.Contains("Weight"))
256 wxString val
= property
->GetValue().StringValue();
257 fontWeight
= wxStringToFontWeight(val
);
259 if (font
&& (fontWeight
== font
->GetWeight()))
260 return NULL
; // No change
262 else if (font
) fontWeight
= font
->GetWeight();
264 if (name
.Contains("Underlined"))
266 fontUnderlined
= property
->GetValue().BoolValue();
268 if (font
&& (fontUnderlined
== font
->GetUnderlined()))
269 return NULL
; // No change
271 else if (font
) fontUnderlined
= font
->GetUnderlined();
273 wxFont
*newFont
= wxTheFontList
->FindOrCreateFont(pointSize
, fontFamily
, fontStyle
, fontWeight
, fontUnderlined
);
282 wxProperty
*wxWindowPropertyInfo::GetProperty(wxString
& name
)
284 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
286 wxFont
*font
= & m_propertyWindow
->GetFont();
287 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
288 name
== "fontUnderlined")
289 return GetFontProperty(name
, font
);
290 else if (name
== "name")
291 return new wxProperty("name", m_propertyWindow
->GetName(), "string");
292 else if (name
== "title")
293 return new wxProperty("title", m_propertyWindow
->GetTitle(), "string");
294 else if (name
== "x")
296 return new wxProperty("x", (long)resource
->GetX(), "integer");
298 else if (name
== "y")
300 return new wxProperty("y", (long)resource
->GetY(), "integer");
302 else if (name
== "width")
304 return new wxProperty("width", (long)resource
->GetWidth(), "integer");
306 else if (name
== "height")
308 return new wxProperty("height", (long)resource
->GetHeight(), "integer");
310 else if (name
== "id")
312 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
315 int id
= resource
->GetId();
317 idStr
.Printf("%d", id
);
318 wxString symbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id
);
321 // symbolName is now e.g. "ID_PANEL21=105"
322 return new wxProperty("id", symbolName
, "window_id");
327 else if (name
== "border")
330 if (m_propertyWindow
->GetWindowStyleFlag() & wxSIMPLE_BORDER
)
331 border
= "wxSIMPLE_BORDER";
332 else if (m_propertyWindow
->GetWindowStyleFlag() & wxRAISED_BORDER
)
333 border
= "wxRAISED_BORDER";
334 else if (m_propertyWindow
->GetWindowStyleFlag() & wxSUNKEN_BORDER
)
335 border
= "wxSUNKEN_BORDER";
336 else if (m_propertyWindow
->GetWindowStyleFlag() & wxDOUBLE_BORDER
)
337 border
= "wxDOUBLE_BORDER";
338 else if (m_propertyWindow
->GetWindowStyleFlag() & wxSTATIC_BORDER
)
339 border
= "wxSTATIC_BORDER";
341 border
= "wxNO_BORDER";
343 return new wxProperty("border", border
, "string",
344 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
345 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL
)));
351 bool wxWindowPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
353 wxFont
*font
= & m_propertyWindow
->GetFont();
354 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
356 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
358 m_propertyWindow
->SetFont(* newFont
);
361 else if (name
== "name")
363 // Remove old name from resource table, if it's there.
364 wxItemResource
*oldResource
= (wxItemResource
*)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow
->GetName());
367 // It's a top-level resource
368 m_propertyWindow
->SetName(property
->GetValue().StringValue());
369 oldResource
->SetName(property
->GetValue().StringValue());
370 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow
->GetName(), oldResource
);
374 // It's a child of something; just set the name of the resource and the window.
375 m_propertyWindow
->SetName(property
->GetValue().StringValue());
376 m_propertyResource
->SetName(property
->GetValue().StringValue());
378 // Refresh the resource manager list, because the name changed.
379 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
382 else if (name
== "title")
384 m_propertyWindow
->SetTitle(property
->GetValue().StringValue());
387 else if (name
== "x")
389 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
391 m_propertyWindow
->GetPosition(&x
, &y
);
392 int newX
= (int)property
->GetValue().IntegerValue();
395 // We need to convert to pixels if this is not a dialog or panel, but
396 // the parent resource specifies dialog units.
397 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
399 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
400 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
402 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(newX
, y
));
406 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
408 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
409 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
411 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(newX
, y
));
418 m_propertyWindow
->Move(pixelX
, y
);
419 resource
->SetSize(newX
, resource
->GetY(), resource
->GetWidth(), resource
->GetHeight());
423 else if (name
== "y")
425 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
427 m_propertyWindow
->GetPosition(&x
, &y
);
428 int newY
= (int)property
->GetValue().IntegerValue();
431 // We need to convert to pixels if this is not a dialog or panel, but
432 // the parent resource specifies dialog units.
433 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
435 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
436 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
438 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(x
, newY
));
442 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
444 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
445 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
447 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(x
, newY
));
454 m_propertyWindow
->Move(x
, pixelY
);
455 resource
->SetSize(resource
->GetX(), newY
, resource
->GetWidth(), resource
->GetHeight());
459 else if (name
== "width")
461 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
463 m_propertyWindow
->GetSize(&width
, &height
);
464 int newWidth
= (int)property
->GetValue().IntegerValue();
465 int pixelWidth
= newWidth
;
467 // We need to convert to pixels if this is not a dialog or panel, but
468 // the parent resource specifies dialog units.
469 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
471 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
472 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
474 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(newWidth
, height
));
478 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
480 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
481 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
483 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(newWidth
, height
));
488 if (width
!= pixelWidth
)
490 m_propertyWindow
->SetSize(pixelWidth
, height
);
491 resource
->SetSize(resource
->GetX(), resource
->GetY(), newWidth
, resource
->GetHeight());
495 else if (name
== "height")
497 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
499 m_propertyWindow
->GetSize(&width
, &height
);
500 int newHeight
= (int)property
->GetValue().IntegerValue();
501 int pixelHeight
= newHeight
;
503 // We need to convert to pixels if this is not a dialog or panel, but
504 // the parent resource specifies dialog units.
505 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
507 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
508 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
510 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(width
, newHeight
));
514 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
516 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
517 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
519 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(width
, newHeight
));
524 if (height
!= pixelHeight
)
526 m_propertyWindow
->SetSize(width
, pixelHeight
);
527 resource
->SetSize(resource
->GetX(), resource
->GetY(), resource
->GetWidth(), newHeight
);
531 else if (name
== "id")
533 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
536 wxString value
= property
->GetValue().StringValue();
538 wxString strName
= value
.Before('=');
539 wxString strId
= value
.After('=');
540 int id
= atoi(strId
);
542 wxString oldSymbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource
->GetId());
543 int oldSymbolId
= resource
->GetId();
547 // If we change the id for an existing symbol, we need to:
548 // 1) Check if there are any other resources currently using the original id.
549 // If so, will need to change their id to the new id.
550 // 2) Remove the old symbol, add the new symbol.
551 // In this check, we don't have to do this, but we need to do it in SetProperty.
553 if (strName
== oldSymbolName
&& id
!= oldSymbolId
)
555 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
557 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
558 // because ids are unique and changing one resource's id must change all identical ones.
559 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId
, id
);
561 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
562 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
565 // If we change the name but not the id, we'll just need to remove and
566 // re-add the symbol/id pair.
567 if (strName
!= oldSymbolName
&& id
== oldSymbolId
)
569 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
571 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
573 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
575 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
579 // What if we're changing both the name and the id?
580 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
581 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
583 if (strName
!= oldSymbolName
&& id
!= oldSymbolId
)
585 // Remove old symbol if it's not being used
586 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource
, oldSymbolId
) &&
587 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
))
589 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
592 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
594 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
605 else if (name
== "border")
607 long borderStyle
= wxNO_BORDER
;
608 wxString val
= property
->GetValue().StringValue();
610 if (val
== "wxSIMPLE_BORDER")
611 borderStyle
= wxSIMPLE_BORDER
;
612 else if (val
== "wxRAISED_BORDER")
613 borderStyle
= wxRAISED_BORDER
;
614 else if (val
== "wxSUNKEN_BORDER")
615 borderStyle
= wxSUNKEN_BORDER
;
616 else if (val
== "wxDOUBLE_BORDER")
617 borderStyle
= wxDOUBLE_BORDER
;
618 else if (val
== "wxSTATIC_BORDER")
619 borderStyle
= wxSTATIC_BORDER
;
621 borderStyle
= wxNO_BORDER
;
623 SetWindowStyle(m_propertyWindow
, wxSIMPLE_BORDER
, FALSE
);
624 SetWindowStyle(m_propertyWindow
, wxRAISED_BORDER
, FALSE
);
625 SetWindowStyle(m_propertyWindow
, wxSUNKEN_BORDER
, FALSE
);
626 SetWindowStyle(m_propertyWindow
, wxDOUBLE_BORDER
, FALSE
);
627 SetWindowStyle(m_propertyWindow
, wxSTATIC_BORDER
, FALSE
);
628 SetWindowStyle(m_propertyWindow
, wxNO_BORDER
, FALSE
);
630 SetWindowStyle(m_propertyWindow
, borderStyle
, TRUE
);
632 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
633 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
640 void wxWindowPropertyInfo::GetPropertyNames(wxStringList
& names
)
649 if (!m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
651 names
.Add("fontPoints");
652 names
.Add("fontFamily");
653 names
.Add("fontStyle");
654 names
.Add("fontWeight");
655 names
.Add("fontUnderlined");
659 // Fill in the wxItemResource members to mirror the current window settings
660 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource
*resource
)
662 // resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName());
664 // resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
665 wxString
str(m_propertyWindow
->GetName());
666 resource
->SetName(str
);
671 if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
672 m_propertyWindow
->GetClientSize(&w
, &h
);
674 m_propertyWindow
->GetSize(&w
, &h
);
676 m_propertyWindow
->GetPosition(&x
, &y
);
678 // We need to convert to dialog units if this is not a dialog or panel, but
679 // the parent resource specifies dialog units.
680 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
682 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
683 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
685 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxPoint(x
, y
));
687 wxSize sz
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxSize(w
, h
));
691 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
693 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
695 wxPoint pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(x
, y
));
697 wxSize sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(w
, h
));
702 resource
->SetSize(x
, y
, w
, h
);
708 // Set the window style
709 void wxWindowPropertyInfo::SetWindowStyle(wxWindow
* win
, long style
, bool set
)
714 if ((win
->GetWindowStyleFlag() & style
) == style
)
718 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() - style
);
725 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() | style
);
734 wxProperty
*wxItemPropertyInfo::GetProperty(wxString
& name
)
736 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
737 wxFont
*font
= & itemWindow
->GetFont();
739 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
740 name
== "fontUnderlined")
741 return GetFontProperty(name
, font
);
742 else if (name
== "label" && itemWindow
->GetLabel())
743 return new wxProperty("label", m_propertyWindow
->GetLabel(), "string");
745 return wxWindowPropertyInfo::GetProperty(name
);
748 bool wxItemPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
750 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
751 wxFont
*font
= & itemWindow
->GetFont();
753 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
755 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
757 itemWindow
->SetFont(* newFont
);
760 else if (name
== "label")
762 itemWindow
->SetLabel(property
->GetValue().StringValue());
766 return wxWindowPropertyInfo::SetProperty(name
, property
);
769 void wxItemPropertyInfo::GetPropertyNames(wxStringList
& names
)
771 wxWindowPropertyInfo::GetPropertyNames(names
);
773 names
.Add("fontPoints");
774 names
.Add("fontFamily");
775 names
.Add("fontStyle");
776 names
.Add("fontWeight");
777 names
.Add("fontUnderlined");
780 bool wxItemPropertyInfo::InstantiateResource(wxItemResource
*resource
)
782 wxWindowPropertyInfo::InstantiateResource(resource
);
784 wxControl
*item
= (wxControl
*)m_propertyWindow
;
785 wxString
str(item
->GetLabel());
786 resource
->SetTitle(str
);
788 if (item
->GetFont().Ok())
789 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(item
->GetFont().GetPointSize(),
790 item
->GetFont().GetFamily(), item
->GetFont().GetStyle(), item
->GetFont().GetWeight(),
791 item
->GetFont().GetUnderlined(), item
->GetFont().GetFaceName()));
799 wxProperty
*wxButtonPropertyInfo::GetProperty(wxString
& name
)
801 return wxItemPropertyInfo::GetProperty(name
);
804 bool wxButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
806 return wxItemPropertyInfo::SetProperty(name
, property
);
809 void wxButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
811 wxItemPropertyInfo::GetPropertyNames(names
);
815 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
817 return wxItemPropertyInfo::InstantiateResource(resource
);
824 wxProperty
*wxBitmapButtonPropertyInfo::GetProperty(wxString
& name
)
826 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
827 if (name
== "bitmapFilename")
829 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
830 wxString
str("none.bmp");
834 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
836 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
839 return wxButtonPropertyInfo::GetProperty(name
);
842 bool wxBitmapButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
844 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
845 if (name
== "bitmapFilename")
847 char *s
= property
->GetValue().StringValue();
848 if (s
&& wxFileExists(s
))
851 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
859 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
862 wxString
oldResource(resource
->GetValue4());
863 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
864 resource
->SetValue4(resName
);
866 if (!oldResource
.IsNull())
867 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
870 button
->SetLabel(* bitmap
);
877 return wxButtonPropertyInfo::SetProperty(name
, property
);
880 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
882 wxButtonPropertyInfo::GetPropertyNames(names
);
883 names
.Delete("label");
884 names
.Add("bitmapFilename");
887 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
889 return wxItemPropertyInfo::InstantiateResource(resource
);
896 wxProperty
*wxStaticTextPropertyInfo::GetProperty(wxString
& name
)
898 return wxItemPropertyInfo::GetProperty(name
);
901 bool wxStaticTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
903 return wxItemPropertyInfo::SetProperty(name
, property
);
906 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
908 wxItemPropertyInfo::GetPropertyNames(names
);
912 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
914 return wxItemPropertyInfo::InstantiateResource(resource
);
921 wxProperty
*wxStaticBitmapPropertyInfo::GetProperty(wxString
& name
)
923 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
924 if (name
== "bitmapFilename")
926 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
927 wxString
str("none.bmp");
931 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
933 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
936 return wxItemPropertyInfo::GetProperty(name
);
939 bool wxStaticBitmapPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
941 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
942 if (name
== "bitmapFilename")
944 char *s
= property
->GetValue().StringValue();
945 if (s
&& wxFileExists(s
))
949 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
957 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
960 wxString
oldResource(resource
->GetValue4());
961 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
962 resource
->SetValue4(resName
);
964 if (!oldResource
.IsNull())
965 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
968 message
->SetBitmap(* bitmap
);
975 return wxItemPropertyInfo::SetProperty(name
, property
);
978 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList
& names
)
980 wxItemPropertyInfo::GetPropertyNames(names
);
981 names
.Add("bitmapFilename");
984 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource
*resource
)
986 return wxItemPropertyInfo::InstantiateResource(resource
);
993 wxProperty
*wxTextPropertyInfo::GetProperty(wxString
& name
)
995 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
997 return new wxProperty("value", text
->GetValue(), "string");
998 else if (name
== "password")
1000 bool isPassword
= ((text
->GetWindowStyleFlag() & wxTE_PASSWORD
) == wxTE_PASSWORD
);
1001 return new wxProperty("password", isPassword
, "bool");
1003 else if (name
== "readonly")
1005 bool isReadOnly
= ((text
->GetWindowStyleFlag() & wxTE_READONLY
) == wxTE_READONLY
);
1006 return new wxProperty("readonly", isReadOnly
, "bool");
1009 return wxItemPropertyInfo::GetProperty(name
);
1012 bool wxTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1014 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1015 if (name
== "value")
1017 text
->SetValue(property
->GetValue().StringValue());
1020 else if (name
== "password")
1022 long flag
= text
->GetWindowStyleFlag();
1023 if (property
->GetValue().BoolValue())
1025 if ((flag
& wxTE_PASSWORD
) != wxTE_PASSWORD
)
1026 flag
|= wxTE_PASSWORD
;
1030 if ((flag
& wxTE_PASSWORD
) == wxTE_PASSWORD
)
1031 flag
-= wxTE_PASSWORD
;
1033 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1034 resource
->SetStyle(flag
);
1036 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1039 else if (name
== "readonly")
1041 long flag
= text
->GetWindowStyleFlag();
1042 if (property
->GetValue().BoolValue())
1044 if ((flag
& wxTE_READONLY
) != wxTE_READONLY
)
1045 flag
|= wxTE_READONLY
;
1049 if ((flag
& wxTE_READONLY
) == wxTE_READONLY
)
1050 flag
-= wxTE_READONLY
;
1052 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1053 resource
->SetStyle(flag
);
1055 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1059 return wxItemPropertyInfo::SetProperty(name
, property
);
1062 void wxTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
1064 wxItemPropertyInfo::GetPropertyNames(names
);
1066 names
.Add("readonly");
1067 names
.Add("password");
1070 bool wxTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1072 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1073 wxString
str(text
->GetValue());
1074 resource
->SetValue4(str
);
1076 return wxItemPropertyInfo::InstantiateResource(resource
);
1083 wxProperty
*wxListBoxPropertyInfo::GetProperty(wxString
& name
)
1085 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1086 if (name
== "values")
1088 wxStringList
*stringList
= new wxStringList
;
1090 for (i
= 0; i
< listBox
->Number(); i
++)
1091 stringList
->Add(listBox
->GetString(i
));
1093 return new wxProperty(name
, stringList
, "stringlist");
1095 else if (name
== "multiple")
1097 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1101 char *mult
= "wxLB_SINGLE";
1103 if ((listBox
->GetWindowStyleFlag() & wxLB_MULTIPLE
) != 0)
1104 mult
= "wxLB_MULTIPLE";
1105 else if ((listBox
->GetWindowStyleFlag() & wxLB_EXTENDED
) != 0)
1106 mult
= "wxLB_EXTENDED";
1108 mult
= "wxLB_SINGLE";
1110 return new wxProperty("multiple", mult
, "string",
1111 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1115 return wxItemPropertyInfo::GetProperty(name
);
1118 bool wxListBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1120 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1121 if (name
== "values")
1124 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1127 char *s
= expr
->StringValue();
1130 expr
= expr
->GetNext();
1134 else if (name
== "multiple")
1136 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, FALSE
);
1137 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, FALSE
);
1138 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, FALSE
);
1140 wxString
str(property
->GetValue().StringValue());
1141 if (str
== "wxLB_MULTIPLE")
1142 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, TRUE
);
1143 else if (str
== "wxLB_EXTENDED")
1144 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, TRUE
);
1146 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, TRUE
);
1148 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1150 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1151 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox
, this);
1155 return wxItemPropertyInfo::SetProperty(name
, property
);
1158 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1160 wxItemPropertyInfo::GetPropertyNames(names
);
1161 names
.Add("values");
1162 names
.Add("multiple");
1165 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1167 wxListBox
*lbox
= (wxListBox
*)m_propertyWindow
;
1168 // This will be set for the wxItemResource on reading or in SetProperty
1169 // resource->SetValue1(lbox->GetSelectionMode());
1171 if (lbox
->Number() == 0)
1172 resource
->SetStringValues(NULL
);
1177 for (i
= 0; i
< lbox
->Number(); i
++)
1178 slist
.Add(lbox
->GetString(i
));
1180 resource
->SetStringValues(slist
);
1182 return wxItemPropertyInfo::InstantiateResource(resource
);
1189 wxProperty
*wxChoicePropertyInfo::GetProperty(wxString
& name
)
1191 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1192 if (name
== "values")
1194 wxStringList
* stringList
= new wxStringList
;
1196 for (i
= 0; i
< choice
->Number(); i
++)
1197 stringList
->Add(choice
->GetString(i
));
1199 return new wxProperty(name
, stringList
, "stringlist");
1202 return wxItemPropertyInfo::GetProperty(name
);
1205 bool wxChoicePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1207 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1208 if (name
== "values")
1211 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1214 char *s
= expr
->StringValue();
1217 expr
= expr
->GetNext();
1219 if (choice
->Number() > 0)
1220 choice
->SetSelection(0);
1224 return wxItemPropertyInfo::SetProperty(name
, property
);
1227 void wxChoicePropertyInfo::GetPropertyNames(wxStringList
& names
)
1229 wxItemPropertyInfo::GetPropertyNames(names
);
1230 names
.Add("values");
1233 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1235 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1237 if (choice
->Number() == 0)
1238 resource
->SetStringValues(NULL
);
1243 for (i
= 0; i
< choice
->Number(); i
++)
1244 slist
.Add(choice
->GetString(i
));
1246 resource
->SetStringValues(slist
);
1248 return wxItemPropertyInfo::InstantiateResource(resource
);
1255 wxProperty
*wxComboBoxPropertyInfo::GetProperty(wxString
& name
)
1257 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1258 if (name
== "values")
1260 wxStringList
*stringList
= new wxStringList
;
1262 for (i
= 0; i
< choice
->Number(); i
++)
1263 stringList
->Add(choice
->GetString(i
));
1265 return new wxProperty(name
, stringList
, "stringlist");
1267 else if (name
== "sort")
1269 bool sort
= ((m_propertyWindow
->GetWindowStyleFlag() & wxCB_SORT
) == wxCB_SORT
);
1270 return new wxProperty(name
, sort
, "bool");
1272 else if (name
== "style")
1274 wxString
styleStr("dropdown");
1275 if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_SIMPLE
)
1276 styleStr
= "simple";
1277 else if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_READONLY
)
1278 styleStr
= "readonly";
1280 styleStr
= "dropdown";
1282 return new wxProperty(name
, styleStr
, "string",
1283 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1287 return wxItemPropertyInfo::GetProperty(name
);
1290 bool wxComboBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1292 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1293 if (name
== "values")
1296 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1299 char *s
= expr
->StringValue();
1302 expr
= expr
->GetNext();
1304 if (choice
->Number() > 0)
1305 choice
->SetSelection(0);
1308 else if (name
== "sort")
1310 SetWindowStyle(m_propertyWindow
, wxCB_SORT
, property
->GetValue().BoolValue());
1312 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1313 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1315 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1318 else if (name
== "style")
1320 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, FALSE
);
1321 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, FALSE
);
1322 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, FALSE
);
1324 wxString
styleStr(property
->GetValue().StringValue());
1325 if (styleStr
== "simple")
1326 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, TRUE
);
1327 else if (styleStr
== "dropdown")
1328 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, TRUE
);
1329 else if (styleStr
== "readonly")
1330 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, TRUE
);
1333 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1334 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1336 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1341 return wxItemPropertyInfo::SetProperty(name
, property
);
1344 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1346 wxItemPropertyInfo::GetPropertyNames(names
);
1347 names
.Add("values");
1352 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1354 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1356 if (choice
->Number() == 0)
1357 resource
->SetStringValues(NULL
);
1362 for (i
= 0; i
< choice
->Number(); i
++)
1363 slist
.Add(choice
->GetString(i
));
1365 resource
->SetStringValues(slist
);
1367 return wxItemPropertyInfo::InstantiateResource(resource
);
1374 wxProperty
*wxRadioBoxPropertyInfo::GetProperty(wxString
& name
)
1376 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1377 if (name
== "numberRowsOrCols")
1379 return new wxProperty("numberRowsOrCols", (long)radioBox
->GetNumberOfRowsOrCols(), "integer");
1381 if (name
== "orientation")
1384 if (m_propertyWindow
->GetWindowStyleFlag() & wxRA_SPECIFY_COLS
)
1385 orient
= "wxRA_SPECIFY_COLS";
1387 orient
= "wxRA_SPECIFY_ROWS";
1389 return new wxProperty("orientation", orient
, "string",
1390 new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS",
1393 else if (name
== "values")
1395 wxStringList
*stringList
= new wxStringList
;
1397 for (i
= 0; i
< radioBox
->Number(); i
++)
1398 stringList
->Add(radioBox
->GetString(i
));
1400 return new wxProperty(name
, stringList
, "stringlist");
1402 return wxItemPropertyInfo::GetProperty(name
);
1405 bool wxRadioBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1407 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1408 if (name
== "numberRowsOrCols")
1410 radioBox
->SetNumberOfRowsOrCols((int)property
->GetValue().IntegerValue());
1411 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1414 else if (name
== "orientation")
1416 long windowStyle
= radioBox
->GetWindowStyleFlag();
1417 wxString
val(property
->GetValue().StringValue());
1418 if (val
== "wxRA_SPECIFY_COLS")
1420 if (windowStyle
& wxRA_SPECIFY_ROWS
)
1421 windowStyle
-= wxRA_SPECIFY_ROWS
;
1422 windowStyle
|= wxRA_SPECIFY_COLS
;
1426 if (windowStyle
& wxRA_SPECIFY_COLS
)
1427 windowStyle
-= wxRA_SPECIFY_COLS
;
1428 windowStyle
|= wxRA_SPECIFY_ROWS
;
1430 radioBox
->SetWindowStyleFlag(windowStyle
);
1431 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox
);
1432 resource
->SetStyle(windowStyle
);
1434 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1437 else if (name
== "values")
1439 // Set property into *resource*, not wxRadioBox, and then recreate
1440 // the wxRadioBox. This is because we can't dynamically set the strings
1442 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1446 wxStringList stringList
;
1447 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1450 char *s
= expr
->StringValue();
1453 expr
= expr
->GetNext();
1455 resource
->SetStringValues(stringList
);
1456 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1459 return wxItemPropertyInfo::SetProperty(name
, property
);
1462 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1464 wxItemPropertyInfo::GetPropertyNames(names
);
1466 names
.Add("values");
1467 names
.Add("orientation");
1468 names
.Add("numberRowsOrCols");
1471 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1473 wxRadioBox
*rbox
= (wxRadioBox
*)m_propertyWindow
;
1474 // Take strings from resource instead
1477 if (rbox->Number() == 0)
1478 resource->SetStringValues(NULL);
1481 wxStringList *slist = new wxStringList;
1483 for (i = 0; i < rbox->Number(); i++)
1484 slist->Add(rbox->GetString(i));
1486 resource->SetStringValues(slist);
1489 resource
->SetValue1(rbox
->GetNumberOfRowsOrCols());
1490 return wxItemPropertyInfo::InstantiateResource(resource
);
1497 wxProperty
*wxGroupBoxPropertyInfo::GetProperty(wxString
& name
)
1499 return wxItemPropertyInfo::GetProperty(name
);
1502 bool wxGroupBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1504 return wxItemPropertyInfo::SetProperty(name
, property
);
1507 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1509 wxItemPropertyInfo::GetPropertyNames(names
);
1513 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1515 return wxItemPropertyInfo::InstantiateResource(resource
);
1522 wxProperty
*wxCheckBoxPropertyInfo::GetProperty(wxString
& name
)
1524 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1525 if (name
== "value")
1526 return new wxProperty("value", checkBox
->GetValue(), "bool");
1528 return wxItemPropertyInfo::GetProperty(name
);
1531 bool wxCheckBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1533 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1534 if (name
== "value")
1536 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1540 return wxItemPropertyInfo::SetProperty(name
, property
);
1543 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1545 wxItemPropertyInfo::GetPropertyNames(names
);
1550 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1552 wxCheckBox
*cbox
= (wxCheckBox
*)m_propertyWindow
;
1553 resource
->SetValue1(cbox
->GetValue());
1554 return wxItemPropertyInfo::InstantiateResource(resource
);
1561 wxProperty
*wxRadioButtonPropertyInfo::GetProperty(wxString
& name
)
1563 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1564 if (name
== "value")
1565 return new wxProperty("value", checkBox
->GetValue(), "bool");
1567 return wxItemPropertyInfo::GetProperty(name
);
1570 bool wxRadioButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1572 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1573 if (name
== "value")
1575 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1579 return wxItemPropertyInfo::SetProperty(name
, property
);
1582 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
1584 wxItemPropertyInfo::GetPropertyNames(names
);
1589 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1591 wxRadioButton
*cbox
= (wxRadioButton
*)m_propertyWindow
;
1592 resource
->SetValue1(cbox
->GetValue());
1593 return wxItemPropertyInfo::InstantiateResource(resource
);
1600 wxProperty
*wxSliderPropertyInfo::GetProperty(wxString
& name
)
1602 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1603 if (name
== "value")
1604 return new wxProperty("value", (long)slider
->GetValue(), "integer");
1605 else if (name
== "orientation")
1608 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1609 pos
= "wxHORIZONTAL";
1613 return new wxProperty("orientation", pos
, "string",
1614 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1617 else if (name
== "minValue")
1618 return new wxProperty("minValue", (long)slider
->GetMin(), "integer");
1619 else if (name
== "maxValue")
1620 return new wxProperty("maxValue", (long)slider
->GetMax(), "integer");
1622 return wxItemPropertyInfo::GetProperty(name
);
1625 bool wxSliderPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1627 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1628 if (name
== "value")
1630 slider
->SetValue((int)property
->GetValue().IntegerValue());
1633 else if (name
== "orientation")
1635 long windowStyle
= slider
->GetWindowStyleFlag();
1636 long oldWindowStyle
= windowStyle
;
1637 wxString
val(property
->GetValue().StringValue());
1638 if (val
== "wxHORIZONTAL")
1640 if (windowStyle
& wxVERTICAL
)
1641 windowStyle
-= wxVERTICAL
;
1642 windowStyle
|= wxHORIZONTAL
;
1646 if (windowStyle
& wxHORIZONTAL
)
1647 windowStyle
-= wxHORIZONTAL
;
1648 windowStyle
|= wxVERTICAL
;
1651 if (oldWindowStyle
== windowStyle
)
1654 slider
->SetWindowStyleFlag(windowStyle
);
1656 // If the window style has changed, we swap the width and height parameters.
1658 slider
->GetSize(&w
, &h
);
1660 slider
= (wxSlider
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider
, this);
1661 slider
->SetSize(-1, -1, h
, w
);
1662 m_propertyWindow
= slider
;
1666 else if (name
== "minValue")
1668 slider
->SetRange((int)property
->GetValue().IntegerValue(), slider
->GetMax());
1671 else if (name
== "maxValue")
1673 slider
->SetRange(slider
->GetMin(), (int)property
->GetValue().IntegerValue());
1677 return wxItemPropertyInfo::SetProperty(name
, property
);
1680 void wxSliderPropertyInfo::GetPropertyNames(wxStringList
& names
)
1682 wxItemPropertyInfo::GetPropertyNames(names
);
1684 names
.Add("orientation");
1685 names
.Add("minValue");
1686 names
.Add("maxValue");
1689 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1691 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1692 resource
->SetValue1(slider
->GetValue());
1693 resource
->SetValue2(slider
->GetMin());
1694 resource
->SetValue3(slider
->GetMax());
1695 return wxItemPropertyInfo::InstantiateResource(resource
);
1702 wxProperty
*wxGaugePropertyInfo::GetProperty(wxString
& name
)
1704 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1705 if (name
== "value")
1706 return new wxProperty("value", (long)gauge
->GetValue(), "integer");
1707 else if (name
== "maxValue")
1708 return new wxProperty("maxValue", (long)gauge
->GetRange(), "integer");
1710 return wxItemPropertyInfo::GetProperty(name
);
1713 bool wxGaugePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1715 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1716 if (name
== "value")
1718 gauge
->SetValue((int)property
->GetValue().IntegerValue());
1721 else if (name
== "maxValue")
1723 gauge
->SetRange((int)property
->GetValue().IntegerValue());
1727 return wxItemPropertyInfo::SetProperty(name
, property
);
1730 void wxGaugePropertyInfo::GetPropertyNames(wxStringList
& names
)
1732 wxItemPropertyInfo::GetPropertyNames(names
);
1734 names
.Add("maxValue");
1737 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1739 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1740 resource
->SetValue1(gauge
->GetValue());
1741 resource
->SetValue2(gauge
->GetRange());
1742 return wxItemPropertyInfo::InstantiateResource(resource
);
1749 wxProperty
*wxScrollBarPropertyInfo::GetProperty(wxString
& name
)
1751 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1752 if (name
== "thumbPosition")
1753 return new wxProperty("value", (long)scrollBar
->GetThumbPosition(), "integer");
1754 else if (name
== "orientation")
1757 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1758 pos
= "wxHORIZONTAL";
1762 return new wxProperty("orientation", pos
, "string",
1763 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1766 else if (name
== "pageSize")
1768 int pageLength
= scrollBar
->GetPageSize();
1770 return new wxProperty("pageSize", (long)pageLength
, "integer");
1772 else if (name
== "thumbSize")
1774 int thumbSize
= scrollBar
->GetThumbSize();
1776 return new wxProperty("thumbSize", (long)thumbSize
, "integer");
1778 else if (name
== "range")
1780 int range
= scrollBar
->GetRange();
1781 return new wxProperty("range", (long)range
, "integer");
1784 return wxItemPropertyInfo::GetProperty(name
);
1787 bool wxScrollBarPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1789 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1790 if (name
== "thumbPosition")
1792 scrollBar
->SetThumbPosition((int)property
->GetValue().IntegerValue());
1795 else if (name
== "orientation")
1797 long windowStyle
= scrollBar
->GetWindowStyleFlag();
1798 long oldWindowStyle
= windowStyle
;
1799 wxString
val(property
->GetValue().StringValue());
1800 if (val
== "wxHORIZONTAL")
1802 if (windowStyle
& wxVERTICAL
)
1803 windowStyle
-= wxVERTICAL
;
1804 windowStyle
|= wxHORIZONTAL
;
1808 if (windowStyle
& wxHORIZONTAL
)
1809 windowStyle
-= wxHORIZONTAL
;
1810 windowStyle
|= wxVERTICAL
;
1813 if (oldWindowStyle
== windowStyle
)
1816 scrollBar
->SetWindowStyleFlag(windowStyle
);
1818 // If the window style has changed, we swap the width and height parameters.
1820 // scrollBar->GetSize(&w, &h);
1821 wxItemResource
*item
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar
);
1823 item
->SetSize(item
->GetX(), item
->GetY(), item
->GetHeight(), item
->GetWidth());
1824 item
->SetStyle(windowStyle
);
1827 scrollBar
= (wxScrollBar
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar
, this);
1828 m_propertyWindow
= scrollBar
;
1832 else if (name
== "pageSize")
1834 int pos
= scrollBar
->GetThumbPosition();
1835 int range
= scrollBar
->GetRange();
1836 int thumbSize
= scrollBar
->GetThumbSize();
1837 scrollBar
->SetScrollbar(pos
, thumbSize
, range
, (int)property
->GetValue().IntegerValue());
1840 else if (name
== "thumbSize")
1842 int pos
= scrollBar
->GetThumbPosition();
1843 int range
= scrollBar
->GetRange();
1844 int pageSize
= scrollBar
->GetPageSize();
1845 scrollBar
->SetScrollbar(pos
, (int)property
->GetValue().IntegerValue(), range
, pageSize
);
1848 else if (name
== "range")
1850 int pos
= scrollBar
->GetThumbPosition();
1851 int thumbSize
= scrollBar
->GetThumbSize();
1852 int pageSize
= scrollBar
->GetPageSize();
1853 scrollBar
->SetScrollbar(pos
, thumbSize
, (int)property
->GetValue().IntegerValue(), pageSize
);
1857 return wxItemPropertyInfo::SetProperty(name
, property
);
1860 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList
& names
)
1862 wxItemPropertyInfo::GetPropertyNames(names
);
1863 names
.Add("orientation");
1864 names
.Add("thumbPosition");
1865 names
.Add("thumbSize");
1866 names
.Add("pageSize");
1869 // Remove some properties we don't inherit
1870 names
.Delete("fontPoints");
1871 names
.Delete("fontFamily");
1872 names
.Delete("fontStyle");
1873 names
.Delete("fontWeight");
1874 names
.Delete("fontUnderlined");
1877 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1879 wxScrollBar
*sbar
= (wxScrollBar
*)m_propertyWindow
;
1881 int thumbPosition
= sbar
->GetThumbPosition();
1882 int thumbSize
= sbar
->GetThumbSize();
1883 int pageSize
= sbar
->GetPageSize();
1884 int range
= sbar
->GetRange();
1886 resource
->SetValue1(thumbPosition
);
1887 resource
->SetValue2(thumbSize
);
1888 resource
->SetValue3(range
);
1889 resource
->SetValue5(pageSize
);
1891 return wxItemPropertyInfo::InstantiateResource(resource
);
1898 wxProperty
*wxPanelPropertyInfo::GetProperty(wxString
& name
)
1900 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
1903 wxFont *labelFont = panelWindow->GetLabelFont();
1904 wxFont *buttonFont = panelWindow->GetButtonFont();
1906 if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" ||
1907 name == "labelFontUnderlined")
1908 return GetFontProperty(name, labelFont);
1909 else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" ||
1910 name == "buttonFontUnderlined")
1911 return GetFontProperty(name, buttonFont);
1917 if (panelWindow
->GetWindowStyleFlag() & wxNO_3D
)
1920 userColours
= FALSE
;
1922 return new wxProperty(name
, (bool)userColours
, "bool");
1924 else if (name
== "backgroundColour")
1926 wxColour
col(panelWindow
->GetBackgroundColour());
1928 wxDecToHex(col
.Red(), buf
);
1929 wxDecToHex(col
.Green(), buf
+2);
1930 wxDecToHex(col
.Blue(), buf
+4);
1932 return new wxProperty(name
, buf
, "string", new wxColourListValidator
);
1934 else if (name
== "title")
1936 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1938 return new wxProperty(name
, resource
->GetTitle(), "string");
1940 return new wxProperty(name
, "Could not get title", "string");
1942 else if (name
== "caption")
1944 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxCAPTION
) == wxCAPTION
),
1947 else if (name
== "systemMenu")
1949 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxSYSTEM_MENU
) == wxSYSTEM_MENU
),
1952 else if (name
== "thickFrame")
1954 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxTHICK_FRAME
) == wxTHICK_FRAME
),
1957 else if (name
== "useSystemDefaults")
1959 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1960 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) == wxRESOURCE_USE_DEFAULTS
),
1963 else if (name
== "useDialogUnits")
1965 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1966 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == wxRESOURCE_DIALOG_UNITS
),
1970 return wxWindowPropertyInfo::GetProperty(name
);
1973 bool wxPanelPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1975 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
1977 wxFont *labelFont = panelWindow->GetLabelFont();
1978 wxFont *buttonFont = panelWindow->GetButtonFont();
1980 if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" ))
1982 wxFont *newFont = SetFontProperty(name, property, labelFont);
1984 panelWindow->SetLabelFont(* newFont);
1987 else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" ))
1989 wxFont *newFont = SetFontProperty(name, property, buttonFont);
1991 panelWindow->SetButtonFont(* newFont);
1998 bool userColours
= property
->GetValue().BoolValue();
2002 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) != wxNO_3D
)
2003 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() | wxNO_3D
);
2007 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) == wxNO_3D
)
2008 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() - wxNO_3D
);
2010 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2011 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2013 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2016 else if (name
== "backgroundColour")
2018 char *hex
= property
->GetValue().StringValue();
2019 int r
= wxHexToDec(hex
);
2020 int g
= wxHexToDec(hex
+2);
2021 int b
= wxHexToDec(hex
+4);
2023 wxColour
col(r
,g
,b
);
2024 panelWindow
->SetBackgroundColour(col
);
2025 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2026 m_propertyWindow
= panelWindow
;
2029 else if (name
== "title")
2031 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2034 resource
->SetTitle(property
->GetValue().StringValue());
2040 else if (name
== "caption")
2042 SetWindowStyle(panelWindow
, wxCAPTION
, property
->GetValue().BoolValue());
2044 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2045 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2048 else if (name
== "thickFrame")
2050 SetWindowStyle(panelWindow
, wxTHICK_FRAME
, property
->GetValue().BoolValue());
2052 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2053 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2056 else if (name
== "systemMenu")
2058 SetWindowStyle(panelWindow
, wxSYSTEM_MENU
, property
->GetValue().BoolValue());
2060 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2061 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2064 else if (name
== "useSystemDefaults")
2066 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2067 bool useDefaults
= property
->GetValue().BoolValue();
2068 long style
= resource
->GetResourceStyle();
2071 if ((style
& wxRESOURCE_USE_DEFAULTS
) == 0)
2072 style
|= wxRESOURCE_USE_DEFAULTS
;
2076 if ((style
& wxRESOURCE_USE_DEFAULTS
) != 0)
2077 style
-= wxRESOURCE_USE_DEFAULTS
;
2079 resource
->SetResourceStyle(style
);
2080 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2083 else if (name
== "useDialogUnits")
2085 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2086 bool useDialogUnits
= property
->GetValue().BoolValue();
2087 long style
= resource
->GetResourceStyle();
2090 if ((style
& wxRESOURCE_DIALOG_UNITS
) == 0)
2092 style
|= wxRESOURCE_DIALOG_UNITS
;
2093 ConvertDialogUnits(TRUE
); // Convert all resources
2098 if ((style
& wxRESOURCE_DIALOG_UNITS
) != 0)
2100 style
-= wxRESOURCE_DIALOG_UNITS
;
2101 ConvertDialogUnits(FALSE
); // Convert all resources
2104 resource
->SetResourceStyle(style
);
2105 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2106 m_propertyWindow
= panelWindow
;
2107 // TODO: need to regenerate the width and height properties else they'll be inconsistent.
2111 return wxWindowPropertyInfo::SetProperty(name
, property
);
2114 void wxPanelPropertyInfo::GetPropertyNames(wxStringList
& names
)
2116 wxWindowPropertyInfo::GetPropertyNames(names
);
2120 names
.Add("backgroundColour");
2121 names
.Add("caption");
2122 names
.Add("systemMenu");
2123 names
.Add("thickFrame");
2124 names
.Add("useSystemDefaults");
2125 names
.Add("useDialogUnits");
2128 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2130 wxPanel
*panel
= (wxPanel
*)m_propertyWindow
;
2131 if (panel
->GetFont().Ok())
2132 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(panel
->GetFont().GetPointSize(),
2133 panel
->GetFont().GetFamily(), panel
->GetFont().GetStyle(), panel
->GetFont().GetWeight(),
2134 panel
->GetFont().GetUnderlined(), panel
->GetFont().GetFaceName()));
2136 resource
->SetBackgroundColour(wxColour(panel
->GetBackgroundColour()));
2138 return wxWindowPropertyInfo::InstantiateResource(resource
);
2141 // Convert this dialog, and its children, to or from dialog units
2142 void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits
)
2144 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
2150 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2151 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2155 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2156 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2158 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2160 wxNode
* node
= m_propertyWindow
->GetChildren().First();
2163 wxWindow
* child
= (wxWindow
*) node
->Data();
2164 if (child
->IsKindOf(CLASSINFO(wxControl
)))
2166 resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(child
);
2169 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2170 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2174 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2175 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2177 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2179 node
= node
->Next();
2188 wxProperty
*wxDialogPropertyInfo::GetProperty(wxString
& name
)
2190 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2191 if (name
== "modal")
2193 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2197 bool modal
= (resource
->GetValue1() != 0);
2198 return new wxProperty(name
, modal
, "bool");
2201 return wxPanelPropertyInfo::GetProperty(name
);
2204 bool wxDialogPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
2206 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2208 if (name
== "modal")
2210 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2214 resource
->SetValue1(property
->GetValue().BoolValue());
2218 return wxPanelPropertyInfo::SetProperty(name
, property
);
2221 void wxDialogPropertyInfo::GetPropertyNames(wxStringList
& names
)
2223 wxPanelPropertyInfo::GetPropertyNames(names
);
2228 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2230 wxDialog
*dialog
= (wxDialog
*)m_propertyWindow
;
2231 wxString
str(dialog
->GetTitle());
2232 resource
->SetTitle(str
);
2234 return wxPanelPropertyInfo::InstantiateResource(resource
);
2242 int wxStringToFontWeight(wxString
& val
)
2244 if (val
== "wxBOLD") return wxBOLD
;
2245 else if (val
== "wxLIGHT") return wxLIGHT
;
2246 else return wxNORMAL
;
2249 int wxStringToFontStyle(wxString
& val
)
2251 if (val
== "wxITALIC") return wxITALIC
;
2252 else if (val
== "wxSLANT") return wxSLANT
;
2253 else return wxNORMAL
;
2256 int wxStringToFontFamily(wxString
& val
)
2258 if (val
== "wxDECORATIVE") return wxDECORATIVE
;
2259 else if (val
== "wxROMAN") return wxROMAN
;
2260 else if (val
== "wxSCRIPT") return wxSCRIPT
;
2261 else if (val
== "wxMODERN") return wxMODERN
;
2262 else if (val
== "wxTELETYPE") return wxTELETYPE
;
2263 else return wxSWISS
;
2267 /// Resource symbol validator
2269 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator
, wxPropertyListValidator
)
2271 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags
):
2272 wxPropertyListValidator(flags
)
2276 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2280 bool wxResourceSymbolValidator::OnCheckValue(wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
))
2285 // Called when TICK is pressed or focus is lost or view wants to update
2286 // the property list.
2287 // Does the transferance from the property editing area to the property itself
2288 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2290 if (!view
->GetValueText())
2292 wxString
value(view
->GetValueText()->GetValue());
2293 property
->GetValue() = value
;
2297 // Called when TICK is pressed or focus is lost or view wants to update
2298 // the property list.
2299 // Does the transferance from the property editing area to the property itself
2300 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2302 if (!view
->GetValueText())
2304 wxString
str(property
->GetValue().GetStringRepresentation());
2305 view
->GetValueText()->SetValue(str
);
2309 // Called when the property is double clicked. Extra functionality can be provided,
2310 // cycling through possible values.
2311 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2313 if (!view
->GetValueText())
2315 OnEdit(property
, view
, parentWindow
);
2319 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty
*WXUNUSED(property
), wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2321 if (view
->GetConfirmButton())
2322 view
->GetConfirmButton()->Enable(TRUE
);
2323 if (view
->GetCancelButton())
2324 view
->GetCancelButton()->Enable(TRUE
);
2325 if (view
->GetEditButton())
2326 view
->GetEditButton()->Enable(TRUE
);
2327 if (view
->GetValueText())
2328 view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
);
2332 void wxResourceSymbolValidator::OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2334 if (!view
->GetValueText())
2337 wxResourceSymbolDialog
* dialog
= new wxResourceSymbolDialog(parentWindow
, -1, "Edit Symbol");
2339 // Split name/id pair e.g. "IDC_TEXT=123"
2340 wxString
value(property
->GetValue().StringValue());
2342 wxString strName
= value
.Before('=');
2343 wxString strId
= value
.After('=');
2345 dialog
->SetSymbol(strName
);
2346 dialog
->SetId(atoi(strId
));
2350 if (dialog
->ShowModal() == wxID_OK
)
2352 wxString
symbolName(dialog
->GetSymbol());
2353 long id
= dialog
->GetId();
2356 str
.Printf("%d", id
);
2357 property
->GetValue() = symbolName
+ wxString("=") + str
;
2359 view
->DisplayProperty(property
);
2360 view
->UpdatePropertyDisplayInList(property
);
2361 view
->OnPropertyChanged(property
);
2363 // Moved from the 'if' branch on suggestion of Roman Pavlov
2367 BEGIN_EVENT_TABLE(wxResourceSymbolDialog
, wxDialog
)
2368 EVT_BUTTON(wxID_OK
, wxResourceSymbolDialog::OnOK
)
2369 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnComboBoxSelect
)
2370 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnSymbolNameUpdate
)
2373 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
2374 const wxSize
& size
, long style
):
2375 wxDialog(parent
, id
, title
, pos
, size
, style
)
2380 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x
, y
));
2384 m_nameCtrl
= new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX
, "",
2385 wxPoint(x
, y
), wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
|wxCB_SORT
);
2390 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x
, y
));
2394 m_idCtrl
= new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL
, "",
2395 wxPoint(x
, y
), wxSize(200, -1));
2399 (void) new wxButton(this, wxID_OK
, "OK", wxPoint(x
, y
), wxSize(80, -1));
2402 (void) new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(x
, y
), wxSize(80, -1));
2408 void wxResourceSymbolDialog::Init()
2411 defaultId
.Printf("%ld", m_symbolId
);
2413 m_nameCtrl
->SetValue(m_symbolName
);
2414 m_idCtrl
->SetValue(defaultId
);
2416 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl
);
2419 void wxResourceSymbolDialog::OnOK(wxCommandEvent
& event
)
2423 wxDialog::OnOK(event
);
2427 bool wxResourceSymbolDialog::CheckValues()
2429 wxString
nameStr(m_nameCtrl
->GetValue());
2430 wxString
idStr(m_idCtrl
->GetValue());
2431 int id
= atoi(idStr
);
2435 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2440 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2443 if (nameStr
.Contains(" "))
2445 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2448 if (nameStr
.Contains("="))
2450 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2453 if (nameStr
.IsNumber())
2455 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2458 // TODO: other checks on the name syntax.
2460 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr
))
2462 // If we change the id for an existing symbol, we need to:
2463 // 1) Check if there are any other resources currently using the original id.
2464 // If so, will need to change their id to the new id, in SetProperty.
2465 // 2) Remove the old symbol, add the new symbol.
2466 // In this check, we don't have to do this, but we need to do it in SetProperty.
2468 if (nameStr
== GetSymbol() && id
!= GetId())
2470 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2474 // If we change the name but not the id... we'll just need to remove and
2475 // re-add the symbol/id pair, in SetProperty.
2476 if (nameStr
!= GetSymbol() && id
== GetId())
2480 // What if we're changing both the name and the id?
2481 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2482 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2484 if (nameStr
!= GetSymbol() && id
!= GetId())
2486 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr
, id
))
2488 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2489 "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2502 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent
& WXUNUSED(event
))
2504 wxString
str(m_nameCtrl
->GetStringSelection());
2505 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2507 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2509 str2
.Printf("%d", id
);
2510 m_idCtrl
->SetValue(str2
);
2511 m_idCtrl
->Enable(FALSE
);
2515 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2517 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2519 str2
.Printf("%d", id
);
2520 m_idCtrl
->SetValue(str2
);
2522 m_idCtrl
->Enable(TRUE
);
2526 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent
& WXUNUSED(event
))
2528 wxString
str(m_nameCtrl
->GetValue());
2529 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2531 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2533 str2
.Printf("%d", id
);
2534 m_idCtrl
->SetValue(str2
);
2535 m_idCtrl
->Enable(FALSE
);
2539 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2541 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2543 str2
.Printf("%d", id
);
2544 m_idCtrl
->SetValue(str2
);
2546 m_idCtrl
->Enable(TRUE
);