]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/dialoged/src/reseditr.cpp
SetTitle() works even if menu was created without title initially (and setting
[wxWidgets.git] / utils / dialoged / src / reseditr.cpp
index ebdfdc6a8aa73d70999b63f893f7658c80e07a7d..507ced9872bf1409f7420b7bc94a1f50e2adc567 100644 (file)
@@ -37,6 +37,7 @@
 #endif
 
 #include "wx/scrolbar.h"
+#include "wx/config.h"
 
 #include <ctype.h>
 #include <stdlib.h>
@@ -53,7 +54,7 @@
 #include <windows.h>
 #endif
 
-#ifndef __WXGTK__
+#ifdef __WXMSW__
 #include "wx/help.h"
 #endif
 
@@ -70,17 +71,17 @@ wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL;
 #include "bitmaps/load.xpm"
 #include "bitmaps/save.xpm"
 #include "bitmaps/new.xpm"
-#include "bitmaps/vert.xbm"
-#include "bitmaps/alignt.xbm"
-#include "bitmaps/alignb.xbm"
-#include "bitmaps/horiz.xbm"
-#include "bitmaps/alignl.xbm"
-#include "bitmaps/alignr.xbm"
-#include "bitmaps/copysize.xbm"
-#include "bitmaps/tofront.xbm"
-#include "bitmaps/toback.xbm"
-#include "bitmaps/help.xbm"
-#include "bitmaps/wxwin.xbm"
+#include "bitmaps/vert.xpm"
+#include "bitmaps/alignt.xpm"
+#include "bitmaps/alignb.xpm"
+#include "bitmaps/horiz.xpm"
+#include "bitmaps/alignl.xpm"
+#include "bitmaps/alignr.xpm"
+#include "bitmaps/copysize.xpm"
+#include "bitmaps/tofront.xpm"
+#include "bitmaps/toback.xpm"
+#include "bitmaps/help.xpm"
+#include "bitmaps/wxwin.xpm"
 #endif
 
 /*
@@ -104,8 +105,8 @@ wxResourceManager::wxResourceManager():
   m_editorToolBar = NULL;
 
   // Default window positions
-  m_resourceEditorWindowSize.width = 470;
-  m_resourceEditorWindowSize.height = 300;
+  m_resourceEditorWindowSize.width = 500;
+  m_resourceEditorWindowSize.height = 450;
 
   m_resourceEditorWindowSize.x = 0;
   m_resourceEditorWindowSize.y = 0;
@@ -113,7 +114,7 @@ wxResourceManager::wxResourceManager():
   m_propertyWindowSize.width = 300;
   m_propertyWindowSize.height = 300;
 
-#ifndef __WXGTK__
+#ifdef __WXMSW__
   m_helpController = NULL;
 #endif
 
@@ -126,7 +127,7 @@ wxResourceManager::~wxResourceManager()
   sm_currentResourceManager = NULL;
   SaveOptions();
 
-#ifndef __WXGTK__
+#ifdef __WXMSW__
   if (m_helpController)
   {
     m_helpController->Quit();
@@ -149,17 +150,15 @@ bool wxResourceManager::Initialize()
   strcat(buf, "\\dialoged.ini");
   m_optionsResourceFilename = buf;
 #elif defined(__WXGTK__)
-  char buf[500];
-  wxGetHomeDir(buf);
-  strcat(buf, "/.dialogedrc");
-  m_optionsResourceFilename = buf;
+  wxGetHomeDir( &m_optionsResourceFilename );
+  m_optionsResourceFilename += "/.dialogedrc";
 #else
 #error "Unsupported platform."
 #endif
 
   LoadOptions();
 
-#ifndef __WXGTK__
+#ifdef __WXMSW__
   m_helpController = new wxHelpController;
   m_helpController->Initialize("dialoged");
 #endif
@@ -174,7 +173,7 @@ bool wxResourceManager::Initialize()
     m_bitmapImage = new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE);
 #endif
 #ifdef __WXGTK__
-    m_bitmapImage = new wxBitmap(wxwin_bits, wxwin_width, wxwin_height);
+    m_bitmapImage = new wxBitmap( wxwin_xpm );
 #endif
   }
 
@@ -197,6 +196,18 @@ bool wxResourceManager::Initialize()
 
 bool wxResourceManager::LoadOptions()
 {
+  wxConfig config("DialogEd", "wxWindows");
+
+  config.Read("editorWindowX", &m_resourceEditorWindowSize.x);
+  config.Read("editorWindowY", &m_resourceEditorWindowSize.y);
+  config.Read("editorWindowWidth", &m_resourceEditorWindowSize.width);
+  config.Read("editorWindowHeight", &m_resourceEditorWindowSize.height);
+  config.Read("propertyWindowX", &m_propertyWindowSize.x);
+  config.Read("propertyWindowY", &m_propertyWindowSize.y);
+  config.Read("propertyWindowWidth", &m_propertyWindowSize.width);
+  config.Read("propertyWindowHeight", &m_propertyWindowSize.height);
+
+  /*
   wxGetResource("DialogEd", "editorWindowX", &m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
   wxGetResource("DialogEd", "editorWindowY", &m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
   wxGetResource("DialogEd", "editorWindowWidth", &m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
@@ -205,11 +216,23 @@ bool wxResourceManager::LoadOptions()
   wxGetResource("DialogEd", "propertyWindowY", &m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
   wxGetResource("DialogEd", "propertyWindowWidth", &m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
   wxGetResource("DialogEd", "propertyWindowHeight", &m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
+  */
   return TRUE;
 }
 
 bool wxResourceManager::SaveOptions()
 {
+  wxConfig config("DialogEd", "wxWindows");
+
+  config.Write("editorWindowX", m_resourceEditorWindowSize.x);
+  config.Write("editorWindowY", m_resourceEditorWindowSize.y);
+  config.Write("editorWindowWidth", m_resourceEditorWindowSize.width);
+  config.Write("editorWindowHeight", m_resourceEditorWindowSize.height);
+  config.Write("propertyWindowX", m_propertyWindowSize.x);
+  config.Write("propertyWindowY", m_propertyWindowSize.y);
+  config.Write("propertyWindowWidth", m_propertyWindowSize.width);
+  config.Write("propertyWindowHeight", m_propertyWindowSize.height);
+  /*
   wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
   wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
   wxWriteResource("DialogEd", "editorWindowWidth", m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
@@ -219,6 +242,7 @@ bool wxResourceManager::SaveOptions()
   wxWriteResource("DialogEd", "propertyWindowY", m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
   wxWriteResource("DialogEd", "propertyWindowWidth", m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
   wxWriteResource("DialogEd", "propertyWindowHeight", m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
+  */
 
   return TRUE;
 }
