#include <math.h>
#include <string.h>
-#if wxUSE_IOSTREAMH
-#if defined(__WXMSW__) && !defined(__GNUWIN32__)
-#include <strstrea.h>
-#else
-#include <strstream.h>
-#endif
-#else
-#include <strstream>
-#endif
-
#ifdef __WXMSW__
#include <windows.h>
#endif
{
delete m_propSheet;
delete m_propInfo;
- wxPropertyInfo::sm_propertyWindow = NULL;
+ if (wxPropertyInfo::sm_propertyWindow == this)
+ wxPropertyInfo::sm_propertyWindow = NULL;
}
/*
// 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
+ {
+ 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;
+
+ // Close the window, so we can create a new one for the different window
+ sm_propertyWindow->Destroy();
+ sm_propertyWindow = (wxDialogEditorPropertyListFrame *) NULL;
+ }
+ }
int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width;
int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height;
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)))
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
if (resource)
{
wxString oldResource(resource->GetValue4());
- wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s);
+ wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str);
resource->SetValue4(resName);
if (!oldResource.IsNull())
}
button->SetLabel(* bitmap);
- delete[] s;
return TRUE;
}
}
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)
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
if (resource)
{
wxString oldResource(resource->GetValue4());
- wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s);
+ wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str);
resource->SetValue4(resName);
if (!oldResource.IsNull())
}
message->SetBitmap(* bitmap);
- delete[] s;
return TRUE;
}
}
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")
wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text);
resource->SetStyle(flag);
- wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this);
+ m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this);
return TRUE;
}
else
wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox);
if (resource)
resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
- wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this);
+ m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this);
return TRUE;
}
else
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")
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;
}
if (name == "numberRowsOrCols")
{
radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue());
- wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
+ m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
return TRUE;
}
else if (name == "orientation")
wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox);
resource->SetStyle(windowStyle);
- wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
+ m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
return TRUE;
}
else if (name == "values")
expr = expr->GetNext();
}
resource->SetStringValues(stringList);
- wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
+ m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
return TRUE;
}
return wxItemPropertyInfo::SetProperty(name, property);
slider = (wxSlider *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider, this);
slider->SetSize(-1, -1, h, w);
+ m_propertyWindow = slider;
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);
-
+// 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")
wxColour col(r,g,b);
panelWindow->SetBackgroundColour(col);
panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this);
+ m_propertyWindow = panelWindow;
return TRUE;
}
else if (name == "title")
}
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;
}
{
wxString symbolName(dialog->GetSymbol());
long id = dialog->GetId();
- dialog->Destroy();
wxString str;
str.Printf("%d", id);
view->UpdatePropertyDisplayInList(property);
view->OnPropertyChanged(property);
}
+ // Moved from the 'if' branch on suggestion of Roman Pavlov
+ dialog->Destroy();
}
BEGIN_EVENT_TABLE(wxResourceSymbolDialog, wxDialog)