X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd71308fc89eac2dd212b715eba68a993fa78f53..8a693e6e0460b6b3c32e4b6f114a3ab7b7cd24ea:/utils/dialoged/src/winprop.cpp diff --git a/utils/dialoged/src/winprop.cpp b/utils/dialoged/src/winprop.cpp index 7eabff4260..dde79ec61c 100644 --- a/utils/dialoged/src/winprop.cpp +++ b/utils/dialoged/src/winprop.cpp @@ -29,12 +29,6 @@ #include #include -#if defined(__WXMSW__) && !defined(__GNUWIN32__) -#include -#else -#include -#endif - #ifdef __WXMSW__ #include #endif @@ -106,7 +100,8 @@ wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame() { delete m_propSheet; delete m_propInfo; - wxPropertyInfo::sm_propertyWindow = NULL; + if (wxPropertyInfo::sm_propertyWindow == this) + wxPropertyInfo::sm_propertyWindow = NULL; } /* @@ -117,11 +112,20 @@ wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame() // might be. bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title) { - if (sm_propertyWindow) - { + if (sm_propertyWindow) + { + wxWindowPropertyInfo* thisProp = (wxWindowPropertyInfo*) this; + wxWindowPropertyInfo* oldProp = (wxWindowPropertyInfo*) (((wxDialogEditorPropertyListFrame *) sm_propertyWindow)->GetInfo()); + if (oldProp->GetWindow() == thisProp->GetWindow()) + { sm_propertyWindow->Raise(); return TRUE; - } + } + else + { + CloseWindow(); // Close the window so we can open a new one + } + } int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width; int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height; @@ -149,7 +153,7 @@ bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title) propSheet->SetAllModified(FALSE); wxResourcePropertyListView *view = new wxResourcePropertyListView(this, NULL, - wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | + wxPROP_BUTTON_OK | // wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES); wxDialogEditorPropertyListFrame *propWin = new wxDialogEditorPropertyListFrame(view, @@ -175,9 +179,34 @@ bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title) view->ShowView(propSheet, propWin->GetPropertyPanel()); propWin->Show(TRUE); + + // Otherwise doesn't show itself +#ifdef __WXMOTIF__ + wxNoOptimize noOptimize; + propWin->SetSize(-1, -1, width, height); +#endif + return TRUE; } +void wxPropertyInfo::CloseWindow() +{ + if (sm_propertyWindow) + { + int w, h, x, y; + sm_propertyWindow->GetSize(& w, & h); + sm_propertyWindow->GetPosition(& x, & y); + + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width = w; + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height = h; + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x = x; + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y = y; + + sm_propertyWindow->Destroy(); + sm_propertyWindow = (wxDialogEditorPropertyListFrame *) NULL; + } +} + /* * wxWindowPropertyInfo */ @@ -282,7 +311,7 @@ wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) { wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - wxFont *font = m_propertyWindow->GetFont(); + wxFont *font = & m_propertyWindow->GetFont(); if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined") return GetFontProperty(name, font); @@ -304,7 +333,7 @@ wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) } else if (name == "height") { - return new wxProperty("width", (long)resource->GetHeight(), "integer"); + return new wxProperty("height", (long)resource->GetHeight(), "integer"); } else if (name == "id") { @@ -349,12 +378,20 @@ wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxFont *font = m_propertyWindow->GetFont(); + wxFont *font = & m_propertyWindow->GetFont(); if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) { wxFont *newFont = SetFontProperty(name, property, font); if (newFont) - m_propertyWindow->SetFont(newFont); + { + m_propertyWindow->SetFont(* newFont); + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource) + { + resource->SetFont(* newFont); + } + } + return TRUE; } else if (name == "name") @@ -385,9 +422,11 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) } else if (name == "x") { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); int x, y; m_propertyWindow->GetPosition(&x, &y); int newX = (int)property->GetValue().IntegerValue(); + int pixelX = newX; // We need to convert to pixels if this is not a dialog or panel, but // the parent resource specifies dialog units. @@ -397,7 +436,7 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(newX, y)); - newX = pt.x; + pixelX = pt.x; } } else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) @@ -406,19 +445,24 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(newX, y)); - newX = pt.x; + pixelX = pt.x; } } - if (x != newX) - m_propertyWindow->Move(newX, y); + if (x != pixelX) + { + m_propertyWindow->Move(pixelX, y); + resource->SetSize(newX, resource->GetY(), resource->GetWidth(), resource->GetHeight()); + } return TRUE; } else if (name == "y") { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); int x, y; m_propertyWindow->GetPosition(&x, &y); int newY = (int)property->GetValue().IntegerValue(); + int pixelY = newY; // We need to convert to pixels if this is not a dialog or panel, but // the parent resource specifies dialog units. @@ -428,7 +472,7 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(x, newY)); - newY = pt.y; + pixelY = pt.y; } } else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) @@ -437,19 +481,24 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(x, newY)); - newY = pt.y; + pixelY = pt.y; } } - if (y != newY) - m_propertyWindow->Move(x, newY); + if (y != pixelY) + { + m_propertyWindow->Move(x, pixelY); + resource->SetSize(resource->GetX(), newY, resource->GetWidth(), resource->GetHeight()); + } return TRUE; } else if (name == "width") { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); int width, height; m_propertyWindow->GetSize(&width, &height); int newWidth = (int)property->GetValue().IntegerValue(); + int pixelWidth = newWidth; // We need to convert to pixels if this is not a dialog or panel, but // the parent resource specifies dialog units. @@ -459,7 +508,7 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(newWidth, height)); - newWidth = sz.x; + pixelWidth = sz.x; } } else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) @@ -468,21 +517,24 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(newWidth, height)); - newWidth = sz.x; + pixelWidth = sz.x; } } - if (width != newWidth) + if (width != pixelWidth) { - m_propertyWindow->SetSize(newWidth, height); + m_propertyWindow->SetSize(pixelWidth, height); + resource->SetSize(resource->GetX(), resource->GetY(), newWidth, resource->GetHeight()); } return TRUE; } else if (name == "height") { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); int width, height; m_propertyWindow->GetSize(&width, &height); int newHeight = (int)property->GetValue().IntegerValue(); + int pixelHeight = newHeight; // We need to convert to pixels if this is not a dialog or panel, but // the parent resource specifies dialog units. @@ -492,7 +544,7 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(width, newHeight)); - newHeight = sz.y; + pixelHeight = sz.y; } } else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) @@ -501,13 +553,14 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(width, newHeight)); - newHeight = sz.y; + pixelHeight = sz.y; } } - if (height != newHeight) + if (height != pixelHeight) { - m_propertyWindow->SetSize(width, newHeight); + m_propertyWindow->SetSize(width, pixelHeight); + resource->SetSize(resource->GetX(), resource->GetY(), resource->GetWidth(), newHeight); } return TRUE; } @@ -648,7 +701,9 @@ bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource) wxString str(m_propertyWindow->GetName()); resource->SetName(str); -#if 0 +#if 0 // Why did we comment this out? Possibly because of rounding errors + // that will build up as the conversion is repeatedly done. + // so only do the conversion when a resize happens. int x, y, w, h; if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) @@ -717,7 +772,7 @@ void wxWindowPropertyInfo::SetWindowStyle(wxWindow* win, long style, bool set) wxProperty *wxItemPropertyInfo::GetProperty(wxString& name) { wxControl *itemWindow = (wxControl *)m_propertyWindow; - wxFont *font = itemWindow->GetFont(); + wxFont *font = & itemWindow->GetFont(); if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined") @@ -731,16 +786,19 @@ wxProperty *wxItemPropertyInfo::GetProperty(wxString& name) bool wxItemPropertyInfo::SetProperty(wxString& name, wxProperty *property) { wxControl *itemWindow = (wxControl *)m_propertyWindow; - wxFont *font = itemWindow->GetFont(); +#if 0 + wxFont *font = & itemWindow->GetFont(); if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) { wxFont *newFont = SetFontProperty(name, property, font); if (newFont) - itemWindow->SetLabelFont(newFont); + itemWindow->SetFont(* newFont); return TRUE; } - else if (name == "label") + else +#endif + if (name == "label") { itemWindow->SetLabel(property->GetValue().StringValue()); return TRUE; @@ -767,10 +825,11 @@ bool wxItemPropertyInfo::InstantiateResource(wxItemResource *resource) wxControl *item = (wxControl *)m_propertyWindow; wxString str(item->GetLabel()); resource->SetTitle(str); - if (item->GetFont() && item->GetFont()->Ok()) - resource->SetFont(wxTheFontList->FindOrCreateFont(item->GetFont()->GetPointSize(), - item->GetFont()->GetFamily(), item->GetFont()->GetStyle(), item->GetFont()->GetWeight(), - item->GetFont()->GetUnderlined(), item->GetFont()->GetFaceName())); + + if (item->GetFont().Ok()) + resource->SetFont(* wxTheFontList->FindOrCreateFont(item->GetFont().GetPointSize(), + item->GetFont().GetFamily(), item->GetFont().GetStyle(), item->GetFont().GetWeight(), + item->GetFont().GetUnderlined(), item->GetFont().GetFaceName())); return TRUE; } @@ -806,7 +865,7 @@ bool wxButtonPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) { wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; - if (name == "label") + if (name == "bitmapFilename") { wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button); wxString str("none.bmp"); @@ -815,7 +874,7 @@ wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) { str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); } - return new wxProperty("label", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); + return new wxProperty("bitmapFilename", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); } else return wxButtonPropertyInfo::GetProperty(name); @@ -824,17 +883,16 @@ wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; - if (name == "label") + if (name == "bitmapFilename") { char *s = property->GetValue().StringValue(); if (s && wxFileExists(s)) { - s = copystring(s); - wxBitmap *bitmap = new wxBitmap(s, wxBITMAP_TYPE_BMP); + wxString str(s); + wxBitmap *bitmap = new wxBitmap(str, wxBITMAP_TYPE_BMP); if (!bitmap->Ok()) { delete bitmap; - delete[] s; return FALSE; } else @@ -843,15 +901,14 @@ bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *propert if (resource) { wxString oldResource(resource->GetValue4()); - wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s); + wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str); resource->SetValue4(resName); if (!oldResource.IsNull()) wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); } - button->SetLabel(bitmap); - delete[] s; + button->SetLabel(* bitmap); return TRUE; } } @@ -863,8 +920,9 @@ bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *propert void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList& names) { -// names.Add("label"); wxButtonPropertyInfo::GetPropertyNames(names); + names.Delete("label"); + names.Add("bitmapFilename"); } bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource *resource) @@ -883,7 +941,37 @@ wxProperty *wxStaticTextPropertyInfo::GetProperty(wxString& name) bool wxStaticTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - return wxItemPropertyInfo::SetProperty(name, property); + wxStaticText* itemWindow = (wxStaticText*) m_propertyWindow; + if (name == "label") + { + // Because setting a wxStaticText control's label may change the + // size, we must get the size and instantiate the resource immediately. + itemWindow->SetLabel(property->GetValue().StringValue()); + int w, h; + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(itemWindow); + + m_propertyWindow->GetSize(&w, &h); + // m_propertyWindow->GetPosition(&x, &y); + + // We need to convert to dialog units if + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent()) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + // wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y)); + // x = pt.x; y = pt.y; + wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + } + resource->SetSize(resource->GetX(), resource->GetY(), w, h); + return TRUE; + } + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList& names) @@ -904,7 +992,7 @@ bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) { wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; - if (name == "label") + if (name == "bitmapFilename") { wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message); wxString str("none.bmp"); @@ -913,7 +1001,7 @@ wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) { str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); } - return new wxProperty("label", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); + return new wxProperty("bitmapFilename", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); } else return wxItemPropertyInfo::GetProperty(name); @@ -922,18 +1010,17 @@ wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *property) { wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; - if (name == "label") + if (name == "bitmapFilename") { char *s = property->GetValue().StringValue(); if (s && wxFileExists(s)) { - s = copystring(s); + wxString str(s); - wxBitmap *bitmap = new wxBitmap(s, wxBITMAP_TYPE_BMP); + wxBitmap *bitmap = new wxBitmap(str, wxBITMAP_TYPE_BMP); if (!bitmap->Ok()) { delete bitmap; - delete[] s; return FALSE; } else @@ -942,15 +1029,14 @@ bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *propert if (resource) { wxString oldResource(resource->GetValue4()); - wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s); + wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str); resource->SetValue4(resName); if (!oldResource.IsNull()) wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); } - message->SetBitmap(bitmap); - delete[] s; + message->SetBitmap(* bitmap); return TRUE; } } @@ -963,7 +1049,7 @@ bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *propert void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList& names) { wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); + names.Add("bitmapFilename"); } bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource *resource) @@ -1018,7 +1104,7 @@ bool wxTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text); resource->SetStyle(flag); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); return TRUE; } else if (name == "readonly") @@ -1037,7 +1123,7 @@ bool wxTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text); resource->SetStyle(flag); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); return TRUE; } else @@ -1082,22 +1168,16 @@ wxProperty *wxListBoxPropertyInfo::GetProperty(wxString& name) wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); if (!resource) return NULL; + + char *mult = "wxLB_SINGLE"; - char *mult = "wxSINGLE"; - - switch (resource->GetValue1()) - { - case wxLB_MULTIPLE: + if ((listBox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) mult = "wxLB_MULTIPLE"; - break; - case wxLB_EXTENDED: + else if ((listBox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0) mult = "wxLB_EXTENDED"; - break; - default: - case wxLB_SINGLE: + else mult = "wxLB_SINGLE"; - break; - } + return new wxProperty("multiple", mult, "string", new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED", NULL))); @@ -1124,18 +1204,22 @@ bool wxListBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) } else if (name == "multiple") { - int mult = wxLB_SINGLE; + SetWindowStyle(m_propertyWindow, wxLB_SINGLE, FALSE); + SetWindowStyle(m_propertyWindow, wxLB_MULTIPLE, FALSE); + SetWindowStyle(m_propertyWindow, wxLB_EXTENDED, FALSE); + wxString str(property->GetValue().StringValue()); if (str == "wxLB_MULTIPLE") - mult = wxLB_MULTIPLE; + SetWindowStyle(m_propertyWindow, wxLB_MULTIPLE, TRUE); else if (str == "wxLB_EXTENDED") - mult = wxLB_EXTENDED; + SetWindowStyle(m_propertyWindow, wxLB_EXTENDED, TRUE); else - mult = wxLB_SINGLE; + SetWindowStyle(m_propertyWindow, wxLB_SINGLE, TRUE); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); if (resource) - resource->SetValue1(mult); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this); return TRUE; } else @@ -1299,7 +1383,7 @@ bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); return TRUE; } else if (name == "style") @@ -1320,7 +1404,7 @@ bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); return TRUE; } @@ -1368,13 +1452,13 @@ wxProperty *wxRadioBoxPropertyInfo::GetProperty(wxString& name) if (name == "orientation") { wxString orient; - if (m_propertyWindow->GetWindowStyleFlag() & wxRA_HORIZONTAL) - orient = "wxRA_HORIZONTAL"; + if (m_propertyWindow->GetWindowStyleFlag() & wxRA_SPECIFY_COLS) + orient = "wxRA_SPECIFY_COLS"; else - orient = "wxRA_VERTICAL"; + orient = "wxRA_SPECIFY_ROWS"; return new wxProperty("orientation", orient, "string", - new wxStringListValidator(new wxStringList("wxRA_HORIZONTAL", "wxRA_VERTICAL", + new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS", NULL))); } else if (name == "values") @@ -1394,31 +1478,36 @@ bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; if (name == "numberRowsOrCols") { + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); + radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue()); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); return TRUE; } else if (name == "orientation") { long windowStyle = radioBox->GetWindowStyleFlag(); wxString val(property->GetValue().StringValue()); - if (val == "wxRA_HORIZONTAL") + if (val == "wxRA_SPECIFY_COLS") { - if (windowStyle & wxRA_VERTICAL) - windowStyle -= wxRA_VERTICAL; - windowStyle |= wxRA_HORIZONTAL; + if (windowStyle & wxRA_SPECIFY_ROWS) + windowStyle -= wxRA_SPECIFY_ROWS; + windowStyle |= wxRA_SPECIFY_COLS; } else { - if (windowStyle & wxRA_HORIZONTAL) - windowStyle -= wxRA_HORIZONTAL; - windowStyle |= wxRA_VERTICAL; + if (windowStyle & wxRA_SPECIFY_COLS) + windowStyle -= wxRA_SPECIFY_COLS; + windowStyle |= wxRA_SPECIFY_ROWS; } + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); + radioBox->SetWindowStyleFlag(windowStyle); wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox); resource->SetStyle(windowStyle); + resource->SetSize(resource->GetX(), resource->GetY(), -1, -1); // Let it calculate it's own size - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE); return TRUE; } else if (name == "values") @@ -1440,9 +1529,32 @@ bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) expr = expr->GetNext(); } resource->SetStringValues(stringList); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); + resource->SetSize(resource->GetX(), resource->GetY(), -1, -1); // Let it calculate it's own size + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE); return TRUE; } + else if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" ) + { + wxFont *font = & m_propertyWindow->GetFont(); + if (!font) + return FALSE; + wxFont *newFont = SetFontProperty(name, property, font); + if (newFont) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource) + { + resource->SetFont(* newFont); + } + + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); + + radioBox->SetFont(* newFont); + radioBox->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + return TRUE; + } + } + return wxItemPropertyInfo::SetProperty(name, property); } @@ -1646,6 +1758,7 @@ bool wxSliderPropertyInfo::SetProperty(wxString& name, wxProperty *property) slider = (wxSlider *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider, this); slider->SetSize(-1, -1, h, w); + m_propertyWindow = slider; return TRUE; } @@ -1735,8 +1848,8 @@ bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name) { wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; - if (name == "value") - return new wxProperty("value", (long)scrollBar->GetValue(), "integer"); + if (name == "thumbPosition") + return new wxProperty("value", (long)scrollBar->GetThumbPosition(), "integer"); else if (name == "orientation") { char *pos = NULL; @@ -1751,24 +1864,20 @@ wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name) } else if (name == "pageSize") { - int viewStart, pageLength, objectLength, viewLength; - scrollBar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength); + int pageLength = scrollBar->GetPageSize(); return new wxProperty("pageSize", (long)pageLength, "integer"); } - else if (name == "viewLength") + else if (name == "thumbSize") { - int viewStart, pageLength, objectLength, viewLength; - scrollBar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength); + int thumbSize = scrollBar->GetThumbSize(); - return new wxProperty("viewLength", (long)viewLength, "integer"); + return new wxProperty("thumbSize", (long)thumbSize, "integer"); } - else if (name == "objectLength") + else if (name == "range") { - int viewStart, pageLength, objectLength, viewLength; - scrollBar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength); - - return new wxProperty("objectLength", (long)objectLength, "integer"); + int range = scrollBar->GetRange(); + return new wxProperty("range", (long)range, "integer"); } else return wxItemPropertyInfo::GetProperty(name); @@ -1777,9 +1886,9 @@ wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name) bool wxScrollBarPropertyInfo::SetProperty(wxString& name, wxProperty *property) { wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; - if (name == "value") + if (name == "thumbPosition") { - scrollBar->SetValue((int)property->GetValue().IntegerValue()); + scrollBar->SetThumbPosition((int)property->GetValue().IntegerValue()); return TRUE; } else if (name == "orientation") @@ -1806,27 +1915,41 @@ bool wxScrollBarPropertyInfo::SetProperty(wxString& name, wxProperty *property) scrollBar->SetWindowStyleFlag(windowStyle); // If the window style has changed, we swap the width and height parameters. - int w, h; - scrollBar->GetSize(&w, &h); - +// 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); - scrollBar->SetSize(-1, -1, h, w); - + m_propertyWindow = scrollBar; + return TRUE; } else if (name == "pageSize") { - scrollBar->SetPageSize((int)property->GetValue().IntegerValue()); + 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 == "viewLength") + else if (name == "thumbSize") { - scrollBar->SetViewLength((int)property->GetValue().IntegerValue()); + 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 == "objectLength") + else if (name == "range") { - scrollBar->SetObjectLength((int)property->GetValue().IntegerValue()); + int pos = scrollBar->GetThumbPosition(); + int thumbSize = scrollBar->GetThumbSize(); + int pageSize = scrollBar->GetPageSize(); + scrollBar->SetScrollbar(pos, thumbSize, (int)property->GetValue().IntegerValue(), pageSize); return TRUE; } else @@ -1837,10 +1960,10 @@ void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList& names) { wxItemPropertyInfo::GetPropertyNames(names); names.Add("orientation"); - names.Add("value"); + names.Add("thumbPosition"); + names.Add("thumbSize"); names.Add("pageSize"); - names.Add("viewLength"); - names.Add("objectLength"); + names.Add("range"); // Remove some properties we don't inherit names.Delete("fontPoints"); @@ -1854,14 +1977,15 @@ bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource) { wxScrollBar *sbar = (wxScrollBar *)m_propertyWindow; - resource->SetValue1(sbar->GetValue()); - - int viewStart, pageLength, objectLength, viewLength; - sbar->GetValues(&viewStart, &viewLength, &objectLength, &pageLength); + int thumbPosition = sbar->GetThumbPosition(); + int thumbSize = sbar->GetThumbSize(); + int pageSize = sbar->GetPageSize(); + int range = sbar->GetRange(); - resource->SetValue2(pageLength); - resource->SetValue3(objectLength); - resource->SetValue5(viewLength); + resource->SetValue1(thumbPosition); + resource->SetValue2(thumbSize); + resource->SetValue3(range); + resource->SetValue5(pageSize); return wxItemPropertyInfo::InstantiateResource(resource); } @@ -1873,6 +1997,8 @@ bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name) { wxPanel *panelWindow = (wxPanel *)m_propertyWindow; + +/* wxFont *labelFont = panelWindow->GetLabelFont(); wxFont *buttonFont = panelWindow->GetButtonFont(); @@ -1882,7 +2008,9 @@ wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name) else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined") return GetFontProperty(name, buttonFont); - else if (name == "no3D") +*/ + + if (name == "no3D") { bool userColours; if (panelWindow->GetWindowStyleFlag() & wxNO_3D) @@ -1944,24 +2072,27 @@ wxProperty *wxPanelPropertyInfo::GetProperty(wxString& 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); + 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); + panelWindow->SetButtonFont(* newFont); return TRUE; } - else if (name == "no3D") +*/ + + if (name == "no3D") { bool userColours = property->GetValue().BoolValue(); @@ -1991,6 +2122,7 @@ bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property) wxColour col(r,g,b); panelWindow->SetBackgroundColour(col); panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + m_propertyWindow = panelWindow; return TRUE; } else if (name == "title") @@ -2070,6 +2202,7 @@ bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property) } 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; } @@ -2094,10 +2227,10 @@ void wxPanelPropertyInfo::GetPropertyNames(wxStringList& names) bool wxPanelPropertyInfo::InstantiateResource(wxItemResource *resource) { wxPanel *panel = (wxPanel *)m_propertyWindow; - if (panel->GetFont() && panel->GetFont()->Ok()) - resource->SetFont(wxTheFontList->FindOrCreateFont(panel->GetFont()->GetPointSize(), - panel->GetFont()->GetFamily(), panel->GetFont()->GetStyle(), panel->GetFont()->GetWeight(), - panel->GetFont()->GetUnderlined(), panel->GetFont()->GetFaceName())); + if (panel->GetFont().Ok()) + resource->SetFont(* wxTheFontList->FindOrCreateFont(panel->GetFont().GetPointSize(), + panel->GetFont().GetFamily(), panel->GetFont().GetStyle(), panel->GetFont().GetWeight(), + panel->GetFont().GetUnderlined(), panel->GetFont().GetFaceName())); resource->SetBackgroundColour(wxColour(panel->GetBackgroundColour())); @@ -2123,7 +2256,7 @@ void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits) } resource->SetSize(pt.x, pt.y, sz.x, sz.y); - wxNode* node = m_propertyWindow->GetChildren()->First(); + wxNode* node = m_propertyWindow->GetChildren().First(); while (node) { wxWindow* child = (wxWindow*) node->Data(); @@ -2317,7 +2450,6 @@ void wxResourceSymbolValidator::OnEdit(wxProperty *property, wxPropertyListView { wxString symbolName(dialog->GetSymbol()); long id = dialog->GetId(); - dialog->Destroy(); wxString str; str.Printf("%d", id); @@ -2327,6 +2459,8 @@ void wxResourceSymbolValidator::OnEdit(wxProperty *property, wxPropertyListView view->UpdatePropertyDisplayInList(property); view->OnPropertyChanged(property); } + // Moved from the 'if' branch on suggestion of Roman Pavlov + dialog->Destroy(); } BEGIN_EVENT_TABLE(wxResourceSymbolDialog, wxDialog)