+ wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("label");
+ names.Add("value");
+}
+
+bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
+{
+ wxCheckBox *cbox = (wxCheckBox *)m_propertyWindow;
+ resource->SetValue1(cbox->GetValue());
+ return wxItemPropertyInfo::InstantiateResource(resource);
+}
+
+/*
+* Radiobutton item
+*/
+
+wxProperty *wxRadioButtonPropertyInfo::GetProperty(wxString& name)
+{
+ wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow;
+ if (name == "value")
+ return new wxProperty("value", checkBox->GetValue(), "bool");
+ else
+ return wxItemPropertyInfo::GetProperty(name);
+}
+
+bool wxRadioButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property)
+{
+ wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow;
+ if (name == "value")
+ {
+ checkBox->SetValue((bool)property->GetValue().BoolValue());
+ return TRUE;
+ }
+ else
+ return wxItemPropertyInfo::SetProperty(name, property);
+}
+
+void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList& names)
+{
+ wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("label");
+ names.Add("value");
+}
+
+bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource *resource)
+{
+ wxRadioButton *cbox = (wxRadioButton *)m_propertyWindow;
+ resource->SetValue1(cbox->GetValue());
+ return wxItemPropertyInfo::InstantiateResource(resource);
+}
+
+/*
+* Slider item
+*/
+
+wxProperty *wxSliderPropertyInfo::GetProperty(wxString& name)
+{
+ wxSlider *slider = (wxSlider *)m_propertyWindow;
+ if (name == "value")
+ return new wxProperty("value", (long)slider->GetValue(), "integer");
+ else if (name == "orientation")
+ {
+ char *pos = NULL;
+ if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL)
+ pos = "wxHORIZONTAL";
+ else
+ pos = "wxVERTICAL";
+
+ return new wxProperty("orientation", pos, "string",
+ new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
+ NULL)));
+ }
+ else if (name == "minValue")
+ return new wxProperty("minValue", (long)slider->GetMin(), "integer");
+ else if (name == "maxValue")
+ return new wxProperty("maxValue", (long)slider->GetMax(), "integer");
+ else
+ return wxItemPropertyInfo::GetProperty(name);
+}
+
+bool wxSliderPropertyInfo::SetProperty(wxString& name, wxProperty *property)
+{
+ wxSlider *slider = (wxSlider *)m_propertyWindow;
+ if (name == "value")
+ {
+ slider->SetValue((int)property->GetValue().IntegerValue());
+ return TRUE;
+ }
+ else if (name == "orientation")
+ {
+ long windowStyle = slider->GetWindowStyleFlag();
+ long oldWindowStyle = windowStyle;
+ wxString val(property->GetValue().StringValue());
+ if (val == "wxHORIZONTAL")
+ {
+ if (windowStyle & wxVERTICAL)
+ windowStyle -= wxVERTICAL;
+ windowStyle |= wxHORIZONTAL;
+ }
+ else
+ {
+ if (windowStyle & wxHORIZONTAL)
+ windowStyle -= wxHORIZONTAL;
+ windowStyle |= wxVERTICAL;
+ }
+
+ if (oldWindowStyle == windowStyle)
+ return TRUE;
+
+ slider->SetWindowStyleFlag(windowStyle);
+
+ // If the window style has changed, we swap the width and height parameters.
+ int w, h;
+ slider->GetSize(&w, &h);
+
+ slider = (wxSlider *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider, this);
+ slider->SetSize(-1, -1, h, w);
+ m_propertyWindow = slider;
+
+ return TRUE;
+ }
+ else if (name == "minValue")
+ {
+ slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax());
+ return TRUE;
+ }
+ else if (name == "maxValue")
+ {
+ slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue());
+ return TRUE;
+ }
+ else
+ return wxItemPropertyInfo::SetProperty(name, property);
+}
+
+void wxSliderPropertyInfo::GetPropertyNames(wxStringList& names)
+{
+ wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("value");
+ names.Add("orientation");
+ names.Add("minValue");
+ names.Add("maxValue");
+}
+
+bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource)
+{
+ wxSlider *slider = (wxSlider *)m_propertyWindow;
+ resource->SetValue1(slider->GetValue());
+ resource->SetValue2(slider->GetMin());
+ resource->SetValue3(slider->GetMax());
+ return wxItemPropertyInfo::InstantiateResource(resource);
+}
+
+/*
+* Gauge item
+*/
+
+wxProperty *wxGaugePropertyInfo::GetProperty(wxString& name)
+{
+ wxGauge *gauge = (wxGauge *)m_propertyWindow;
+ if (name == "value")
+ return new wxProperty("value", (long)gauge->GetValue(), "integer");
+ else if (name == "maxValue")
+ return new wxProperty("maxValue", (long)gauge->GetRange(), "integer");
+ else
+ return wxItemPropertyInfo::GetProperty(name);
+}
+
+bool wxGaugePropertyInfo::SetProperty(wxString& name, wxProperty *property)
+{
+ wxGauge *gauge = (wxGauge *)m_propertyWindow;
+ if (name == "value")
+ {
+ gauge->SetValue((int)property->GetValue().IntegerValue());
+ return TRUE;
+ }
+ else if (name == "maxValue")
+ {
+ gauge->SetRange((int)property->GetValue().IntegerValue());
+ return TRUE;
+ }
+ else
+ return wxItemPropertyInfo::SetProperty(name, property);
+}
+
+void wxGaugePropertyInfo::GetPropertyNames(wxStringList& names)
+{
+ wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("value");
+ names.Add("maxValue");
+}
+
+bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource)
+{
+ wxGauge *gauge = (wxGauge *)m_propertyWindow;
+ resource->SetValue1(gauge->GetValue());
+ resource->SetValue2(gauge->GetRange());
+ return wxItemPropertyInfo::InstantiateResource(resource);
+}
+
+/*
+* Scrollbar item
+*/
+
+wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name)
+{
+ wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow;
+ if (name == "thumbPosition")
+ return new wxProperty("value", (long)scrollBar->GetThumbPosition(), "integer");
+ else if (name == "orientation")
+ {
+ char *pos = NULL;
+ if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL)
+ pos = "wxHORIZONTAL";
+ else
+ pos = "wxVERTICAL";
+
+ return new wxProperty("orientation", pos, "string",
+ new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
+ NULL)));
+ }
+ else if (name == "pageSize")
+ {
+ int pageLength = scrollBar->GetPageSize();
+
+ return new wxProperty("pageSize", (long)pageLength, "integer");
+ }
+ else if (name == "thumbSize")
+ {
+ int thumbSize = scrollBar->GetThumbSize();
+
+ return new wxProperty("thumbSize", (long)thumbSize, "integer");
+ }
+ else if (name == "range")
+ {
+ int range = scrollBar->GetRange();
+ return new wxProperty("range", (long)range, "integer");
+ }
+ else
+ return wxItemPropertyInfo::GetProperty(name);
+}
+
+bool wxScrollBarPropertyInfo::SetProperty(wxString& name, wxProperty *property)
+{
+ wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow;
+ if (name == "thumbPosition")
+ {
+ scrollBar->SetThumbPosition((int)property->GetValue().IntegerValue());
+ return TRUE;
+ }
+ else if (name == "orientation")
+ {
+ long windowStyle = scrollBar->GetWindowStyleFlag();
+ long oldWindowStyle = windowStyle;
+ wxString val(property->GetValue().StringValue());
+ if (val == "wxHORIZONTAL")
+ {
+ if (windowStyle & wxVERTICAL)
+ windowStyle -= wxVERTICAL;
+ windowStyle |= wxHORIZONTAL;
+ }
+ else
+ {
+ if (windowStyle & wxHORIZONTAL)
+ windowStyle -= wxHORIZONTAL;
+ windowStyle |= wxVERTICAL;
+ }
+
+ if (oldWindowStyle == windowStyle)
+ return TRUE;
+
+ scrollBar->SetWindowStyleFlag(windowStyle);
+
+ // If the window style has changed, we swap the width and height parameters.
+ // int w, h;
+ // scrollBar->GetSize(&w, &h);
+ wxItemResource *item = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar);
+ if ( item ) {
+ item->SetSize(item->GetX(), item->GetY(), item->GetHeight(), item->GetWidth());
+ item->SetStyle(windowStyle);
+ } /* IF */
+
+ scrollBar = (wxScrollBar *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar, this);
+ m_propertyWindow = scrollBar;
+
+ return TRUE;
+ }
+ else if (name == "pageSize")
+ {
+ int pos = scrollBar->GetThumbPosition();
+ int range = scrollBar->GetRange();
+ int thumbSize = scrollBar->GetThumbSize();
+ scrollBar->SetScrollbar(pos, thumbSize, range, (int)property->GetValue().IntegerValue());
+ return TRUE;
+ }
+ else if (name == "thumbSize")
+ {
+ int pos = scrollBar->GetThumbPosition();
+ int range = scrollBar->GetRange();
+ int pageSize = scrollBar->GetPageSize();
+ scrollBar->SetScrollbar(pos, (int)property->GetValue().IntegerValue(), range, pageSize);
+ return TRUE;
+ }
+ else if (name == "range")
+ {
+ int pos = scrollBar->GetThumbPosition();
+ int thumbSize = scrollBar->GetThumbSize();
+ int pageSize = scrollBar->GetPageSize();
+ scrollBar->SetScrollbar(pos, thumbSize, (int)property->GetValue().IntegerValue(), pageSize);
+ return TRUE;
+ }
+ else
+ return wxItemPropertyInfo::SetProperty(name, property);
+}
+
+void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList& names)
+{
+ wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("orientation");
+ names.Add("thumbPosition");
+ names.Add("thumbSize");
+ names.Add("pageSize");
+ names.Add("range");
+
+ // Remove some properties we don't inherit
+ names.Delete("fontPoints");
+ names.Delete("fontFamily");
+ names.Delete("fontStyle");
+ names.Delete("fontWeight");
+ names.Delete("fontUnderlined");
+}
+
+bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource)
+{
+ wxScrollBar *sbar = (wxScrollBar *)m_propertyWindow;
+
+ int thumbPosition = sbar->GetThumbPosition();
+ int thumbSize = sbar->GetThumbSize();
+ int pageSize = sbar->GetPageSize();
+ int range = sbar->GetRange();
+
+ resource->SetValue1(thumbPosition);
+ resource->SetValue2(thumbSize);
+ resource->SetValue3(range);
+ resource->SetValue5(pageSize);
+
+ return wxItemPropertyInfo::InstantiateResource(resource);
+}
+
+/*
+* Panels
+*/
+
+wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name)
+{
+ wxPanel *panelWindow = (wxPanel *)m_propertyWindow;
+
+ /*
+ wxFont *labelFont = panelWindow->GetLabelFont();
+ wxFont *buttonFont = panelWindow->GetButtonFont();
+
+ if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" ||
+ name == "labelFontUnderlined")
+ return GetFontProperty(name, labelFont);
+ else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" ||
+ name == "buttonFontUnderlined")
+ return GetFontProperty(name, buttonFont);
+ */
+
+ if (name == "no3D")
+ {
+ bool userColours;
+ if (panelWindow->GetWindowStyleFlag() & wxNO_3D)
+ userColours = TRUE;
+ else
+ userColours = FALSE;
+
+ return new wxProperty(name, (bool)userColours, "bool");
+ }
+ else if (name == "backgroundColour")
+ {
+ wxColour col(panelWindow->GetBackgroundColour());
+ char buf[7];
+ wxDecToHex(col.Red(), buf);
+ wxDecToHex(col.Green(), buf+2);
+ wxDecToHex(col.Blue(), buf+4);
+
+ return new wxProperty(name, buf, "string", new wxColourListValidator);
+ }
+ else if (name == "title")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ if (resource)
+ return new wxProperty(name, resource->GetTitle(), "string");
+ else
+ return new wxProperty(name, "Could not get title", "string");
+ }
+ else if (name == "caption")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxCAPTION) == wxCAPTION),
+ "bool");
+ }
+ else if (name == "systemMenu")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxSYSTEM_MENU) == wxSYSTEM_MENU),
+ "bool");
+ }
+ else if (name == "thickFrame")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxTHICK_FRAME) == wxTHICK_FRAME),
+ "bool");
+ }
+ else if (name == "modal")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL),
+ "bool");
+ }
+ else if (name == "useSystemDefaults")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) == wxRESOURCE_USE_DEFAULTS),
+ "bool");
+ }
+ else if (name == "useDialogUnits")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == wxRESOURCE_DIALOG_UNITS),
+ "bool");
+ }
+ else
+ return wxWindowPropertyInfo::GetProperty(name);
+}
+
+bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property)
+{
+ wxPanel *panelWindow = (wxPanel *)m_propertyWindow;
+ /*
+ wxFont *labelFont = panelWindow->GetLabelFont();
+ wxFont *buttonFont = panelWindow->GetButtonFont();
+
+ if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" ))
+ {
+ wxFont *newFont = SetFontProperty(name, property, labelFont);
+ if (newFont)
+ panelWindow->SetLabelFont(* newFont);
+ return TRUE;
+ }
+ else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" ))
+ {
+ wxFont *newFont = SetFontProperty(name, property, buttonFont);
+ if (newFont)
+ panelWindow->SetButtonFont(* newFont);
+ return TRUE;
+ }
+ */
+
+ if (name == "no3D")
+ {
+ bool userColours = property->GetValue().BoolValue();
+
+ if (userColours)
+ {
+ if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) != wxNO_3D)
+ panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() | wxNO_3D);
+ }
+ else
+ {
+ if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) == wxNO_3D)
+ panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() - wxNO_3D);
+ }
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+
+ panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
+ return TRUE;
+ }
+ else if (name == "backgroundColour")
+ {
+ char *hex = property->GetValue().StringValue();
+ int r = wxHexToDec(hex);
+ int g = wxHexToDec(hex+2);
+ int b = wxHexToDec(hex+4);
+
+ wxColour col(r,g,b);
+ panelWindow->SetBackgroundColour(col);
+ panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
+ m_propertyWindow = panelWindow;
+ return TRUE;
+ }
+ else if (name == "title")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ if (resource)
+ {
+ resource->SetTitle(property->GetValue().StringValue());
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else if (name == "caption")
+ {
+ SetWindowStyle(panelWindow, wxCAPTION, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else if (name == "thickFrame")
+ {
+ SetWindowStyle(panelWindow, wxTHICK_FRAME, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else if (name == "systemMenu")
+ {
+ SetWindowStyle(panelWindow, wxSYSTEM_MENU, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else if (name == "modal")
+ {
+ SetWindowStyle(panelWindow, wxDIALOG_MODAL, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else if (name == "useSystemDefaults")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ bool useDefaults = property->GetValue().BoolValue();
+ long style = resource->GetResourceStyle();
+ if (useDefaults)
+ {
+ if ((style & wxRESOURCE_USE_DEFAULTS) == 0)
+ style |= wxRESOURCE_USE_DEFAULTS;
+ }
+ else
+ {
+ if ((style & wxRESOURCE_USE_DEFAULTS) != 0)
+ style -= wxRESOURCE_USE_DEFAULTS;
+ }
+ resource->SetResourceStyle(style);
+ panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
+ return TRUE;
+ }
+ else if (name == "useDialogUnits")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ bool useDialogUnits = property->GetValue().BoolValue();
+ long style = resource->GetResourceStyle();
+ if (useDialogUnits)
+ {
+ if ((style & wxRESOURCE_DIALOG_UNITS) == 0)
+ {
+ style |= wxRESOURCE_DIALOG_UNITS;
+ ConvertDialogUnits(TRUE); // Convert all resources
+ }
+ }
+ else
+ {
+ if ((style & wxRESOURCE_DIALOG_UNITS) != 0)
+ {
+ style -= wxRESOURCE_DIALOG_UNITS;
+ ConvertDialogUnits(FALSE); // Convert all resources
+ }
+ }
+ resource->SetResourceStyle(style);
+ panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
+ m_propertyWindow = panelWindow;
+ // TODO: need to regenerate the width and height properties else they'll be inconsistent.
+ return TRUE;
+ }
+ else
+ return wxWindowPropertyInfo::SetProperty(name, property);