+ wxWindowPropertyInfo *info = NULL;
+ if (win->IsKindOf(CLASSINFO(wxScrollBar)))
+ {
+ info = new wxScrollBarPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxStaticBox)))
+ {
+ info = new wxGroupBoxPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxCheckBox)))
+ {
+ info = new wxCheckBoxPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxSlider)))
+ {
+ info = new wxSliderPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxGauge)))
+ {
+ info = new wxGaugePropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxListBox)))
+ {
+ info = new wxListBoxPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxRadioBox)))
+ {
+ info = new wxRadioBoxPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxRadioButton)))
+ {
+ info = new wxRadioButtonPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxComboBox)))
+ {
+ info = new wxComboBoxPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxChoice)))
+ {
+ info = new wxChoicePropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxBitmapButton)))
+ {
+ info = new wxBitmapButtonPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxButton)))
+ {
+ info = new wxButtonPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxStaticBitmap)))
+ {
+ info = new wxStaticBitmapPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxStaticText)))
+ {
+ info = new wxStaticTextPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxTextCtrl)))
+ {
+ info = new wxTextPropertyInfo(win);
+ }
+ else if (win->IsKindOf(CLASSINFO(wxPanel)))
+ {
+ info = new wxPanelPropertyInfo(win);
+ }
+ else
+ {
+ info = new wxWindowPropertyInfo(win);
+ }
+ return info;
+}
+
+// Edit the given window
+void wxResourceManager::EditWindow(wxWindow *win)
+{
+ wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(win);
+ if (info)
+ {
+ info->SetResource(FindResourceForWindow(win));
+ wxString str("Editing ");
+ str += win->GetClassInfo()->GetClassName();
+ str += ": ";
+ if (win->GetName() != "")
+ str += win->GetName();
+ else
+ str += "properties";
+ info->Edit(NULL, str);
+ }
+}
+
+// Generate a window id and a first stab at a name
+int wxResourceManager::GenerateWindowId(const wxString& prefix, wxString& idName)
+{
+ m_symbolIdCounter ++;
+ while (m_symbolTable.IdExists(m_symbolIdCounter))
+ m_symbolIdCounter ++;
+
+ int nameId = m_symbolIdCounter;
+
+ wxString str;
+ str.Printf("%d", nameId);
+ idName = prefix + str;
+
+ while (m_symbolTable.SymbolExists(idName))
+ {
+ nameId ++;
+ str.Printf("%d", nameId);
+ idName = prefix + str;
+ }
+
+ return m_symbolIdCounter;
+}
+
+
+/*
+* Resource editor frame
+*/
+
+IMPLEMENT_CLASS(wxResourceEditorFrame, wxFrame)
+
+BEGIN_EVENT_TABLE(wxResourceEditorFrame, wxFrame)
+EVT_MENU(wxID_NEW, wxResourceEditorFrame::OnNew)
+EVT_MENU(RESED_NEW_DIALOG, wxResourceEditorFrame::OnNewDialog)
+EVT_MENU(wxID_OPEN, wxResourceEditorFrame::OnOpen)
+EVT_MENU(RESED_CLEAR, wxResourceEditorFrame::OnClear)
+EVT_MENU(wxID_SAVE, wxResourceEditorFrame::OnSave)
+EVT_MENU(wxID_SAVEAS, wxResourceEditorFrame::OnSaveAs)
+EVT_MENU(wxID_EXIT, wxResourceEditorFrame::OnExit)
+EVT_MENU(wxID_ABOUT, wxResourceEditorFrame::OnAbout)
+EVT_MENU(RESED_CONTENTS, wxResourceEditorFrame::OnContents)
+EVT_MENU(RESED_DELETE, wxResourceEditorFrame::OnDeleteSelection)
+EVT_MENU(RESED_RECREATE, wxResourceEditorFrame::OnRecreateSelection)
+EVT_MENU(RESED_TEST, wxResourceEditorFrame::OnTest)
+EVT_MENU(RESED_CONVERT_WXRS, wxResourceEditorFrame::OnConvertWXRs)
+EVT_CLOSE(wxResourceEditorFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title,
+ const wxPoint& pos, const wxSize& size, long style, const wxString& name):
+wxFrame(parent, -1, title, pos, size, style, name)
+{
+ manager = resMan;
+}
+
+wxResourceEditorFrame::~wxResourceEditorFrame()
+{
+}
+
+void wxResourceEditorFrame::OnConvertWXRs(wxCommandEvent& WXUNUSED(event))
+{
+ manager->ConvertWXRs();
+}
+
+void wxResourceEditorFrame::OnNew(wxCommandEvent& WXUNUSED(event))
+{
+ manager->New(FALSE);
+}
+
+void wxResourceEditorFrame::OnNewDialog(wxCommandEvent& WXUNUSED(event))
+{
+ manager->CreateNewPanel();
+}
+
+void wxResourceEditorFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
+{
+ manager->New(TRUE);
+}
+
+void wxResourceEditorFrame::OnClear(wxCommandEvent& WXUNUSED(event))
+{
+ manager->Clear(TRUE, FALSE);
+}
+
+void wxResourceEditorFrame::OnSave(wxCommandEvent& WXUNUSED(event))
+{
+ manager->Save();
+}
+
+void wxResourceEditorFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event))
+{
+ manager->SaveAs();
+}
+
+void wxResourceEditorFrame::OnExit(wxCommandEvent& WXUNUSED(event))
+{
+ manager->Clear(TRUE, FALSE) ;
+ this->Destroy();
+}
+
+void wxResourceEditorFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+ char buf[300];
+ sprintf(buf, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart <julian.smart@ukonline.co.uk>\nJulian Smart (c) 1996-1999", wxDIALOG_EDITOR_VERSION);
+ wxMessageBox(buf, "About Dialog Editor", wxOK|wxCENTRE);
+}
+
+void wxResourceEditorFrame::OnTest(wxCommandEvent& WXUNUSED(event))
+{
+ manager->TestCurrentDialog(this);
+}
+
+void wxResourceEditorFrame::OnContents(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WXMSW__
+ wxBeginBusyCursor();
+ manager->GetHelpController()->LoadFile();
+ manager->GetHelpController()->DisplayContents();
+ wxEndBusyCursor();
+#endif
+}
+
+void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent& WXUNUSED(event))
+{
+ manager->DeleteSelection();
+}
+
+void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent& WXUNUSED(event))
+{
+ manager->RecreateSelection();
+}
+
+void wxResourceEditorFrame::OnCloseWindow(wxCloseEvent& event)
+{
+ wxPropertyInfo::CloseWindow();
+ manager->ClearCurrentDialog();
+ if (manager->Modified())
+ {
+ if (!manager->Clear(TRUE, FALSE))
+ {
+ event.Veto();
+ return;
+ }
+ }
+
+ if (!IsIconized())
+ {
+ int w, h;
+ GetSize(&w, &h);
+ manager->m_resourceEditorWindowSize.width = w;
+ manager->m_resourceEditorWindowSize.height = h;
+
+ int x, y;
+ GetPosition(&x, &y);
+
+ manager->m_resourceEditorWindowSize.x = x;
+ manager->m_resourceEditorWindowSize.y = y;
+ }
+ manager->SetEditorFrame(NULL);
+ manager->SetEditorToolBar(NULL);
+
+ this->Destroy();
+}
+
+/*
+* Resource editor window that contains the dialog/panel being edited
+*/
+
+BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow, wxScrolledWindow)
+EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint)
+END_EVENT_TABLE()
+
+wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size,
+ long style):
+wxScrolledWindow(parent, -1, pos, size, style)
+{
+ m_marginX = 10;
+ m_marginY = 40;
+ m_childWindow = NULL;
+
+ SetBackgroundColour(* wxWHITE);
+}
+
+wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
+{
+}
+
+void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
+{
+ wxPaintDC dc(this);
+
+ DrawTitle(dc);
+}
+
+void wxResourceEditorScrolledWindow::DrawTitle(wxDC& dc)
+{
+ if (m_childWindow)
+ {
+ wxItemResource* res = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_childWindow);
+ if (res)
+ {
+ wxString str(res->GetTitle());
+ int x, y;
+ GetViewStart(& x, & y);
+
+ wxFont font(10, wxSWISS, wxNORMAL, wxBOLD);
+ dc.SetFont(font);
+ dc.SetBackgroundMode(wxTRANSPARENT);
+ dc.SetTextForeground(wxColour(0, 0, 0));
+
+ long w, h;
+ dc.GetTextExtent(str, & w, & h);
+
+ dc.DrawText(str, m_marginX + (- x * 10), m_marginY + (- y * 10) - h - 5);
+ }
+ }
+}
+
+/*
+* Main toolbar
+*
+*/
+
+BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
+// EVT_PAINT(EditorToolBar::OnPaint)
+END_EVENT_TABLE()
+
+EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size,
+ long style):
+wxToolBar(frame, -1, pos, size, style)
+{
+}
+
+bool EditorToolBar::OnLeftClick(int toolIndex, bool WXUNUSED(toggled))
+{
+ wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager();
+
+ switch (toolIndex)
+ {
+ case TOOLBAR_LOAD_FILE:
+ {
+ manager->New(TRUE);
+ break;
+ }
+ case TOOLBAR_NEW:
+ {
+ manager->CreateNewPanel();
+ break;
+ }
+ case TOOLBAR_SAVE_FILE: