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"
33 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
36 #include <strstream.h>
49 // Causes immediate feedback.
50 void wxResourcePropertyListView::OnPropertyChanged(wxProperty
*property
)
52 // Sets the value of the property back into the actual object,
53 // IF the property value was modified.
54 if (property
->GetValue().GetModified())
56 m_propertyInfo
->SetProperty(property
->GetName(), property
);
57 property
->GetValue().SetModified(FALSE
);
58 wxResourceManager::GetCurrentResourceManager()->Modify(TRUE
);
62 bool wxResourcePropertyListView::OnClose(void)
65 GetManagedWindow()->GetSize(& w
, & h
);
66 GetManagedWindow()->GetPosition(& x
, & y
);
68 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
= w
;
69 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
= h
;
70 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
= x
;
71 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
= y
;
73 return wxPropertyListView::OnClose();
76 wxWindow
*wxPropertyInfo::sm_propertyWindow
;
79 * wxDialogEditorPropertyListDialog
83 wxDialogEditorPropertyListDialog::wxDialogEditorPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title,
84 const wxPoint& pos, const wxSize& size,
85 long style, const wxString& name):
86 wxPropertyListDialog(v, parent, title, pos, size, style, name)
92 wxDialogEditorPropertyListDialog::~wxDialogEditorPropertyListDialog()
96 wxPropertyInfo::sm_propertyWindow = NULL;
100 wxDialogEditorPropertyListFrame::wxDialogEditorPropertyListFrame(wxPropertyListView
*v
, wxFrame
*parent
, const wxString
& title
,
101 const wxPoint
& pos
, const wxSize
& size
,
102 long style
, const wxString
& name
):
103 wxPropertyListFrame(v
, parent
, title
, pos
, size
, style
, name
)
109 wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
113 wxPropertyInfo::sm_propertyWindow
= NULL
;
120 // Edit the information represented by this object, whatever that
122 bool wxPropertyInfo::Edit(wxWindow
*WXUNUSED(parent
), const wxString
& title
)
124 if (sm_propertyWindow
)
126 sm_propertyWindow
->Raise();
130 int width
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
;
131 int height
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
;
132 int x
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
;
133 int y
= wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
;
135 wxPropertySheet
*propSheet
= new wxPropertySheet
;
137 wxStringList propNames
;
138 GetPropertyNames(propNames
);
140 wxNode
*node
= propNames
.First();
143 wxString
name((char *)node
->Data());
144 wxProperty
*prop
= GetProperty(name
);
147 propSheet
->AddProperty(prop
);
152 // Reset 'modified' flags for all property values
153 propSheet
->SetAllModified(FALSE
);
155 wxResourcePropertyListView
*view
= new wxResourcePropertyListView(this, NULL
,
156 wxPROP_BUTTON_OK
| wxPROP_BUTTON_CANCEL
|
157 wxPROP_BUTTON_CHECK_CROSS
|wxPROP_DYNAMIC_VALUE_FIELD
|wxPROP_PULLDOWN
|wxPROP_SHOWVALUES
);
159 wxDialogEditorPropertyListFrame
*propWin
= new wxDialogEditorPropertyListFrame(view
,
160 wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title
, wxPoint(x
, y
),
161 wxSize(width
, height
), wxDEFAULT_FRAME_STYLE
);
162 sm_propertyWindow
= propWin
;
164 propWin
->m_registry
.RegisterValidator(wxString("real"), new wxRealListValidator
);
165 propWin
->m_registry
.RegisterValidator(wxString("string"), new wxStringListValidator
);
166 propWin
->m_registry
.RegisterValidator(wxString("integer"), new wxIntegerListValidator
);
167 propWin
->m_registry
.RegisterValidator(wxString("bool"), new wxBoolListValidator
);
168 propWin
->m_registry
.RegisterValidator(wxString("filename"), new wxFilenameListValidator
);
169 propWin
->m_registry
.RegisterValidator(wxString("stringlist"), new wxListOfStringsListValidator
);
170 propWin
->m_registry
.RegisterValidator(wxString("window_id"), new wxResourceSymbolValidator
);
172 propWin
->m_propInfo
= this;
173 propWin
->m_propSheet
= propSheet
;
175 // view->m_propertyWindow = propWin;
176 view
->AddRegistry(&(propWin
->m_registry
));
178 propWin
->Initialize();
179 view
->ShowView(propSheet
, propWin
->GetPropertyPanel());
183 // Otherwise doesn't show itself
185 wxNoOptimize noOptimize
;
186 propWin
->SetSize(-1, -1, width
, height
);
193 * wxWindowPropertyInfo
196 wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
)
198 m_propertyWindow
= win
;
199 m_propertyResource
= res
;
202 wxWindowPropertyInfo::~wxWindowPropertyInfo(void)
206 wxProperty
*wxWindowPropertyInfo::GetFontProperty(wxString
& name
, wxFont
*font
)
211 if (name
.Contains("Points"))
212 return new wxProperty(name
, (long)font
->GetPointSize(), "integer", new wxIntegerListValidator(1, 100));
213 else if (name
.Contains("Family"))
214 return new wxProperty(name
, font
->GetFamilyString(), "string",
215 new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN",
217 else if (name
.Contains("Style"))
218 return new wxProperty(name
, font
->GetStyleString(), "string",
219 new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL
)));
220 else if (name
.Contains("Weight"))
221 return new wxProperty(name
, font
->GetWeightString(), "string",
222 new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL
)));
223 else if (name
.Contains("Underlined"))
224 return new wxProperty(name
, (bool)font
->GetUnderlined(), "bool");
229 wxFont
*wxWindowPropertyInfo::SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*font
)
232 int fontFamily
= wxMODERN
;
233 int fontStyle
= wxNORMAL
;
234 int fontWeight
= wxNORMAL
;
235 bool fontUnderlined
= FALSE
;
237 if (name
.Contains("Points"))
239 pointSize
= (int)property
->GetValue().IntegerValue();
240 if (font
&& (pointSize
== font
->GetPointSize()))
241 return NULL
; // No change
243 else if (font
) pointSize
= font
->GetPointSize();
245 if (name
.Contains("Family"))
247 wxString val
= property
->GetValue().StringValue();
248 fontFamily
= wxStringToFontFamily(val
);
250 if (font
&& (fontFamily
== font
->GetFamily()))
251 return NULL
; // No change
253 else if (font
) fontFamily
= font
->GetFamily();
255 if (name
.Contains("Style"))
257 wxString val
= property
->GetValue().StringValue();
258 fontStyle
= wxStringToFontStyle(val
);
260 if (font
&& (fontStyle
== font
->GetStyle()))
261 return NULL
; // No change
263 else if (font
) fontStyle
= font
->GetStyle();
264 if (name
.Contains("Weight"))
266 wxString val
= property
->GetValue().StringValue();
267 fontWeight
= wxStringToFontWeight(val
);
269 if (font
&& (fontWeight
== font
->GetWeight()))
270 return NULL
; // No change
272 else if (font
) fontWeight
= font
->GetWeight();
274 if (name
.Contains("Underlined"))
276 fontUnderlined
= property
->GetValue().BoolValue();
278 if (font
&& (fontUnderlined
== font
->GetUnderlined()))
279 return NULL
; // No change
281 else if (font
) fontUnderlined
= font
->GetUnderlined();
283 wxFont
*newFont
= wxTheFontList
->FindOrCreateFont(pointSize
, fontFamily
, fontStyle
, fontWeight
, fontUnderlined
);
292 wxProperty
*wxWindowPropertyInfo::GetProperty(wxString
& name
)
294 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
296 wxFont
*font
= & m_propertyWindow
->GetFont();
297 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
298 name
== "fontUnderlined")
299 return GetFontProperty(name
, font
);
300 else if (name
== "name")
301 return new wxProperty("name", m_propertyWindow
->GetName(), "string");
302 else if (name
== "title")
303 return new wxProperty("title", m_propertyWindow
->GetTitle(), "string");
304 else if (name
== "x")
306 return new wxProperty("x", (long)resource
->GetX(), "integer");
308 else if (name
== "y")
310 return new wxProperty("y", (long)resource
->GetY(), "integer");
312 else if (name
== "width")
314 return new wxProperty("width", (long)resource
->GetWidth(), "integer");
316 else if (name
== "height")
318 return new wxProperty("height", (long)resource
->GetHeight(), "integer");
320 else if (name
== "id")
322 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
325 int id
= resource
->GetId();
327 idStr
.Printf("%d", id
);
328 wxString symbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id
);
331 // symbolName is now e.g. "ID_PANEL21=105"
332 return new wxProperty("id", symbolName
, "window_id");
337 else if (name
== "border")
340 if (m_propertyWindow
->GetWindowStyleFlag() & wxSIMPLE_BORDER
)
341 border
= "wxSIMPLE_BORDER";
342 else if (m_propertyWindow
->GetWindowStyleFlag() & wxRAISED_BORDER
)
343 border
= "wxRAISED_BORDER";
344 else if (m_propertyWindow
->GetWindowStyleFlag() & wxSUNKEN_BORDER
)
345 border
= "wxSUNKEN_BORDER";
346 else if (m_propertyWindow
->GetWindowStyleFlag() & wxDOUBLE_BORDER
)
347 border
= "wxDOUBLE_BORDER";
348 else if (m_propertyWindow
->GetWindowStyleFlag() & wxSTATIC_BORDER
)
349 border
= "wxSTATIC_BORDER";
351 border
= "wxNO_BORDER";
353 return new wxProperty("border", border
, "string",
354 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
355 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL
)));
361 bool wxWindowPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
363 wxFont
*font
= & m_propertyWindow
->GetFont();
364 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
366 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
368 m_propertyWindow
->SetFont(* newFont
);
371 else if (name
== "name")
373 // Remove old name from resource table, if it's there.
374 wxItemResource
*oldResource
= (wxItemResource
*)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow
->GetName());
377 // It's a top-level resource
378 m_propertyWindow
->SetName(property
->GetValue().StringValue());
379 oldResource
->SetName(property
->GetValue().StringValue());
380 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow
->GetName(), oldResource
);
384 // It's a child of something; just set the name of the resource and the window.
385 m_propertyWindow
->SetName(property
->GetValue().StringValue());
386 m_propertyResource
->SetName(property
->GetValue().StringValue());
388 // Refresh the resource manager list, because the name changed.
389 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
392 else if (name
== "title")
394 m_propertyWindow
->SetTitle(property
->GetValue().StringValue());
397 else if (name
== "x")
399 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
401 m_propertyWindow
->GetPosition(&x
, &y
);
402 int newX
= (int)property
->GetValue().IntegerValue();
405 // We need to convert to pixels if this is not a dialog or panel, but
406 // the parent resource specifies dialog units.
407 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
409 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
410 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
412 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(newX
, y
));
416 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
418 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
419 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
421 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(newX
, y
));
428 m_propertyWindow
->Move(pixelX
, y
);
429 resource
->SetSize(newX
, resource
->GetY(), resource
->GetWidth(), resource
->GetHeight());
433 else if (name
== "y")
435 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
437 m_propertyWindow
->GetPosition(&x
, &y
);
438 int newY
= (int)property
->GetValue().IntegerValue();
441 // We need to convert to pixels if this is not a dialog or panel, but
442 // the parent resource specifies dialog units.
443 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
445 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
446 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
448 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(x
, newY
));
452 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
454 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
455 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
457 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(x
, newY
));
464 m_propertyWindow
->Move(x
, pixelY
);
465 resource
->SetSize(resource
->GetX(), newY
, resource
->GetWidth(), resource
->GetHeight());
469 else if (name
== "width")
471 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
473 m_propertyWindow
->GetSize(&width
, &height
);
474 int newWidth
= (int)property
->GetValue().IntegerValue();
475 int pixelWidth
= newWidth
;
477 // We need to convert to pixels if this is not a dialog or panel, but
478 // the parent resource specifies dialog units.
479 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
481 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
482 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
484 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(newWidth
, height
));
488 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
490 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
491 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
493 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(newWidth
, height
));
498 if (width
!= pixelWidth
)
500 m_propertyWindow
->SetSize(pixelWidth
, height
);
501 resource
->SetSize(resource
->GetX(), resource
->GetY(), newWidth
, resource
->GetHeight());
505 else if (name
== "height")
507 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
509 m_propertyWindow
->GetSize(&width
, &height
);
510 int newHeight
= (int)property
->GetValue().IntegerValue();
511 int pixelHeight
= newHeight
;
513 // We need to convert to pixels if this is not a dialog or panel, but
514 // the parent resource specifies dialog units.
515 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
517 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
518 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
520 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(width
, newHeight
));
524 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
526 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
527 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
529 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(width
, newHeight
));
534 if (height
!= pixelHeight
)
536 m_propertyWindow
->SetSize(width
, pixelHeight
);
537 resource
->SetSize(resource
->GetX(), resource
->GetY(), resource
->GetWidth(), newHeight
);
541 else if (name
== "id")
543 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
546 wxString value
= property
->GetValue().StringValue();
548 wxString strName
= value
.Before('=');
549 wxString strId
= value
.After('=');
550 int id
= atoi(strId
);
552 wxString oldSymbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource
->GetId());
553 int oldSymbolId
= resource
->GetId();
557 // If we change the id for an existing symbol, we need to:
558 // 1) Check if there are any other resources currently using the original id.
559 // If so, will need to change their id to the new id.
560 // 2) Remove the old symbol, add the new symbol.
561 // In this check, we don't have to do this, but we need to do it in SetProperty.
563 if (strName
== oldSymbolName
&& id
!= oldSymbolId
)
565 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
567 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
568 // because ids are unique and changing one resource's id must change all identical ones.
569 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId
, id
);
571 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
572 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
575 // If we change the name but not the id, we'll just need to remove and
576 // re-add the symbol/id pair.
577 if (strName
!= oldSymbolName
&& id
== oldSymbolId
)
579 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
581 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
583 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
585 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
589 // What if we're changing both the name and the id?
590 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
591 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
593 if (strName
!= oldSymbolName
&& id
!= oldSymbolId
)
595 // Remove old symbol if it's not being used
596 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource
, oldSymbolId
) &&
597 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
))
599 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
602 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
604 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
615 else if (name
== "border")
617 long borderStyle
= wxNO_BORDER
;
618 wxString val
= property
->GetValue().StringValue();
620 if (val
== "wxSIMPLE_BORDER")
621 borderStyle
= wxSIMPLE_BORDER
;
622 else if (val
== "wxRAISED_BORDER")
623 borderStyle
= wxRAISED_BORDER
;
624 else if (val
== "wxSUNKEN_BORDER")
625 borderStyle
= wxSUNKEN_BORDER
;
626 else if (val
== "wxDOUBLE_BORDER")
627 borderStyle
= wxDOUBLE_BORDER
;
628 else if (val
== "wxSTATIC_BORDER")
629 borderStyle
= wxSTATIC_BORDER
;
631 borderStyle
= wxNO_BORDER
;
633 SetWindowStyle(m_propertyWindow
, wxSIMPLE_BORDER
, FALSE
);
634 SetWindowStyle(m_propertyWindow
, wxRAISED_BORDER
, FALSE
);
635 SetWindowStyle(m_propertyWindow
, wxSUNKEN_BORDER
, FALSE
);
636 SetWindowStyle(m_propertyWindow
, wxDOUBLE_BORDER
, FALSE
);
637 SetWindowStyle(m_propertyWindow
, wxSTATIC_BORDER
, FALSE
);
638 SetWindowStyle(m_propertyWindow
, wxNO_BORDER
, FALSE
);
640 SetWindowStyle(m_propertyWindow
, borderStyle
, TRUE
);
642 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
643 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
650 void wxWindowPropertyInfo::GetPropertyNames(wxStringList
& names
)
659 if (!m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
661 names
.Add("fontPoints");
662 names
.Add("fontFamily");
663 names
.Add("fontStyle");
664 names
.Add("fontWeight");
665 names
.Add("fontUnderlined");
669 // Fill in the wxItemResource members to mirror the current window settings
670 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource
*resource
)
672 // resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName());
674 // resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
675 wxString
str(m_propertyWindow
->GetName());
676 resource
->SetName(str
);
681 if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
682 m_propertyWindow
->GetClientSize(&w
, &h
);
684 m_propertyWindow
->GetSize(&w
, &h
);
686 m_propertyWindow
->GetPosition(&x
, &y
);
688 // We need to convert to dialog units if this is not a dialog or panel, but
689 // the parent resource specifies dialog units.
690 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
692 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
693 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
695 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxPoint(x
, y
));
697 wxSize sz
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxSize(w
, h
));
701 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
703 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
705 wxPoint pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(x
, y
));
707 wxSize sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(w
, h
));
712 resource
->SetSize(x
, y
, w
, h
);
718 // Set the window style
719 void wxWindowPropertyInfo::SetWindowStyle(wxWindow
* win
, long style
, bool set
)
724 if ((win
->GetWindowStyleFlag() & style
) == style
)
728 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() - style
);
735 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() | style
);
744 wxProperty
*wxItemPropertyInfo::GetProperty(wxString
& name
)
746 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
747 wxFont
*font
= & itemWindow
->GetFont();
749 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
750 name
== "fontUnderlined")
751 return GetFontProperty(name
, font
);
752 else if (name
== "label" && itemWindow
->GetLabel())
753 return new wxProperty("label", m_propertyWindow
->GetLabel(), "string");
755 return wxWindowPropertyInfo::GetProperty(name
);
758 bool wxItemPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
760 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
761 wxFont
*font
= & itemWindow
->GetFont();
763 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
765 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
767 itemWindow
->SetFont(* newFont
);
770 else if (name
== "label")
772 itemWindow
->SetLabel(property
->GetValue().StringValue());
776 return wxWindowPropertyInfo::SetProperty(name
, property
);
779 void wxItemPropertyInfo::GetPropertyNames(wxStringList
& names
)
781 wxWindowPropertyInfo::GetPropertyNames(names
);
783 names
.Add("fontPoints");
784 names
.Add("fontFamily");
785 names
.Add("fontStyle");
786 names
.Add("fontWeight");
787 names
.Add("fontUnderlined");
790 bool wxItemPropertyInfo::InstantiateResource(wxItemResource
*resource
)
792 wxWindowPropertyInfo::InstantiateResource(resource
);
794 wxControl
*item
= (wxControl
*)m_propertyWindow
;
795 wxString
str(item
->GetLabel());
796 resource
->SetTitle(str
);
798 if (item
->GetFont().Ok())
799 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(item
->GetFont().GetPointSize(),
800 item
->GetFont().GetFamily(), item
->GetFont().GetStyle(), item
->GetFont().GetWeight(),
801 item
->GetFont().GetUnderlined(), item
->GetFont().GetFaceName()));
809 wxProperty
*wxButtonPropertyInfo::GetProperty(wxString
& name
)
811 return wxItemPropertyInfo::GetProperty(name
);
814 bool wxButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
816 return wxItemPropertyInfo::SetProperty(name
, property
);
819 void wxButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
821 wxItemPropertyInfo::GetPropertyNames(names
);
825 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
827 return wxItemPropertyInfo::InstantiateResource(resource
);
834 wxProperty
*wxBitmapButtonPropertyInfo::GetProperty(wxString
& name
)
836 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
837 if (name
== "bitmapFilename")
839 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
840 wxString
str("none.bmp");
844 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
846 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
849 return wxButtonPropertyInfo::GetProperty(name
);
852 bool wxBitmapButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
854 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
855 if (name
== "bitmapFilename")
857 char *s
= property
->GetValue().StringValue();
858 if (s
&& wxFileExists(s
))
861 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
869 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
872 wxString
oldResource(resource
->GetValue4());
873 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
874 resource
->SetValue4(resName
);
876 if (!oldResource
.IsNull())
877 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
880 button
->SetLabel(* bitmap
);
887 return wxButtonPropertyInfo::SetProperty(name
, property
);
890 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
892 wxButtonPropertyInfo::GetPropertyNames(names
);
893 names
.Delete("label");
894 names
.Add("bitmapFilename");
897 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
899 return wxItemPropertyInfo::InstantiateResource(resource
);
906 wxProperty
*wxStaticTextPropertyInfo::GetProperty(wxString
& name
)
908 return wxItemPropertyInfo::GetProperty(name
);
911 bool wxStaticTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
913 return wxItemPropertyInfo::SetProperty(name
, property
);
916 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
918 wxItemPropertyInfo::GetPropertyNames(names
);
922 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
924 return wxItemPropertyInfo::InstantiateResource(resource
);
931 wxProperty
*wxStaticBitmapPropertyInfo::GetProperty(wxString
& name
)
933 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
934 if (name
== "bitmapFilename")
936 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
937 wxString
str("none.bmp");
941 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
943 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
946 return wxItemPropertyInfo::GetProperty(name
);
949 bool wxStaticBitmapPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
951 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
952 if (name
== "bitmapFilename")
954 char *s
= property
->GetValue().StringValue();
955 if (s
&& wxFileExists(s
))
959 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
967 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
970 wxString
oldResource(resource
->GetValue4());
971 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
972 resource
->SetValue4(resName
);
974 if (!oldResource
.IsNull())
975 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
978 message
->SetBitmap(* bitmap
);
985 return wxItemPropertyInfo::SetProperty(name
, property
);
988 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList
& names
)
990 wxItemPropertyInfo::GetPropertyNames(names
);
991 names
.Add("bitmapFilename");
994 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource
*resource
)
996 return wxItemPropertyInfo::InstantiateResource(resource
);
1003 wxProperty
*wxTextPropertyInfo::GetProperty(wxString
& name
)
1005 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1006 if (name
== "value")
1007 return new wxProperty("value", text
->GetValue(), "string");
1008 else if (name
== "password")
1010 bool isPassword
= ((text
->GetWindowStyleFlag() & wxTE_PASSWORD
) == wxTE_PASSWORD
);
1011 return new wxProperty("password", isPassword
, "bool");
1013 else if (name
== "readonly")
1015 bool isReadOnly
= ((text
->GetWindowStyleFlag() & wxTE_READONLY
) == wxTE_READONLY
);
1016 return new wxProperty("readonly", isReadOnly
, "bool");
1019 return wxItemPropertyInfo::GetProperty(name
);
1022 bool wxTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1024 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1025 if (name
== "value")
1027 text
->SetValue(property
->GetValue().StringValue());
1030 else if (name
== "password")
1032 long flag
= text
->GetWindowStyleFlag();
1033 if (property
->GetValue().BoolValue())
1035 if ((flag
& wxTE_PASSWORD
) != wxTE_PASSWORD
)
1036 flag
|= wxTE_PASSWORD
;
1040 if ((flag
& wxTE_PASSWORD
) == wxTE_PASSWORD
)
1041 flag
-= wxTE_PASSWORD
;
1043 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1044 resource
->SetStyle(flag
);
1046 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1049 else if (name
== "readonly")
1051 long flag
= text
->GetWindowStyleFlag();
1052 if (property
->GetValue().BoolValue())
1054 if ((flag
& wxTE_READONLY
) != wxTE_READONLY
)
1055 flag
|= wxTE_READONLY
;
1059 if ((flag
& wxTE_READONLY
) == wxTE_READONLY
)
1060 flag
-= wxTE_READONLY
;
1062 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1063 resource
->SetStyle(flag
);
1065 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1069 return wxItemPropertyInfo::SetProperty(name
, property
);
1072 void wxTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
1074 wxItemPropertyInfo::GetPropertyNames(names
);
1076 names
.Add("readonly");
1077 names
.Add("password");
1080 bool wxTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1082 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1083 wxString
str(text
->GetValue());
1084 resource
->SetValue4(str
);
1086 return wxItemPropertyInfo::InstantiateResource(resource
);
1093 wxProperty
*wxListBoxPropertyInfo::GetProperty(wxString
& name
)
1095 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1096 if (name
== "values")
1098 wxStringList
*stringList
= new wxStringList
;
1100 for (i
= 0; i
< listBox
->Number(); i
++)
1101 stringList
->Add(listBox
->GetString(i
));
1103 return new wxProperty(name
, stringList
, "stringlist");
1105 else if (name
== "multiple")
1107 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1111 char *mult
= "wxLB_SINGLE";
1113 if ((listBox
->GetWindowStyleFlag() & wxLB_MULTIPLE
) != 0)
1114 mult
= "wxLB_MULTIPLE";
1115 else if ((listBox
->GetWindowStyleFlag() & wxLB_EXTENDED
) != 0)
1116 mult
= "wxLB_EXTENDED";
1118 mult
= "wxLB_SINGLE";
1120 return new wxProperty("multiple", mult
, "string",
1121 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1125 return wxItemPropertyInfo::GetProperty(name
);
1128 bool wxListBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1130 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1131 if (name
== "values")
1134 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1137 char *s
= expr
->StringValue();
1140 expr
= expr
->GetNext();
1144 else if (name
== "multiple")
1146 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, FALSE
);
1147 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, FALSE
);
1148 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, FALSE
);
1150 wxString
str(property
->GetValue().StringValue());
1151 if (str
== "wxLB_MULTIPLE")
1152 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, TRUE
);
1153 else if (str
== "wxLB_EXTENDED")
1154 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, TRUE
);
1156 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, TRUE
);
1158 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1160 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1161 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox
, this);
1165 return wxItemPropertyInfo::SetProperty(name
, property
);
1168 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1170 wxItemPropertyInfo::GetPropertyNames(names
);
1171 names
.Add("values");
1172 names
.Add("multiple");
1175 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1177 wxListBox
*lbox
= (wxListBox
*)m_propertyWindow
;
1178 // This will be set for the wxItemResource on reading or in SetProperty
1179 // resource->SetValue1(lbox->GetSelectionMode());
1181 if (lbox
->Number() == 0)
1182 resource
->SetStringValues(NULL
);
1187 for (i
= 0; i
< lbox
->Number(); i
++)
1188 slist
.Add(lbox
->GetString(i
));
1190 resource
->SetStringValues(slist
);
1192 return wxItemPropertyInfo::InstantiateResource(resource
);
1199 wxProperty
*wxChoicePropertyInfo::GetProperty(wxString
& name
)
1201 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1202 if (name
== "values")
1204 wxStringList
* stringList
= new wxStringList
;
1206 for (i
= 0; i
< choice
->Number(); i
++)
1207 stringList
->Add(choice
->GetString(i
));
1209 return new wxProperty(name
, stringList
, "stringlist");
1212 return wxItemPropertyInfo::GetProperty(name
);
1215 bool wxChoicePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1217 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1218 if (name
== "values")
1221 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1224 char *s
= expr
->StringValue();
1227 expr
= expr
->GetNext();
1229 if (choice
->Number() > 0)
1230 choice
->SetSelection(0);
1234 return wxItemPropertyInfo::SetProperty(name
, property
);
1237 void wxChoicePropertyInfo::GetPropertyNames(wxStringList
& names
)
1239 wxItemPropertyInfo::GetPropertyNames(names
);
1240 names
.Add("values");
1243 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1245 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1247 if (choice
->Number() == 0)
1248 resource
->SetStringValues(NULL
);
1253 for (i
= 0; i
< choice
->Number(); i
++)
1254 slist
.Add(choice
->GetString(i
));
1256 resource
->SetStringValues(slist
);
1258 return wxItemPropertyInfo::InstantiateResource(resource
);
1265 wxProperty
*wxComboBoxPropertyInfo::GetProperty(wxString
& name
)
1267 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1268 if (name
== "values")
1270 wxStringList
*stringList
= new wxStringList
;
1272 for (i
= 0; i
< choice
->Number(); i
++)
1273 stringList
->Add(choice
->GetString(i
));
1275 return new wxProperty(name
, stringList
, "stringlist");
1277 else if (name
== "sort")
1279 bool sort
= ((m_propertyWindow
->GetWindowStyleFlag() & wxCB_SORT
) == wxCB_SORT
);
1280 return new wxProperty(name
, sort
, "bool");
1282 else if (name
== "style")
1284 wxString
styleStr("dropdown");
1285 if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_SIMPLE
)
1286 styleStr
= "simple";
1287 else if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_READONLY
)
1288 styleStr
= "readonly";
1290 styleStr
= "dropdown";
1292 return new wxProperty(name
, styleStr
, "string",
1293 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1297 return wxItemPropertyInfo::GetProperty(name
);
1300 bool wxComboBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1302 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1303 if (name
== "values")
1306 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1309 char *s
= expr
->StringValue();
1312 expr
= expr
->GetNext();
1314 if (choice
->Number() > 0)
1315 choice
->SetSelection(0);
1318 else if (name
== "sort")
1320 SetWindowStyle(m_propertyWindow
, wxCB_SORT
, property
->GetValue().BoolValue());
1322 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1323 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1325 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1328 else if (name
== "style")
1330 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, FALSE
);
1331 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, FALSE
);
1332 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, FALSE
);
1334 wxString
styleStr(property
->GetValue().StringValue());
1335 if (styleStr
== "simple")
1336 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, TRUE
);
1337 else if (styleStr
== "dropdown")
1338 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, TRUE
);
1339 else if (styleStr
== "readonly")
1340 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, TRUE
);
1343 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1344 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1346 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1351 return wxItemPropertyInfo::SetProperty(name
, property
);
1354 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1356 wxItemPropertyInfo::GetPropertyNames(names
);
1357 names
.Add("values");
1362 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1364 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1366 if (choice
->Number() == 0)
1367 resource
->SetStringValues(NULL
);
1372 for (i
= 0; i
< choice
->Number(); i
++)
1373 slist
.Add(choice
->GetString(i
));
1375 resource
->SetStringValues(slist
);
1377 return wxItemPropertyInfo::InstantiateResource(resource
);
1384 wxProperty
*wxRadioBoxPropertyInfo::GetProperty(wxString
& name
)
1386 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1387 if (name
== "numberRowsOrCols")
1389 return new wxProperty("numberRowsOrCols", (long)radioBox
->GetNumberOfRowsOrCols(), "integer");
1391 if (name
== "orientation")
1394 if (m_propertyWindow
->GetWindowStyleFlag() & wxRA_SPECIFY_COLS
)
1395 orient
= "wxRA_SPECIFY_COLS";
1397 orient
= "wxRA_SPECIFY_ROWS";
1399 return new wxProperty("orientation", orient
, "string",
1400 new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS",
1403 else if (name
== "values")
1405 wxStringList
*stringList
= new wxStringList
;
1407 for (i
= 0; i
< radioBox
->Number(); i
++)
1408 stringList
->Add(radioBox
->GetString(i
));
1410 return new wxProperty(name
, stringList
, "stringlist");
1412 return wxItemPropertyInfo::GetProperty(name
);
1415 bool wxRadioBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1417 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1418 if (name
== "numberRowsOrCols")
1420 radioBox
->SetNumberOfRowsOrCols((int)property
->GetValue().IntegerValue());
1421 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1424 else if (name
== "orientation")
1426 long windowStyle
= radioBox
->GetWindowStyleFlag();
1427 wxString
val(property
->GetValue().StringValue());
1428 if (val
== "wxRA_SPECIFY_COLS")
1430 if (windowStyle
& wxRA_SPECIFY_ROWS
)
1431 windowStyle
-= wxRA_SPECIFY_ROWS
;
1432 windowStyle
|= wxRA_SPECIFY_COLS
;
1436 if (windowStyle
& wxRA_SPECIFY_COLS
)
1437 windowStyle
-= wxRA_SPECIFY_COLS
;
1438 windowStyle
|= wxRA_SPECIFY_ROWS
;
1440 radioBox
->SetWindowStyleFlag(windowStyle
);
1441 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox
);
1442 resource
->SetStyle(windowStyle
);
1444 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1447 else if (name
== "values")
1449 // Set property into *resource*, not wxRadioBox, and then recreate
1450 // the wxRadioBox. This is because we can't dynamically set the strings
1452 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1456 wxStringList stringList
;
1457 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1460 char *s
= expr
->StringValue();
1463 expr
= expr
->GetNext();
1465 resource
->SetStringValues(stringList
);
1466 wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1469 return wxItemPropertyInfo::SetProperty(name
, property
);
1472 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1474 wxItemPropertyInfo::GetPropertyNames(names
);
1476 names
.Add("values");
1477 names
.Add("orientation");
1478 names
.Add("numberRowsOrCols");
1481 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1483 wxRadioBox
*rbox
= (wxRadioBox
*)m_propertyWindow
;
1484 // Take strings from resource instead
1487 if (rbox->Number() == 0)
1488 resource->SetStringValues(NULL);
1491 wxStringList *slist = new wxStringList;
1493 for (i = 0; i < rbox->Number(); i++)
1494 slist->Add(rbox->GetString(i));
1496 resource->SetStringValues(slist);
1499 resource
->SetValue1(rbox
->GetNumberOfRowsOrCols());
1500 return wxItemPropertyInfo::InstantiateResource(resource
);
1507 wxProperty
*wxGroupBoxPropertyInfo::GetProperty(wxString
& name
)
1509 return wxItemPropertyInfo::GetProperty(name
);
1512 bool wxGroupBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1514 return wxItemPropertyInfo::SetProperty(name
, property
);
1517 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1519 wxItemPropertyInfo::GetPropertyNames(names
);
1523 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1525 return wxItemPropertyInfo::InstantiateResource(resource
);
1532 wxProperty
*wxCheckBoxPropertyInfo::GetProperty(wxString
& name
)
1534 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1535 if (name
== "value")
1536 return new wxProperty("value", checkBox
->GetValue(), "bool");
1538 return wxItemPropertyInfo::GetProperty(name
);
1541 bool wxCheckBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1543 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1544 if (name
== "value")
1546 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1550 return wxItemPropertyInfo::SetProperty(name
, property
);
1553 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1555 wxItemPropertyInfo::GetPropertyNames(names
);
1560 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1562 wxCheckBox
*cbox
= (wxCheckBox
*)m_propertyWindow
;
1563 resource
->SetValue1(cbox
->GetValue());
1564 return wxItemPropertyInfo::InstantiateResource(resource
);
1571 wxProperty
*wxRadioButtonPropertyInfo::GetProperty(wxString
& name
)
1573 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1574 if (name
== "value")
1575 return new wxProperty("value", checkBox
->GetValue(), "bool");
1577 return wxItemPropertyInfo::GetProperty(name
);
1580 bool wxRadioButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1582 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1583 if (name
== "value")
1585 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1589 return wxItemPropertyInfo::SetProperty(name
, property
);
1592 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
1594 wxItemPropertyInfo::GetPropertyNames(names
);
1599 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1601 wxRadioButton
*cbox
= (wxRadioButton
*)m_propertyWindow
;
1602 resource
->SetValue1(cbox
->GetValue());
1603 return wxItemPropertyInfo::InstantiateResource(resource
);
1610 wxProperty
*wxSliderPropertyInfo::GetProperty(wxString
& name
)
1612 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1613 if (name
== "value")
1614 return new wxProperty("value", (long)slider
->GetValue(), "integer");
1615 else if (name
== "orientation")
1618 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1619 pos
= "wxHORIZONTAL";
1623 return new wxProperty("orientation", pos
, "string",
1624 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1627 else if (name
== "minValue")
1628 return new wxProperty("minValue", (long)slider
->GetMin(), "integer");
1629 else if (name
== "maxValue")
1630 return new wxProperty("maxValue", (long)slider
->GetMax(), "integer");
1632 return wxItemPropertyInfo::GetProperty(name
);
1635 bool wxSliderPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1637 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1638 if (name
== "value")
1640 slider
->SetValue((int)property
->GetValue().IntegerValue());
1643 else if (name
== "orientation")
1645 long windowStyle
= slider
->GetWindowStyleFlag();
1646 long oldWindowStyle
= windowStyle
;
1647 wxString
val(property
->GetValue().StringValue());
1648 if (val
== "wxHORIZONTAL")
1650 if (windowStyle
& wxVERTICAL
)
1651 windowStyle
-= wxVERTICAL
;
1652 windowStyle
|= wxHORIZONTAL
;
1656 if (windowStyle
& wxHORIZONTAL
)
1657 windowStyle
-= wxHORIZONTAL
;
1658 windowStyle
|= wxVERTICAL
;
1661 if (oldWindowStyle
== windowStyle
)
1664 slider
->SetWindowStyleFlag(windowStyle
);
1666 // If the window style has changed, we swap the width and height parameters.
1668 slider
->GetSize(&w
, &h
);
1670 slider
= (wxSlider
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider
, this);
1671 slider
->SetSize(-1, -1, h
, w
);
1675 else if (name
== "minValue")
1677 slider
->SetRange((int)property
->GetValue().IntegerValue(), slider
->GetMax());
1680 else if (name
== "maxValue")
1682 slider
->SetRange(slider
->GetMin(), (int)property
->GetValue().IntegerValue());
1686 return wxItemPropertyInfo::SetProperty(name
, property
);
1689 void wxSliderPropertyInfo::GetPropertyNames(wxStringList
& names
)
1691 wxItemPropertyInfo::GetPropertyNames(names
);
1693 names
.Add("orientation");
1694 names
.Add("minValue");
1695 names
.Add("maxValue");
1698 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1700 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1701 resource
->SetValue1(slider
->GetValue());
1702 resource
->SetValue2(slider
->GetMin());
1703 resource
->SetValue3(slider
->GetMax());
1704 return wxItemPropertyInfo::InstantiateResource(resource
);
1711 wxProperty
*wxGaugePropertyInfo::GetProperty(wxString
& name
)
1713 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1714 if (name
== "value")
1715 return new wxProperty("value", (long)gauge
->GetValue(), "integer");
1716 else if (name
== "maxValue")
1717 return new wxProperty("maxValue", (long)gauge
->GetRange(), "integer");
1719 return wxItemPropertyInfo::GetProperty(name
);
1722 bool wxGaugePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1724 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1725 if (name
== "value")
1727 gauge
->SetValue((int)property
->GetValue().IntegerValue());
1730 else if (name
== "maxValue")
1732 gauge
->SetRange((int)property
->GetValue().IntegerValue());
1736 return wxItemPropertyInfo::SetProperty(name
, property
);
1739 void wxGaugePropertyInfo::GetPropertyNames(wxStringList
& names
)
1741 wxItemPropertyInfo::GetPropertyNames(names
);
1743 names
.Add("maxValue");
1746 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1748 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1749 resource
->SetValue1(gauge
->GetValue());
1750 resource
->SetValue2(gauge
->GetRange());
1751 return wxItemPropertyInfo::InstantiateResource(resource
);
1758 wxProperty
*wxScrollBarPropertyInfo::GetProperty(wxString
& name
)
1760 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1761 if (name
== "thumbPosition")
1762 return new wxProperty("value", (long)scrollBar
->GetThumbPosition(), "integer");
1763 else if (name
== "orientation")
1766 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1767 pos
= "wxHORIZONTAL";
1771 return new wxProperty("orientation", pos
, "string",
1772 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1775 else if (name
== "pageSize")
1777 int pageLength
= scrollBar
->GetPageSize();
1779 return new wxProperty("pageSize", (long)pageLength
, "integer");
1781 else if (name
== "thumbSize")
1783 int thumbSize
= scrollBar
->GetThumbSize();
1785 return new wxProperty("thumbSize", (long)thumbSize
, "integer");
1787 else if (name
== "range")
1789 int range
= scrollBar
->GetRange();
1790 return new wxProperty("range", (long)range
, "integer");
1793 return wxItemPropertyInfo::GetProperty(name
);
1796 bool wxScrollBarPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1798 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1799 if (name
== "thumbPosition")
1801 scrollBar
->SetThumbPosition((int)property
->GetValue().IntegerValue());
1804 else if (name
== "orientation")
1806 long windowStyle
= scrollBar
->GetWindowStyleFlag();
1807 long oldWindowStyle
= windowStyle
;
1808 wxString
val(property
->GetValue().StringValue());
1809 if (val
== "wxHORIZONTAL")
1811 if (windowStyle
& wxVERTICAL
)
1812 windowStyle
-= wxVERTICAL
;
1813 windowStyle
|= wxHORIZONTAL
;
1817 if (windowStyle
& wxHORIZONTAL
)
1818 windowStyle
-= wxHORIZONTAL
;
1819 windowStyle
|= wxVERTICAL
;
1822 if (oldWindowStyle
== windowStyle
)
1825 scrollBar
->SetWindowStyleFlag(windowStyle
);
1827 // If the window style has changed, we swap the width and height parameters.
1829 // scrollBar->GetSize(&w, &h);
1830 wxItemResource
*item
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar
);
1832 item
->SetSize(item
->GetX(), item
->GetY(), item
->GetHeight(), item
->GetWidth());
1833 item
->SetStyle(windowStyle
);
1836 scrollBar
= (wxScrollBar
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar
, this);
1840 else if (name
== "pageSize")
1842 int pos
= scrollBar
->GetThumbPosition();
1843 int range
= scrollBar
->GetRange();
1844 int thumbSize
= scrollBar
->GetThumbSize();
1845 scrollBar
->SetScrollbar(pos
, thumbSize
, range
, (int)property
->GetValue().IntegerValue());
1848 else if (name
== "thumbSize")
1850 int pos
= scrollBar
->GetThumbPosition();
1851 int range
= scrollBar
->GetRange();
1852 int pageSize
= scrollBar
->GetPageSize();
1853 scrollBar
->SetScrollbar(pos
, (int)property
->GetValue().IntegerValue(), range
, pageSize
);
1856 else if (name
== "range")
1858 int pos
= scrollBar
->GetThumbPosition();
1859 int thumbSize
= scrollBar
->GetThumbSize();
1860 int pageSize
= scrollBar
->GetPageSize();
1861 scrollBar
->SetScrollbar(pos
, thumbSize
, (int)property
->GetValue().IntegerValue(), pageSize
);
1865 return wxItemPropertyInfo::SetProperty(name
, property
);
1868 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList
& names
)
1870 wxItemPropertyInfo::GetPropertyNames(names
);
1871 names
.Add("orientation");
1872 names
.Add("thumbPosition");
1873 names
.Add("thumbSize");
1874 names
.Add("pageSize");
1877 // Remove some properties we don't inherit
1878 names
.Delete("fontPoints");
1879 names
.Delete("fontFamily");
1880 names
.Delete("fontStyle");
1881 names
.Delete("fontWeight");
1882 names
.Delete("fontUnderlined");
1885 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1887 wxScrollBar
*sbar
= (wxScrollBar
*)m_propertyWindow
;
1889 int thumbPosition
= sbar
->GetThumbPosition();
1890 int thumbSize
= sbar
->GetThumbSize();
1891 int pageSize
= sbar
->GetPageSize();
1892 int range
= sbar
->GetRange();
1894 resource
->SetValue1(thumbPosition
);
1895 resource
->SetValue2(thumbSize
);
1896 resource
->SetValue3(range
);
1897 resource
->SetValue5(pageSize
);
1899 return wxItemPropertyInfo::InstantiateResource(resource
);
1906 wxProperty
*wxPanelPropertyInfo::GetProperty(wxString
& name
)
1908 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
1911 wxFont *labelFont = panelWindow->GetLabelFont();
1912 wxFont *buttonFont = panelWindow->GetButtonFont();
1914 if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" ||
1915 name == "labelFontUnderlined")
1916 return GetFontProperty(name, labelFont);
1917 else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" ||
1918 name == "buttonFontUnderlined")
1919 return GetFontProperty(name, buttonFont);
1925 if (panelWindow
->GetWindowStyleFlag() & wxNO_3D
)
1928 userColours
= FALSE
;
1930 return new wxProperty(name
, (bool)userColours
, "bool");
1932 else if (name
== "backgroundColour")
1934 wxColour
col(panelWindow
->GetBackgroundColour());
1936 wxDecToHex(col
.Red(), buf
);
1937 wxDecToHex(col
.Green(), buf
+2);
1938 wxDecToHex(col
.Blue(), buf
+4);
1940 return new wxProperty(name
, buf
, "string", new wxColourListValidator
);
1942 else if (name
== "title")
1944 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1946 return new wxProperty(name
, resource
->GetTitle(), "string");
1948 return new wxProperty(name
, "Could not get title", "string");
1950 else if (name
== "caption")
1952 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxCAPTION
) == wxCAPTION
),
1955 else if (name
== "systemMenu")
1957 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxSYSTEM_MENU
) == wxSYSTEM_MENU
),
1960 else if (name
== "thickFrame")
1962 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxTHICK_FRAME
) == wxTHICK_FRAME
),
1965 else if (name
== "useSystemDefaults")
1967 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1968 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) == wxRESOURCE_USE_DEFAULTS
),
1971 else if (name
== "useDialogUnits")
1973 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
1974 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == wxRESOURCE_DIALOG_UNITS
),
1978 return wxWindowPropertyInfo::GetProperty(name
);
1981 bool wxPanelPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1983 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
1985 wxFont *labelFont = panelWindow->GetLabelFont();
1986 wxFont *buttonFont = panelWindow->GetButtonFont();
1988 if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" ))
1990 wxFont *newFont = SetFontProperty(name, property, labelFont);
1992 panelWindow->SetLabelFont(* newFont);
1995 else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" ))
1997 wxFont *newFont = SetFontProperty(name, property, buttonFont);
1999 panelWindow->SetButtonFont(* newFont);
2006 bool userColours
= property
->GetValue().BoolValue();
2010 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) != wxNO_3D
)
2011 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() | wxNO_3D
);
2015 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) == wxNO_3D
)
2016 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() - wxNO_3D
);
2018 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2019 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2021 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2024 else if (name
== "backgroundColour")
2026 char *hex
= property
->GetValue().StringValue();
2027 int r
= wxHexToDec(hex
);
2028 int g
= wxHexToDec(hex
+2);
2029 int b
= wxHexToDec(hex
+4);
2031 wxColour
col(r
,g
,b
);
2032 panelWindow
->SetBackgroundColour(col
);
2033 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2036 else if (name
== "title")
2038 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2041 resource
->SetTitle(property
->GetValue().StringValue());
2047 else if (name
== "caption")
2049 SetWindowStyle(panelWindow
, wxCAPTION
, property
->GetValue().BoolValue());
2051 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2052 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2055 else if (name
== "thickFrame")
2057 SetWindowStyle(panelWindow
, wxTHICK_FRAME
, property
->GetValue().BoolValue());
2059 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2060 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2063 else if (name
== "systemMenu")
2065 SetWindowStyle(panelWindow
, wxSYSTEM_MENU
, property
->GetValue().BoolValue());
2067 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2068 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2071 else if (name
== "useSystemDefaults")
2073 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2074 bool useDefaults
= property
->GetValue().BoolValue();
2075 long style
= resource
->GetResourceStyle();
2078 if ((style
& wxRESOURCE_USE_DEFAULTS
) == 0)
2079 style
|= wxRESOURCE_USE_DEFAULTS
;
2083 if ((style
& wxRESOURCE_USE_DEFAULTS
) != 0)
2084 style
-= wxRESOURCE_USE_DEFAULTS
;
2086 resource
->SetResourceStyle(style
);
2087 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2090 else if (name
== "useDialogUnits")
2092 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2093 bool useDialogUnits
= property
->GetValue().BoolValue();
2094 long style
= resource
->GetResourceStyle();
2097 if ((style
& wxRESOURCE_DIALOG_UNITS
) == 0)
2099 style
|= wxRESOURCE_DIALOG_UNITS
;
2100 ConvertDialogUnits(TRUE
); // Convert all resources
2105 if ((style
& wxRESOURCE_DIALOG_UNITS
) != 0)
2107 style
-= wxRESOURCE_DIALOG_UNITS
;
2108 ConvertDialogUnits(FALSE
); // Convert all resources
2111 resource
->SetResourceStyle(style
);
2112 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2113 // TODO: need to regenerate the width and height properties else they'll be inconsistent.
2117 return wxWindowPropertyInfo::SetProperty(name
, property
);
2120 void wxPanelPropertyInfo::GetPropertyNames(wxStringList
& names
)
2122 wxWindowPropertyInfo::GetPropertyNames(names
);
2126 names
.Add("backgroundColour");
2127 names
.Add("caption");
2128 names
.Add("systemMenu");
2129 names
.Add("thickFrame");
2130 names
.Add("useSystemDefaults");
2131 names
.Add("useDialogUnits");
2134 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2136 wxPanel
*panel
= (wxPanel
*)m_propertyWindow
;
2137 if (panel
->GetFont().Ok())
2138 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(panel
->GetFont().GetPointSize(),
2139 panel
->GetFont().GetFamily(), panel
->GetFont().GetStyle(), panel
->GetFont().GetWeight(),
2140 panel
->GetFont().GetUnderlined(), panel
->GetFont().GetFaceName()));
2142 resource
->SetBackgroundColour(wxColour(panel
->GetBackgroundColour()));
2144 return wxWindowPropertyInfo::InstantiateResource(resource
);
2147 // Convert this dialog, and its children, to or from dialog units
2148 void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits
)
2150 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
2156 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2157 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2161 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2162 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2164 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2166 wxNode
* node
= m_propertyWindow
->GetChildren().First();
2169 wxWindow
* child
= (wxWindow
*) node
->Data();
2170 if (child
->IsKindOf(CLASSINFO(wxControl
)))
2172 resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(child
);
2175 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2176 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2180 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2181 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2183 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2185 node
= node
->Next();
2194 wxProperty
*wxDialogPropertyInfo::GetProperty(wxString
& name
)
2196 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2197 if (name
== "modal")
2199 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2203 bool modal
= (resource
->GetValue1() != 0);
2204 return new wxProperty(name
, modal
, "bool");
2207 return wxPanelPropertyInfo::GetProperty(name
);
2210 bool wxDialogPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
2212 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2214 if (name
== "modal")
2216 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2220 resource
->SetValue1(property
->GetValue().BoolValue());
2224 return wxPanelPropertyInfo::SetProperty(name
, property
);
2227 void wxDialogPropertyInfo::GetPropertyNames(wxStringList
& names
)
2229 wxPanelPropertyInfo::GetPropertyNames(names
);
2234 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2236 wxDialog
*dialog
= (wxDialog
*)m_propertyWindow
;
2237 wxString
str(dialog
->GetTitle());
2238 resource
->SetTitle(str
);
2240 return wxPanelPropertyInfo::InstantiateResource(resource
);
2248 int wxStringToFontWeight(wxString
& val
)
2250 if (val
== "wxBOLD") return wxBOLD
;
2251 else if (val
== "wxLIGHT") return wxLIGHT
;
2252 else return wxNORMAL
;
2255 int wxStringToFontStyle(wxString
& val
)
2257 if (val
== "wxITALIC") return wxITALIC
;
2258 else if (val
== "wxSLANT") return wxSLANT
;
2259 else return wxNORMAL
;
2262 int wxStringToFontFamily(wxString
& val
)
2264 if (val
== "wxDECORATIVE") return wxDECORATIVE
;
2265 else if (val
== "wxROMAN") return wxROMAN
;
2266 else if (val
== "wxSCRIPT") return wxSCRIPT
;
2267 else if (val
== "wxMODERN") return wxMODERN
;
2268 else if (val
== "wxTELETYPE") return wxTELETYPE
;
2269 else return wxSWISS
;
2273 /// Resource symbol validator
2275 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator
, wxPropertyListValidator
)
2277 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags
):
2278 wxPropertyListValidator(flags
)
2282 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2286 bool wxResourceSymbolValidator::OnCheckValue(wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
))
2291 // Called when TICK is pressed or focus is lost or view wants to update
2292 // the property list.
2293 // Does the transferance from the property editing area to the property itself
2294 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2296 if (!view
->GetValueText())
2298 wxString
value(view
->GetValueText()->GetValue());
2299 property
->GetValue() = value
;
2303 // Called when TICK is pressed or focus is lost or view wants to update
2304 // the property list.
2305 // Does the transferance from the property editing area to the property itself
2306 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2308 if (!view
->GetValueText())
2310 wxString
str(property
->GetValue().GetStringRepresentation());
2311 view
->GetValueText()->SetValue(str
);
2315 // Called when the property is double clicked. Extra functionality can be provided,
2316 // cycling through possible values.
2317 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2319 if (!view
->GetValueText())
2321 OnEdit(property
, view
, parentWindow
);
2325 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty
*WXUNUSED(property
), wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2327 if (view
->GetConfirmButton())
2328 view
->GetConfirmButton()->Enable(TRUE
);
2329 if (view
->GetCancelButton())
2330 view
->GetCancelButton()->Enable(TRUE
);
2331 if (view
->GetEditButton())
2332 view
->GetEditButton()->Enable(TRUE
);
2333 if (view
->GetValueText())
2334 view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
);
2338 void wxResourceSymbolValidator::OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2340 if (!view
->GetValueText())
2343 wxResourceSymbolDialog
* dialog
= new wxResourceSymbolDialog(parentWindow
, -1, "Edit Symbol");
2345 // Split name/id pair e.g. "IDC_TEXT=123"
2346 wxString
value(property
->GetValue().StringValue());
2348 wxString strName
= value
.Before('=');
2349 wxString strId
= value
.After('=');
2351 dialog
->SetSymbol(strName
);
2352 dialog
->SetId(atoi(strId
));
2356 if (dialog
->ShowModal() == wxID_OK
)
2358 wxString
symbolName(dialog
->GetSymbol());
2359 long id
= dialog
->GetId();
2363 str
.Printf("%d", id
);
2364 property
->GetValue() = symbolName
+ wxString("=") + str
;
2366 view
->DisplayProperty(property
);
2367 view
->UpdatePropertyDisplayInList(property
);
2368 view
->OnPropertyChanged(property
);
2372 BEGIN_EVENT_TABLE(wxResourceSymbolDialog
, wxDialog
)
2373 EVT_BUTTON(wxID_OK
, wxResourceSymbolDialog::OnOK
)
2374 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnComboBoxSelect
)
2375 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnSymbolNameUpdate
)
2378 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
2379 const wxSize
& size
, long style
):
2380 wxDialog(parent
, id
, title
, pos
, size
, style
)
2385 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x
, y
));
2389 m_nameCtrl
= new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX
, "",
2390 wxPoint(x
, y
), wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
|wxCB_SORT
);
2395 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x
, y
));
2399 m_idCtrl
= new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL
, "",
2400 wxPoint(x
, y
), wxSize(200, -1));
2404 (void) new wxButton(this, wxID_OK
, "OK", wxPoint(x
, y
), wxSize(80, -1));
2407 (void) new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(x
, y
), wxSize(80, -1));
2413 void wxResourceSymbolDialog::Init()
2416 defaultId
.Printf("%ld", m_symbolId
);
2418 m_nameCtrl
->SetValue(m_symbolName
);
2419 m_idCtrl
->SetValue(defaultId
);
2421 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl
);
2424 void wxResourceSymbolDialog::OnOK(wxCommandEvent
& event
)
2428 wxDialog::OnOK(event
);
2432 bool wxResourceSymbolDialog::CheckValues()
2434 wxString
nameStr(m_nameCtrl
->GetValue());
2435 wxString
idStr(m_idCtrl
->GetValue());
2436 int id
= atoi(idStr
);
2440 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2445 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2448 if (nameStr
.Contains(" "))
2450 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2453 if (nameStr
.Contains("="))
2455 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2458 if (nameStr
.IsNumber())
2460 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2463 // TODO: other checks on the name syntax.
2465 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr
))
2467 // If we change the id for an existing symbol, we need to:
2468 // 1) Check if there are any other resources currently using the original id.
2469 // If so, will need to change their id to the new id, in SetProperty.
2470 // 2) Remove the old symbol, add the new symbol.
2471 // In this check, we don't have to do this, but we need to do it in SetProperty.
2473 if (nameStr
== GetSymbol() && id
!= GetId())
2475 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2479 // If we change the name but not the id... we'll just need to remove and
2480 // re-add the symbol/id pair, in SetProperty.
2481 if (nameStr
!= GetSymbol() && id
== GetId())
2485 // What if we're changing both the name and the id?
2486 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2487 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2489 if (nameStr
!= GetSymbol() && id
!= GetId())
2491 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr
, id
))
2493 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2494 "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2507 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent
& WXUNUSED(event
))
2509 wxString
str(m_nameCtrl
->GetStringSelection());
2510 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2512 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2514 str2
.Printf("%d", id
);
2515 m_idCtrl
->SetValue(str2
);
2516 m_idCtrl
->Enable(FALSE
);
2520 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2522 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2524 str2
.Printf("%d", id
);
2525 m_idCtrl
->SetValue(str2
);
2527 m_idCtrl
->Enable(TRUE
);
2531 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent
& WXUNUSED(event
))
2533 wxString
str(m_nameCtrl
->GetValue());
2534 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2536 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2538 str2
.Printf("%d", id
);
2539 m_idCtrl
->SetValue(str2
);
2540 m_idCtrl
->Enable(FALSE
);
2544 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2546 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2548 str2
.Printf("%d", id
);
2549 m_idCtrl
->SetValue(str2
);
2551 m_idCtrl
->Enable(TRUE
);