#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
+ {
+ CloseWindow(); // Close the window so we can open a new one
+ }
+ }
int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width;
int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height;
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,
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
*/
{
wxFont *newFont = SetFontProperty(name, property, font);
if (newFont)
+ {
m_propertyWindow->SetFont(* newFont);
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ if (resource)
+ {
+ resource->SetFont(* newFont);
+ }
+ }
+
return TRUE;
}
else if (name == "name")
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)))
bool wxItemPropertyInfo::SetProperty(wxString& name, wxProperty *property)
{
wxControl *itemWindow = (wxControl *)m_propertyWindow;
+#if 0
wxFont *font = & itemWindow->GetFont();
if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" ))
itemWindow->SetFont(* newFont);
return TRUE;
}
- else if (name == "label")
+ else
+#endif
+ if (name == "label")
{
itemWindow->SetLabel(property->GetValue().StringValue());
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)
wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow;
if (name == "numberRowsOrCols")
{
+ wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox);
+
radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue());
m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
return TRUE;
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
- m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this);
+ m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE);
return TRUE;
}
else if (name == "values")
expr = expr->GetNext();
}
resource->SetStringValues(stringList);
- m_propertyWindow = 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);
}