@@ -285,7 +309,7 @@ bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent)
     c->bottom.SameAs     (m_editorFrame, wxBottom, 0);
     c->width.Unconstrained();
 #ifdef __WXGTK__
-    c->height.Absolute(70);
+    c->height.Absolute(140);
 #else
     c->height.Absolute(60);
 #endif
@@ -663,8 +687,7 @@ wxFrame *wxResourceManager::OnCreateEditorFrame(const char *title)
 
   frame->SetAutoLayout(TRUE);
 #ifdef __WXMSW__
-  wxIcon *icon = new wxIcon("DIALOGEDICON");
-  frame->SetIcon(icon);
+  frame->SetIcon(wxIcon("DIALOGEDICON"));
 #endif
   return frame;
 }
@@ -734,16 +757,16 @@ wxToolBar *wxResourceManager::OnCreateToolBar(wxFrame *parent)
   wxBitmap ToolbarLoadBitmap( load_xpm );
   wxBitmap ToolbarSaveBitmap( save_xpm);
   wxBitmap ToolbarNewBitmap( new_xpm );
-  wxBitmap ToolbarVertBitmap(vert_bits, vert_width, vert_height);
-  wxBitmap ToolbarAlignTBitmap(alignt_bits, alignt_width, alignt_height);
-  wxBitmap ToolbarAlignBBitmap(alignb_bits, alignb_width, alignb_height);
-  wxBitmap ToolbarHorizBitmap(horiz_bits, horiz_width, horiz_height);
-  wxBitmap ToolbarAlignLBitmap(alignl_bits, alignl_width, alignl_height);
-  wxBitmap ToolbarAlignRBitmap(alignr_bits, alignr_width, alignr_height);
-  wxBitmap ToolbarCopySizeBitmap(copysize_bits, copysize_width, copysize_height);
-  wxBitmap ToolbarToBackBitmap(toback_bits, toback_width, toback_height);
-  wxBitmap ToolbarToFrontBitmap(tofront_bits, tofront_width, tofront_height);
-  wxBitmap ToolbarHelpBitmap(help_bits, help_width, help_height);
+  wxBitmap ToolbarVertBitmap( vert_xpm );
+  wxBitmap ToolbarAlignTBitmap( alignt_xpm );
+  wxBitmap ToolbarAlignBBitmap( alignb_xpm );
+  wxBitmap ToolbarHorizBitmap( horiz_xpm );
+  wxBitmap ToolbarAlignLBitmap( alignl_xpm );
+  wxBitmap ToolbarAlignRBitmap( alignr_xpm );
+  wxBitmap ToolbarCopySizeBitmap( copysize_xpm );
+  wxBitmap ToolbarToBackBitmap( toback_xpm );
+  wxBitmap ToolbarToFrontBitmap( tofront_xpm );
+  wxBitmap ToolbarHelpBitmap( help_xpm );
 #endif
 
   // Create the toolbar
