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 if (wxPropertyInfo::sm_propertyWindow
== this)
104 wxPropertyInfo::sm_propertyWindow
= NULL
;
111 // Edit the information represented by this object, whatever that
113 bool wxPropertyInfo::Edit(wxWindow
*WXUNUSED(parent
), const wxString
& title
)
115 if (sm_propertyWindow
)
117 wxWindowPropertyInfo
* thisProp
= (wxWindowPropertyInfo
*) this;
118 wxWindowPropertyInfo
* oldProp
= (wxWindowPropertyInfo
*) (((wxDialogEditorPropertyListFrame
*) sm_propertyWindow
)->GetInfo());
119 if (oldProp
->GetWindow() == thisProp
->GetWindow())
121 sm_propertyWindow
->Raise();
126 CloseWindow(); // Close the window so we can open a new one
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
);
192 void wxPropertyInfo::CloseWindow()
194 if (sm_propertyWindow
)
197 sm_propertyWindow
->GetSize(& w
, & h
);
198 sm_propertyWindow
->GetPosition(& x
, & y
);
200 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width
= w
;
201 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height
= h
;
202 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x
= x
;
203 wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y
= y
;
205 sm_propertyWindow
->Destroy();
206 sm_propertyWindow
= (wxDialogEditorPropertyListFrame
*) NULL
;
211 * wxWindowPropertyInfo
214 wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
)
216 m_propertyWindow
= win
;
217 m_propertyResource
= res
;
220 wxWindowPropertyInfo::~wxWindowPropertyInfo(void)
224 wxProperty
*wxWindowPropertyInfo::GetFontProperty(wxString
& name
, wxFont
*font
)
229 if (name
.Contains("Points"))
230 return new wxProperty(name
, (long)font
->GetPointSize(), "integer", new wxIntegerListValidator(1, 100));
231 else if (name
.Contains("Family"))
232 return new wxProperty(name
, font
->GetFamilyString(), "string",
233 new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN",
235 else if (name
.Contains("Style"))
236 return new wxProperty(name
, font
->GetStyleString(), "string",
237 new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL
)));
238 else if (name
.Contains("Weight"))
239 return new wxProperty(name
, font
->GetWeightString(), "string",
240 new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL
)));
241 else if (name
.Contains("Underlined"))
242 return new wxProperty(name
, (bool)font
->GetUnderlined(), "bool");
247 wxFont
*wxWindowPropertyInfo::SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*font
)
250 int fontFamily
= wxMODERN
;
251 int fontStyle
= wxNORMAL
;
252 int fontWeight
= wxNORMAL
;
253 bool fontUnderlined
= FALSE
;
255 if (name
.Contains("Points"))
257 pointSize
= (int)property
->GetValue().IntegerValue();
258 if (font
&& (pointSize
== font
->GetPointSize()))
259 return NULL
; // No change
261 else if (font
) pointSize
= font
->GetPointSize();
263 if (name
.Contains("Family"))
265 wxString val
= property
->GetValue().StringValue();
266 fontFamily
= wxStringToFontFamily(val
);
268 if (font
&& (fontFamily
== font
->GetFamily()))
269 return NULL
; // No change
271 else if (font
) fontFamily
= font
->GetFamily();
273 if (name
.Contains("Style"))
275 wxString val
= property
->GetValue().StringValue();
276 fontStyle
= wxStringToFontStyle(val
);
278 if (font
&& (fontStyle
== font
->GetStyle()))
279 return NULL
; // No change
281 else if (font
) fontStyle
= font
->GetStyle();
282 if (name
.Contains("Weight"))
284 wxString val
= property
->GetValue().StringValue();
285 fontWeight
= wxStringToFontWeight(val
);
287 if (font
&& (fontWeight
== font
->GetWeight()))
288 return NULL
; // No change
290 else if (font
) fontWeight
= font
->GetWeight();
292 if (name
.Contains("Underlined"))
294 fontUnderlined
= property
->GetValue().BoolValue();
296 if (font
&& (fontUnderlined
== font
->GetUnderlined()))
297 return NULL
; // No change
299 else if (font
) fontUnderlined
= font
->GetUnderlined();
301 wxFont
*newFont
= wxTheFontList
->FindOrCreateFont(pointSize
, fontFamily
, fontStyle
, fontWeight
, fontUnderlined
);
310 wxProperty
*wxWindowPropertyInfo::GetProperty(wxString
& name
)
312 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
314 wxFont
*font
= & m_propertyWindow
->GetFont();
315 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
316 name
== "fontUnderlined")
317 return GetFontProperty(name
, font
);
318 else if (name
== "name")
319 return new wxProperty("name", m_propertyWindow
->GetName(), "string");
320 else if (name
== "title")
321 return new wxProperty("title", m_propertyWindow
->GetTitle(), "string");
322 else if (name
== "x")
324 return new wxProperty("x", (long)resource
->GetX(), "integer");
326 else if (name
== "y")
328 return new wxProperty("y", (long)resource
->GetY(), "integer");
330 else if (name
== "width")
332 return new wxProperty("width", (long)resource
->GetWidth(), "integer");
334 else if (name
== "height")
336 return new wxProperty("height", (long)resource
->GetHeight(), "integer");
338 else if (name
== "id")
340 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
343 int id
= resource
->GetId();
345 idStr
.Printf("%d", id
);
346 wxString symbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id
);
349 // symbolName is now e.g. "ID_PANEL21=105"
350 return new wxProperty("id", symbolName
, "window_id");
355 else if (name
== "border")
358 if (m_propertyWindow
->GetWindowStyleFlag() & wxSIMPLE_BORDER
)
359 border
= "wxSIMPLE_BORDER";
360 else if (m_propertyWindow
->GetWindowStyleFlag() & wxRAISED_BORDER
)
361 border
= "wxRAISED_BORDER";
362 else if (m_propertyWindow
->GetWindowStyleFlag() & wxSUNKEN_BORDER
)
363 border
= "wxSUNKEN_BORDER";
364 else if (m_propertyWindow
->GetWindowStyleFlag() & wxDOUBLE_BORDER
)
365 border
= "wxDOUBLE_BORDER";
366 else if (m_propertyWindow
->GetWindowStyleFlag() & wxSTATIC_BORDER
)
367 border
= "wxSTATIC_BORDER";
369 border
= "wxNO_BORDER";
371 return new wxProperty("border", border
, "string",
372 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
373 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL
)));
379 bool wxWindowPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
381 wxFont
*font
= & m_propertyWindow
->GetFont();
382 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
384 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
387 m_propertyWindow
->SetFont(* newFont
);
388 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
391 resource
->SetFont(* newFont
);
397 else if (name
== "name")
399 // Remove old name from resource table, if it's there.
400 wxItemResource
*oldResource
= (wxItemResource
*)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow
->GetName());
403 // It's a top-level resource
404 m_propertyWindow
->SetName(property
->GetValue().StringValue());
405 oldResource
->SetName(property
->GetValue().StringValue());
406 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow
->GetName(), oldResource
);
410 // It's a child of something; just set the name of the resource and the window.
411 m_propertyWindow
->SetName(property
->GetValue().StringValue());
412 m_propertyResource
->SetName(property
->GetValue().StringValue());
414 // Refresh the resource manager list, because the name changed.
415 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
418 else if (name
== "title")
420 m_propertyWindow
->SetTitle(property
->GetValue().StringValue());
423 else if (name
== "x")
425 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
427 m_propertyWindow
->GetPosition(&x
, &y
);
428 int newX
= (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(newX
, y
));
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(newX
, y
));
454 m_propertyWindow
->Move(pixelX
, y
);
455 resource
->SetSize(newX
, resource
->GetY(), resource
->GetWidth(), resource
->GetHeight());
459 else if (name
== "y")
461 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
463 m_propertyWindow
->GetPosition(&x
, &y
);
464 int newY
= (int)property
->GetValue().IntegerValue();
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 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(x
, newY
));
478 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
480 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
481 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
483 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(x
, newY
));
490 m_propertyWindow
->Move(x
, pixelY
);
491 resource
->SetSize(resource
->GetX(), newY
, resource
->GetWidth(), resource
->GetHeight());
495 else if (name
== "width")
497 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
499 m_propertyWindow
->GetSize(&width
, &height
);
500 int newWidth
= (int)property
->GetValue().IntegerValue();
501 int pixelWidth
= newWidth
;
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(newWidth
, height
));
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(newWidth
, height
));
524 if (width
!= pixelWidth
)
526 m_propertyWindow
->SetSize(pixelWidth
, height
);
527 resource
->SetSize(resource
->GetX(), resource
->GetY(), newWidth
, resource
->GetHeight());
531 else if (name
== "height")
533 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
535 m_propertyWindow
->GetSize(&width
, &height
);
536 int newHeight
= (int)property
->GetValue().IntegerValue();
537 int pixelHeight
= newHeight
;
539 // We need to convert to pixels if this is not a dialog or panel, but
540 // the parent resource specifies dialog units.
541 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
543 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
544 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
546 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(width
, newHeight
));
550 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
552 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
553 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
555 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(width
, newHeight
));
560 if (height
!= pixelHeight
)
562 m_propertyWindow
->SetSize(width
, pixelHeight
);
563 resource
->SetSize(resource
->GetX(), resource
->GetY(), resource
->GetWidth(), newHeight
);
567 else if (name
== "id")
569 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
572 wxString value
= property
->GetValue().StringValue();
574 wxString strName
= value
.Before('=');
575 wxString strId
= value
.After('=');
576 int id
= atoi(strId
);
578 wxString oldSymbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource
->GetId());
579 int oldSymbolId
= resource
->GetId();
583 // If we change the id for an existing symbol, we need to:
584 // 1) Check if there are any other resources currently using the original id.
585 // If so, will need to change their id to the new id.
586 // 2) Remove the old symbol, add the new symbol.
587 // In this check, we don't have to do this, but we need to do it in SetProperty.
589 if (strName
== oldSymbolName
&& id
!= oldSymbolId
)
591 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
593 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
594 // because ids are unique and changing one resource's id must change all identical ones.
595 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId
, id
);
597 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
598 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
601 // If we change the name but not the id, we'll just need to remove and
602 // re-add the symbol/id pair.
603 if (strName
!= oldSymbolName
&& id
== oldSymbolId
)
605 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
607 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
609 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
611 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
615 // What if we're changing both the name and the id?
616 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
617 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
619 if (strName
!= oldSymbolName
&& id
!= oldSymbolId
)
621 // Remove old symbol if it's not being used
622 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource
, oldSymbolId
) &&
623 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
))
625 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
628 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
630 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
641 else if (name
== "border")
643 long borderStyle
= wxNO_BORDER
;
644 wxString val
= property
->GetValue().StringValue();
646 if (val
== "wxSIMPLE_BORDER")
647 borderStyle
= wxSIMPLE_BORDER
;
648 else if (val
== "wxRAISED_BORDER")
649 borderStyle
= wxRAISED_BORDER
;
650 else if (val
== "wxSUNKEN_BORDER")
651 borderStyle
= wxSUNKEN_BORDER
;
652 else if (val
== "wxDOUBLE_BORDER")
653 borderStyle
= wxDOUBLE_BORDER
;
654 else if (val
== "wxSTATIC_BORDER")
655 borderStyle
= wxSTATIC_BORDER
;
657 borderStyle
= wxNO_BORDER
;
659 SetWindowStyle(m_propertyWindow
, wxSIMPLE_BORDER
, FALSE
);
660 SetWindowStyle(m_propertyWindow
, wxRAISED_BORDER
, FALSE
);
661 SetWindowStyle(m_propertyWindow
, wxSUNKEN_BORDER
, FALSE
);
662 SetWindowStyle(m_propertyWindow
, wxDOUBLE_BORDER
, FALSE
);
663 SetWindowStyle(m_propertyWindow
, wxSTATIC_BORDER
, FALSE
);
664 SetWindowStyle(m_propertyWindow
, wxNO_BORDER
, FALSE
);
666 SetWindowStyle(m_propertyWindow
, borderStyle
, TRUE
);
668 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
669 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
676 void wxWindowPropertyInfo::GetPropertyNames(wxStringList
& names
)
685 if (!m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
687 names
.Add("fontPoints");
688 names
.Add("fontFamily");
689 names
.Add("fontStyle");
690 names
.Add("fontWeight");
691 names
.Add("fontUnderlined");
695 // Fill in the wxItemResource members to mirror the current window settings
696 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource
*resource
)
698 // resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName());
700 // resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
701 wxString
str(m_propertyWindow
->GetName());
702 resource
->SetName(str
);
704 #if 0 // Why did we comment this out? Possibly because of rounding errors
705 // that will build up as the conversion is repeatedly done.
706 // so only do the conversion when a resize happens.
709 if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
710 m_propertyWindow
->GetClientSize(&w
, &h
);
712 m_propertyWindow
->GetSize(&w
, &h
);
714 m_propertyWindow
->GetPosition(&x
, &y
);
716 // We need to convert to dialog units if this is not a dialog or panel, but
717 // the parent resource specifies dialog units.
718 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
720 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
721 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
723 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxPoint(x
, y
));
725 wxSize sz
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxSize(w
, h
));
729 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
731 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
733 wxPoint pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(x
, y
));
735 wxSize sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(w
, h
));
740 resource
->SetSize(x
, y
, w
, h
);
746 // Set the window style
747 void wxWindowPropertyInfo::SetWindowStyle(wxWindow
* win
, long style
, bool set
)
752 if ((win
->GetWindowStyleFlag() & style
) == style
)
756 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() - style
);
763 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() | style
);
772 wxProperty
*wxItemPropertyInfo::GetProperty(wxString
& name
)
774 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
775 wxFont
*font
= & itemWindow
->GetFont();
777 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
778 name
== "fontUnderlined")
779 return GetFontProperty(name
, font
);
780 else if (name
== "label" && itemWindow
->GetLabel())
781 return new wxProperty("label", m_propertyWindow
->GetLabel(), "string");
783 return wxWindowPropertyInfo::GetProperty(name
);
786 bool wxItemPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
788 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
790 wxFont
*font
= & itemWindow
->GetFont();
792 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
794 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
796 itemWindow
->SetFont(* newFont
);
803 itemWindow
->SetLabel(property
->GetValue().StringValue());
807 return wxWindowPropertyInfo::SetProperty(name
, property
);
810 void wxItemPropertyInfo::GetPropertyNames(wxStringList
& names
)
812 wxWindowPropertyInfo::GetPropertyNames(names
);
814 names
.Add("fontPoints");
815 names
.Add("fontFamily");
816 names
.Add("fontStyle");
817 names
.Add("fontWeight");
818 names
.Add("fontUnderlined");
821 bool wxItemPropertyInfo::InstantiateResource(wxItemResource
*resource
)
823 wxWindowPropertyInfo::InstantiateResource(resource
);
825 wxControl
*item
= (wxControl
*)m_propertyWindow
;
826 wxString
str(item
->GetLabel());
827 resource
->SetTitle(str
);
829 if (item
->GetFont().Ok())
830 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(item
->GetFont().GetPointSize(),
831 item
->GetFont().GetFamily(), item
->GetFont().GetStyle(), item
->GetFont().GetWeight(),
832 item
->GetFont().GetUnderlined(), item
->GetFont().GetFaceName()));
840 wxProperty
*wxButtonPropertyInfo::GetProperty(wxString
& name
)
842 return wxItemPropertyInfo::GetProperty(name
);
845 bool wxButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
847 return wxItemPropertyInfo::SetProperty(name
, property
);
850 void wxButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
852 wxItemPropertyInfo::GetPropertyNames(names
);
856 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
858 return wxItemPropertyInfo::InstantiateResource(resource
);
865 wxProperty
*wxBitmapButtonPropertyInfo::GetProperty(wxString
& name
)
867 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
868 if (name
== "bitmapFilename")
870 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
871 wxString
str("none.bmp");
875 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
877 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
880 return wxButtonPropertyInfo::GetProperty(name
);
883 bool wxBitmapButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
885 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
886 if (name
== "bitmapFilename")
888 char *s
= property
->GetValue().StringValue();
889 if (s
&& wxFileExists(s
))
892 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
900 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
903 wxString
oldResource(resource
->GetValue4());
904 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
905 resource
->SetValue4(resName
);
907 if (!oldResource
.IsNull())
908 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
911 button
->SetLabel(* bitmap
);
918 return wxButtonPropertyInfo::SetProperty(name
, property
);
921 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
923 wxButtonPropertyInfo::GetPropertyNames(names
);
924 names
.Delete("label");
925 names
.Add("bitmapFilename");
928 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
930 return wxItemPropertyInfo::InstantiateResource(resource
);
937 wxProperty
*wxStaticTextPropertyInfo::GetProperty(wxString
& name
)
939 return wxItemPropertyInfo::GetProperty(name
);
942 bool wxStaticTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
944 wxStaticText
* itemWindow
= (wxStaticText
*) m_propertyWindow
;
947 // Because setting a wxStaticText control's label may change the
948 // size, we must get the size and instantiate the resource immediately.
949 itemWindow
->SetLabel(property
->GetValue().StringValue());
952 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(itemWindow
);
954 m_propertyWindow
->GetSize(&w
, &h
);
955 // m_propertyWindow->GetPosition(&x, &y);
957 // We need to convert to dialog units if
958 // the parent resource specifies dialog units.
959 if (m_propertyWindow
->GetParent())
961 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
962 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
964 // wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y));
965 // x = pt.x; y = pt.y;
966 wxSize sz
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxSize(w
, h
));
970 resource
->SetSize(resource
->GetX(), resource
->GetY(), w
, h
);
974 return wxItemPropertyInfo::SetProperty(name
, property
);
977 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
979 wxItemPropertyInfo::GetPropertyNames(names
);
983 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
985 return wxItemPropertyInfo::InstantiateResource(resource
);
992 wxProperty
*wxStaticBitmapPropertyInfo::GetProperty(wxString
& name
)
994 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
995 if (name
== "bitmapFilename")
997 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
998 wxString
str("none.bmp");
1002 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
1004 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
1007 return wxItemPropertyInfo::GetProperty(name
);
1010 bool wxStaticBitmapPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1012 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
1013 if (name
== "bitmapFilename")
1015 char *s
= property
->GetValue().StringValue();
1016 if (s
&& wxFileExists(s
))
1020 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
1028 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
1031 wxString
oldResource(resource
->GetValue4());
1032 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
1033 resource
->SetValue4(resName
);
1035 if (!oldResource
.IsNull())
1036 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
1039 message
->SetBitmap(* bitmap
);
1046 return wxItemPropertyInfo::SetProperty(name
, property
);
1049 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList
& names
)
1051 wxItemPropertyInfo::GetPropertyNames(names
);
1052 names
.Add("bitmapFilename");
1055 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1057 return wxItemPropertyInfo::InstantiateResource(resource
);
1064 wxProperty
*wxTextPropertyInfo::GetProperty(wxString
& name
)
1066 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1067 if (name
== "value")
1068 return new wxProperty("value", text
->GetValue(), "string");
1069 else if (name
== "password")
1071 bool isPassword
= ((text
->GetWindowStyleFlag() & wxTE_PASSWORD
) == wxTE_PASSWORD
);
1072 return new wxProperty("password", isPassword
, "bool");
1074 else if (name
== "readonly")
1076 bool isReadOnly
= ((text
->GetWindowStyleFlag() & wxTE_READONLY
) == wxTE_READONLY
);
1077 return new wxProperty("readonly", isReadOnly
, "bool");
1080 return wxItemPropertyInfo::GetProperty(name
);
1083 bool wxTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1085 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1086 if (name
== "value")
1088 text
->SetValue(property
->GetValue().StringValue());
1091 else if (name
== "password")
1093 long flag
= text
->GetWindowStyleFlag();
1094 if (property
->GetValue().BoolValue())
1096 if ((flag
& wxTE_PASSWORD
) != wxTE_PASSWORD
)
1097 flag
|= wxTE_PASSWORD
;
1101 if ((flag
& wxTE_PASSWORD
) == wxTE_PASSWORD
)
1102 flag
-= wxTE_PASSWORD
;
1104 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1105 resource
->SetStyle(flag
);
1107 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1110 else if (name
== "readonly")
1112 long flag
= text
->GetWindowStyleFlag();
1113 if (property
->GetValue().BoolValue())
1115 if ((flag
& wxTE_READONLY
) != wxTE_READONLY
)
1116 flag
|= wxTE_READONLY
;
1120 if ((flag
& wxTE_READONLY
) == wxTE_READONLY
)
1121 flag
-= wxTE_READONLY
;
1123 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1124 resource
->SetStyle(flag
);
1126 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1130 return wxItemPropertyInfo::SetProperty(name
, property
);
1133 void wxTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
1135 wxItemPropertyInfo::GetPropertyNames(names
);
1137 names
.Add("readonly");
1138 names
.Add("password");
1141 bool wxTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1143 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1144 wxString
str(text
->GetValue());
1145 resource
->SetValue4(str
);
1147 return wxItemPropertyInfo::InstantiateResource(resource
);
1154 wxProperty
*wxListBoxPropertyInfo::GetProperty(wxString
& name
)
1156 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1157 if (name
== "values")
1159 wxStringList
*stringList
= new wxStringList
;
1161 for (i
= 0; i
< listBox
->Number(); i
++)
1162 stringList
->Add(listBox
->GetString(i
));
1164 return new wxProperty(name
, stringList
, "stringlist");
1166 else if (name
== "multiple")
1168 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1172 char *mult
= "wxLB_SINGLE";
1174 if ((listBox
->GetWindowStyleFlag() & wxLB_MULTIPLE
) != 0)
1175 mult
= "wxLB_MULTIPLE";
1176 else if ((listBox
->GetWindowStyleFlag() & wxLB_EXTENDED
) != 0)
1177 mult
= "wxLB_EXTENDED";
1179 mult
= "wxLB_SINGLE";
1181 return new wxProperty("multiple", mult
, "string",
1182 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1186 return wxItemPropertyInfo::GetProperty(name
);
1189 bool wxListBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1191 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1192 if (name
== "values")
1195 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1198 char *s
= expr
->StringValue();
1201 expr
= expr
->GetNext();
1205 else if (name
== "multiple")
1207 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, FALSE
);
1208 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, FALSE
);
1209 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, FALSE
);
1211 wxString
str(property
->GetValue().StringValue());
1212 if (str
== "wxLB_MULTIPLE")
1213 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, TRUE
);
1214 else if (str
== "wxLB_EXTENDED")
1215 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, TRUE
);
1217 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, TRUE
);
1219 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1221 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1222 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox
, this);
1226 return wxItemPropertyInfo::SetProperty(name
, property
);
1229 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1231 wxItemPropertyInfo::GetPropertyNames(names
);
1232 names
.Add("values");
1233 names
.Add("multiple");
1236 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1238 wxListBox
*lbox
= (wxListBox
*)m_propertyWindow
;
1239 // This will be set for the wxItemResource on reading or in SetProperty
1240 // resource->SetValue1(lbox->GetSelectionMode());
1242 if (lbox
->Number() == 0)
1243 resource
->SetStringValues(NULL
);
1248 for (i
= 0; i
< lbox
->Number(); i
++)
1249 slist
.Add(lbox
->GetString(i
));
1251 resource
->SetStringValues(slist
);
1253 return wxItemPropertyInfo::InstantiateResource(resource
);
1260 wxProperty
*wxChoicePropertyInfo::GetProperty(wxString
& name
)
1262 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1263 if (name
== "values")
1265 wxStringList
* stringList
= new wxStringList
;
1267 for (i
= 0; i
< choice
->Number(); i
++)
1268 stringList
->Add(choice
->GetString(i
));
1270 return new wxProperty(name
, stringList
, "stringlist");
1273 return wxItemPropertyInfo::GetProperty(name
);
1276 bool wxChoicePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1278 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1279 if (name
== "values")
1282 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1285 char *s
= expr
->StringValue();
1288 expr
= expr
->GetNext();
1290 if (choice
->Number() > 0)
1291 choice
->SetSelection(0);
1295 return wxItemPropertyInfo::SetProperty(name
, property
);
1298 void wxChoicePropertyInfo::GetPropertyNames(wxStringList
& names
)
1300 wxItemPropertyInfo::GetPropertyNames(names
);
1301 names
.Add("values");
1304 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1306 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1308 if (choice
->Number() == 0)
1309 resource
->SetStringValues(NULL
);
1314 for (i
= 0; i
< choice
->Number(); i
++)
1315 slist
.Add(choice
->GetString(i
));
1317 resource
->SetStringValues(slist
);
1319 return wxItemPropertyInfo::InstantiateResource(resource
);
1326 wxProperty
*wxComboBoxPropertyInfo::GetProperty(wxString
& name
)
1328 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1329 if (name
== "values")
1331 wxStringList
*stringList
= new wxStringList
;
1333 for (i
= 0; i
< choice
->Number(); i
++)
1334 stringList
->Add(choice
->GetString(i
));
1336 return new wxProperty(name
, stringList
, "stringlist");
1338 else if (name
== "sort")
1340 bool sort
= ((m_propertyWindow
->GetWindowStyleFlag() & wxCB_SORT
) == wxCB_SORT
);
1341 return new wxProperty(name
, sort
, "bool");
1343 else if (name
== "style")
1345 wxString
styleStr("dropdown");
1346 if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_SIMPLE
)
1347 styleStr
= "simple";
1348 else if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_READONLY
)
1349 styleStr
= "readonly";
1351 styleStr
= "dropdown";
1353 return new wxProperty(name
, styleStr
, "string",
1354 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1358 return wxItemPropertyInfo::GetProperty(name
);
1361 bool wxComboBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1363 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1364 if (name
== "values")
1367 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1370 char *s
= expr
->StringValue();
1373 expr
= expr
->GetNext();
1375 if (choice
->Number() > 0)
1376 choice
->SetSelection(0);
1379 else if (name
== "sort")
1381 SetWindowStyle(m_propertyWindow
, wxCB_SORT
, property
->GetValue().BoolValue());
1383 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1384 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1386 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1389 else if (name
== "style")
1391 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, FALSE
);
1392 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, FALSE
);
1393 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, FALSE
);
1395 wxString
styleStr(property
->GetValue().StringValue());
1396 if (styleStr
== "simple")
1397 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, TRUE
);
1398 else if (styleStr
== "dropdown")
1399 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, TRUE
);
1400 else if (styleStr
== "readonly")
1401 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, TRUE
);
1404 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1405 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1407 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1412 return wxItemPropertyInfo::SetProperty(name
, property
);
1415 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1417 wxItemPropertyInfo::GetPropertyNames(names
);
1418 names
.Add("values");
1423 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1425 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1427 if (choice
->Number() == 0)
1428 resource
->SetStringValues(NULL
);
1433 for (i
= 0; i
< choice
->Number(); i
++)
1434 slist
.Add(choice
->GetString(i
));
1436 resource
->SetStringValues(slist
);
1438 return wxItemPropertyInfo::InstantiateResource(resource
);
1445 wxProperty
*wxRadioBoxPropertyInfo::GetProperty(wxString
& name
)
1447 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1448 if (name
== "numberRowsOrCols")
1450 return new wxProperty("numberRowsOrCols", (long)radioBox
->GetNumberOfRowsOrCols(), "integer");
1452 if (name
== "orientation")
1455 if (m_propertyWindow
->GetWindowStyleFlag() & wxRA_SPECIFY_COLS
)
1456 orient
= "wxRA_SPECIFY_COLS";
1458 orient
= "wxRA_SPECIFY_ROWS";
1460 return new wxProperty("orientation", orient
, "string",
1461 new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS",
1464 else if (name
== "values")
1466 wxStringList
*stringList
= new wxStringList
;
1468 for (i
= 0; i
< radioBox
->Number(); i
++)
1469 stringList
->Add(radioBox
->GetString(i
));
1471 return new wxProperty(name
, stringList
, "stringlist");
1473 return wxItemPropertyInfo::GetProperty(name
);
1476 bool wxRadioBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1478 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1479 if (name
== "numberRowsOrCols")
1481 wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox
);
1483 radioBox
->SetNumberOfRowsOrCols((int)property
->GetValue().IntegerValue());
1484 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1487 else if (name
== "orientation")
1489 long windowStyle
= radioBox
->GetWindowStyleFlag();
1490 wxString
val(property
->GetValue().StringValue());
1491 if (val
== "wxRA_SPECIFY_COLS")
1493 if (windowStyle
& wxRA_SPECIFY_ROWS
)
1494 windowStyle
-= wxRA_SPECIFY_ROWS
;
1495 windowStyle
|= wxRA_SPECIFY_COLS
;
1499 if (windowStyle
& wxRA_SPECIFY_COLS
)
1500 windowStyle
-= wxRA_SPECIFY_COLS
;
1501 windowStyle
|= wxRA_SPECIFY_ROWS
;
1503 wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox
);
1505 radioBox
->SetWindowStyleFlag(windowStyle
);
1506 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox
);
1507 resource
->SetStyle(windowStyle
);
1508 resource
->SetSize(resource
->GetX(), resource
->GetY(), -1, -1); // Let it calculate it's own size
1510 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this, FALSE
);
1513 else if (name
== "values")
1515 // Set property into *resource*, not wxRadioBox, and then recreate
1516 // the wxRadioBox. This is because we can't dynamically set the strings
1518 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1522 wxStringList stringList
;
1523 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1526 char *s
= expr
->StringValue();
1529 expr
= expr
->GetNext();
1531 resource
->SetStringValues(stringList
);
1532 resource
->SetSize(resource
->GetX(), resource
->GetY(), -1, -1); // Let it calculate it's own size
1533 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this, FALSE
);
1536 else if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" )
1538 wxFont
*font
= & m_propertyWindow
->GetFont();
1541 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
1544 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1547 resource
->SetFont(* newFont
);
1550 wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox
);
1552 radioBox
->SetFont(* newFont
);
1553 radioBox
->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH
| wxSIZE_AUTO_HEIGHT
);
1558 return wxItemPropertyInfo::SetProperty(name
, property
);
1561 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1563 wxItemPropertyInfo::GetPropertyNames(names
);
1565 names
.Add("values");
1566 names
.Add("orientation");
1567 names
.Add("numberRowsOrCols");
1570 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1572 wxRadioBox
*rbox
= (wxRadioBox
*)m_propertyWindow
;
1573 // Take strings from resource instead
1576 if (rbox->Number() == 0)
1577 resource->SetStringValues(NULL);
1580 wxStringList *slist = new wxStringList;
1582 for (i = 0; i < rbox->Number(); i++)
1583 slist->Add(rbox->GetString(i));
1585 resource->SetStringValues(slist);
1588 resource
->SetValue1(rbox
->GetNumberOfRowsOrCols());
1589 return wxItemPropertyInfo::InstantiateResource(resource
);
1596 wxProperty
*wxGroupBoxPropertyInfo::GetProperty(wxString
& name
)
1598 return wxItemPropertyInfo::GetProperty(name
);
1601 bool wxGroupBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1603 return wxItemPropertyInfo::SetProperty(name
, property
);
1606 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1608 wxItemPropertyInfo::GetPropertyNames(names
);
1612 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1614 return wxItemPropertyInfo::InstantiateResource(resource
);
1621 wxProperty
*wxCheckBoxPropertyInfo::GetProperty(wxString
& name
)
1623 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1624 if (name
== "value")
1625 return new wxProperty("value", checkBox
->GetValue(), "bool");
1627 return wxItemPropertyInfo::GetProperty(name
);
1630 bool wxCheckBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1632 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1633 if (name
== "value")
1635 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1639 return wxItemPropertyInfo::SetProperty(name
, property
);
1642 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1644 wxItemPropertyInfo::GetPropertyNames(names
);
1649 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1651 wxCheckBox
*cbox
= (wxCheckBox
*)m_propertyWindow
;
1652 resource
->SetValue1(cbox
->GetValue());
1653 return wxItemPropertyInfo::InstantiateResource(resource
);
1660 wxProperty
*wxRadioButtonPropertyInfo::GetProperty(wxString
& name
)
1662 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1663 if (name
== "value")
1664 return new wxProperty("value", checkBox
->GetValue(), "bool");
1666 return wxItemPropertyInfo::GetProperty(name
);
1669 bool wxRadioButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1671 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1672 if (name
== "value")
1674 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1678 return wxItemPropertyInfo::SetProperty(name
, property
);
1681 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
1683 wxItemPropertyInfo::GetPropertyNames(names
);
1688 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1690 wxRadioButton
*cbox
= (wxRadioButton
*)m_propertyWindow
;
1691 resource
->SetValue1(cbox
->GetValue());
1692 return wxItemPropertyInfo::InstantiateResource(resource
);
1699 wxProperty
*wxSliderPropertyInfo::GetProperty(wxString
& name
)
1701 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1702 if (name
== "value")
1703 return new wxProperty("value", (long)slider
->GetValue(), "integer");
1704 else if (name
== "orientation")
1707 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1708 pos
= "wxHORIZONTAL";
1712 return new wxProperty("orientation", pos
, "string",
1713 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1716 else if (name
== "minValue")
1717 return new wxProperty("minValue", (long)slider
->GetMin(), "integer");
1718 else if (name
== "maxValue")
1719 return new wxProperty("maxValue", (long)slider
->GetMax(), "integer");
1721 return wxItemPropertyInfo::GetProperty(name
);
1724 bool wxSliderPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1726 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1727 if (name
== "value")
1729 slider
->SetValue((int)property
->GetValue().IntegerValue());
1732 else if (name
== "orientation")
1734 long windowStyle
= slider
->GetWindowStyleFlag();
1735 long oldWindowStyle
= windowStyle
;
1736 wxString
val(property
->GetValue().StringValue());
1737 if (val
== "wxHORIZONTAL")
1739 if (windowStyle
& wxVERTICAL
)
1740 windowStyle
-= wxVERTICAL
;
1741 windowStyle
|= wxHORIZONTAL
;
1745 if (windowStyle
& wxHORIZONTAL
)
1746 windowStyle
-= wxHORIZONTAL
;
1747 windowStyle
|= wxVERTICAL
;
1750 if (oldWindowStyle
== windowStyle
)
1753 slider
->SetWindowStyleFlag(windowStyle
);
1755 // If the window style has changed, we swap the width and height parameters.
1757 slider
->GetSize(&w
, &h
);
1759 slider
= (wxSlider
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider
, this);
1760 slider
->SetSize(-1, -1, h
, w
);
1761 m_propertyWindow
= slider
;
1765 else if (name
== "minValue")
1767 slider
->SetRange((int)property
->GetValue().IntegerValue(), slider
->GetMax());
1770 else if (name
== "maxValue")
1772 slider
->SetRange(slider
->GetMin(), (int)property
->GetValue().IntegerValue());
1776 return wxItemPropertyInfo::SetProperty(name
, property
);
1779 void wxSliderPropertyInfo::GetPropertyNames(wxStringList
& names
)
1781 wxItemPropertyInfo::GetPropertyNames(names
);
1783 names
.Add("orientation");
1784 names
.Add("minValue");
1785 names
.Add("maxValue");
1788 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1790 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1791 resource
->SetValue1(slider
->GetValue());
1792 resource
->SetValue2(slider
->GetMin());
1793 resource
->SetValue3(slider
->GetMax());
1794 return wxItemPropertyInfo::InstantiateResource(resource
);
1801 wxProperty
*wxGaugePropertyInfo::GetProperty(wxString
& name
)
1803 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1804 if (name
== "value")
1805 return new wxProperty("value", (long)gauge
->GetValue(), "integer");
1806 else if (name
== "maxValue")
1807 return new wxProperty("maxValue", (long)gauge
->GetRange(), "integer");
1809 return wxItemPropertyInfo::GetProperty(name
);
1812 bool wxGaugePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1814 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1815 if (name
== "value")
1817 gauge
->SetValue((int)property
->GetValue().IntegerValue());
1820 else if (name
== "maxValue")
1822 gauge
->SetRange((int)property
->GetValue().IntegerValue());
1826 return wxItemPropertyInfo::SetProperty(name
, property
);
1829 void wxGaugePropertyInfo::GetPropertyNames(wxStringList
& names
)
1831 wxItemPropertyInfo::GetPropertyNames(names
);
1833 names
.Add("maxValue");
1836 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1838 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1839 resource
->SetValue1(gauge
->GetValue());
1840 resource
->SetValue2(gauge
->GetRange());
1841 return wxItemPropertyInfo::InstantiateResource(resource
);
1848 wxProperty
*wxScrollBarPropertyInfo::GetProperty(wxString
& name
)
1850 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1851 if (name
== "thumbPosition")
1852 return new wxProperty("value", (long)scrollBar
->GetThumbPosition(), "integer");
1853 else if (name
== "orientation")
1856 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1857 pos
= "wxHORIZONTAL";
1861 return new wxProperty("orientation", pos
, "string",
1862 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1865 else if (name
== "pageSize")
1867 int pageLength
= scrollBar
->GetPageSize();
1869 return new wxProperty("pageSize", (long)pageLength
, "integer");
1871 else if (name
== "thumbSize")
1873 int thumbSize
= scrollBar
->GetThumbSize();
1875 return new wxProperty("thumbSize", (long)thumbSize
, "integer");
1877 else if (name
== "range")
1879 int range
= scrollBar
->GetRange();
1880 return new wxProperty("range", (long)range
, "integer");
1883 return wxItemPropertyInfo::GetProperty(name
);
1886 bool wxScrollBarPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1888 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1889 if (name
== "thumbPosition")
1891 scrollBar
->SetThumbPosition((int)property
->GetValue().IntegerValue());
1894 else if (name
== "orientation")
1896 long windowStyle
= scrollBar
->GetWindowStyleFlag();
1897 long oldWindowStyle
= windowStyle
;
1898 wxString
val(property
->GetValue().StringValue());
1899 if (val
== "wxHORIZONTAL")
1901 if (windowStyle
& wxVERTICAL
)
1902 windowStyle
-= wxVERTICAL
;
1903 windowStyle
|= wxHORIZONTAL
;
1907 if (windowStyle
& wxHORIZONTAL
)
1908 windowStyle
-= wxHORIZONTAL
;
1909 windowStyle
|= wxVERTICAL
;
1912 if (oldWindowStyle
== windowStyle
)
1915 scrollBar
->SetWindowStyleFlag(windowStyle
);
1917 // If the window style has changed, we swap the width and height parameters.
1919 // scrollBar->GetSize(&w, &h);
1920 wxItemResource
*item
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar
);
1922 item
->SetSize(item
->GetX(), item
->GetY(), item
->GetHeight(), item
->GetWidth());
1923 item
->SetStyle(windowStyle
);
1926 scrollBar
= (wxScrollBar
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar
, this);
1927 m_propertyWindow
= scrollBar
;
1931 else if (name
== "pageSize")
1933 int pos
= scrollBar
->GetThumbPosition();
1934 int range
= scrollBar
->GetRange();
1935 int thumbSize
= scrollBar
->GetThumbSize();
1936 scrollBar
->SetScrollbar(pos
, thumbSize
, range
, (int)property
->GetValue().IntegerValue());
1939 else if (name
== "thumbSize")
1941 int pos
= scrollBar
->GetThumbPosition();
1942 int range
= scrollBar
->GetRange();
1943 int pageSize
= scrollBar
->GetPageSize();
1944 scrollBar
->SetScrollbar(pos
, (int)property
->GetValue().IntegerValue(), range
, pageSize
);
1947 else if (name
== "range")
1949 int pos
= scrollBar
->GetThumbPosition();
1950 int thumbSize
= scrollBar
->GetThumbSize();
1951 int pageSize
= scrollBar
->GetPageSize();
1952 scrollBar
->SetScrollbar(pos
, thumbSize
, (int)property
->GetValue().IntegerValue(), pageSize
);
1956 return wxItemPropertyInfo::SetProperty(name
, property
);
1959 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList
& names
)
1961 wxItemPropertyInfo::GetPropertyNames(names
);
1962 names
.Add("orientation");
1963 names
.Add("thumbPosition");
1964 names
.Add("thumbSize");
1965 names
.Add("pageSize");
1968 // Remove some properties we don't inherit
1969 names
.Delete("fontPoints");
1970 names
.Delete("fontFamily");
1971 names
.Delete("fontStyle");
1972 names
.Delete("fontWeight");
1973 names
.Delete("fontUnderlined");
1976 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1978 wxScrollBar
*sbar
= (wxScrollBar
*)m_propertyWindow
;
1980 int thumbPosition
= sbar
->GetThumbPosition();
1981 int thumbSize
= sbar
->GetThumbSize();
1982 int pageSize
= sbar
->GetPageSize();
1983 int range
= sbar
->GetRange();
1985 resource
->SetValue1(thumbPosition
);
1986 resource
->SetValue2(thumbSize
);
1987 resource
->SetValue3(range
);
1988 resource
->SetValue5(pageSize
);
1990 return wxItemPropertyInfo::InstantiateResource(resource
);
1997 wxProperty
*wxPanelPropertyInfo::GetProperty(wxString
& name
)
1999 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
2002 wxFont *labelFont = panelWindow->GetLabelFont();
2003 wxFont *buttonFont = panelWindow->GetButtonFont();
2005 if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" ||
2006 name == "labelFontUnderlined")
2007 return GetFontProperty(name, labelFont);
2008 else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" ||
2009 name == "buttonFontUnderlined")
2010 return GetFontProperty(name, buttonFont);
2016 if (panelWindow
->GetWindowStyleFlag() & wxNO_3D
)
2019 userColours
= FALSE
;
2021 return new wxProperty(name
, (bool)userColours
, "bool");
2023 else if (name
== "backgroundColour")
2025 wxColour
col(panelWindow
->GetBackgroundColour());
2027 wxDecToHex(col
.Red(), buf
);
2028 wxDecToHex(col
.Green(), buf
+2);
2029 wxDecToHex(col
.Blue(), buf
+4);
2031 return new wxProperty(name
, buf
, "string", new wxColourListValidator
);
2033 else if (name
== "title")
2035 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2037 return new wxProperty(name
, resource
->GetTitle(), "string");
2039 return new wxProperty(name
, "Could not get title", "string");
2041 else if (name
== "caption")
2043 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxCAPTION
) == wxCAPTION
),
2046 else if (name
== "systemMenu")
2048 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxSYSTEM_MENU
) == wxSYSTEM_MENU
),
2051 else if (name
== "thickFrame")
2053 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxTHICK_FRAME
) == wxTHICK_FRAME
),
2056 else if (name
== "useSystemDefaults")
2058 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2059 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) == wxRESOURCE_USE_DEFAULTS
),
2062 else if (name
== "useDialogUnits")
2064 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2065 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == wxRESOURCE_DIALOG_UNITS
),
2069 return wxWindowPropertyInfo::GetProperty(name
);
2072 bool wxPanelPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
2074 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
2076 wxFont *labelFont = panelWindow->GetLabelFont();
2077 wxFont *buttonFont = panelWindow->GetButtonFont();
2079 if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" ))
2081 wxFont *newFont = SetFontProperty(name, property, labelFont);
2083 panelWindow->SetLabelFont(* newFont);
2086 else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" ))
2088 wxFont *newFont = SetFontProperty(name, property, buttonFont);
2090 panelWindow->SetButtonFont(* newFont);
2097 bool userColours
= property
->GetValue().BoolValue();
2101 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) != wxNO_3D
)
2102 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() | wxNO_3D
);
2106 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) == wxNO_3D
)
2107 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() - wxNO_3D
);
2109 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2110 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2112 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2115 else if (name
== "backgroundColour")
2117 char *hex
= property
->GetValue().StringValue();
2118 int r
= wxHexToDec(hex
);
2119 int g
= wxHexToDec(hex
+2);
2120 int b
= wxHexToDec(hex
+4);
2122 wxColour
col(r
,g
,b
);
2123 panelWindow
->SetBackgroundColour(col
);
2124 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2125 m_propertyWindow
= panelWindow
;
2128 else if (name
== "title")
2130 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2133 resource
->SetTitle(property
->GetValue().StringValue());
2139 else if (name
== "caption")
2141 SetWindowStyle(panelWindow
, wxCAPTION
, property
->GetValue().BoolValue());
2143 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2144 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2147 else if (name
== "thickFrame")
2149 SetWindowStyle(panelWindow
, wxTHICK_FRAME
, property
->GetValue().BoolValue());
2151 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2152 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2155 else if (name
== "systemMenu")
2157 SetWindowStyle(panelWindow
, wxSYSTEM_MENU
, property
->GetValue().BoolValue());
2159 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2160 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2163 else if (name
== "useSystemDefaults")
2165 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2166 bool useDefaults
= property
->GetValue().BoolValue();
2167 long style
= resource
->GetResourceStyle();
2170 if ((style
& wxRESOURCE_USE_DEFAULTS
) == 0)
2171 style
|= wxRESOURCE_USE_DEFAULTS
;
2175 if ((style
& wxRESOURCE_USE_DEFAULTS
) != 0)
2176 style
-= wxRESOURCE_USE_DEFAULTS
;
2178 resource
->SetResourceStyle(style
);
2179 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2182 else if (name
== "useDialogUnits")
2184 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2185 bool useDialogUnits
= property
->GetValue().BoolValue();
2186 long style
= resource
->GetResourceStyle();
2189 if ((style
& wxRESOURCE_DIALOG_UNITS
) == 0)
2191 style
|= wxRESOURCE_DIALOG_UNITS
;
2192 ConvertDialogUnits(TRUE
); // Convert all resources
2197 if ((style
& wxRESOURCE_DIALOG_UNITS
) != 0)
2199 style
-= wxRESOURCE_DIALOG_UNITS
;
2200 ConvertDialogUnits(FALSE
); // Convert all resources
2203 resource
->SetResourceStyle(style
);
2204 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2205 m_propertyWindow
= panelWindow
;
2206 // TODO: need to regenerate the width and height properties else they'll be inconsistent.
2210 return wxWindowPropertyInfo::SetProperty(name
, property
);
2213 void wxPanelPropertyInfo::GetPropertyNames(wxStringList
& names
)
2215 wxWindowPropertyInfo::GetPropertyNames(names
);
2219 names
.Add("backgroundColour");
2220 names
.Add("caption");
2221 names
.Add("systemMenu");
2222 names
.Add("thickFrame");
2223 names
.Add("useSystemDefaults");
2224 names
.Add("useDialogUnits");
2227 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2229 wxPanel
*panel
= (wxPanel
*)m_propertyWindow
;
2230 if (panel
->GetFont().Ok())
2231 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(panel
->GetFont().GetPointSize(),
2232 panel
->GetFont().GetFamily(), panel
->GetFont().GetStyle(), panel
->GetFont().GetWeight(),
2233 panel
->GetFont().GetUnderlined(), panel
->GetFont().GetFaceName()));
2235 resource
->SetBackgroundColour(wxColour(panel
->GetBackgroundColour()));
2237 return wxWindowPropertyInfo::InstantiateResource(resource
);
2240 // Convert this dialog, and its children, to or from dialog units
2241 void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits
)
2243 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
2249 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2250 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2254 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2255 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2257 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2259 wxNode
* node
= m_propertyWindow
->GetChildren().First();
2262 wxWindow
* child
= (wxWindow
*) node
->Data();
2263 if (child
->IsKindOf(CLASSINFO(wxControl
)))
2265 resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(child
);
2268 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2269 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2273 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2274 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2276 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2278 node
= node
->Next();
2287 wxProperty
*wxDialogPropertyInfo::GetProperty(wxString
& name
)
2289 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2290 if (name
== "modal")
2292 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2296 bool modal
= (resource
->GetValue1() != 0);
2297 return new wxProperty(name
, modal
, "bool");
2300 return wxPanelPropertyInfo::GetProperty(name
);
2303 bool wxDialogPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
2305 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2307 if (name
== "modal")
2309 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2313 resource
->SetValue1(property
->GetValue().BoolValue());
2317 return wxPanelPropertyInfo::SetProperty(name
, property
);
2320 void wxDialogPropertyInfo::GetPropertyNames(wxStringList
& names
)
2322 wxPanelPropertyInfo::GetPropertyNames(names
);
2327 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2329 wxDialog
*dialog
= (wxDialog
*)m_propertyWindow
;
2330 wxString
str(dialog
->GetTitle());
2331 resource
->SetTitle(str
);
2333 return wxPanelPropertyInfo::InstantiateResource(resource
);
2341 int wxStringToFontWeight(wxString
& val
)
2343 if (val
== "wxBOLD") return wxBOLD
;
2344 else if (val
== "wxLIGHT") return wxLIGHT
;
2345 else return wxNORMAL
;
2348 int wxStringToFontStyle(wxString
& val
)
2350 if (val
== "wxITALIC") return wxITALIC
;
2351 else if (val
== "wxSLANT") return wxSLANT
;
2352 else return wxNORMAL
;
2355 int wxStringToFontFamily(wxString
& val
)
2357 if (val
== "wxDECORATIVE") return wxDECORATIVE
;
2358 else if (val
== "wxROMAN") return wxROMAN
;
2359 else if (val
== "wxSCRIPT") return wxSCRIPT
;
2360 else if (val
== "wxMODERN") return wxMODERN
;
2361 else if (val
== "wxTELETYPE") return wxTELETYPE
;
2362 else return wxSWISS
;
2366 /// Resource symbol validator
2368 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator
, wxPropertyListValidator
)
2370 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags
):
2371 wxPropertyListValidator(flags
)
2375 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2379 bool wxResourceSymbolValidator::OnCheckValue(wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
))
2384 // Called when TICK is pressed or focus is lost or view wants to update
2385 // the property list.
2386 // Does the transferance from the property editing area to the property itself
2387 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2389 if (!view
->GetValueText())
2391 wxString
value(view
->GetValueText()->GetValue());
2392 property
->GetValue() = value
;
2396 // Called when TICK is pressed or focus is lost or view wants to update
2397 // the property list.
2398 // Does the transferance from the property editing area to the property itself
2399 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2401 if (!view
->GetValueText())
2403 wxString
str(property
->GetValue().GetStringRepresentation());
2404 view
->GetValueText()->SetValue(str
);
2408 // Called when the property is double clicked. Extra functionality can be provided,
2409 // cycling through possible values.
2410 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2412 if (!view
->GetValueText())
2414 OnEdit(property
, view
, parentWindow
);
2418 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty
*WXUNUSED(property
), wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2420 if (view
->GetConfirmButton())
2421 view
->GetConfirmButton()->Enable(TRUE
);
2422 if (view
->GetCancelButton())
2423 view
->GetCancelButton()->Enable(TRUE
);
2424 if (view
->GetEditButton())
2425 view
->GetEditButton()->Enable(TRUE
);
2426 if (view
->GetValueText())
2427 view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
);
2431 void wxResourceSymbolValidator::OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2433 if (!view
->GetValueText())
2436 wxResourceSymbolDialog
* dialog
= new wxResourceSymbolDialog(parentWindow
, -1, "Edit Symbol");
2438 // Split name/id pair e.g. "IDC_TEXT=123"
2439 wxString
value(property
->GetValue().StringValue());
2441 wxString strName
= value
.Before('=');
2442 wxString strId
= value
.After('=');
2444 dialog
->SetSymbol(strName
);
2445 dialog
->SetId(atoi(strId
));
2449 if (dialog
->ShowModal() == wxID_OK
)
2451 wxString
symbolName(dialog
->GetSymbol());
2452 long id
= dialog
->GetId();
2455 str
.Printf("%d", id
);
2456 property
->GetValue() = symbolName
+ wxString("=") + str
;
2458 view
->DisplayProperty(property
);
2459 view
->UpdatePropertyDisplayInList(property
);
2460 view
->OnPropertyChanged(property
);
2462 // Moved from the 'if' branch on suggestion of Roman Pavlov
2466 BEGIN_EVENT_TABLE(wxResourceSymbolDialog
, wxDialog
)
2467 EVT_BUTTON(wxID_OK
, wxResourceSymbolDialog::OnOK
)
2468 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnComboBoxSelect
)
2469 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnSymbolNameUpdate
)
2472 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
2473 const wxSize
& size
, long style
):
2474 wxDialog(parent
, id
, title
, pos
, size
, style
)
2479 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x
, y
));
2483 m_nameCtrl
= new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX
, "",
2484 wxPoint(x
, y
), wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
|wxCB_SORT
);
2489 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x
, y
));
2493 m_idCtrl
= new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL
, "",
2494 wxPoint(x
, y
), wxSize(200, -1));
2498 (void) new wxButton(this, wxID_OK
, "OK", wxPoint(x
, y
), wxSize(80, -1));
2501 (void) new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(x
, y
), wxSize(80, -1));
2507 void wxResourceSymbolDialog::Init()
2510 defaultId
.Printf("%ld", m_symbolId
);
2512 m_nameCtrl
->SetValue(m_symbolName
);
2513 m_idCtrl
->SetValue(defaultId
);
2515 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl
);
2518 void wxResourceSymbolDialog::OnOK(wxCommandEvent
& event
)
2522 wxDialog::OnOK(event
);
2526 bool wxResourceSymbolDialog::CheckValues()
2528 wxString
nameStr(m_nameCtrl
->GetValue());
2529 wxString
idStr(m_idCtrl
->GetValue());
2530 int id
= atoi(idStr
);
2534 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2539 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2542 if (nameStr
.Contains(" "))
2544 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2547 if (nameStr
.Contains("="))
2549 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2552 if (nameStr
.IsNumber())
2554 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2557 // TODO: other checks on the name syntax.
2559 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr
))
2561 // If we change the id for an existing symbol, we need to:
2562 // 1) Check if there are any other resources currently using the original id.
2563 // If so, will need to change their id to the new id, in SetProperty.
2564 // 2) Remove the old symbol, add the new symbol.
2565 // In this check, we don't have to do this, but we need to do it in SetProperty.
2567 if (nameStr
== GetSymbol() && id
!= GetId())
2569 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2573 // If we change the name but not the id... we'll just need to remove and
2574 // re-add the symbol/id pair, in SetProperty.
2575 if (nameStr
!= GetSymbol() && id
== GetId())
2579 // What if we're changing both the name and the id?
2580 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2581 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2583 if (nameStr
!= GetSymbol() && id
!= GetId())
2585 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr
, id
))
2587 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2588 "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2601 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent
& WXUNUSED(event
))
2603 wxString
str(m_nameCtrl
->GetStringSelection());
2604 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2606 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2608 str2
.Printf("%d", id
);
2609 m_idCtrl
->SetValue(str2
);
2610 m_idCtrl
->Enable(FALSE
);
2614 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2616 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2618 str2
.Printf("%d", id
);
2619 m_idCtrl
->SetValue(str2
);
2621 m_idCtrl
->Enable(TRUE
);
2625 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent
& WXUNUSED(event
))
2627 wxString
str(m_nameCtrl
->GetValue());
2628 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2630 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2632 str2
.Printf("%d", id
);
2633 m_idCtrl
->SetValue(str2
);
2634 m_idCtrl
->Enable(FALSE
);
2638 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2640 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2642 str2
.Printf("%d", id
);
2643 m_idCtrl
->SetValue(str2
);
2645 m_idCtrl
->Enable(TRUE
);