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";
368 else if (m_propertyWindow
->GetWindowStyleFlag() & wxNO_BORDER
)
369 border
= "wxNO_BORDER";
371 border
= "default border";
373 return new wxProperty("border", border
, "string",
374 new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER",
375 "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", "default border", NULL
)));
381 bool wxWindowPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
383 wxFont
*font
= & m_propertyWindow
->GetFont();
384 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
386 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
389 m_propertyWindow
->SetFont(* newFont
);
390 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
393 resource
->SetFont(* newFont
);
399 else if (name
== "name")
401 // Remove old name from resource table, if it's there.
402 wxItemResource
*oldResource
= (wxItemResource
*)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow
->GetName());
405 // It's a top-level resource
406 m_propertyWindow
->SetName(property
->GetValue().StringValue());
407 oldResource
->SetName(property
->GetValue().StringValue());
408 wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow
->GetName(), oldResource
);
412 // It's a child of something; just set the name of the resource and the window.
413 m_propertyWindow
->SetName(property
->GetValue().StringValue());
414 m_propertyResource
->SetName(property
->GetValue().StringValue());
416 // Refresh the resource manager list, because the name changed.
417 wxResourceManager::GetCurrentResourceManager()->UpdateResourceList();
420 else if (name
== "title")
422 m_propertyWindow
->SetTitle(property
->GetValue().StringValue());
425 else if (name
== "x")
427 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
429 m_propertyWindow
->GetPosition(&x
, &y
);
430 int newX
= (int)property
->GetValue().IntegerValue();
433 // We need to convert to pixels if this is not a dialog or panel, but
434 // the parent resource specifies dialog units.
435 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
437 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
438 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
440 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(newX
, y
));
444 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
446 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
447 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
449 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(newX
, y
));
456 m_propertyWindow
->Move(pixelX
, y
);
457 resource
->SetSize(newX
, resource
->GetY(), resource
->GetWidth(), resource
->GetHeight());
461 else if (name
== "y")
463 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
465 m_propertyWindow
->GetPosition(&x
, &y
);
466 int newY
= (int)property
->GetValue().IntegerValue();
469 // We need to convert to pixels if this is not a dialog or panel, but
470 // the parent resource specifies dialog units.
471 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
473 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
474 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
476 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxPoint(x
, newY
));
480 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
482 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
483 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
485 wxPoint pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(x
, newY
));
492 m_propertyWindow
->Move(x
, pixelY
);
493 resource
->SetSize(resource
->GetX(), newY
, resource
->GetWidth(), resource
->GetHeight());
497 else if (name
== "width")
499 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
501 m_propertyWindow
->GetSize(&width
, &height
);
502 int newWidth
= (int)property
->GetValue().IntegerValue();
503 int pixelWidth
= newWidth
;
505 // We need to convert to pixels if this is not a dialog or panel, but
506 // the parent resource specifies dialog units.
507 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
509 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
510 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
512 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(newWidth
, height
));
516 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
518 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
519 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
521 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(newWidth
, height
));
526 if (width
!= pixelWidth
)
528 m_propertyWindow
->SetSize(pixelWidth
, height
);
529 resource
->SetSize(resource
->GetX(), resource
->GetY(), newWidth
, resource
->GetHeight());
533 else if (name
== "height")
535 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
537 m_propertyWindow
->GetSize(&width
, &height
);
538 int newHeight
= (int)property
->GetValue().IntegerValue();
539 int pixelHeight
= newHeight
;
541 // We need to convert to pixels if this is not a dialog or panel, but
542 // the parent resource specifies dialog units.
543 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
545 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
546 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
548 wxSize sz
= m_propertyWindow
->GetParent()->ConvertDialogToPixels(wxSize(width
, newHeight
));
552 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
554 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
555 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
557 wxSize sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(width
, newHeight
));
562 if (height
!= pixelHeight
)
564 m_propertyWindow
->SetSize(width
, pixelHeight
);
565 resource
->SetSize(resource
->GetX(), resource
->GetY(), resource
->GetWidth(), newHeight
);
569 else if (name
== "id")
571 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
574 wxString value
= property
->GetValue().StringValue();
576 wxString strName
= value
.Before('=');
577 wxString strId
= value
.After('=');
578 int id
= atoi(strId
);
580 wxString oldSymbolName
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource
->GetId());
581 int oldSymbolId
= resource
->GetId();
585 // If we change the id for an existing symbol, we need to:
586 // 1) Check if there are any other resources currently using the original id.
587 // If so, will need to change their id to the new id.
588 // 2) Remove the old symbol, add the new symbol.
589 // In this check, we don't have to do this, but we need to do it in SetProperty.
591 if (strName
== oldSymbolName
&& id
!= oldSymbolId
)
593 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
595 // It's OK to change just the id. But we'll need to change all matching ids in all resources,
596 // because ids are unique and changing one resource's id must change all identical ones.
597 wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId
, id
);
599 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
600 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
603 // If we change the name but not the id, we'll just need to remove and
604 // re-add the symbol/id pair.
605 if (strName
!= oldSymbolName
&& id
== oldSymbolId
)
607 wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
)) );
609 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
611 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
613 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
617 // What if we're changing both the name and the id?
618 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
619 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
621 if (strName
!= oldSymbolName
&& id
!= oldSymbolId
)
623 // Remove old symbol if it's not being used
624 if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource
, oldSymbolId
) &&
625 !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName
))
627 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName
);
630 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName
))
632 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName
, id
);
643 else if (name
== "border")
645 long borderStyle
= 0;
646 wxString val
= property
->GetValue().StringValue();
648 if (val
== "wxSIMPLE_BORDER")
649 borderStyle
= wxSIMPLE_BORDER
;
650 else if (val
== "wxRAISED_BORDER")
651 borderStyle
= wxRAISED_BORDER
;
652 else if (val
== "wxSUNKEN_BORDER")
653 borderStyle
= wxSUNKEN_BORDER
;
654 else if (val
== "wxDOUBLE_BORDER")
655 borderStyle
= wxDOUBLE_BORDER
;
656 else if (val
== "wxSTATIC_BORDER")
657 borderStyle
= wxSTATIC_BORDER
;
658 else if (val
== "wxNO_BORDER")
659 borderStyle
= wxNO_BORDER
;
661 SetWindowStyle(m_propertyWindow
, wxSIMPLE_BORDER
, FALSE
);
662 SetWindowStyle(m_propertyWindow
, wxRAISED_BORDER
, FALSE
);
663 SetWindowStyle(m_propertyWindow
, wxSUNKEN_BORDER
, FALSE
);
664 SetWindowStyle(m_propertyWindow
, wxDOUBLE_BORDER
, FALSE
);
665 SetWindowStyle(m_propertyWindow
, wxSTATIC_BORDER
, FALSE
);
666 SetWindowStyle(m_propertyWindow
, wxNO_BORDER
, FALSE
);
668 SetWindowStyle(m_propertyWindow
, borderStyle
, TRUE
);
670 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
671 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
678 void wxWindowPropertyInfo::GetPropertyNames(wxStringList
& names
)
687 if (!m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
689 names
.Add("fontPoints");
690 names
.Add("fontFamily");
691 names
.Add("fontStyle");
692 names
.Add("fontWeight");
693 names
.Add("fontUnderlined");
697 // Fill in the wxItemResource members to mirror the current window settings
698 bool wxWindowPropertyInfo::InstantiateResource(wxItemResource
*resource
)
700 // resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName());
702 // resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
703 wxString
str(m_propertyWindow
->GetName());
704 resource
->SetName(str
);
706 #if 0 // Why did we comment this out? Possibly because of rounding errors
707 // that will build up as the conversion is repeatedly done.
708 // so only do the conversion when a resize happens.
711 if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
712 m_propertyWindow
->GetClientSize(&w
, &h
);
714 m_propertyWindow
->GetSize(&w
, &h
);
716 m_propertyWindow
->GetPosition(&x
, &y
);
718 // We need to convert to dialog units if this is not a dialog or panel, but
719 // the parent resource specifies dialog units.
720 if (m_propertyWindow
->GetParent() && m_propertyWindow
->IsKindOf(CLASSINFO(wxControl
)))
722 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
723 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
725 wxPoint pt
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxPoint(x
, y
));
727 wxSize sz
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxSize(w
, h
));
731 else if (m_propertyWindow
->IsKindOf(CLASSINFO(wxPanel
)))
733 if (resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
735 wxPoint pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(x
, y
));
737 wxSize sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(w
, h
));
742 resource
->SetSize(x
, y
, w
, h
);
748 // Set the window style
749 void wxWindowPropertyInfo::SetWindowStyle(wxWindow
* win
, long style
, bool set
)
754 if ((win
->GetWindowStyleFlag() & style
) == style
)
758 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() - style
);
765 win
->SetWindowStyleFlag(win
->GetWindowStyleFlag() | style
);
774 wxProperty
*wxItemPropertyInfo::GetProperty(wxString
& name
)
776 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
777 wxFont
*font
= & itemWindow
->GetFont();
779 if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" ||
780 name
== "fontUnderlined")
781 return GetFontProperty(name
, font
);
782 else if (name
== "label" && itemWindow
->GetLabel())
783 return new wxProperty("label", m_propertyWindow
->GetLabel(), "string");
785 return wxWindowPropertyInfo::GetProperty(name
);
788 bool wxItemPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
790 wxControl
*itemWindow
= (wxControl
*)m_propertyWindow
;
792 wxFont
*font
= & itemWindow
->GetFont();
794 if (font
&& (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" ))
796 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
798 itemWindow
->SetFont(* newFont
);
805 itemWindow
->SetLabel(property
->GetValue().StringValue());
809 return wxWindowPropertyInfo::SetProperty(name
, property
);
812 void wxItemPropertyInfo::GetPropertyNames(wxStringList
& names
)
814 wxWindowPropertyInfo::GetPropertyNames(names
);
816 names
.Add("fontPoints");
817 names
.Add("fontFamily");
818 names
.Add("fontStyle");
819 names
.Add("fontWeight");
820 names
.Add("fontUnderlined");
823 bool wxItemPropertyInfo::InstantiateResource(wxItemResource
*resource
)
825 wxWindowPropertyInfo::InstantiateResource(resource
);
827 wxControl
*item
= (wxControl
*)m_propertyWindow
;
828 wxString
str(item
->GetLabel());
829 resource
->SetTitle(str
);
831 if (item
->GetFont().Ok())
832 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(item
->GetFont().GetPointSize(),
833 item
->GetFont().GetFamily(), item
->GetFont().GetStyle(), item
->GetFont().GetWeight(),
834 item
->GetFont().GetUnderlined(), item
->GetFont().GetFaceName()));
842 wxProperty
*wxButtonPropertyInfo::GetProperty(wxString
& name
)
844 return wxItemPropertyInfo::GetProperty(name
);
847 bool wxButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
849 return wxItemPropertyInfo::SetProperty(name
, property
);
852 void wxButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
854 wxItemPropertyInfo::GetPropertyNames(names
);
858 bool wxButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
860 return wxItemPropertyInfo::InstantiateResource(resource
);
867 wxProperty
*wxBitmapButtonPropertyInfo::GetProperty(wxString
& name
)
869 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
870 if (name
== "bitmapFilename")
872 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
873 wxString
str("none.bmp");
877 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
879 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
882 return wxButtonPropertyInfo::GetProperty(name
);
885 bool wxBitmapButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
887 wxBitmapButton
*button
= (wxBitmapButton
*)m_propertyWindow
;
888 if (name
== "bitmapFilename")
890 char *s
= property
->GetValue().StringValue();
891 if (s
&& wxFileExists(s
))
894 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
902 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button
);
905 wxString
oldResource(resource
->GetValue4());
906 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
907 resource
->SetValue4(resName
);
909 if (!oldResource
.IsNull())
910 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
913 button
->SetLabel(* bitmap
);
920 return wxButtonPropertyInfo::SetProperty(name
, property
);
923 void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
925 wxButtonPropertyInfo::GetPropertyNames(names
);
926 names
.Delete("label");
927 names
.Add("bitmapFilename");
930 bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
932 return wxItemPropertyInfo::InstantiateResource(resource
);
939 wxProperty
*wxStaticTextPropertyInfo::GetProperty(wxString
& name
)
941 return wxItemPropertyInfo::GetProperty(name
);
944 bool wxStaticTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
946 wxStaticText
* itemWindow
= (wxStaticText
*) m_propertyWindow
;
949 // Because setting a wxStaticText control's label may change the
950 // size, we must get the size and instantiate the resource immediately.
951 itemWindow
->SetLabel(property
->GetValue().StringValue());
954 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(itemWindow
);
956 m_propertyWindow
->GetSize(&w
, &h
);
957 // m_propertyWindow->GetPosition(&x, &y);
959 // We need to convert to dialog units if
960 // the parent resource specifies dialog units.
961 if (m_propertyWindow
->GetParent())
963 wxItemResource
* parentResource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
->GetParent());
964 if (parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
)
966 // wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y));
967 // x = pt.x; y = pt.y;
968 wxSize sz
= m_propertyWindow
->GetParent()->ConvertPixelsToDialog(wxSize(w
, h
));
972 resource
->SetSize(resource
->GetX(), resource
->GetY(), w
, h
);
976 return wxItemPropertyInfo::SetProperty(name
, property
);
979 void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
981 wxItemPropertyInfo::GetPropertyNames(names
);
985 bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
987 return wxItemPropertyInfo::InstantiateResource(resource
);
994 wxProperty
*wxStaticBitmapPropertyInfo::GetProperty(wxString
& name
)
996 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
997 if (name
== "bitmapFilename")
999 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
1000 wxString
str("none.bmp");
1004 str
= wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource
);
1006 return new wxProperty("bitmapFilename", str
.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"));
1009 return wxItemPropertyInfo::GetProperty(name
);
1012 bool wxStaticBitmapPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1014 wxStaticBitmap
*message
= (wxStaticBitmap
*)m_propertyWindow
;
1015 if (name
== "bitmapFilename")
1017 char *s
= property
->GetValue().StringValue();
1018 if (s
&& wxFileExists(s
))
1022 wxBitmap
*bitmap
= new wxBitmap(str
, wxBITMAP_TYPE_BMP
);
1030 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message
);
1033 wxString
oldResource(resource
->GetValue4());
1034 wxString resName
= wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str
);
1035 resource
->SetValue4(resName
);
1037 if (!oldResource
.IsNull())
1038 wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource
);
1041 message
->SetBitmap(* bitmap
);
1048 return wxItemPropertyInfo::SetProperty(name
, property
);
1051 void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList
& names
)
1053 wxItemPropertyInfo::GetPropertyNames(names
);
1054 names
.Add("bitmapFilename");
1057 bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1059 return wxItemPropertyInfo::InstantiateResource(resource
);
1066 wxProperty
*wxTextPropertyInfo::GetProperty(wxString
& name
)
1068 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1069 if (name
== "value")
1070 return new wxProperty("value", text
->GetValue(), "string");
1071 else if (name
== "password")
1073 bool isPassword
= ((text
->GetWindowStyleFlag() & wxTE_PASSWORD
) == wxTE_PASSWORD
);
1074 return new wxProperty("password", isPassword
, "bool");
1076 else if (name
== "readonly")
1078 bool isReadOnly
= ((text
->GetWindowStyleFlag() & wxTE_READONLY
) == wxTE_READONLY
);
1079 return new wxProperty("readonly", isReadOnly
, "bool");
1082 return wxItemPropertyInfo::GetProperty(name
);
1085 bool wxTextPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1087 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1088 if (name
== "value")
1090 text
->SetValue(property
->GetValue().StringValue());
1093 else if (name
== "password")
1095 long flag
= text
->GetWindowStyleFlag();
1096 if (property
->GetValue().BoolValue())
1098 if ((flag
& wxTE_PASSWORD
) != wxTE_PASSWORD
)
1099 flag
|= wxTE_PASSWORD
;
1103 if ((flag
& wxTE_PASSWORD
) == wxTE_PASSWORD
)
1104 flag
-= wxTE_PASSWORD
;
1106 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1107 resource
->SetStyle(flag
);
1109 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1112 else if (name
== "readonly")
1114 long flag
= text
->GetWindowStyleFlag();
1115 if (property
->GetValue().BoolValue())
1117 if ((flag
& wxTE_READONLY
) != wxTE_READONLY
)
1118 flag
|= wxTE_READONLY
;
1122 if ((flag
& wxTE_READONLY
) == wxTE_READONLY
)
1123 flag
-= wxTE_READONLY
;
1125 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text
);
1126 resource
->SetStyle(flag
);
1128 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text
, this);
1132 return wxItemPropertyInfo::SetProperty(name
, property
);
1135 void wxTextPropertyInfo::GetPropertyNames(wxStringList
& names
)
1137 wxItemPropertyInfo::GetPropertyNames(names
);
1139 names
.Add("readonly");
1140 names
.Add("password");
1143 bool wxTextPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1145 wxTextCtrl
*text
= (wxTextCtrl
*)m_propertyWindow
;
1146 wxString
str(text
->GetValue());
1147 resource
->SetValue4(str
);
1149 return wxItemPropertyInfo::InstantiateResource(resource
);
1156 wxProperty
*wxListBoxPropertyInfo::GetProperty(wxString
& name
)
1158 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1159 if (name
== "values")
1161 wxStringList
*stringList
= new wxStringList
;
1163 for (i
= 0; i
< listBox
->GetCount(); i
++)
1164 stringList
->Add(listBox
->GetString(i
));
1166 return new wxProperty(name
, stringList
, "stringlist");
1168 else if (name
== "multiple")
1170 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1174 char *mult
= "wxLB_SINGLE";
1176 if ((listBox
->GetWindowStyleFlag() & wxLB_MULTIPLE
) != 0)
1177 mult
= "wxLB_MULTIPLE";
1178 else if ((listBox
->GetWindowStyleFlag() & wxLB_EXTENDED
) != 0)
1179 mult
= "wxLB_EXTENDED";
1181 mult
= "wxLB_SINGLE";
1183 return new wxProperty("multiple", mult
, "string",
1184 new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED",
1188 return wxItemPropertyInfo::GetProperty(name
);
1191 bool wxListBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1193 wxListBox
*listBox
= (wxListBox
*)m_propertyWindow
;
1194 if (name
== "values")
1197 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1200 char *s
= expr
->StringValue();
1203 expr
= expr
->GetNext();
1207 else if (name
== "multiple")
1209 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, FALSE
);
1210 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, FALSE
);
1211 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, FALSE
);
1213 wxString
str(property
->GetValue().StringValue());
1214 if (str
== "wxLB_MULTIPLE")
1215 SetWindowStyle(m_propertyWindow
, wxLB_MULTIPLE
, TRUE
);
1216 else if (str
== "wxLB_EXTENDED")
1217 SetWindowStyle(m_propertyWindow
, wxLB_EXTENDED
, TRUE
);
1219 SetWindowStyle(m_propertyWindow
, wxLB_SINGLE
, TRUE
);
1221 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox
);
1223 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1224 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox
, this);
1228 return wxItemPropertyInfo::SetProperty(name
, property
);
1231 void wxListBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1233 wxItemPropertyInfo::GetPropertyNames(names
);
1234 names
.Add("values");
1235 names
.Add("multiple");
1238 bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1240 wxListBox
*lbox
= (wxListBox
*)m_propertyWindow
;
1241 // This will be set for the wxItemResource on reading or in SetProperty
1242 // resource->SetValue1(lbox->GetSelectionMode());
1244 if (lbox
->GetCount() == 0)
1245 resource
->SetStringValues(NULL
);
1250 for (i
= 0; i
< lbox
->GetCount(); i
++)
1251 slist
.Add(lbox
->GetString(i
));
1253 resource
->SetStringValues(slist
);
1255 return wxItemPropertyInfo::InstantiateResource(resource
);
1262 wxProperty
*wxChoicePropertyInfo::GetProperty(wxString
& name
)
1264 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1265 if (name
== "values")
1267 wxStringList
* stringList
= new wxStringList
;
1269 for (i
= 0; i
< choice
->GetCount(); i
++)
1270 stringList
->Add(choice
->GetString(i
));
1272 return new wxProperty(name
, stringList
, "stringlist");
1275 return wxItemPropertyInfo::GetProperty(name
);
1278 bool wxChoicePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1280 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1281 if (name
== "values")
1284 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1287 char *s
= expr
->StringValue();
1290 expr
= expr
->GetNext();
1292 if (choice
->GetCount() > 0)
1293 choice
->SetSelection(0);
1297 return wxItemPropertyInfo::SetProperty(name
, property
);
1300 void wxChoicePropertyInfo::GetPropertyNames(wxStringList
& names
)
1302 wxItemPropertyInfo::GetPropertyNames(names
);
1303 names
.Add("values");
1306 bool wxChoicePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1308 wxChoice
*choice
= (wxChoice
*)m_propertyWindow
;
1310 if (choice
->GetCount() == 0)
1311 resource
->SetStringValues(NULL
);
1316 for (i
= 0; i
< choice
->GetCount(); i
++)
1317 slist
.Add(choice
->GetString(i
));
1319 resource
->SetStringValues(slist
);
1321 return wxItemPropertyInfo::InstantiateResource(resource
);
1328 wxProperty
*wxComboBoxPropertyInfo::GetProperty(wxString
& name
)
1330 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1331 if (name
== "values")
1333 wxStringList
*stringList
= new wxStringList
;
1335 for (i
= 0; i
< choice
->GetCount(); i
++)
1336 stringList
->Add(choice
->GetString(i
));
1338 return new wxProperty(name
, stringList
, "stringlist");
1340 else if (name
== "sort")
1342 bool sort
= ((m_propertyWindow
->GetWindowStyleFlag() & wxCB_SORT
) == wxCB_SORT
);
1343 return new wxProperty(name
, sort
, "bool");
1345 else if (name
== "style")
1347 wxString
styleStr("dropdown");
1348 if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_SIMPLE
)
1349 styleStr
= "simple";
1350 else if (m_propertyWindow
->GetWindowStyleFlag() & wxCB_READONLY
)
1351 styleStr
= "readonly";
1353 styleStr
= "dropdown";
1355 return new wxProperty(name
, styleStr
, "string",
1356 new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
1360 return wxItemPropertyInfo::GetProperty(name
);
1363 bool wxComboBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1365 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1366 if (name
== "values")
1369 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1372 char *s
= expr
->StringValue();
1375 expr
= expr
->GetNext();
1377 if (choice
->GetCount() > 0)
1378 choice
->SetSelection(0);
1381 else if (name
== "sort")
1383 SetWindowStyle(m_propertyWindow
, wxCB_SORT
, property
->GetValue().BoolValue());
1385 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1386 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1388 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1391 else if (name
== "style")
1393 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, FALSE
);
1394 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, FALSE
);
1395 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, FALSE
);
1397 wxString
styleStr(property
->GetValue().StringValue());
1398 if (styleStr
== "simple")
1399 SetWindowStyle(m_propertyWindow
, wxCB_SIMPLE
, TRUE
);
1400 else if (styleStr
== "dropdown")
1401 SetWindowStyle(m_propertyWindow
, wxCB_DROPDOWN
, TRUE
);
1402 else if (styleStr
== "readonly")
1403 SetWindowStyle(m_propertyWindow
, wxCB_READONLY
, TRUE
);
1406 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1407 resource
->SetStyle(m_propertyWindow
->GetWindowStyleFlag());
1409 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow
, this);
1414 return wxItemPropertyInfo::SetProperty(name
, property
);
1417 void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1419 wxItemPropertyInfo::GetPropertyNames(names
);
1420 names
.Add("values");
1425 bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1427 wxComboBox
*choice
= (wxComboBox
*)m_propertyWindow
;
1429 if (choice
->GetCount() == 0)
1430 resource
->SetStringValues(NULL
);
1435 for (i
= 0; i
< choice
->GetCount(); i
++)
1436 slist
.Add(choice
->GetString(i
));
1438 resource
->SetStringValues(slist
);
1440 return wxItemPropertyInfo::InstantiateResource(resource
);
1447 wxProperty
*wxRadioBoxPropertyInfo::GetProperty(wxString
& name
)
1449 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1450 if (name
== "numberRowsOrCols")
1452 // FIXME: Set/GetNumberOfRowsOrCols only implemented on Motif, MSW and Mac
1453 #if defined(__WXMSW__) || defined(__WXMOTIF__) || defined(__WXMAC__)
1454 return new wxProperty("numberRowsOrCols", (long)radioBox
->GetNumberOfRowsOrCols(), "integer");
1456 return new wxProperty("numberRowsOrCols", (long)1, "integer");
1459 if (name
== "orientation")
1462 if (m_propertyWindow
->GetWindowStyleFlag() & wxRA_SPECIFY_COLS
)
1463 orient
= "wxRA_SPECIFY_COLS";
1465 orient
= "wxRA_SPECIFY_ROWS";
1467 return new wxProperty("orientation", orient
, "string",
1468 new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS",
1471 else if (name
== "values")
1473 wxStringList
*stringList
= new wxStringList
;
1475 for (i
= 0; i
< radioBox
->GetCount(); i
++)
1476 stringList
->Add(radioBox
->GetString(i
));
1478 return new wxProperty(name
, stringList
, "stringlist");
1480 return wxItemPropertyInfo::GetProperty(name
);
1483 bool wxRadioBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1485 wxRadioBox
*radioBox
= (wxRadioBox
*)m_propertyWindow
;
1486 if (name
== "numberRowsOrCols")
1488 // FIXME: Set/GetNumberOfRowsOrCols only implemented on Motif, MSW and Mac
1489 #if defined(__WXMSW__) || defined(__WXMOTIF__) || defined(__WXMAC__)
1490 wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox
);
1492 radioBox
->SetNumberOfRowsOrCols((int)property
->GetValue().IntegerValue());
1493 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this);
1497 else if (name
== "orientation")
1499 long windowStyle
= radioBox
->GetWindowStyleFlag();
1500 wxString
val(property
->GetValue().StringValue());
1501 if (val
== "wxRA_SPECIFY_COLS")
1503 if (windowStyle
& wxRA_SPECIFY_ROWS
)
1504 windowStyle
-= wxRA_SPECIFY_ROWS
;
1505 windowStyle
|= wxRA_SPECIFY_COLS
;
1509 if (windowStyle
& wxRA_SPECIFY_COLS
)
1510 windowStyle
-= wxRA_SPECIFY_COLS
;
1511 windowStyle
|= wxRA_SPECIFY_ROWS
;
1513 wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox
);
1515 radioBox
->SetWindowStyleFlag(windowStyle
);
1516 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox
);
1517 resource
->SetStyle(windowStyle
);
1518 resource
->SetSize(resource
->GetX(), resource
->GetY(), -1, -1); // Let it calculate it's own size
1520 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this, FALSE
);
1523 else if (name
== "values")
1525 // Set property into *resource*, not wxRadioBox, and then recreate
1526 // the wxRadioBox. This is because we can't dynamically set the strings
1528 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1532 wxStringList stringList
;
1533 wxPropertyValue
*expr
= property
->GetValue().GetFirst();
1536 char *s
= expr
->StringValue();
1539 expr
= expr
->GetNext();
1541 resource
->SetStringValues(stringList
);
1542 resource
->SetSize(resource
->GetX(), resource
->GetY(), -1, -1); // Let it calculate it's own size
1543 m_propertyWindow
= wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox
, this, FALSE
);
1546 else if (name
== "fontPoints" || name
== "fontFamily" || name
== "fontStyle" || name
== "fontWeight" || name
== "fontUnderlined" )
1548 wxFont
*font
= & m_propertyWindow
->GetFont();
1551 wxFont
*newFont
= SetFontProperty(name
, property
, font
);
1554 wxItemResource
* resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
1557 resource
->SetFont(* newFont
);
1560 wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox
);
1562 radioBox
->SetFont(* newFont
);
1563 radioBox
->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH
| wxSIZE_AUTO_HEIGHT
);
1568 return wxItemPropertyInfo::SetProperty(name
, property
);
1571 void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1573 wxItemPropertyInfo::GetPropertyNames(names
);
1575 names
.Add("values");
1576 names
.Add("orientation");
1577 names
.Add("numberRowsOrCols");
1580 bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1582 wxRadioBox
*rbox
= (wxRadioBox
*)m_propertyWindow
;
1583 // Take strings from resource instead
1586 if (rbox->GetCount() == 0)
1587 resource->SetStringValues(NULL);
1590 wxStringList *slist = new wxStringList;
1592 for (i = 0; i < rbox->GetCount(); i++)
1593 slist->Add(rbox->GetString(i));
1595 resource->SetStringValues(slist);
1598 // FIXME: Set/GetNumberOfRowsOrCols only implemented on Motif, MSW and Mac
1599 #if defined(__WXMSW__) || defined(__WXMOTIF__) || defined(__WXMAC__)
1600 resource
->SetValue1(rbox
->GetNumberOfRowsOrCols());
1602 resource
->SetValue1(1);
1604 return wxItemPropertyInfo::InstantiateResource(resource
);
1611 wxProperty
*wxGroupBoxPropertyInfo::GetProperty(wxString
& name
)
1613 return wxItemPropertyInfo::GetProperty(name
);
1616 bool wxGroupBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1618 return wxItemPropertyInfo::SetProperty(name
, property
);
1621 void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1623 wxItemPropertyInfo::GetPropertyNames(names
);
1627 bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1629 return wxItemPropertyInfo::InstantiateResource(resource
);
1636 wxProperty
*wxCheckBoxPropertyInfo::GetProperty(wxString
& name
)
1638 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1639 if (name
== "value")
1640 return new wxProperty("value", checkBox
->GetValue(), "bool");
1642 return wxItemPropertyInfo::GetProperty(name
);
1645 bool wxCheckBoxPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1647 wxCheckBox
*checkBox
= (wxCheckBox
*)m_propertyWindow
;
1648 if (name
== "value")
1650 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1654 return wxItemPropertyInfo::SetProperty(name
, property
);
1657 void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList
& names
)
1659 wxItemPropertyInfo::GetPropertyNames(names
);
1664 bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1666 wxCheckBox
*cbox
= (wxCheckBox
*)m_propertyWindow
;
1667 resource
->SetValue1(cbox
->GetValue());
1668 return wxItemPropertyInfo::InstantiateResource(resource
);
1675 wxProperty
*wxRadioButtonPropertyInfo::GetProperty(wxString
& name
)
1677 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1678 if (name
== "value")
1679 return new wxProperty("value", checkBox
->GetValue(), "bool");
1681 return wxItemPropertyInfo::GetProperty(name
);
1684 bool wxRadioButtonPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1686 wxRadioButton
*checkBox
= (wxRadioButton
*)m_propertyWindow
;
1687 if (name
== "value")
1689 checkBox
->SetValue((bool)property
->GetValue().BoolValue());
1693 return wxItemPropertyInfo::SetProperty(name
, property
);
1696 void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList
& names
)
1698 wxItemPropertyInfo::GetPropertyNames(names
);
1703 bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1705 wxRadioButton
*cbox
= (wxRadioButton
*)m_propertyWindow
;
1706 resource
->SetValue1(cbox
->GetValue());
1707 return wxItemPropertyInfo::InstantiateResource(resource
);
1714 wxProperty
*wxSliderPropertyInfo::GetProperty(wxString
& name
)
1716 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1717 if (name
== "value")
1718 return new wxProperty("value", (long)slider
->GetValue(), "integer");
1719 else if (name
== "orientation")
1722 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1723 pos
= "wxHORIZONTAL";
1727 return new wxProperty("orientation", pos
, "string",
1728 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1731 else if (name
== "minValue")
1732 return new wxProperty("minValue", (long)slider
->GetMin(), "integer");
1733 else if (name
== "maxValue")
1734 return new wxProperty("maxValue", (long)slider
->GetMax(), "integer");
1736 return wxItemPropertyInfo::GetProperty(name
);
1739 bool wxSliderPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1741 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1742 if (name
== "value")
1744 slider
->SetValue((int)property
->GetValue().IntegerValue());
1747 else if (name
== "orientation")
1749 long windowStyle
= slider
->GetWindowStyleFlag();
1750 long oldWindowStyle
= windowStyle
;
1751 wxString
val(property
->GetValue().StringValue());
1752 if (val
== "wxHORIZONTAL")
1754 if (windowStyle
& wxVERTICAL
)
1755 windowStyle
-= wxVERTICAL
;
1756 windowStyle
|= wxHORIZONTAL
;
1760 if (windowStyle
& wxHORIZONTAL
)
1761 windowStyle
-= wxHORIZONTAL
;
1762 windowStyle
|= wxVERTICAL
;
1765 if (oldWindowStyle
== windowStyle
)
1768 slider
->SetWindowStyleFlag(windowStyle
);
1770 // If the window style has changed, we swap the width and height parameters.
1772 slider
->GetSize(&w
, &h
);
1774 slider
= (wxSlider
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider
, this);
1775 slider
->SetSize(-1, -1, h
, w
);
1776 m_propertyWindow
= slider
;
1780 else if (name
== "minValue")
1782 slider
->SetRange((int)property
->GetValue().IntegerValue(), slider
->GetMax());
1785 else if (name
== "maxValue")
1787 slider
->SetRange(slider
->GetMin(), (int)property
->GetValue().IntegerValue());
1791 return wxItemPropertyInfo::SetProperty(name
, property
);
1794 void wxSliderPropertyInfo::GetPropertyNames(wxStringList
& names
)
1796 wxItemPropertyInfo::GetPropertyNames(names
);
1798 names
.Add("orientation");
1799 names
.Add("minValue");
1800 names
.Add("maxValue");
1803 bool wxSliderPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1805 wxSlider
*slider
= (wxSlider
*)m_propertyWindow
;
1806 resource
->SetValue1(slider
->GetValue());
1807 resource
->SetValue2(slider
->GetMin());
1808 resource
->SetValue3(slider
->GetMax());
1809 return wxItemPropertyInfo::InstantiateResource(resource
);
1816 wxProperty
*wxGaugePropertyInfo::GetProperty(wxString
& name
)
1818 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1819 if (name
== "value")
1820 return new wxProperty("value", (long)gauge
->GetValue(), "integer");
1821 else if (name
== "maxValue")
1822 return new wxProperty("maxValue", (long)gauge
->GetRange(), "integer");
1824 return wxItemPropertyInfo::GetProperty(name
);
1827 bool wxGaugePropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1829 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1830 if (name
== "value")
1832 gauge
->SetValue((int)property
->GetValue().IntegerValue());
1835 else if (name
== "maxValue")
1837 gauge
->SetRange((int)property
->GetValue().IntegerValue());
1841 return wxItemPropertyInfo::SetProperty(name
, property
);
1844 void wxGaugePropertyInfo::GetPropertyNames(wxStringList
& names
)
1846 wxItemPropertyInfo::GetPropertyNames(names
);
1848 names
.Add("maxValue");
1851 bool wxGaugePropertyInfo::InstantiateResource(wxItemResource
*resource
)
1853 wxGauge
*gauge
= (wxGauge
*)m_propertyWindow
;
1854 resource
->SetValue1(gauge
->GetValue());
1855 resource
->SetValue2(gauge
->GetRange());
1856 return wxItemPropertyInfo::InstantiateResource(resource
);
1863 wxProperty
*wxScrollBarPropertyInfo::GetProperty(wxString
& name
)
1865 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1866 if (name
== "thumbPosition")
1867 return new wxProperty("value", (long)scrollBar
->GetThumbPosition(), "integer");
1868 else if (name
== "orientation")
1871 if (m_propertyWindow
->GetWindowStyleFlag() & wxHORIZONTAL
)
1872 pos
= "wxHORIZONTAL";
1876 return new wxProperty("orientation", pos
, "string",
1877 new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
1880 else if (name
== "pageSize")
1882 int pageLength
= scrollBar
->GetPageSize();
1884 return new wxProperty("pageSize", (long)pageLength
, "integer");
1886 else if (name
== "thumbSize")
1888 int thumbSize
= scrollBar
->GetThumbSize();
1890 return new wxProperty("thumbSize", (long)thumbSize
, "integer");
1892 else if (name
== "range")
1894 int range
= scrollBar
->GetRange();
1895 return new wxProperty("range", (long)range
, "integer");
1898 return wxItemPropertyInfo::GetProperty(name
);
1901 bool wxScrollBarPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
1903 wxScrollBar
*scrollBar
= (wxScrollBar
*)m_propertyWindow
;
1904 if (name
== "thumbPosition")
1906 scrollBar
->SetThumbPosition((int)property
->GetValue().IntegerValue());
1909 else if (name
== "orientation")
1911 long windowStyle
= scrollBar
->GetWindowStyleFlag();
1912 long oldWindowStyle
= windowStyle
;
1913 wxString
val(property
->GetValue().StringValue());
1914 if (val
== "wxHORIZONTAL")
1916 if (windowStyle
& wxVERTICAL
)
1917 windowStyle
-= wxVERTICAL
;
1918 windowStyle
|= wxHORIZONTAL
;
1922 if (windowStyle
& wxHORIZONTAL
)
1923 windowStyle
-= wxHORIZONTAL
;
1924 windowStyle
|= wxVERTICAL
;
1927 if (oldWindowStyle
== windowStyle
)
1930 scrollBar
->SetWindowStyleFlag(windowStyle
);
1932 // If the window style has changed, we swap the width and height parameters.
1934 // scrollBar->GetSize(&w, &h);
1935 wxItemResource
*item
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar
);
1937 item
->SetSize(item
->GetX(), item
->GetY(), item
->GetHeight(), item
->GetWidth());
1938 item
->SetStyle(windowStyle
);
1941 scrollBar
= (wxScrollBar
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar
, this);
1942 m_propertyWindow
= scrollBar
;
1946 else if (name
== "pageSize")
1948 int pos
= scrollBar
->GetThumbPosition();
1949 int range
= scrollBar
->GetRange();
1950 int thumbSize
= scrollBar
->GetThumbSize();
1951 scrollBar
->SetScrollbar(pos
, thumbSize
, range
, (int)property
->GetValue().IntegerValue());
1954 else if (name
== "thumbSize")
1956 int pos
= scrollBar
->GetThumbPosition();
1957 int range
= scrollBar
->GetRange();
1958 int pageSize
= scrollBar
->GetPageSize();
1959 scrollBar
->SetScrollbar(pos
, (int)property
->GetValue().IntegerValue(), range
, pageSize
);
1962 else if (name
== "range")
1964 int pos
= scrollBar
->GetThumbPosition();
1965 int thumbSize
= scrollBar
->GetThumbSize();
1966 int pageSize
= scrollBar
->GetPageSize();
1967 scrollBar
->SetScrollbar(pos
, thumbSize
, (int)property
->GetValue().IntegerValue(), pageSize
);
1971 return wxItemPropertyInfo::SetProperty(name
, property
);
1974 void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList
& names
)
1976 wxItemPropertyInfo::GetPropertyNames(names
);
1977 names
.Add("orientation");
1978 names
.Add("thumbPosition");
1979 names
.Add("thumbSize");
1980 names
.Add("pageSize");
1983 // Remove some properties we don't inherit
1984 names
.Delete("fontPoints");
1985 names
.Delete("fontFamily");
1986 names
.Delete("fontStyle");
1987 names
.Delete("fontWeight");
1988 names
.Delete("fontUnderlined");
1991 bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource
*resource
)
1993 wxScrollBar
*sbar
= (wxScrollBar
*)m_propertyWindow
;
1995 int thumbPosition
= sbar
->GetThumbPosition();
1996 int thumbSize
= sbar
->GetThumbSize();
1997 int pageSize
= sbar
->GetPageSize();
1998 int range
= sbar
->GetRange();
2000 resource
->SetValue1(thumbPosition
);
2001 resource
->SetValue2(thumbSize
);
2002 resource
->SetValue3(range
);
2003 resource
->SetValue5(pageSize
);
2005 return wxItemPropertyInfo::InstantiateResource(resource
);
2012 // next functions may contain unreacheable code
2013 # pragma message disable codcauunr
2016 wxProperty
*wxPanelPropertyInfo::GetProperty(wxString
& name
)
2018 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
2021 wxFont *labelFont = panelWindow->GetLabelFont();
2022 wxFont *buttonFont = panelWindow->GetButtonFont();
2024 if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" ||
2025 name == "labelFontUnderlined")
2026 return GetFontProperty(name, labelFont);
2027 else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" ||
2028 name == "buttonFontUnderlined")
2029 return GetFontProperty(name, buttonFont);
2035 if (panelWindow
->GetWindowStyleFlag() & wxNO_3D
)
2038 userColours
= FALSE
;
2040 return new wxProperty(name
, (bool)userColours
, "bool");
2042 else if (name
== "backgroundColour")
2044 wxColour
col(panelWindow
->GetBackgroundColour());
2046 wxDecToHex(col
.Red(), buf
);
2047 wxDecToHex(col
.Green(), buf
+2);
2048 wxDecToHex(col
.Blue(), buf
+4);
2050 return new wxProperty(name
, buf
, "string", new wxColourListValidator
);
2052 else if (name
== "title")
2054 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2056 return new wxProperty(name
, resource
->GetTitle(), "string");
2058 return new wxProperty(name
, "Could not get title", "string");
2060 else if (name
== "caption")
2062 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxCAPTION
) == wxCAPTION
),
2065 else if (name
== "systemMenu")
2067 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxSYSTEM_MENU
) == wxSYSTEM_MENU
),
2070 else if (name
== "thickFrame")
2072 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxTHICK_FRAME
) == wxTHICK_FRAME
),
2075 else if (name
== "modal")
2077 return new wxProperty(name
, ((panelWindow
->GetWindowStyleFlag() & wxDIALOG_MODAL
) == wxDIALOG_MODAL
),
2080 else if (name
== "useSystemDefaults")
2082 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2083 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) == wxRESOURCE_USE_DEFAULTS
),
2086 else if (name
== "useDialogUnits")
2088 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2089 return new wxProperty(name
, ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == wxRESOURCE_DIALOG_UNITS
),
2093 return wxWindowPropertyInfo::GetProperty(name
);
2096 bool wxPanelPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
2098 wxPanel
*panelWindow
= (wxPanel
*)m_propertyWindow
;
2100 wxFont *labelFont = panelWindow->GetLabelFont();
2101 wxFont *buttonFont = panelWindow->GetButtonFont();
2103 if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" ))
2105 wxFont *newFont = SetFontProperty(name, property, labelFont);
2107 panelWindow->SetLabelFont(* newFont);
2110 else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" ))
2112 wxFont *newFont = SetFontProperty(name, property, buttonFont);
2114 panelWindow->SetButtonFont(* newFont);
2121 bool userColours
= property
->GetValue().BoolValue();
2125 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) != wxNO_3D
)
2126 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() | wxNO_3D
);
2130 if ((panelWindow
->GetWindowStyleFlag() & wxNO_3D
) == wxNO_3D
)
2131 panelWindow
->SetWindowStyleFlag(panelWindow
->GetWindowStyleFlag() - wxNO_3D
);
2133 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2134 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2136 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2139 else if (name
== "backgroundColour")
2141 char *hex
= property
->GetValue().StringValue();
2142 int r
= wxHexToDec(hex
);
2143 int g
= wxHexToDec(hex
+2);
2144 int b
= wxHexToDec(hex
+4);
2146 wxColour
col(r
,g
,b
);
2147 panelWindow
->SetBackgroundColour(col
);
2148 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2149 m_propertyWindow
= panelWindow
;
2152 else if (name
== "title")
2154 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2157 resource
->SetTitle(property
->GetValue().StringValue());
2163 else if (name
== "caption")
2165 SetWindowStyle(panelWindow
, wxCAPTION
, property
->GetValue().BoolValue());
2167 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2168 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2171 else if (name
== "thickFrame")
2173 SetWindowStyle(panelWindow
, wxTHICK_FRAME
, property
->GetValue().BoolValue());
2175 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2176 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2179 else if (name
== "systemMenu")
2181 SetWindowStyle(panelWindow
, wxSYSTEM_MENU
, property
->GetValue().BoolValue());
2183 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2184 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2187 else if (name
== "modal")
2189 SetWindowStyle(panelWindow
, wxDIALOG_MODAL
, property
->GetValue().BoolValue());
2191 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2192 resource
->SetStyle(panelWindow
->GetWindowStyleFlag());
2195 else if (name
== "useSystemDefaults")
2197 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2198 bool useDefaults
= property
->GetValue().BoolValue();
2199 long style
= resource
->GetResourceStyle();
2202 if ((style
& wxRESOURCE_USE_DEFAULTS
) == 0)
2203 style
|= wxRESOURCE_USE_DEFAULTS
;
2207 if ((style
& wxRESOURCE_USE_DEFAULTS
) != 0)
2208 style
-= wxRESOURCE_USE_DEFAULTS
;
2210 resource
->SetResourceStyle(style
);
2211 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2214 else if (name
== "useDialogUnits")
2216 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow
);
2217 bool useDialogUnits
= property
->GetValue().BoolValue();
2218 long style
= resource
->GetResourceStyle();
2221 if ((style
& wxRESOURCE_DIALOG_UNITS
) == 0)
2223 style
|= wxRESOURCE_DIALOG_UNITS
;
2224 ConvertDialogUnits(TRUE
); // Convert all resources
2229 if ((style
& wxRESOURCE_DIALOG_UNITS
) != 0)
2231 style
-= wxRESOURCE_DIALOG_UNITS
;
2232 ConvertDialogUnits(FALSE
); // Convert all resources
2235 resource
->SetResourceStyle(style
);
2236 panelWindow
= (wxPanel
*)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow
, this);
2237 m_propertyWindow
= panelWindow
;
2238 // TODO: need to regenerate the width and height properties else they'll be inconsistent.
2242 return wxWindowPropertyInfo::SetProperty(name
, property
);
2245 # pragma message enable codcauunr
2248 void wxPanelPropertyInfo::GetPropertyNames(wxStringList
& names
)
2250 wxWindowPropertyInfo::GetPropertyNames(names
);
2254 names
.Add("backgroundColour");
2255 names
.Add("caption");
2256 names
.Add("systemMenu");
2257 names
.Add("thickFrame");
2258 names
.Add("useSystemDefaults");
2259 names
.Add("useDialogUnits");
2263 bool wxPanelPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2265 wxPanel
*panel
= (wxPanel
*)m_propertyWindow
;
2266 if (panel
->GetFont().Ok())
2267 resource
->SetFont(* wxTheFontList
->FindOrCreateFont(panel
->GetFont().GetPointSize(),
2268 panel
->GetFont().GetFamily(), panel
->GetFont().GetStyle(), panel
->GetFont().GetWeight(),
2269 panel
->GetFont().GetUnderlined(), panel
->GetFont().GetFaceName()));
2271 resource
->SetBackgroundColour(wxColour(panel
->GetBackgroundColour()));
2273 return wxWindowPropertyInfo::InstantiateResource(resource
);
2276 // Convert this dialog, and its children, to or from dialog units
2277 void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits
)
2279 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow
);
2285 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2286 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2290 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2291 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2293 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2295 wxNode
* node
= m_propertyWindow
->GetChildren().First();
2298 wxWindow
* child
= (wxWindow
*) node
->Data();
2299 if (child
->IsKindOf(CLASSINFO(wxControl
)))
2301 resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(child
);
2304 sz
= m_propertyWindow
->ConvertPixelsToDialog(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2305 pt
= m_propertyWindow
->ConvertPixelsToDialog(wxPoint(resource
->GetX(), resource
->GetY()));
2309 sz
= m_propertyWindow
->ConvertDialogToPixels(wxSize(resource
->GetWidth(), resource
->GetHeight()));
2310 pt
= m_propertyWindow
->ConvertDialogToPixels(wxPoint(resource
->GetX(), resource
->GetY()));
2312 resource
->SetSize(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
2314 node
= node
->Next();
2323 wxProperty
*wxDialogPropertyInfo::GetProperty(wxString
& name
)
2325 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2326 if (name
== "modal")
2328 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2332 bool modal
= (resource
->GetValue1() != 0);
2333 return new wxProperty(name
, modal
, "bool");
2336 return wxPanelPropertyInfo::GetProperty(name
);
2339 bool wxDialogPropertyInfo::SetProperty(wxString
& name
, wxProperty
*property
)
2341 wxDialog
*dialogWindow
= (wxDialog
*)m_propertyWindow
;
2343 if (name
== "modal")
2345 wxItemResource
*resource
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow
);
2349 resource
->SetValue1(property
->GetValue().BoolValue());
2353 return wxPanelPropertyInfo::SetProperty(name
, property
);
2356 void wxDialogPropertyInfo::GetPropertyNames(wxStringList
& names
)
2358 wxPanelPropertyInfo::GetPropertyNames(names
);
2363 bool wxDialogPropertyInfo::InstantiateResource(wxItemResource
*resource
)
2365 wxDialog
*dialog
= (wxDialog
*)m_propertyWindow
;
2366 wxString
str(dialog
->GetTitle());
2367 resource
->SetTitle(str
);
2369 return wxPanelPropertyInfo::InstantiateResource(resource
);
2377 int wxStringToFontWeight(wxString
& val
)
2379 if (val
== "wxBOLD") return wxBOLD
;
2380 else if (val
== "wxLIGHT") return wxLIGHT
;
2381 else return wxNORMAL
;
2384 int wxStringToFontStyle(wxString
& val
)
2386 if (val
== "wxITALIC") return wxITALIC
;
2387 else if (val
== "wxSLANT") return wxSLANT
;
2388 else return wxNORMAL
;
2391 int wxStringToFontFamily(wxString
& val
)
2393 if (val
== "wxDECORATIVE") return wxDECORATIVE
;
2394 else if (val
== "wxROMAN") return wxROMAN
;
2395 else if (val
== "wxSCRIPT") return wxSCRIPT
;
2396 else if (val
== "wxMODERN") return wxMODERN
;
2397 else if (val
== "wxTELETYPE") return wxTELETYPE
;
2398 else return wxSWISS
;
2402 /// Resource symbol validator
2404 IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator
, wxPropertyListValidator
)
2406 wxResourceSymbolValidator::wxResourceSymbolValidator(long flags
):
2407 wxPropertyListValidator(flags
)
2411 wxResourceSymbolValidator::~wxResourceSymbolValidator(void)
2415 bool wxResourceSymbolValidator::OnCheckValue(wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
))
2420 // Called when TICK is pressed or focus is lost or view wants to update
2421 // the property list.
2422 // Does the transferance from the property editing area to the property itself
2423 bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2425 if (!view
->GetValueText())
2427 wxString
value(view
->GetValueText()->GetValue());
2428 property
->GetValue() = value
;
2432 // Called when TICK is pressed or focus is lost or view wants to update
2433 // the property list.
2434 // Does the transferance from the property editing area to the property itself
2435 bool wxResourceSymbolValidator::OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2437 if (!view
->GetValueText())
2439 wxString
str(property
->GetValue().GetStringRepresentation());
2440 view
->GetValueText()->SetValue(str
);
2444 // Called when the property is double clicked. Extra functionality can be provided,
2445 // cycling through possible values.
2446 bool wxResourceSymbolValidator::OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2448 if (!view
->GetValueText())
2450 OnEdit(property
, view
, parentWindow
);
2454 bool wxResourceSymbolValidator::OnPrepareControls(wxProperty
*WXUNUSED(property
), wxPropertyListView
*view
, wxWindow
*WXUNUSED(parentWindow
))
2456 if (view
->GetConfirmButton())
2457 view
->GetConfirmButton()->Enable(TRUE
);
2458 if (view
->GetCancelButton())
2459 view
->GetCancelButton()->Enable(TRUE
);
2460 if (view
->GetEditButton())
2461 view
->GetEditButton()->Enable(TRUE
);
2462 if (view
->GetValueText())
2463 view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
);
2467 void wxResourceSymbolValidator::OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
)
2469 if (!view
->GetValueText())
2472 wxResourceSymbolDialog
* dialog
= new wxResourceSymbolDialog(parentWindow
, -1, "Edit Symbol");
2474 // Split name/id pair e.g. "IDC_TEXT=123"
2475 wxString
value(property
->GetValue().StringValue());
2477 wxString strName
= value
.Before('=');
2478 wxString strId
= value
.After('=');
2480 dialog
->SetSymbol(strName
);
2481 dialog
->SetId(atoi(strId
));
2485 if (dialog
->ShowModal() == wxID_OK
)
2487 wxString
symbolName(dialog
->GetSymbol());
2488 long id
= dialog
->GetId();
2491 str
.Printf("%d", id
);
2492 property
->GetValue() = symbolName
+ wxString("=") + str
;
2494 view
->DisplayProperty(property
);
2495 view
->UpdatePropertyDisplayInList(property
);
2496 view
->OnPropertyChanged(property
);
2498 // Moved from the 'if' branch on suggestion of Roman Pavlov
2502 BEGIN_EVENT_TABLE(wxResourceSymbolDialog
, wxDialog
)
2503 EVT_BUTTON(wxID_OK
, wxResourceSymbolDialog::OnOK
)
2504 EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnComboBoxSelect
)
2505 EVT_TEXT(ID_SYMBOLNAME_COMBOBOX
, wxResourceSymbolDialog::OnSymbolNameUpdate
)
2508 wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
2509 const wxSize
& size
, long style
):
2510 wxDialog(parent
, id
, title
, pos
, size
, style
)
2515 (void) new wxStaticText(this, -1, "Name: ", wxPoint(x
, y
));
2519 m_nameCtrl
= new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX
, "",
2520 wxPoint(x
, y
), wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
|wxCB_SORT
);
2525 (void) new wxStaticText(this, -1, "Id: ", wxPoint(x
, y
));
2529 m_idCtrl
= new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL
, "",
2530 wxPoint(x
, y
), wxSize(200, -1));
2534 (void) new wxButton(this, wxID_OK
, "OK", wxPoint(x
, y
), wxSize(80, -1));
2537 (void) new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(x
, y
), wxSize(80, -1));
2543 void wxResourceSymbolDialog::Init()
2546 defaultId
.Printf("%ld", m_symbolId
);
2548 m_nameCtrl
->SetValue(m_symbolName
);
2549 m_idCtrl
->SetValue(defaultId
);
2551 wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl
);
2554 void wxResourceSymbolDialog::OnOK(wxCommandEvent
& event
)
2558 wxDialog::OnOK(event
);
2562 bool wxResourceSymbolDialog::CheckValues()
2564 wxString
nameStr(m_nameCtrl
->GetValue());
2565 wxString
idStr(m_idCtrl
->GetValue());
2566 int id
= atoi(idStr
);
2570 wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2575 wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2578 if (nameStr
.Contains(" "))
2580 wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2583 if (nameStr
.Contains("="))
2585 wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2588 if (nameStr
.IsNumber())
2590 wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2593 // TODO: other checks on the name syntax.
2595 if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr
))
2597 // If we change the id for an existing symbol, we need to:
2598 // 1) Check if there are any other resources currently using the original id.
2599 // If so, will need to change their id to the new id, in SetProperty.
2600 // 2) Remove the old symbol, add the new symbol.
2601 // In this check, we don't have to do this, but we need to do it in SetProperty.
2603 if (nameStr
== GetSymbol() && id
!= GetId())
2605 // It's OK to change the id. But we'll need to change all matching ids in all resources,
2609 // If we change the name but not the id... we'll just need to remove and
2610 // re-add the symbol/id pair, in SetProperty.
2611 if (nameStr
!= GetSymbol() && id
== GetId())
2615 // What if we're changing both the name and the id?
2616 // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
2617 // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
2619 if (nameStr
!= GetSymbol() && id
!= GetId())
2621 if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr
, id
))
2623 wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
2624 "Dialog Editor", wxOK
|wxICON_EXCLAMATION
, this);
2637 void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent
& WXUNUSED(event
))
2639 wxString
str(m_nameCtrl
->GetStringSelection());
2640 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2642 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2644 str2
.Printf("%d", id
);
2645 m_idCtrl
->SetValue(str2
);
2646 m_idCtrl
->Enable(FALSE
);
2650 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2652 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2654 str2
.Printf("%d", id
);
2655 m_idCtrl
->SetValue(str2
);
2657 m_idCtrl
->Enable(TRUE
);
2661 void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent
& WXUNUSED(event
))
2663 wxString
str(m_nameCtrl
->GetValue());
2664 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str
))
2666 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2668 str2
.Printf("%d", id
);
2669 m_idCtrl
->SetValue(str2
);
2670 m_idCtrl
->Enable(FALSE
);
2674 if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str
))
2676 int id
= wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str
);
2678 str2
.Printf("%d", id
);
2679 m_idCtrl
->SetValue(str2
);
2681 m_idCtrl
->Enable(TRUE
);