1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Resource editor class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "reseditr.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/checkbox.h"
27 #include "wx/button.h"
28 #include "wx/choice.h"
29 #include "wx/listbox.h"
30 #include "wx/radiobox.h"
31 #include "wx/statbox.h"
33 #include "wx/slider.h"
34 #include "wx/textctrl.h"
36 #include "wx/toolbar.h"
39 #include "wx/scrolbar.h"
40 #include "wx/config.h"
47 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
50 #include <strstream.h>
67 static void ObjectMenuProc(wxMenu
& menu
, wxCommandEvent
& event
);
68 wxResourceManager
*wxResourceManager::sm_currentResourceManager
= NULL
;
71 #include "bitmaps/load.xpm"
72 #include "bitmaps/save.xpm"
73 #include "bitmaps/new.xpm"
74 #include "bitmaps/vert.xpm"
75 #include "bitmaps/alignt.xpm"
76 #include "bitmaps/alignb.xpm"
77 #include "bitmaps/horiz.xpm"
78 #include "bitmaps/alignl.xpm"
79 #include "bitmaps/alignr.xpm"
80 #include "bitmaps/copysize.xpm"
81 #include "bitmaps/tofront.xpm"
82 #include "bitmaps/toback.xpm"
83 #include "bitmaps/help.xpm"
84 #include "bitmaps/wxwin.xpm"
91 wxResourceManager::wxResourceManager():
92 m_imageList(16, 16, TRUE
)
94 sm_currentResourceManager
= this;
98 m_editorResourceTree
= NULL
;
99 m_editorControlList
= NULL
;
101 m_symbolIdCounter
= 99;
103 m_currentFilename
= "";
104 m_symbolFilename
= "";
105 m_editorToolBar
= NULL
;
107 // Default window positions
108 m_resourceEditorWindowSize
.width
= 500;
109 m_resourceEditorWindowSize
.height
= 450;
111 m_resourceEditorWindowSize
.x
= 0;
112 m_resourceEditorWindowSize
.y
= 0;
114 m_propertyWindowSize
.width
= 300;
115 m_propertyWindowSize
.height
= 300;
118 m_helpController
= NULL
;
121 m_bitmapImage
= NULL
;
122 m_rootDialogItem
= 0;
125 wxResourceManager::~wxResourceManager()
127 sm_currentResourceManager
= NULL
;
131 if (m_helpController
)
133 m_helpController
->Quit();
134 delete m_helpController
;
135 m_helpController
= NULL
;
139 delete m_bitmapImage
;
143 bool wxResourceManager::Initialize()
145 // Set up the resource filename for each platform.
147 // dialoged.ini in the Windows directory
149 GetWindowsDirectory(buf
, 256);
150 strcat(buf
, "\\dialoged.ini");
151 m_optionsResourceFilename
= buf
;
152 #elif defined(__WXGTK__)
153 wxGetHomeDir( &m_optionsResourceFilename
);
154 m_optionsResourceFilename
+= "/.dialogedrc";
156 #error "Unsupported platform."
162 m_helpController
= new wxHelpController
;
163 m_helpController
->Initialize("dialoged");
166 m_popupMenu
= new wxMenu("", (wxFunction
)ObjectMenuProc
);
167 m_popupMenu
->Append(OBJECT_MENU_EDIT
, "Edit properties");
168 m_popupMenu
->Append(OBJECT_MENU_DELETE
, "Delete object");
173 m_bitmapImage
= new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE
);
176 m_bitmapImage
= new wxBitmap( wxwin_xpm
);
180 // Initialize the image list icons
182 wxIcon
icon1("DIALOG_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
183 wxIcon
icon2("FOLDER1_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
184 wxIcon
icon3("FOLDER2_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
185 wxIcon
icon4("BUTTONSM_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
186 m_imageList
.Add(icon1
);
187 m_imageList
.Add(icon2
);
188 m_imageList
.Add(icon3
);
189 m_imageList
.Add(icon4
);
192 m_symbolTable
.AddStandardSymbols();
197 bool wxResourceManager::LoadOptions()
199 wxConfig
config("DialogEd", "wxWindows");
201 config
.Read("editorWindowX", &m_resourceEditorWindowSize
.x
);
202 config
.Read("editorWindowY", &m_resourceEditorWindowSize
.y
);
203 config
.Read("editorWindowWidth", &m_resourceEditorWindowSize
.width
);
204 config
.Read("editorWindowHeight", &m_resourceEditorWindowSize
.height
);
205 config
.Read("propertyWindowX", &m_propertyWindowSize
.x
);
206 config
.Read("propertyWindowY", &m_propertyWindowSize
.y
);
207 config
.Read("propertyWindowWidth", &m_propertyWindowSize
.width
);
208 config
.Read("propertyWindowHeight", &m_propertyWindowSize
.height
);
211 wxGetResource("DialogEd", "editorWindowX", &m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
212 wxGetResource("DialogEd", "editorWindowY", &m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
213 wxGetResource("DialogEd", "editorWindowWidth", &m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
214 wxGetResource("DialogEd", "editorWindowHeight", &m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
215 wxGetResource("DialogEd", "propertyWindowX", &m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
216 wxGetResource("DialogEd", "propertyWindowY", &m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
217 wxGetResource("DialogEd", "propertyWindowWidth", &m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
218 wxGetResource("DialogEd", "propertyWindowHeight", &m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
223 bool wxResourceManager::SaveOptions()
225 wxConfig
config("DialogEd", "wxWindows");
227 config
.Write("editorWindowX", m_resourceEditorWindowSize
.x
);
228 config
.Write("editorWindowY", m_resourceEditorWindowSize
.y
);
229 config
.Write("editorWindowWidth", m_resourceEditorWindowSize
.width
);
230 config
.Write("editorWindowHeight", m_resourceEditorWindowSize
.height
);
231 config
.Write("propertyWindowX", m_propertyWindowSize
.x
);
232 config
.Write("propertyWindowY", m_propertyWindowSize
.y
);
233 config
.Write("propertyWindowWidth", m_propertyWindowSize
.width
);
234 config
.Write("propertyWindowHeight", m_propertyWindowSize
.height
);
236 wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
237 wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
238 wxWriteResource("DialogEd", "editorWindowWidth", m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
239 wxWriteResource("DialogEd", "editorWindowHeight", m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
241 wxWriteResource("DialogEd", "propertyWindowX", m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
242 wxWriteResource("DialogEd", "propertyWindowY", m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
243 wxWriteResource("DialogEd", "propertyWindowWidth", m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
244 wxWriteResource("DialogEd", "propertyWindowHeight", m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
250 // Show or hide the resource editor frame, which displays a list
251 // of resources with ability to edit them.
252 bool wxResourceManager::ShowResourceEditor(bool show
, wxWindow
*WXUNUSED(parent
), const char *title
)
258 m_editorFrame
->Iconize(FALSE
);
259 m_editorFrame
->Show(TRUE
);
262 m_editorFrame
= OnCreateEditorFrame(title
);
264 wxMenuBar
*menuBar
= OnCreateEditorMenuBar(m_editorFrame
);
265 m_editorFrame
->SetMenuBar(menuBar
);
267 m_editorToolBar
= (EditorToolBar
*)OnCreateToolBar(m_editorFrame
);
268 m_editorControlList
= new wxResourceEditorControlList(m_editorFrame
, IDC_LISTCTRL
, wxPoint(0, 0), wxSize(-1, -1));
269 m_editorResourceTree
= new wxResourceEditorProjectTree(m_editorFrame
, IDC_TREECTRL
, wxPoint(0, 0), wxSize(-1, -1),
271 m_editorPanel
= OnCreateEditorPanel(m_editorFrame
);
273 m_editorResourceTree
->SetImageList(& m_imageList
);
275 // Constraints for toolbar
276 wxLayoutConstraints
*c
= new wxLayoutConstraints
;
277 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
278 c
->top
.SameAs (m_editorFrame
, wxTop
, 0);
279 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
280 c
->bottom
.Unconstrained();
281 c
->width
.Unconstrained();
282 c
->height
.Absolute(28);
283 m_editorToolBar
->SetConstraints(c
);
285 // Constraints for listbox
286 c
= new wxLayoutConstraints
;
287 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
288 c
->top
.SameAs (m_editorToolBar
, wxBottom
, 0);
289 c
->right
.Absolute (150);
290 c
->bottom
.SameAs (m_editorControlList
, wxTop
, 0);
291 c
->width
.Unconstrained();
292 c
->height
.Unconstrained();
293 m_editorResourceTree
->SetConstraints(c
);
295 // Constraints for panel
296 c
= new wxLayoutConstraints
;
297 c
->left
.SameAs (m_editorResourceTree
, wxRight
, 0);
298 c
->top
.SameAs (m_editorToolBar
, wxBottom
, 0);
299 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
300 c
->bottom
.SameAs (m_editorControlList
, wxTop
, 0);
301 c
->width
.Unconstrained();
302 c
->height
.Unconstrained();
303 m_editorPanel
->SetConstraints(c
);
305 // Constraints for control list (bottom window)
306 c
= new wxLayoutConstraints
;
307 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
308 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
309 c
->bottom
.SameAs (m_editorFrame
, wxBottom
, 0);
310 c
->width
.Unconstrained();
312 c
->height
.Absolute(140);
314 c
->height
.Absolute(60);
317 m_editorControlList
->SetConstraints(c
);
319 m_editorFrame
->SetAutoLayout(TRUE
);
321 UpdateResourceList();
323 m_editorFrame
->Show(TRUE
);
328 wxFrame
*fr
= m_editorFrame
;
329 if (m_editorFrame
->OnClose())
333 m_editorFrame
= NULL
;
334 m_editorPanel
= NULL
;
340 void wxResourceManager::SetFrameTitle(const wxString
& filename
)
344 if (filename
== wxString(""))
345 m_editorFrame
->SetTitle("wxWindows Dialog Editor - untitled");
348 wxString
str("wxWindows Dialog Editor - ");
349 wxString
str2(wxFileNameFromPath(WXSTRINGCAST filename
));
351 m_editorFrame
->SetTitle(str
);
356 bool wxResourceManager::Save()
358 if (m_currentFilename
== wxString(""))
361 return Save(m_currentFilename
);
364 bool wxResourceManager::Save(const wxString
& filename
)
366 // Ensure all visible windows are saved to their resources
367 m_currentFilename
= filename
;
368 SetFrameTitle(m_currentFilename
);
369 InstantiateAllResourcesFromWindows();
370 if (m_resourceTable
.Save(filename
))
372 m_symbolTable
.WriteIncludeFile(m_symbolFilename
);
380 bool wxResourceManager::SaveAs()
382 wxString
s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename
), wxFileNameFromPath(WXSTRINGCAST m_currentFilename
),
383 "wxr", "*.wxr", wxSAVE
| wxOVERWRITE_PROMPT
));
385 if (s
.IsNull() || s
== "")
388 m_currentFilename
= s
;
389 wxStripExtension(m_currentFilename
);
390 m_currentFilename
+= ".wxr";
392 // Construct include filename from this file
393 m_symbolFilename
= m_currentFilename
;
395 wxStripExtension(m_symbolFilename
);
396 m_symbolFilename
+= ".h";
398 Save(m_currentFilename
);
402 bool wxResourceManager::SaveIfModified()
409 bool wxResourceManager::Load(const wxString
& filename
)
411 return New(TRUE
, filename
);
414 bool wxResourceManager::New(bool loadFromFile
, const wxString
& filename
)
416 if (!Clear(TRUE
, FALSE
))
419 m_symbolTable
.AddStandardSymbols();
423 wxString str
= filename
;
424 if (str
== wxString(""))
426 wxString
f(wxFileSelector("Open resource file", NULL
, NULL
, "wxr", "*.wxr", 0, NULL
));
427 if (!f
.IsNull() && f
!= "")
433 if (!m_resourceTable
.ParseResourceFile(WXSTRINGCAST str
))
435 wxMessageBox("Could not read file.", "Resource file load error", wxOK
| wxICON_EXCLAMATION
);
438 m_currentFilename
= str
;
440 SetFrameTitle(m_currentFilename
);
442 UpdateResourceList();
444 // Construct include filename from this file
445 m_symbolFilename
= m_currentFilename
;
447 wxStripExtension(m_symbolFilename
);
448 m_symbolFilename
+= ".h";
450 if (!m_symbolTable
.ReadIncludeFile(m_symbolFilename
))
452 wxString
str("Could not find include file ");
453 str
+= m_symbolFilename
;
454 str
+= ".\nDialog Editor maintains a header file containing id symbols to be used in the application.\n";
455 str
+= "The next time this .wxr file is saved, a header file will be saved also.";
456 wxMessageBox(str
, "Dialog Editor Warning", wxOK
);
458 m_symbolIdCounter
= 99;
462 // Set the id counter to the last known id
463 m_symbolIdCounter
= m_symbolTable
.FindHighestId();
466 // Now check in case some (or all) resources don't have resource ids, or they
467 // don't match the .h file, or something of that nature.
468 bool altered
= RepairResourceIds();
471 wxMessageBox("Some resources have had new identifiers associated with them, since they were missing.",
472 "Dialog Editor Warning", wxOK
);
483 m_currentFilename
= "";
490 bool wxResourceManager::Clear(bool WXUNUSED(deleteWindows
), bool force
)
492 if (!force
&& Modified())
494 int ans
= wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO
| wxCANCEL
);
498 if (!SaveIfModified())
504 ClearCurrentDialog();
505 DisassociateWindows();
507 m_symbolTable
.Clear();
508 m_resourceTable
.ClearTable();
509 UpdateResourceList();
514 bool wxResourceManager::DisassociateWindows()
516 m_resourceTable
.BeginFind();
518 while ((node
= m_resourceTable
.Next()))
520 wxItemResource
*res
= (wxItemResource
*)node
->Data();
521 DisassociateResource(res
);
527 void wxResourceManager::AssociateResource(wxItemResource
*resource
, wxWindow
*win
)
529 if (!m_resourceAssociations
.Get((long)resource
))
530 m_resourceAssociations
.Put((long)resource
, win
);
532 wxNode
*node
= resource
->GetChildren().First();
535 wxItemResource
*child
= (wxItemResource
*)node
->Data();
536 wxWindow
*childWindow
= (wxWindow
*)m_resourceAssociations
.Get((long)child
);
538 childWindow
= win
->FindWindow(child
->GetName());
540 AssociateResource(child
, childWindow
);
544 sprintf(buf
, "AssociateResource: cannot find child window %s", child
->GetName() ? (const char*) child
->GetName() : "(unnamed)");
545 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
552 bool wxResourceManager::DisassociateResource(wxItemResource
*resource
)
554 wxWindow
*win
= FindWindowForResource(resource
);
558 // Disassociate children of window
559 if (win
->GetChildren())
561 wxNode
*node
= win
->GetChildren()->First();
564 wxWindow
*child
= (wxWindow
*)node
->Data();
565 if (child
->IsKindOf(CLASSINFO(wxControl
)))
566 DisassociateResource(child
);
571 RemoveSelection(win
);
572 m_resourceAssociations
.Delete((long)resource
);
576 bool wxResourceManager::DisassociateResource(wxWindow
*win
)
578 wxItemResource
*res
= FindResourceForWindow(win
);
580 return DisassociateResource(res
);
585 // Saves the window info into the resource, and deletes the
586 // handler. Doesn't actually disassociate the window from
587 // the resources. Replaces OnClose.
588 bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow
* win
)
590 wxItemResource
*res
= FindResourceForWindow(win
);
592 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
594 wxResourceEditorDialogHandler
* handler
= (wxResourceEditorDialogHandler
*) win
->GetEventHandler();
595 win
->PopEventHandler();
597 // Now reset all child event handlers
598 wxNode
*node
= win
->GetChildren()->First();
601 wxWindow
*child
= (wxWindow
*)node
->Data();
602 wxEvtHandler
*childHandler
= child
->GetEventHandler();
603 if ( child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
!= child
)
605 child
->PopEventHandler(TRUE
);
613 win
->PopEventHandler(TRUE
);
616 // Save the information
617 InstantiateResourceFromWindow(res
, win
, TRUE
);
619 // DisassociateResource(win);
624 // Destroys the window. If this is the 'current' panel, NULLs the
626 bool wxResourceManager::DeleteWindow(wxWindow
* win
)
628 bool clearDisplay
= FALSE
;
629 if (m_editorPanel
->m_childWindow
== win
)
631 m_editorPanel
->m_childWindow
= NULL
;
638 m_editorPanel
->Clear();
643 wxItemResource
*wxResourceManager::FindResourceForWindow(wxWindow
*win
)
645 m_resourceAssociations
.BeginFind();
647 while ((node
= m_resourceAssociations
.Next()))
649 wxWindow
*w
= (wxWindow
*)node
->Data();
652 return (wxItemResource
*)node
->key
.integer
;
658 wxWindow
*wxResourceManager::FindWindowForResource(wxItemResource
*resource
)
660 return (wxWindow
*)m_resourceAssociations
.Get((long)resource
);
664 void wxResourceManager::MakeUniqueName(char *prefix
, char *buf
)
668 sprintf(buf
, "%s%d", prefix
, m_nameCounter
);
671 if (!m_resourceTable
.FindResource(buf
))
676 wxFrame
*wxResourceManager::OnCreateEditorFrame(const char *title
)
679 int frameWidth = 420;
680 int frameHeight = 300;
683 wxResourceEditorFrame
*frame
= new wxResourceEditorFrame(this, NULL
, title
,
684 wxPoint(m_resourceEditorWindowSize
.x
, m_resourceEditorWindowSize
.y
),
685 wxSize(m_resourceEditorWindowSize
.width
, m_resourceEditorWindowSize
.height
),
686 wxDEFAULT_FRAME_STYLE
);
688 frame
->CreateStatusBar(1);
690 frame
->SetAutoLayout(TRUE
);
692 frame
->SetIcon(wxIcon("DIALOGEDICON"));
697 wxMenuBar
*wxResourceManager::OnCreateEditorMenuBar(wxFrame
*WXUNUSED(parent
))
699 wxMenuBar
*menuBar
= new wxMenuBar
;
701 wxMenu
*fileMenu
= new wxMenu
;
702 fileMenu
->Append(RESED_NEW_DIALOG
, "New &dialog", "Create a new dialog");
703 fileMenu
->AppendSeparator();
704 fileMenu
->Append(wxID_NEW
, "&New project", "Clear the current project");
705 fileMenu
->Append(wxID_OPEN
, "&Open...", "Load a resource file");
706 fileMenu
->Append(wxID_SAVE
, "&Save", "Save a resource file");
707 fileMenu
->Append(wxID_SAVEAS
, "Save &As...", "Save a resource file as...");
708 fileMenu
->Append(RESED_CLEAR
, "&Clear", "Clear current resources");
709 fileMenu
->AppendSeparator();
710 fileMenu
->Append(wxID_EXIT
, "E&xit", "Exit resource editor");
712 wxMenu
*editMenu
= new wxMenu
;
713 editMenu
->Append(RESED_TEST
, "&Test Dialog", "Test dialog");
714 editMenu
->Append(RESED_RECREATE
, "&Recreate", "Recreate the selected resource(s)");
715 editMenu
->Append(RESED_DELETE
, "&Delete", "Delete the selected resource(s)");
717 wxMenu
*helpMenu
= new wxMenu
;
718 helpMenu
->Append(RESED_CONTENTS
, "&Help topics", "Invokes the on-line help");
719 helpMenu
->AppendSeparator();
720 helpMenu
->Append(wxID_ABOUT
, "&About", "About wxWindows Dialog Editor");
722 menuBar
->Append(fileMenu
, "&File");
723 menuBar
->Append(editMenu
, "&Edit");
724 menuBar
->Append(helpMenu
, "&Help");
729 wxResourceEditorScrolledWindow
*wxResourceManager::OnCreateEditorPanel(wxFrame
*parent
)
731 wxResourceEditorScrolledWindow
*panel
= new wxResourceEditorScrolledWindow(parent
, wxDefaultPosition
, wxDefaultSize
,
732 // wxSUNKEN_BORDER|wxCLIP_CHILDREN);
735 panel
->SetScrollbars(10, 10, 100, 100);
740 wxToolBar
*wxResourceManager::OnCreateToolBar(wxFrame
*parent
)
742 // Load palette bitmaps
744 wxBitmap
ToolbarLoadBitmap("LOADTOOL");
745 wxBitmap
ToolbarSaveBitmap("SAVETOOL");
746 wxBitmap
ToolbarNewBitmap("NEWTOOL");
747 wxBitmap
ToolbarVertBitmap("VERTTOOL");
748 wxBitmap
ToolbarAlignTBitmap("ALIGNTTOOL");
749 wxBitmap
ToolbarAlignBBitmap("ALIGNBTOOL");
750 wxBitmap
ToolbarHorizBitmap("HORIZTOOL");
751 wxBitmap
ToolbarAlignLBitmap("ALIGNLTOOL");
752 wxBitmap
ToolbarAlignRBitmap("ALIGNRTOOL");
753 wxBitmap
ToolbarCopySizeBitmap("COPYSIZETOOL");
754 wxBitmap
ToolbarToBackBitmap("TOBACKTOOL");
755 wxBitmap
ToolbarToFrontBitmap("TOFRONTTOOL");
756 wxBitmap
ToolbarHelpBitmap("HELPTOOL");
759 wxBitmap
ToolbarLoadBitmap( load_xpm
);
760 wxBitmap
ToolbarSaveBitmap( save_xpm
);
761 wxBitmap
ToolbarNewBitmap( new_xpm
);
762 wxBitmap
ToolbarVertBitmap( vert_xpm
);
763 wxBitmap
ToolbarAlignTBitmap( alignt_xpm
);
764 wxBitmap
ToolbarAlignBBitmap( alignb_xpm
);
765 wxBitmap
ToolbarHorizBitmap( horiz_xpm
);
766 wxBitmap
ToolbarAlignLBitmap( alignl_xpm
);
767 wxBitmap
ToolbarAlignRBitmap( alignr_xpm
);
768 wxBitmap
ToolbarCopySizeBitmap( copysize_xpm
);
769 wxBitmap
ToolbarToBackBitmap( toback_xpm
);
770 wxBitmap
ToolbarToFrontBitmap( tofront_xpm
);
771 wxBitmap
ToolbarHelpBitmap( help_xpm
);
774 // Create the toolbar
775 EditorToolBar
*toolbar
= new EditorToolBar(parent
, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER
|wxTB_HORIZONTAL
);
776 toolbar
->SetMargins(2, 2);
783 int width
= 24; // ToolbarLoadBitmap->GetWidth(); ???
788 toolbar
->AddSeparator();
789 toolbar
->AddTool(TOOLBAR_NEW
, ToolbarNewBitmap
, (wxBitmap
*)NULL
,
790 FALSE
, (float)currentX
, -1, NULL
, "New dialog");
791 currentX
+= width
+ dx
;
792 toolbar
->AddTool(TOOLBAR_LOAD_FILE
, ToolbarLoadBitmap
, (wxBitmap
*)NULL
,
793 FALSE
, (float)currentX
, -1, NULL
, "Load");
794 currentX
+= width
+ dx
;
795 toolbar
->AddTool(TOOLBAR_SAVE_FILE
, ToolbarSaveBitmap
, (wxBitmap
*)NULL
,
796 FALSE
, (float)currentX
, -1, NULL
, "Save");
797 currentX
+= width
+ dx
+ gap
;
798 toolbar
->AddSeparator();
799 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ
, ToolbarVertBitmap
, (wxBitmap
*)NULL
,
800 FALSE
, (float)currentX
, -1, NULL
, "Horizontal align");
801 currentX
+= width
+ dx
;
802 toolbar
->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN
, ToolbarAlignTBitmap
, (wxBitmap
*)NULL
,
803 FALSE
, (float)currentX
, -1, NULL
, "Top align");
804 currentX
+= width
+ dx
;
805 toolbar
->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN
, ToolbarAlignBBitmap
, (wxBitmap
*)NULL
,
806 FALSE
, (float)currentX
, -1, NULL
, "Bottom align");
807 currentX
+= width
+ dx
;
808 toolbar
->AddTool(TOOLBAR_FORMAT_VERT
, ToolbarHorizBitmap
, (wxBitmap
*)NULL
,
809 FALSE
, (float)currentX
, -1, NULL
, "Vertical align");
810 currentX
+= width
+ dx
;
811 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
, ToolbarAlignLBitmap
, (wxBitmap
*)NULL
,
812 FALSE
, (float)currentX
, -1, NULL
, "Left align");
813 currentX
+= width
+ dx
;
814 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
, ToolbarAlignRBitmap
, (wxBitmap
*)NULL
,
815 FALSE
, (float)currentX
, -1, NULL
, "Right align");
816 currentX
+= width
+ dx
;
817 toolbar
->AddTool(TOOLBAR_COPY_SIZE
, ToolbarCopySizeBitmap
, (wxBitmap
*)NULL
,
818 FALSE
, (float)currentX
, -1, NULL
, "Copy size");
819 currentX
+= width
+ dx
+ gap
;
820 toolbar
->AddSeparator();
821 toolbar
->AddTool(TOOLBAR_TO_FRONT
, ToolbarToFrontBitmap
, (wxBitmap
*)NULL
,
822 FALSE
, (float)currentX
, -1, NULL
, "To front");
823 currentX
+= width
+ dx
;
824 toolbar
->AddTool(TOOLBAR_TO_BACK
, ToolbarToBackBitmap
, (wxBitmap
*)NULL
,
825 FALSE
, (float)currentX
, -1, NULL
, "To back");
826 currentX
+= width
+ dx
+ gap
;
828 toolbar
->AddSeparator();
829 toolbar
->AddTool(TOOLBAR_HELP
, ToolbarHelpBitmap
, (wxBitmap
*)NULL
,
830 FALSE
, (float)currentX
, -1, NULL
, "Help");
831 currentX
+= width
+ dx
;
838 void wxResourceManager::UpdateResourceList()
840 if (!m_editorResourceTree
)
843 m_editorResourceTree
->SetInvalid(TRUE
);
844 m_editorResourceTree
->DeleteAllItems();
846 long id
= m_editorResourceTree
->InsertItem(0, "Dialogs"
852 m_resourceTable
.BeginFind();
854 while ((node
= m_resourceTable
.Next()))
856 wxItemResource
*res
= (wxItemResource
*)node
->Data();
857 wxString
resType(res
->GetType());
858 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel" || resType
== "wxBitmap")
860 AddItemsRecursively(id
, res
);
863 m_editorResourceTree
->ExpandItem(id
, wxTREE_EXPAND_EXPAND
);
864 m_editorResourceTree
->SetInvalid(FALSE
);
867 void wxResourceManager::AddItemsRecursively(long parent
, wxItemResource
*resource
)
869 wxString
theString("");
870 theString
= resource
->GetName();
873 wxString
resType(resource
->GetType());
874 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
879 long id
= m_editorResourceTree
->InsertItem(parent
, theString
885 m_editorResourceTree
->SetItemData(id
, (long) resource
);
887 if (strcmp(resource
->GetType(), "wxBitmap") != 0)
889 wxNode
*node
= resource
->GetChildren().First();
892 wxItemResource
*res
= (wxItemResource
*)node
->Data();
893 AddItemsRecursively(id
, res
);
897 // m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND);
900 bool wxResourceManager::EditSelectedResource()
902 int sel
= m_editorResourceTree
->GetSelection();
905 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
911 bool wxResourceManager::Edit(wxItemResource
*res
)
913 ClearCurrentDialog();
915 wxString
resType(res
->GetType());
916 wxPanel
*panel
= (wxPanel
*)FindWindowForResource(res
);
920 wxMessageBox("Should not find panel in wxResourceManager::Edit");
925 // long style = res->GetStyle();
926 // res->SetStyle(style|wxRAISED_BORDER);
928 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, res
, panel
->GetEventHandler(),
931 panel
->LoadFromResource(m_editorPanel
, res
->GetName(), &m_resourceTable
);
933 panel
->PushEventHandler(handler
);
935 // res->SetStyle(style);
936 handler
->AddChildHandlers(); // Add event handlers for all controls
937 AssociateResource(res
, panel
);
939 m_editorPanel
->m_childWindow
= panel
;
940 panel
->Move(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY());
944 wxClientDC
dc(m_editorPanel
);
945 m_editorPanel
->DrawTitle(dc
);
950 bool wxResourceManager::CreateNewPanel()
952 ClearCurrentDialog();
955 MakeUniqueName("dialog", buf
);
957 wxItemResource
*resource
= new wxItemResource
;
958 resource
->SetType("wxDialog");
959 resource
->SetName(buf
);
960 resource
->SetTitle(buf
);
961 resource
->SetResourceStyle(wxRESOURCE_USE_DEFAULTS
);
962 resource
->SetResourceStyle(wxRESOURCE_DIALOG_UNITS
);
965 int id
= GenerateWindowId("ID_DIALOG", newIdName
);
968 // This is now guaranteed to be unique, so just add to symbol table
969 m_symbolTable
.AddSymbol(newIdName
, id
);
971 m_resourceTable
.AddResource(resource
);
973 wxSize
size(400, 300);
975 wxPanel
*panel
= new wxPanel(m_editorPanel
, -1,
976 wxPoint(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY()),
977 size
, wxRAISED_BORDER
|wxDEFAULT_DIALOG_STYLE
, buf
);
978 m_editorPanel
->m_childWindow
= panel
;
980 resource
->SetStyle(panel
->GetWindowStyleFlag());
982 // Store dialog units in resource
983 size
= panel
->ConvertPixelsToDialog(size
);
985 resource
->SetSize(10, 10, size
.x
, size
.y
);
987 // For editing in situ we will need to use the hash table to ensure
988 // we don't dereference invalid pointers.
989 // resourceWindowTable.Put((long)resource, panel);
991 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, resource
, panel
->GetEventHandler(),
993 panel
->PushEventHandler(handler
);
995 AssociateResource(resource
, panel
);
996 UpdateResourceList();
999 m_editorPanel
->m_childWindow
->Refresh();
1001 // panel->Refresh();
1003 wxClientDC
dc(m_editorPanel
);
1004 m_editorPanel
->DrawTitle(dc
);
1009 bool wxResourceManager::CreatePanelItem(wxItemResource
*panelResource
, wxPanel
*panel
, char *iType
, int x
, int y
, bool isBitmap
)
1012 if (!panel
->IsKindOf(CLASSINFO(wxPanel
)) && !panel
->IsKindOf(CLASSINFO(wxDialog
)))
1017 wxItemResource
*res
= new wxItemResource
;
1018 wxControl
*newItem
= NULL
;
1020 if ((panelResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
1022 wxPoint pt
= panel
->ConvertPixelsToDialog(pt
);
1023 res
->SetSize(pt
.x
, pt
.y
, -1, -1);
1025 else res
->SetSize(x
, y
, -1, -1);
1027 res
->SetType(iType
);
1031 wxString
itemType(iType
);
1033 if (itemType
== "wxButton")
1035 prefix
= "ID_BUTTON";
1036 MakeUniqueName("button", buf
);
1039 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1041 newItem
= new wxButton(panel
, -1, "Button", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1043 if (itemType
== "wxBitmapButton")
1045 prefix
= "ID_BITMAPBUTTON";
1046 MakeUniqueName("button", buf
);
1048 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1050 else if (itemType
== "wxMessage" || itemType
== "wxStaticText")
1052 prefix
= "ID_STATIC";
1053 MakeUniqueName("statictext", buf
);
1056 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(0, 0), 0, buf
);
1058 newItem
= new wxStaticText(panel
, -1, "Static", wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1060 else if (itemType
== "wxStaticBitmap")
1062 prefix
= "ID_STATICBITMAP";
1063 MakeUniqueName("static", buf
);
1065 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1067 else if (itemType
== "wxCheckBox")
1069 prefix
= "ID_CHECKBOX";
1070 MakeUniqueName("checkbox", buf
);
1072 newItem
= new wxCheckBox(panel
, -1, "Checkbox", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1074 else if (itemType
== "wxListBox")
1076 prefix
= "ID_LISTBOX";
1077 MakeUniqueName("listbox", buf
);
1079 newItem
= new wxListBox(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1081 else if (itemType
== "wxRadioBox")
1083 prefix
= "ID_RADIOBOX";
1084 MakeUniqueName("radiobox", buf
);
1086 wxString names
[] = { "One", "Two" };
1087 newItem
= new wxRadioBox(panel
, -1, "Radiobox", wxPoint(x
, y
), wxSize(-1, -1), 2, names
, 2,
1088 wxHORIZONTAL
, wxDefaultValidator
, buf
);
1089 res
->SetStringValues(wxStringList("One", "Two", NULL
));
1091 else if (itemType
== "wxRadioButton")
1093 prefix
= "ID_RADIOBUTTON";
1094 MakeUniqueName("radiobutton", buf
);
1096 wxString names
[] = { "One", "Two" };
1097 newItem
= new wxRadioButton(panel
, -1, "Radiobutton", wxPoint(x
, y
), wxSize(-1, -1),
1098 0, wxDefaultValidator
, buf
);
1100 else if (itemType
== "wxChoice")
1102 prefix
= "ID_CHOICE";
1103 MakeUniqueName("choice", buf
);
1105 newItem
= new wxChoice(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1107 else if (itemType
== "wxComboBox")
1109 prefix
= "ID_COMBOBOX";
1110 MakeUniqueName("combobox", buf
);
1112 newItem
= new wxComboBox(panel
, -1, "", wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, wxCB_DROPDOWN
, wxDefaultValidator
, buf
);
1114 else if (itemType
== "wxGroupBox" || itemType
== "wxStaticBox")
1116 prefix
= "ID_STATICBOX";
1117 MakeUniqueName("staticbox", buf
);
1119 newItem
= new wxStaticBox(panel
, -1, "Static", wxPoint(x
, y
), wxSize(200, 200), 0, buf
);
1121 else if (itemType
== "wxGauge")
1123 prefix
= "ID_GAUGE";
1124 MakeUniqueName("gauge", buf
);
1126 newItem
= new wxGauge(panel
, -1, 10, wxPoint(x
, y
), wxSize(80, 30), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1128 else if (itemType
== "wxSlider")
1130 prefix
= "ID_SLIDER";
1131 MakeUniqueName("slider", buf
);
1133 newItem
= new wxSlider(panel
, -1, 1, 1, 10, wxPoint(x
, y
), wxSize(120, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1135 else if (itemType
== "wxText" || itemType
== "wxTextCtrl (single-line)")
1137 prefix
= "ID_TEXTCTRL";
1138 MakeUniqueName("textctrl", buf
);
1140 res
->SetType("wxTextCtrl");
1141 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, -1), 0, wxDefaultValidator
, buf
);
1143 else if (itemType
== "wxMultiText" || itemType
== "wxTextCtrl (multi-line)")
1145 prefix
= "ID_TEXTCTRL";
1146 MakeUniqueName("textctrl", buf
);
1148 res
->SetType("wxTextCtrl");
1149 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, 100), wxTE_MULTILINE
, wxDefaultValidator
, buf
);
1151 else if (itemType
== "wxScrollBar")
1153 prefix
= "ID_SCROLLBAR";
1154 MakeUniqueName("scrollbar", buf
);
1156 newItem
= new wxScrollBar(panel
, -1, wxPoint(x
, y
), wxSize(140, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1162 int id
= GenerateWindowId(prefix
, newIdName
);
1165 // This is now guaranteed to be unique, so just add to symbol table
1166 m_symbolTable
.AddSymbol(newIdName
, id
);
1168 newItem
->PushEventHandler(new wxResourceEditorControlHandler(newItem
, newItem
));
1170 res
->SetStyle(newItem
->GetWindowStyleFlag());
1171 AssociateResource(res
, newItem
);
1172 panelResource
->GetChildren().Append(res
);
1174 UpdateResourceList();
1179 void wxResourceManager::ClearCurrentDialog()
1181 if (m_editorPanel
->m_childWindow
)
1183 SaveInfoAndDeleteHandler(m_editorPanel
->m_childWindow
);
1184 DisassociateResource(m_editorPanel
->m_childWindow
);
1185 DeleteWindow(m_editorPanel
->m_childWindow
);
1186 m_editorPanel
->m_childWindow
= NULL
;
1187 m_editorPanel
->Clear();
1191 bool wxResourceManager::TestCurrentDialog(wxWindow
* parent
)
1193 if (m_editorPanel
->m_childWindow
)
1195 wxItemResource
* item
= FindResourceForWindow(m_editorPanel
->m_childWindow
);
1199 // Make sure the resources are up-to-date w.r.t. the window
1200 InstantiateResourceFromWindow(item
, m_editorPanel
->m_childWindow
, TRUE
);
1202 wxDialog
* dialog
= new wxDialog
;
1203 bool success
= FALSE
;
1204 if (dialog
->LoadFromResource(parent
, item
->GetName(), & m_resourceTable
))
1207 dialog
->ShowModal();
1215 // Find the first dialog or panel for which
1216 // there is a selected panel item.
1217 wxWindow
*wxResourceManager::FindParentOfSelection()
1219 m_resourceTable
.BeginFind();
1221 while ((node
= m_resourceTable
.Next()))
1223 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1224 wxWindow
*win
= FindWindowForResource(res
);
1227 wxNode
*node1
= win
->GetChildren()->First();
1230 wxControl
*item
= (wxControl
*)node1
->Data();
1231 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1232 if (item
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
->IsSelected())
1234 node1
= node1
->Next();
1241 // Format the panel items according to 'flag'
1242 void wxResourceManager::AlignItems(int flag
)
1244 wxWindow
*win
= FindParentOfSelection();
1248 wxNode
*node
= GetSelections().First();
1252 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1253 if (firstSelection
->GetParent() != win
)
1258 firstSelection
->GetPosition(&firstX
, &firstY
);
1259 firstSelection
->GetSize(&firstW
, &firstH
);
1260 int centreX
= (int)(firstX
+ (firstW
/ 2));
1261 int centreY
= (int)(firstY
+ (firstH
/ 2));
1263 while ((node
= node
->Next()))
1265 wxControl
*item
= (wxControl
*)node
->Data();
1266 if (item
->GetParent() == win
)
1269 item
->GetPosition(&x
, &y
);
1270 item
->GetSize(&w
, &h
);
1276 case TOOLBAR_FORMAT_HORIZ
:
1279 newY
= (int)(centreY
- (h
/2.0));
1282 case TOOLBAR_FORMAT_VERT
:
1284 newX
= (int)(centreX
- (w
/2.0));
1288 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
1294 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
1300 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
1302 newX
= firstX
+ firstW
- w
;
1306 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
1309 newY
= firstY
+ firstH
- h
;
1317 item
->SetSize(newX
, newY
, w
, h
);
1323 // Copy the first image's size to subsequent images
1324 void wxResourceManager::CopySize()
1326 wxWindow
*win
= FindParentOfSelection();
1330 wxNode
*node
= GetSelections().First();
1334 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1335 if (firstSelection
->GetParent() != win
)
1340 firstSelection
->GetPosition(&firstX
, &firstY
);
1341 firstSelection
->GetSize(&firstW
, &firstH
);
1343 while ((node
= node
->Next()))
1345 wxControl
*item
= (wxControl
*)node
->Data();
1346 if (item
->GetParent() == win
)
1347 item
->SetSize(-1, -1, firstW
, firstH
);
1352 void wxResourceManager::ToBackOrFront(bool toBack
)
1354 wxWindow
*win
= FindParentOfSelection();
1357 wxItemResource
*winResource
= FindResourceForWindow(win
);
1359 wxNode
*node
= GetSelections().First();
1362 wxControl
*item
= (wxControl
*)node
->Data();
1363 wxItemResource
*itemResource
= FindResourceForWindow(item
);
1364 if (item
->GetParent() == win
)
1366 win
->GetChildren()->DeleteObject(item
);
1368 winResource
->GetChildren().DeleteObject(itemResource
);
1371 win
->GetChildren()->Insert(item
);
1373 winResource
->GetChildren().Insert(itemResource
);
1377 win
->GetChildren()->Append(item
);
1379 winResource
->GetChildren().Append(itemResource
);
1382 node
= node
->Next();
1387 void wxResourceManager::AddSelection(wxWindow
*win
)
1389 if (!m_selections
.Member(win
))
1390 m_selections
.Append(win
);
1393 void wxResourceManager::RemoveSelection(wxWindow
*win
)
1395 m_selections
.DeleteObject(win
);
1398 // Need to search through resource table removing this from
1399 // any resource which has this as a parent.
1400 bool wxResourceManager::RemoveResourceFromParent(wxItemResource
*res
)
1402 m_resourceTable
.BeginFind();
1404 while ((node
= m_resourceTable
.Next()))
1406 wxItemResource
*thisRes
= (wxItemResource
*)node
->Data();
1407 if (thisRes
->GetChildren().Member(res
))
1409 thisRes
->GetChildren().DeleteObject(res
);
1416 bool wxResourceManager::DeleteResource(wxItemResource
*res
)
1421 RemoveResourceFromParent(res
);
1423 wxNode
*node
= res
->GetChildren().First();
1426 wxNode
*next
= node
->Next();
1427 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1428 DeleteResource(child
);
1432 // If this is a button or message resource, delete the
1433 // associate bitmap resource if not being used.
1434 wxString
resType(res
->GetType());
1436 /* shouldn't have to do this now bitmaps are ref-counted
1437 if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4())
1439 PossiblyDeleteBitmapResource(res->GetValue4());
1443 // Remove symbol from table if appropriate
1444 if (!IsSymbolUsed(res
, res
->GetId()))
1446 m_symbolTable
.RemoveSymbol(res
->GetId());
1449 m_resourceTable
.Delete(res
->GetName());
1455 bool wxResourceManager::DeleteResource(wxWindow
*win
)
1457 if (win
->IsKindOf(CLASSINFO(wxControl
)))
1459 // Deselect and refresh window in case we leave selection
1461 wxControl
*item
= (wxControl
*)win
;
1462 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1463 if (childHandler
->IsSelected())
1465 RemoveSelection(item
);
1466 childHandler
->SelectItem(FALSE
);
1468 item
->GetParent()->Refresh();
1473 wxItemResource
*res
= FindResourceForWindow(win
);
1475 DisassociateResource(res
);
1476 DeleteResource(res
);
1477 UpdateResourceList();
1482 // Will eventually have bitmap type information, for different
1484 wxString
wxResourceManager::AddBitmapResource(const wxString
& filename
)
1486 wxItemResource
*resource
= FindBitmapResourceByFilename(filename
);
1490 MakeUniqueName("bitmap", buf
);
1491 resource
= new wxItemResource
;
1492 resource
->SetType("wxBitmap");
1493 resource
->SetName(buf
);
1495 // A bitmap resource has one or more children, specifying
1496 // alternative bitmaps.
1497 wxItemResource
*child
= new wxItemResource
;
1498 child
->SetType("wxBitmap");
1499 child
->SetName(filename
);
1500 child
->SetValue1(wxBITMAP_TYPE_BMP
);
1501 child
->SetValue2(RESOURCE_PLATFORM_ANY
);
1502 child
->SetValue3(0); // Depth
1503 child
->SetSize(0,0,0,0);
1504 resource
->GetChildren().Append(child
);
1506 m_resourceTable
.AddResource(resource
);
1508 UpdateResourceList();
1511 return resource
->GetName();
1513 return wxEmptyString
;
1516 // Delete the bitmap resource if it isn't being used by another resource.
1517 void wxResourceManager::PossiblyDeleteBitmapResource(const wxString
& resourceName
)
1519 if (!IsBitmapResourceUsed(resourceName
))
1521 wxItemResource
*res
= m_resourceTable
.FindResource(resourceName
);
1522 DeleteResource(res
);
1523 UpdateResourceList();
1527 bool wxResourceManager::IsBitmapResourceUsed(const wxString
& resourceName
)
1529 m_resourceTable
.BeginFind();
1531 while ((node
= m_resourceTable
.Next()))
1533 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1534 wxString
resType(res
->GetType());
1535 if (resType
== "wxDialog")
1537 wxNode
*node1
= res
->GetChildren().First();
1540 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1541 wxString
childResType(child
->GetType());
1543 if ((childResType
== "wxMessage" || childResType
== "wxButton") &&
1544 child
->GetValue4() &&
1545 (strcmp(child
->GetValue4(), resourceName
) == 0))
1547 node1
= node1
->Next();
1554 // Given a wxButton or wxMessage, find the corresponding bitmap filename.
1555 wxString
wxResourceManager::FindBitmapFilenameForResource(wxItemResource
*resource
)
1557 if (!resource
|| (resource
->GetValue4() == ""))
1558 return wxEmptyString
;
1559 wxItemResource
*bitmapResource
= m_resourceTable
.FindResource(resource
->GetValue4());
1560 if (!bitmapResource
)
1561 return wxEmptyString
;
1563 wxNode
*node
= bitmapResource
->GetChildren().First();
1566 // Eventually augment this to return a bitmap of the right kind or something...
1567 // Maybe the root of the filename remains the same, so it doesn't matter which we
1568 // pick up. Otherwise how do we specify multiple filenames... too boring...
1569 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1570 return child
->GetName();
1572 node
= node
->Next();
1574 return wxEmptyString
;
1577 wxItemResource
*wxResourceManager::FindBitmapResourceByFilename(const wxString
& filename
)
1579 m_resourceTable
.BeginFind();
1581 while ((node
= m_resourceTable
.Next()))
1583 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1584 wxString
resType(res
->GetType());
1585 if (resType
== "wxBitmap")
1587 wxNode
*node1
= res
->GetChildren().First();
1590 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1591 if (child
->GetName() && (strcmp(child
->GetName(), filename
) == 0))
1593 node1
= node1
->Next();
1600 // Is this window identifier symbol in use?
1601 // Let's assume that we can't have 2 names for the same integer id.
1602 // Therefore we can tell by the integer id whether the symbol is
1604 bool wxResourceManager::IsSymbolUsed(wxItemResource
* thisResource
, wxWindowID id
)
1606 m_resourceTable
.BeginFind();
1608 while ((node
= m_resourceTable
.Next()))
1610 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1612 wxString
resType(res
->GetType());
1613 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1615 if ((res
!= thisResource
) && (res
->GetId() == id
))
1618 wxNode
*node1
= res
->GetChildren().First();
1621 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1622 if ((child
!= thisResource
) && (child
->GetId() == id
))
1624 node1
= node1
->Next();
1631 // Is this window identifier compatible with the given name? (i.e.
1632 // does it already exist under a different name)
1633 bool wxResourceManager::IsIdentifierOK(const wxString
& name
, wxWindowID id
)
1635 if (m_symbolTable
.SymbolExists(name
))
1637 int foundId
= m_symbolTable
.GetIdForSymbol(name
);
1644 // Change all integer ids that match oldId, to newId.
1645 // This is necessary if an id is changed for one resource - all resources
1647 void wxResourceManager::ChangeIds(int oldId
, int newId
)
1649 m_resourceTable
.BeginFind();
1651 while ((node
= m_resourceTable
.Next()))
1653 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1655 wxString
resType(res
->GetType());
1656 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1658 if (res
->GetId() == oldId
)
1661 wxNode
*node1
= res
->GetChildren().First();
1664 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1665 if (child
->GetId() == oldId
)
1666 child
->SetId(newId
);
1668 node1
= node1
->Next();
1674 // If any resource ids were missing (or their symbol was missing),
1675 // repair them i.e. give them new ids. Returns TRUE if any resource
1676 // needed repairing.
1677 bool wxResourceManager::RepairResourceIds()
1679 bool repaired
= FALSE
;
1681 m_resourceTable
.BeginFind();
1683 while ((node
= m_resourceTable
.Next()))
1685 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1686 wxString
resType(res
->GetType());
1687 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1690 if ( (res
->GetId() == 0) || ((res
->GetId() > 0) && !m_symbolTable
.IdExists(res
->GetId())) )
1692 wxString newSymbolName
;
1693 int newId
= GenerateWindowId("ID_DIALOG", newSymbolName
) ;
1695 if (res
->GetId() == 0)
1698 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1702 m_symbolTable
.AddSymbol(newSymbolName
, res
->GetId());
1708 wxNode
*node1
= res
->GetChildren().First();
1711 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1713 if ( (child
->GetId() == 0) || ((child
->GetId() > 0) && !m_symbolTable
.IdExists(child
->GetId())) )
1715 wxString newSymbolName
;
1716 int newId
= GenerateWindowId("ID_CONTROL", newSymbolName
) ;
1718 if (child
->GetId() == 0)
1720 child
->SetId(newId
);
1721 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1725 m_symbolTable
.AddSymbol(newSymbolName
, child
->GetId());
1731 node1
= node1
->Next();
1739 // Deletes 'win' and creates a new window from the resource that
1740 // was associated with it. E.g. if you can't change properties on the
1741 // fly, you'll need to delete the window and create it again.
1742 wxWindow
*wxResourceManager::RecreateWindowFromResource(wxWindow
*win
, wxWindowPropertyInfo
*info
)
1744 wxItemResource
*resource
= FindResourceForWindow(win
);
1746 // Put the current window properties into the wxItemResource object
1748 wxWindowPropertyInfo
*newInfo
= NULL
;
1751 newInfo
= CreatePropertyInfoForWindow(win
);
1755 info
->InstantiateResource(resource
);
1757 wxWindow
*newWin
= NULL
;
1758 wxWindow
*parent
= win
->GetParent();
1759 wxItemResource
* parentResource
= NULL
;
1761 FindResourceForWindow(parent
);
1763 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1766 newWin
= FindWindowForResource(resource
);
1770 DisassociateResource(resource
);
1771 if (win
->GetEventHandler() != win
)
1772 win
->PopEventHandler(TRUE
);
1775 newWin
= m_resourceTable
.CreateItem((wxPanel
*)parent
, resource
, parentResource
);
1776 newWin
->PushEventHandler(new wxResourceEditorControlHandler((wxControl
*) newWin
, (wxControl
*) newWin
));
1777 AssociateResource(resource
, newWin
);
1778 UpdateResourceList();
1782 info
->SetPropertyWindow(newWin
);
1790 // Delete resource highlighted in the listbox
1791 bool wxResourceManager::DeleteSelection()
1793 int sel
= m_editorResourceTree
->GetSelection();
1796 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
1797 wxWindow
*win
= FindWindowForResource(res
);
1800 DeleteResource(win
);
1802 UpdateResourceList();
1811 // Delete resource highlighted in the listbox
1812 bool wxResourceManager::RecreateSelection()
1814 wxNode
*node
= GetSelections().First();
1817 wxControl
*item
= (wxControl
*)node
->Data();
1818 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1819 wxNode
*next
= node
->Next();
1820 childHandler
->SelectItem(FALSE
);
1822 RemoveSelection(item
);
1824 RecreateWindowFromResource(item
);
1831 bool wxResourceManager::EditDialog(wxDialog
*WXUNUSED(dialog
), wxWindow
*WXUNUSED(parent
))
1836 // Ensures that all currently shown windows are saved to resources,
1837 // e.g. just before writing to a .wxr file.
1838 bool wxResourceManager::InstantiateAllResourcesFromWindows()
1840 m_resourceTable
.BeginFind();
1842 while ((node
= m_resourceTable
.Next()))
1844 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1845 wxString
resType(res
->GetType());
1847 if (resType
== "wxDialog")
1849 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1851 InstantiateResourceFromWindow(res
, win
, TRUE
);
1853 else if (resType
== "wxPanel")
1855 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1857 InstantiateResourceFromWindow(res
, win
, TRUE
);
1863 bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource
*resource
, wxWindow
*window
, bool recurse
)
1865 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(window
);
1866 info
->SetResource(resource
);
1867 info
->InstantiateResource(resource
);
1872 wxNode
*node
= resource
->GetChildren().First();
1875 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1876 wxWindow
*childWindow
= FindWindowForResource(child
);
1881 sprintf(buf
, "Could not find window %s", (const char*) child
->GetName());
1882 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
1885 InstantiateResourceFromWindow(child
, childWindow
, recurse
);
1886 node
= node
->Next();
1893 // Create a window information object for the give window
1894 wxWindowPropertyInfo
*wxResourceManager::CreatePropertyInfoForWindow(wxWindow
*win
)
1896 wxWindowPropertyInfo
*info
= NULL
;
1897 if (win
->IsKindOf(CLASSINFO(wxScrollBar
)))
1899 info
= new wxScrollBarPropertyInfo(win
);
1901 else if (win
->IsKindOf(CLASSINFO(wxStaticBox
)))
1903 info
= new wxGroupBoxPropertyInfo(win
);
1905 else if (win
->IsKindOf(CLASSINFO(wxCheckBox
)))
1907 info
= new wxCheckBoxPropertyInfo(win
);
1909 else if (win
->IsKindOf(CLASSINFO(wxSlider
)))
1911 info
= new wxSliderPropertyInfo(win
);
1913 else if (win
->IsKindOf(CLASSINFO(wxGauge
)))
1915 info
= new wxGaugePropertyInfo(win
);
1917 else if (win
->IsKindOf(CLASSINFO(wxListBox
)))
1919 info
= new wxListBoxPropertyInfo(win
);
1921 else if (win
->IsKindOf(CLASSINFO(wxRadioBox
)))
1923 info
= new wxRadioBoxPropertyInfo(win
);
1925 else if (win
->IsKindOf(CLASSINFO(wxRadioButton
)))
1927 info
= new wxRadioButtonPropertyInfo(win
);
1929 else if (win
->IsKindOf(CLASSINFO(wxChoice
)))
1931 info
= new wxChoicePropertyInfo(win
);
1933 else if (win
->IsKindOf(CLASSINFO(wxComboBox
)))
1935 info
= new wxComboBoxPropertyInfo(win
);
1937 else if (win
->IsKindOf(CLASSINFO(wxButton
)))
1939 info
= new wxButtonPropertyInfo(win
);
1941 else if (win
->IsKindOf(CLASSINFO(wxBitmapButton
)))
1943 info
= new wxBitmapButtonPropertyInfo(win
);
1945 else if (win
->IsKindOf(CLASSINFO(wxStaticText
)))
1947 info
= new wxStaticTextPropertyInfo(win
);
1949 else if (win
->IsKindOf(CLASSINFO(wxStaticBitmap
)))
1951 info
= new wxStaticBitmapPropertyInfo(win
);
1953 else if (win
->IsKindOf(CLASSINFO(wxTextCtrl
)))
1955 info
= new wxTextPropertyInfo(win
);
1957 else if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1959 info
= new wxPanelPropertyInfo(win
);
1963 info
= new wxWindowPropertyInfo(win
);
1968 // Edit the given window
1969 void wxResourceManager::EditWindow(wxWindow
*win
)
1971 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(win
);
1974 info
->SetResource(FindResourceForWindow(win
));
1975 wxString
str("Editing ");
1976 str
+= win
->GetClassInfo()->GetClassName();
1978 if (win
->GetName() != "")
1979 str
+= win
->GetName();
1981 str
+= "properties";
1982 info
->Edit(NULL
, str
);
1986 // Generate a window id and a first stab at a name
1987 int wxResourceManager::GenerateWindowId(const wxString
& prefix
, wxString
& idName
)
1989 m_symbolIdCounter
++;
1990 while (m_symbolTable
.IdExists(m_symbolIdCounter
))
1991 m_symbolIdCounter
++;
1993 int nameId
= m_symbolIdCounter
;
1996 str
.Printf("%d", nameId
);
1997 idName
= prefix
+ str
;
1999 while (m_symbolTable
.SymbolExists(idName
))
2002 str
.Printf("%d", nameId
);
2003 idName
= prefix
+ str
;
2006 return m_symbolIdCounter
;
2011 * Resource editor frame
2014 IMPLEMENT_CLASS(wxResourceEditorFrame
, wxFrame
)
2016 BEGIN_EVENT_TABLE(wxResourceEditorFrame
, wxFrame
)
2017 EVT_MENU(wxID_NEW
, wxResourceEditorFrame::OnNew
)
2018 EVT_MENU(RESED_NEW_DIALOG
, wxResourceEditorFrame::OnNewDialog
)
2019 EVT_MENU(wxID_OPEN
, wxResourceEditorFrame::OnOpen
)
2020 EVT_MENU(RESED_CLEAR
, wxResourceEditorFrame::OnClear
)
2021 EVT_MENU(wxID_SAVE
, wxResourceEditorFrame::OnSave
)
2022 EVT_MENU(wxID_SAVEAS
, wxResourceEditorFrame::OnSaveAs
)
2023 EVT_MENU(wxID_EXIT
, wxResourceEditorFrame::OnExit
)
2024 EVT_MENU(wxID_ABOUT
, wxResourceEditorFrame::OnAbout
)
2025 EVT_MENU(RESED_CONTENTS
, wxResourceEditorFrame::OnContents
)
2026 EVT_MENU(RESED_DELETE
, wxResourceEditorFrame::OnDeleteSelection
)
2027 EVT_MENU(RESED_RECREATE
, wxResourceEditorFrame::OnRecreateSelection
)
2028 EVT_MENU(RESED_TEST
, wxResourceEditorFrame::OnTest
)
2031 wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager
*resMan
, wxFrame
*parent
, const wxString
& title
,
2032 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
2033 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
2038 wxResourceEditorFrame::~wxResourceEditorFrame()
2042 void wxResourceEditorFrame::OnNew(wxCommandEvent
& WXUNUSED(event
))
2044 manager
->New(FALSE
);
2047 void wxResourceEditorFrame::OnNewDialog(wxCommandEvent
& WXUNUSED(event
))
2049 manager
->CreateNewPanel();
2052 void wxResourceEditorFrame::OnOpen(wxCommandEvent
& WXUNUSED(event
))
2057 void wxResourceEditorFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
2059 manager
->Clear(TRUE
, FALSE
);
2062 void wxResourceEditorFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
2067 void wxResourceEditorFrame::OnSaveAs(wxCommandEvent
& WXUNUSED(event
))
2072 void wxResourceEditorFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
2074 manager
->Clear(TRUE
, FALSE
) ;
2078 void wxResourceEditorFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
2081 sprintf(buf
, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart J.Smart@ed.ac.uk\nJulian Smart (c) 1996", wxDIALOG_EDITOR_VERSION
);
2082 wxMessageBox(buf
, "About Dialog Editor", wxOK
|wxCENTRE
);
2085 void wxResourceEditorFrame::OnTest(wxCommandEvent
& WXUNUSED(event
))
2087 manager
->TestCurrentDialog(this);
2090 void wxResourceEditorFrame::OnContents(wxCommandEvent
& WXUNUSED(event
))
2093 wxBeginBusyCursor();
2094 manager
->GetHelpController()->LoadFile();
2095 manager
->GetHelpController()->DisplayContents();
2100 void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent
& WXUNUSED(event
))
2102 manager
->DeleteSelection();
2105 void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent
& WXUNUSED(event
))
2107 manager
->RecreateSelection();
2110 bool wxResourceEditorFrame::OnClose()
2112 if (manager
->Modified())
2114 if (!manager
->Clear(TRUE
, FALSE
))
2122 manager
->m_resourceEditorWindowSize
.width
= w
;
2123 manager
->m_resourceEditorWindowSize
.height
= h
;
2126 GetPosition(&x
, &y
);
2128 manager
->m_resourceEditorWindowSize
.x
= x
;
2129 manager
->m_resourceEditorWindowSize
.y
= y
;
2131 manager
->SetEditorFrame(NULL
);
2132 manager
->SetEditorToolBar(NULL
);
2138 * Resource editor window that contains the dialog/panel being edited
2141 BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow
, wxScrolledWindow
)
2142 EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll
)
2143 EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint
)
2146 wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow
*parent
, const wxPoint
& pos
, const wxSize
& size
,
2148 wxScrolledWindow(parent
, -1, pos
, size
, style
)
2152 m_childWindow
= NULL
;
2155 wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
2159 void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent
& event
)
2161 wxScrolledWindow::OnScroll(event
);
2164 ViewStart(& x
, & y
);
2167 m_childWindow
->Move(m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10));
2170 void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
2177 void wxResourceEditorScrolledWindow::DrawTitle(wxDC
& dc
)
2181 wxItemResource
* res
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_childWindow
);
2184 wxString
str(res
->GetTitle());
2186 ViewStart(& x
, & y
);
2188 wxFont
font(10, wxSWISS
, wxNORMAL
, wxBOLD
);
2190 dc
.SetBackgroundMode(wxTRANSPARENT
);
2191 dc
.SetTextForeground(wxColour(0, 0, 0));
2194 dc
.GetTextExtent(str
, & w
, & h
);
2196 dc
.DrawText(str
, m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10) - h
- 5);
2201 // Popup menu callback
2202 void ObjectMenuProc(wxMenu
& menu
, wxCommandEvent
& event
)
2204 wxWindow
*data
= (wxWindow
*)menu
.GetClientData();
2208 switch (event
.GetInt())
2210 case OBJECT_MENU_EDIT
:
2212 wxResourceManager::GetCurrentResourceManager()->EditWindow(data
);
2215 case OBJECT_MENU_DELETE
:
2217 wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data
);
2218 wxResourceManager::GetCurrentResourceManager()->DeleteResource(data
);
2219 wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data
);
2232 #ifdef __WXGTK__ // I don't dare to delete it...
2234 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2239 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2240 EVT_PAINT(EditorToolBar::OnPaint
)
2245 EditorToolBar::EditorToolBar(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
,
2247 wxToolBar(frame
, -1, pos
, size
, style
)
2251 bool EditorToolBar::OnLeftClick(int toolIndex
, bool WXUNUSED(toggled
))
2253 wxResourceManager
*manager
= wxResourceManager::GetCurrentResourceManager();
2257 case TOOLBAR_LOAD_FILE
:
2264 manager
->CreateNewPanel();
2267 case TOOLBAR_SAVE_FILE
:
2275 wxBeginBusyCursor();
2276 manager
->GetHelpController()->LoadFile();
2277 manager
->GetHelpController()->DisplayContents();
2282 case TOOLBAR_FORMAT_HORIZ
:
2284 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ
);
2287 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2289 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
);
2292 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2294 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
);
2297 case TOOLBAR_FORMAT_VERT
:
2299 manager
->AlignItems(TOOLBAR_FORMAT_VERT
);
2302 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2304 manager
->AlignItems(TOOLBAR_FORMAT_VERT_TOP_ALIGN
);
2307 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2309 manager
->AlignItems(TOOLBAR_FORMAT_VERT_BOT_ALIGN
);
2312 case TOOLBAR_COPY_SIZE
:
2314 manager
->CopySize();
2317 case TOOLBAR_TO_BACK
:
2319 manager
->ToBackOrFront(TRUE
);
2322 case TOOLBAR_TO_FRONT
:
2324 manager
->ToBackOrFront(FALSE
);
2333 void EditorToolBar::OnMouseEnter(int toolIndex
)
2335 wxFrame
*frame
= (wxFrame
*)GetParent();
2343 case TOOLBAR_LOAD_FILE
:
2344 frame
->SetStatusText("Load project file");
2346 case TOOLBAR_SAVE_FILE
:
2347 frame
->SetStatusText("Save project file");
2350 frame
->SetStatusText("Create a new resource");
2352 case TOOLBAR_FORMAT_HORIZ
:
2353 frame
->SetStatusText("Align items horizontally");
2355 case TOOLBAR_FORMAT_VERT
:
2356 frame
->SetStatusText("Align items vertically");
2358 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2359 frame
->SetStatusText("Left-align items");
2361 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2362 frame
->SetStatusText("Right-align items");
2364 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2365 frame
->SetStatusText("Top-align items");
2367 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2368 frame
->SetStatusText("Bottom-align items");
2370 case TOOLBAR_COPY_SIZE
:
2371 frame
->SetStatusText("Copy size from first selection");
2373 case TOOLBAR_TO_FRONT
:
2374 frame
->SetStatusText("Put image to front");
2376 case TOOLBAR_TO_BACK
:
2377 frame
->SetStatusText("Put image to back");
2380 frame
->SetStatusText("Display help contents");
2386 else frame
->SetStatusText("");