]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/dialoged/src/winprop.cpp
added cmdline.h/.cpp to the makefiles
[wxWidgets.git] / utils / dialoged / src / winprop.cpp
index 5985d0adc77246d50393699fa1b7e1018676eb99..ad0bd926f666c6532d8c001eb8b1f426e39ced09 100644 (file)
 #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
@@ -857,12 +847,11 @@ bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *propert
     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
@@ -871,7 +860,7 @@ 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())
@@ -879,7 +868,6 @@ bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *propert
         }
 
         button->SetLabel(* bitmap);
-        delete[] s;
         return TRUE;
       }
     }
@@ -956,13 +944,12 @@ bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *propert
     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
@@ -971,7 +958,7 @@ 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())
@@ -979,7 +966,6 @@ bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *propert
         }
 
         message->SetBitmap(* bitmap);
-        delete[] s;
         return TRUE;
       }
     }
@@ -1047,7 +1033,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")
@@ -1066,7 +1052,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
@@ -1162,7 +1148,7 @@ bool wxListBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
     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
@@ -1326,7 +1312,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")
@@ -1347,7 +1333,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;
   }
@@ -1422,7 +1408,7 @@ bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
   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")
@@ -1445,7 +1431,7 @@ bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
     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")
@@ -1467,7 +1453,7 @@ bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
       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);
@@ -1673,6 +1659,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;
   }
@@ -1829,12 +1816,17 @@ 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")
@@ -2031,6 +2023,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")
@@ -2110,6 +2103,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;
   }
@@ -2357,7 +2351,6 @@ void wxResourceSymbolValidator::OnEdit(wxProperty *property, wxPropertyListView
   {
     wxString symbolName(dialog->GetSymbol());
     long id = dialog->GetId();
-    dialog->Destroy();
 
     wxString str;
     str.Printf("%d", id);
@@ -2367,6 +2360,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)