@@ -869,7 +892,7 @@ void wxResourceManager::AddItemsRecursively(long parent, wxItemResource *resourc
       node = node->Next();
     }
   }
-  m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND);
+//  m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND);
 }
 
 bool wxResourceManager::EditSelectedResource()
@@ -897,8 +920,8 @@ bool wxResourceManager::Edit(wxItemResource *res)
   }
   else
   {
-        long style = res->GetStyle();
-        res->SetStyle(style|wxRAISED_BORDER);
+//        long style = res->GetStyle();
+//        res->SetStyle(style|wxRAISED_BORDER);
         panel = new wxPanel;
         wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(panel, res, panel->GetEventHandler(),
            this);
@@ -907,7 +930,7 @@ bool wxResourceManager::Edit(wxItemResource *res)
 
         panel->PushEventHandler(handler);
 
-        res->SetStyle(style);
+//        res->SetStyle(style);
                handler->AddChildHandlers(); // Add event handlers for all controls
         AssociateResource(res, panel);
 
@@ -1427,7 +1450,9 @@ bool wxResourceManager::DeleteResource(wxWindow *win)
     {
       RemoveSelection(item);
       childHandler->SelectItem(FALSE);
+#ifndef __WXGTK__
       item->GetParent()->Refresh();
+#endif
     }
   }
   
@@ -2047,7 +2072,7 @@ void wxResourceEditorFrame::OnTest(wxCommandEvent& WXUNUSED(event))
 
 void wxResourceEditorFrame::OnContents(wxCommandEvent& WXUNUSED(event))
 {
-#ifndef __WXGTK__
+#ifdef __WXMSW__
       wxBeginBusyCursor();
       manager->GetHelpController()->LoadFile();
       manager->GetHelpController()->DisplayContents();
@@ -2187,10 +2212,19 @@ void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event)
  *
  */
 
+#ifdef __WXGTK__   // I don't dare to delete it...
+BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
+END_EVENT_TABLE()
+
+#else
+
 BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
        EVT_PAINT(EditorToolBar::OnPaint)
 END_EVENT_TABLE()
 
+#endif
+
 EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size,
             long style):
   wxToolBar(frame, -1, pos, size, style)
@@ -2220,7 +2254,7 @@ bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled)
     }
     case TOOLBAR_HELP:
     {
-#ifndef __WXGTK__
+#ifdef __WXMSW__
       wxBeginBusyCursor();
       manager->GetHelpController()->LoadFile();
       manager->GetHelpController()->DisplayContents();
@@ -2335,18 +2369,3 @@ void EditorToolBar::OnMouseEnter(int toolIndex)
   else frame->SetStatusText("");
 }
 
-void EditorToolBar::OnPaint(wxPaintEvent& event)
-{
-#ifndef __WXGTK__
-  wxToolBar::OnPaint(event);
-
-  wxPaintDC dc(this);
-  int w, h;
-  GetSize(&w, &h);
-  dc.SetPen(wxBLACK_PEN);
-  dc.SetBrush(wxTRANSPARENT_BRUSH);
-  dc.DrawLine(0, h-1, w, h-1);
-#endif
-}
-
-