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() ? 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
)
678 int frameWidth
= 420;
679 int frameHeight
= 300;
681 wxResourceEditorFrame
*frame
= new wxResourceEditorFrame(this, NULL
, title
,
682 wxPoint(m_resourceEditorWindowSize
.x
, m_resourceEditorWindowSize
.y
),
683 wxSize(m_resourceEditorWindowSize
.width
, m_resourceEditorWindowSize
.height
),
684 wxDEFAULT_FRAME_STYLE
);
686 frame
->CreateStatusBar(1);
688 frame
->SetAutoLayout(TRUE
);
690 frame
->SetIcon(wxIcon("DIALOGEDICON"));
695 wxMenuBar
*wxResourceManager::OnCreateEditorMenuBar(wxFrame
*WXUNUSED(parent
))
697 wxMenuBar
*menuBar
= new wxMenuBar
;
699 wxMenu
*fileMenu
= new wxMenu
;
700 fileMenu
->Append(RESED_NEW_DIALOG
, "New &dialog", "Create a new dialog");
701 fileMenu
->AppendSeparator();
702 fileMenu
->Append(wxID_NEW
, "&New project", "Clear the current project");
703 fileMenu
->Append(wxID_OPEN
, "&Open...", "Load a resource file");
704 fileMenu
->Append(wxID_SAVE
, "&Save", "Save a resource file");
705 fileMenu
->Append(wxID_SAVEAS
, "Save &As...", "Save a resource file as...");
706 fileMenu
->Append(RESED_CLEAR
, "&Clear", "Clear current resources");
707 fileMenu
->AppendSeparator();
708 fileMenu
->Append(wxID_EXIT
, "E&xit", "Exit resource editor");
710 wxMenu
*editMenu
= new wxMenu
;
711 editMenu
->Append(RESED_TEST
, "&Test Dialog", "Test dialog");
712 editMenu
->Append(RESED_RECREATE
, "&Recreate", "Recreate the selected resource(s)");
713 editMenu
->Append(RESED_DELETE
, "&Delete", "Delete the selected resource(s)");
715 wxMenu
*helpMenu
= new wxMenu
;
716 helpMenu
->Append(RESED_CONTENTS
, "&Help topics", "Invokes the on-line help");
717 helpMenu
->AppendSeparator();
718 helpMenu
->Append(wxID_ABOUT
, "&About", "About wxWindows Dialog Editor");
720 menuBar
->Append(fileMenu
, "&File");
721 menuBar
->Append(editMenu
, "&Edit");
722 menuBar
->Append(helpMenu
, "&Help");
727 wxResourceEditorScrolledWindow
*wxResourceManager::OnCreateEditorPanel(wxFrame
*parent
)
729 wxResourceEditorScrolledWindow
*panel
= new wxResourceEditorScrolledWindow(parent
, wxDefaultPosition
, wxDefaultSize
,
730 // wxSUNKEN_BORDER|wxCLIP_CHILDREN);
733 panel
->SetScrollbars(10, 10, 100, 100);
738 wxToolBar
*wxResourceManager::OnCreateToolBar(wxFrame
*parent
)
740 // Load palette bitmaps
742 wxBitmap
ToolbarLoadBitmap("LOADTOOL");
743 wxBitmap
ToolbarSaveBitmap("SAVETOOL");
744 wxBitmap
ToolbarNewBitmap("NEWTOOL");
745 wxBitmap
ToolbarVertBitmap("VERTTOOL");
746 wxBitmap
ToolbarAlignTBitmap("ALIGNTTOOL");
747 wxBitmap
ToolbarAlignBBitmap("ALIGNBTOOL");
748 wxBitmap
ToolbarHorizBitmap("HORIZTOOL");
749 wxBitmap
ToolbarAlignLBitmap("ALIGNLTOOL");
750 wxBitmap
ToolbarAlignRBitmap("ALIGNRTOOL");
751 wxBitmap
ToolbarCopySizeBitmap("COPYSIZETOOL");
752 wxBitmap
ToolbarToBackBitmap("TOBACKTOOL");
753 wxBitmap
ToolbarToFrontBitmap("TOFRONTTOOL");
754 wxBitmap
ToolbarHelpBitmap("HELPTOOL");
757 wxBitmap
ToolbarLoadBitmap( load_xpm
);
758 wxBitmap
ToolbarSaveBitmap( save_xpm
);
759 wxBitmap
ToolbarNewBitmap( new_xpm
);
760 wxBitmap
ToolbarVertBitmap( vert_xpm
);
761 wxBitmap
ToolbarAlignTBitmap( alignt_xpm
);
762 wxBitmap
ToolbarAlignBBitmap( alignb_xpm
);
763 wxBitmap
ToolbarHorizBitmap( horiz_xpm
);
764 wxBitmap
ToolbarAlignLBitmap( alignl_xpm
);
765 wxBitmap
ToolbarAlignRBitmap( alignr_xpm
);
766 wxBitmap
ToolbarCopySizeBitmap( copysize_xpm
);
767 wxBitmap
ToolbarToBackBitmap( toback_xpm
);
768 wxBitmap
ToolbarToFrontBitmap( tofront_xpm
);
769 wxBitmap
ToolbarHelpBitmap( help_xpm
);
772 // Create the toolbar
773 EditorToolBar
*toolbar
= new EditorToolBar(parent
, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER
|wxTB_HORIZONTAL
);
774 toolbar
->SetMargins(2, 2);
781 int width
= 24; // ToolbarLoadBitmap->GetWidth(); ???
786 toolbar
->AddSeparator();
787 toolbar
->AddTool(TOOLBAR_NEW
, ToolbarNewBitmap
, (wxBitmap
*)NULL
,
788 FALSE
, (float)currentX
, -1, NULL
, "New dialog");
789 currentX
+= width
+ dx
;
790 toolbar
->AddTool(TOOLBAR_LOAD_FILE
, ToolbarLoadBitmap
, (wxBitmap
*)NULL
,
791 FALSE
, (float)currentX
, -1, NULL
, "Load");
792 currentX
+= width
+ dx
;
793 toolbar
->AddTool(TOOLBAR_SAVE_FILE
, ToolbarSaveBitmap
, (wxBitmap
*)NULL
,
794 FALSE
, (float)currentX
, -1, NULL
, "Save");
795 currentX
+= width
+ dx
+ gap
;
796 toolbar
->AddSeparator();
797 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ
, ToolbarVertBitmap
, (wxBitmap
*)NULL
,
798 FALSE
, (float)currentX
, -1, NULL
, "Horizontal align");
799 currentX
+= width
+ dx
;
800 toolbar
->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN
, ToolbarAlignTBitmap
, (wxBitmap
*)NULL
,
801 FALSE
, (float)currentX
, -1, NULL
, "Top align");
802 currentX
+= width
+ dx
;
803 toolbar
->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN
, ToolbarAlignBBitmap
, (wxBitmap
*)NULL
,
804 FALSE
, (float)currentX
, -1, NULL
, "Bottom align");
805 currentX
+= width
+ dx
;
806 toolbar
->AddTool(TOOLBAR_FORMAT_VERT
, ToolbarHorizBitmap
, (wxBitmap
*)NULL
,
807 FALSE
, (float)currentX
, -1, NULL
, "Vertical align");
808 currentX
+= width
+ dx
;
809 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
, ToolbarAlignLBitmap
, (wxBitmap
*)NULL
,
810 FALSE
, (float)currentX
, -1, NULL
, "Left align");
811 currentX
+= width
+ dx
;
812 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
, ToolbarAlignRBitmap
, (wxBitmap
*)NULL
,
813 FALSE
, (float)currentX
, -1, NULL
, "Right align");
814 currentX
+= width
+ dx
;
815 toolbar
->AddTool(TOOLBAR_COPY_SIZE
, ToolbarCopySizeBitmap
, (wxBitmap
*)NULL
,
816 FALSE
, (float)currentX
, -1, NULL
, "Copy size");
817 currentX
+= width
+ dx
+ gap
;
818 toolbar
->AddSeparator();
819 toolbar
->AddTool(TOOLBAR_TO_FRONT
, ToolbarToFrontBitmap
, (wxBitmap
*)NULL
,
820 FALSE
, (float)currentX
, -1, NULL
, "To front");
821 currentX
+= width
+ dx
;
822 toolbar
->AddTool(TOOLBAR_TO_BACK
, ToolbarToBackBitmap
, (wxBitmap
*)NULL
,
823 FALSE
, (float)currentX
, -1, NULL
, "To back");
824 currentX
+= width
+ dx
+ gap
;
826 toolbar
->AddSeparator();
827 toolbar
->AddTool(TOOLBAR_HELP
, ToolbarHelpBitmap
, (wxBitmap
*)NULL
,
828 FALSE
, (float)currentX
, -1, NULL
, "Help");
829 currentX
+= width
+ dx
;
836 void wxResourceManager::UpdateResourceList()
838 if (!m_editorResourceTree
)
841 m_editorResourceTree
->SetInvalid(TRUE
);
842 m_editorResourceTree
->DeleteAllItems();
844 long id
= m_editorResourceTree
->InsertItem(0, "Dialogs"
850 m_resourceTable
.BeginFind();
852 while (node
= m_resourceTable
.Next())
854 wxItemResource
*res
= (wxItemResource
*)node
->Data();
855 wxString
resType(res
->GetType());
856 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel" || resType
== "wxBitmap")
858 AddItemsRecursively(id
, res
);
861 m_editorResourceTree
->ExpandItem(id
, wxTREE_EXPAND_EXPAND
);
862 m_editorResourceTree
->SetInvalid(FALSE
);
865 void wxResourceManager::AddItemsRecursively(long parent
, wxItemResource
*resource
)
867 wxString
theString("");
868 theString
= resource
->GetName();
871 wxString
resType(resource
->GetType());
872 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
877 long id
= m_editorResourceTree
->InsertItem(parent
, theString
883 m_editorResourceTree
->SetItemData(id
, (long) resource
);
885 if (strcmp(resource
->GetType(), "wxBitmap") != 0)
887 wxNode
*node
= resource
->GetChildren().First();
890 wxItemResource
*res
= (wxItemResource
*)node
->Data();
891 AddItemsRecursively(id
, res
);
895 // m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND);
898 bool wxResourceManager::EditSelectedResource()
900 int sel
= m_editorResourceTree
->GetSelection();
903 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
909 bool wxResourceManager::Edit(wxItemResource
*res
)
911 ClearCurrentDialog();
913 wxString
resType(res
->GetType());
914 wxPanel
*panel
= (wxPanel
*)FindWindowForResource(res
);
918 wxMessageBox("Should not find panel in wxResourceManager::Edit");
923 // long style = res->GetStyle();
924 // res->SetStyle(style|wxRAISED_BORDER);
926 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, res
, panel
->GetEventHandler(),
929 panel
->LoadFromResource(m_editorPanel
, res
->GetName(), &m_resourceTable
);
931 panel
->PushEventHandler(handler
);
933 // res->SetStyle(style);
934 handler
->AddChildHandlers(); // Add event handlers for all controls
935 AssociateResource(res
, panel
);
937 m_editorPanel
->m_childWindow
= panel
;
938 panel
->Move(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY());
942 wxClientDC
dc(m_editorPanel
);
943 m_editorPanel
->DrawTitle(dc
);
948 bool wxResourceManager::CreateNewPanel()
950 ClearCurrentDialog();
953 MakeUniqueName("dialog", buf
);
955 wxItemResource
*resource
= new wxItemResource
;
956 resource
->SetType("wxDialog");
957 resource
->SetName(buf
);
958 resource
->SetTitle(buf
);
961 int id
= GenerateWindowId("ID_DIALOG", newIdName
);
964 // This is now guaranteed to be unique, so just add to symbol table
965 m_symbolTable
.AddSymbol(newIdName
, id
);
967 m_resourceTable
.AddResource(resource
);
969 wxPanel
*panel
= new wxPanel(m_editorPanel
, -1,
970 wxPoint(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY()),
971 wxSize(400, 300), wxRAISED_BORDER
|wxDEFAULT_DIALOG_STYLE
, buf
);
972 m_editorPanel
->m_childWindow
= panel
;
974 resource
->SetStyle(panel
->GetWindowStyleFlag());
975 resource
->SetSize(10, 10, 400, 300);
977 // For editing in situ we will need to use the hash table to ensure
978 // we don't dereference invalid pointers.
979 // resourceWindowTable.Put((long)resource, panel);
981 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, resource
, panel
->GetEventHandler(),
983 panel
->PushEventHandler(handler
);
985 AssociateResource(resource
, panel
);
986 UpdateResourceList();
989 m_editorPanel
->m_childWindow
->Refresh();
993 wxClientDC
dc(m_editorPanel
);
994 m_editorPanel
->DrawTitle(dc
);
999 bool wxResourceManager::CreatePanelItem(wxItemResource
*panelResource
, wxPanel
*panel
, char *iType
, int x
, int y
, bool isBitmap
)
1002 if (!panel
->IsKindOf(CLASSINFO(wxPanel
)) && !panel
->IsKindOf(CLASSINFO(wxDialog
)))
1007 wxItemResource
*res
= new wxItemResource
;
1008 wxControl
*newItem
= NULL
;
1009 res
->SetSize(x
, y
, -1, -1);
1010 res
->SetType(iType
);
1014 wxString
itemType(iType
);
1016 if (itemType
== "wxButton")
1018 prefix
= "ID_BUTTON";
1019 MakeUniqueName("button", buf
);
1022 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1024 newItem
= new wxButton(panel
, -1, "Button", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1026 if (itemType
== "wxBitmapButton")
1028 prefix
= "ID_BITMAPBUTTON";
1029 MakeUniqueName("button", buf
);
1031 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1033 else if (itemType
== "wxMessage" || itemType
== "wxStaticText")
1035 prefix
= "ID_STATIC";
1036 MakeUniqueName("statictext", buf
);
1039 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(0, 0), 0, buf
);
1041 newItem
= new wxStaticText(panel
, -1, "Static", wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1043 else if (itemType
== "wxStaticBitmap")
1045 prefix
= "ID_STATICBITMAP";
1046 MakeUniqueName("static", buf
);
1048 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1050 else if (itemType
== "wxCheckBox")
1052 prefix
= "ID_CHECKBOX";
1053 MakeUniqueName("checkbox", buf
);
1055 newItem
= new wxCheckBox(panel
, -1, "Checkbox", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1057 else if (itemType
== "wxListBox")
1059 prefix
= "ID_LISTBOX";
1060 MakeUniqueName("listbox", buf
);
1062 newItem
= new wxListBox(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1064 else if (itemType
== "wxRadioBox")
1066 prefix
= "ID_RADIOBOX";
1067 MakeUniqueName("radiobox", buf
);
1069 wxString names
[] = { "One", "Two" };
1070 newItem
= new wxRadioBox(panel
, -1, "Radiobox", wxPoint(x
, y
), wxSize(-1, -1), 2, names
, 2,
1071 wxHORIZONTAL
, wxDefaultValidator
, buf
);
1072 res
->SetStringValues(new wxStringList("One", "Two", NULL
));
1074 else if (itemType
== "wxRadioButton")
1076 prefix
= "ID_RADIOBUTTON";
1077 MakeUniqueName("radiobutton", buf
);
1079 wxString names
[] = { "One", "Two" };
1080 newItem
= new wxRadioButton(panel
, -1, "Radiobutton", wxPoint(x
, y
), wxSize(-1, -1),
1081 0, wxDefaultValidator
, buf
);
1083 else if (itemType
== "wxChoice")
1085 prefix
= "ID_CHOICE";
1086 MakeUniqueName("choice", buf
);
1088 newItem
= new wxChoice(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1090 else if (itemType
== "wxComboBox")
1092 prefix
= "ID_COMBOBOX";
1093 MakeUniqueName("combobox", buf
);
1095 newItem
= new wxComboBox(panel
, -1, "", wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, wxCB_DROPDOWN
, wxDefaultValidator
, buf
);
1097 else if (itemType
== "wxGroupBox" || itemType
== "wxStaticBox")
1099 prefix
= "ID_STATICBOX";
1100 MakeUniqueName("staticbox", buf
);
1102 newItem
= new wxStaticBox(panel
, -1, "Static", wxPoint(x
, y
), wxSize(200, 200), 0, buf
);
1104 else if (itemType
== "wxGauge")
1106 prefix
= "ID_GAUGE";
1107 MakeUniqueName("gauge", buf
);
1109 newItem
= new wxGauge(panel
, -1, 10, wxPoint(x
, y
), wxSize(80, 30), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1111 else if (itemType
== "wxSlider")
1113 prefix
= "ID_SLIDER";
1114 MakeUniqueName("slider", buf
);
1116 newItem
= new wxSlider(panel
, -1, 1, 1, 10, wxPoint(x
, y
), wxSize(120, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1118 else if (itemType
== "wxText" || itemType
== "wxTextCtrl (single-line)")
1120 prefix
= "ID_TEXTCTRL";
1121 MakeUniqueName("textctrl", buf
);
1123 res
->SetType("wxTextCtrl");
1124 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, -1), 0, wxDefaultValidator
, buf
);
1126 else if (itemType
== "wxMultiText" || itemType
== "wxTextCtrl (multi-line)")
1128 prefix
= "ID_TEXTCTRL";
1129 MakeUniqueName("textctrl", buf
);
1131 res
->SetType("wxTextCtrl");
1132 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, 100), wxTE_MULTILINE
, wxDefaultValidator
, buf
);
1134 else if (itemType
== "wxScrollBar")
1136 prefix
= "ID_SCROLLBAR";
1137 MakeUniqueName("scrollbar", buf
);
1139 newItem
= new wxScrollBar(panel
, -1, wxPoint(x
, y
), wxSize(140, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1145 int id
= GenerateWindowId(prefix
, newIdName
);
1148 // This is now guaranteed to be unique, so just add to symbol table
1149 m_symbolTable
.AddSymbol(newIdName
, id
);
1151 newItem
->PushEventHandler(new wxResourceEditorControlHandler(newItem
, newItem
));
1153 res
->SetStyle(newItem
->GetWindowStyleFlag());
1154 AssociateResource(res
, newItem
);
1155 panelResource
->GetChildren().Append(res
);
1157 UpdateResourceList();
1162 void wxResourceManager::ClearCurrentDialog()
1164 if (m_editorPanel
->m_childWindow
)
1166 SaveInfoAndDeleteHandler(m_editorPanel
->m_childWindow
);
1167 DisassociateResource(m_editorPanel
->m_childWindow
);
1168 DeleteWindow(m_editorPanel
->m_childWindow
);
1169 m_editorPanel
->m_childWindow
= NULL
;
1170 m_editorPanel
->Clear();
1174 bool wxResourceManager::TestCurrentDialog(wxWindow
* parent
)
1176 if (m_editorPanel
->m_childWindow
)
1178 wxItemResource
* item
= FindResourceForWindow(m_editorPanel
->m_childWindow
);
1182 // Make sure the resources are up-to-date w.r.t. the window
1183 InstantiateResourceFromWindow(item
, m_editorPanel
->m_childWindow
, TRUE
);
1185 wxDialog
* dialog
= new wxDialog
;
1186 long oldStyle
= item
->GetStyle();
1187 bool success
= FALSE
;
1188 // item->SetStyle(wxDEFAULT_DIALOG_STYLE);
1189 if (dialog
->LoadFromResource(parent
, item
->GetName(), & m_resourceTable
))
1192 dialog
->ShowModal();
1195 // item->SetStyle(oldStyle);
1201 // Find the first dialog or panel for which
1202 // there is a selected panel item.
1203 wxWindow
*wxResourceManager::FindParentOfSelection()
1205 m_resourceTable
.BeginFind();
1207 while (node
= m_resourceTable
.Next())
1209 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1210 wxWindow
*win
= FindWindowForResource(res
);
1213 wxNode
*node1
= win
->GetChildren()->First();
1216 wxControl
*item
= (wxControl
*)node1
->Data();
1217 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1218 if (item
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
->IsSelected())
1220 node1
= node1
->Next();
1227 // Format the panel items according to 'flag'
1228 void wxResourceManager::AlignItems(int flag
)
1230 wxWindow
*win
= FindParentOfSelection();
1234 wxNode
*node
= GetSelections().First();
1238 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1239 if (firstSelection
->GetParent() != win
)
1244 firstSelection
->GetPosition(&firstX
, &firstY
);
1245 firstSelection
->GetSize(&firstW
, &firstH
);
1246 int centreX
= (int)(firstX
+ (firstW
/ 2));
1247 int centreY
= (int)(firstY
+ (firstH
/ 2));
1249 while (node
= node
->Next())
1251 wxControl
*item
= (wxControl
*)node
->Data();
1252 if (item
->GetParent() == win
)
1255 item
->GetPosition(&x
, &y
);
1256 item
->GetSize(&w
, &h
);
1262 case TOOLBAR_FORMAT_HORIZ
:
1265 newY
= (int)(centreY
- (h
/2.0));
1268 case TOOLBAR_FORMAT_VERT
:
1270 newX
= (int)(centreX
- (w
/2.0));
1274 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
1280 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
1286 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
1288 newX
= firstX
+ firstW
- w
;
1292 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
1295 newY
= firstY
+ firstH
- h
;
1303 item
->SetSize(newX
, newY
, w
, h
);
1309 // Copy the first image's size to subsequent images
1310 void wxResourceManager::CopySize()
1312 wxWindow
*win
= FindParentOfSelection();
1316 wxNode
*node
= GetSelections().First();
1320 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1321 if (firstSelection
->GetParent() != win
)
1326 firstSelection
->GetPosition(&firstX
, &firstY
);
1327 firstSelection
->GetSize(&firstW
, &firstH
);
1328 int centreX
= (int)(firstX
+ (firstW
/ 2));
1329 int centreY
= (int)(firstY
+ (firstH
/ 2));
1331 while (node
= node
->Next())
1333 wxControl
*item
= (wxControl
*)node
->Data();
1334 if (item
->GetParent() == win
)
1335 item
->SetSize(-1, -1, firstW
, firstH
);
1340 void wxResourceManager::ToBackOrFront(bool toBack
)
1342 wxWindow
*win
= FindParentOfSelection();
1345 wxItemResource
*winResource
= FindResourceForWindow(win
);
1347 wxNode
*node
= GetSelections().First();
1350 wxControl
*item
= (wxControl
*)node
->Data();
1351 wxItemResource
*itemResource
= FindResourceForWindow(item
);
1352 if (item
->GetParent() == win
)
1354 win
->GetChildren()->DeleteObject(item
);
1356 winResource
->GetChildren().DeleteObject(itemResource
);
1359 win
->GetChildren()->Insert(item
);
1361 winResource
->GetChildren().Insert(itemResource
);
1365 win
->GetChildren()->Append(item
);
1367 winResource
->GetChildren().Append(itemResource
);
1370 node
= node
->Next();
1375 void wxResourceManager::AddSelection(wxWindow
*win
)
1377 if (!m_selections
.Member(win
))
1378 m_selections
.Append(win
);
1381 void wxResourceManager::RemoveSelection(wxWindow
*win
)
1383 m_selections
.DeleteObject(win
);
1386 // Need to search through resource table removing this from
1387 // any resource which has this as a parent.
1388 bool wxResourceManager::RemoveResourceFromParent(wxItemResource
*res
)
1390 m_resourceTable
.BeginFind();
1392 while (node
= m_resourceTable
.Next())
1394 wxItemResource
*thisRes
= (wxItemResource
*)node
->Data();
1395 if (thisRes
->GetChildren().Member(res
))
1397 thisRes
->GetChildren().DeleteObject(res
);
1404 bool wxResourceManager::DeleteResource(wxItemResource
*res
)
1409 RemoveResourceFromParent(res
);
1411 wxNode
*node
= res
->GetChildren().First();
1414 wxNode
*next
= node
->Next();
1415 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1416 DeleteResource(child
);
1420 // If this is a button or message resource, delete the
1421 // associate bitmap resource if not being used.
1422 wxString
resType(res
->GetType());
1424 if ((resType
== "wxMessage" || resType
== "wxStaticBitmap" || resType
== "wxButton" || resType
== "wxBitmapButton") && res
->GetValue4())
1426 PossiblyDeleteBitmapResource(res
->GetValue4());
1429 // Remove symbol from table if appropriate
1430 if (!IsSymbolUsed(res
, res
->GetId()))
1432 m_symbolTable
.RemoveSymbol(res
->GetId());
1435 m_resourceTable
.Delete(res
->GetName());
1441 bool wxResourceManager::DeleteResource(wxWindow
*win
)
1443 if (win
->IsKindOf(CLASSINFO(wxControl
)))
1445 // Deselect and refresh window in case we leave selection
1447 wxControl
*item
= (wxControl
*)win
;
1448 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1449 if (childHandler
->IsSelected())
1451 RemoveSelection(item
);
1452 childHandler
->SelectItem(FALSE
);
1454 item
->GetParent()->Refresh();
1459 wxItemResource
*res
= FindResourceForWindow(win
);
1461 DisassociateResource(res
);
1462 DeleteResource(res
);
1463 UpdateResourceList();
1468 // Will eventually have bitmap type information, for different
1470 char *wxResourceManager::AddBitmapResource(char *filename
)
1472 wxItemResource
*resource
= FindBitmapResourceByFilename(filename
);
1476 MakeUniqueName("bitmap", buf
);
1477 resource
= new wxItemResource
;
1478 resource
->SetType("wxBitmap");
1479 resource
->SetName(buf
);
1481 // A bitmap resource has one or more children, specifying
1482 // alternative bitmaps.
1483 wxItemResource
*child
= new wxItemResource
;
1484 child
->SetType("wxBitmap");
1485 child
->SetName(filename
);
1486 child
->SetValue1(wxBITMAP_TYPE_BMP
);
1487 child
->SetValue2(RESOURCE_PLATFORM_ANY
);
1488 child
->SetValue3(0); // Depth
1489 child
->SetSize(0,0,0,0);
1490 resource
->GetChildren().Append(child
);
1492 m_resourceTable
.AddResource(resource
);
1494 UpdateResourceList();
1497 return resource
->GetName();
1502 // Delete the bitmap resource if it isn't being used by another resource.
1503 void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName
)
1505 if (!IsBitmapResourceUsed(resourceName
))
1507 wxItemResource
*res
= m_resourceTable
.FindResource(resourceName
);
1508 DeleteResource(res
);
1509 UpdateResourceList();
1513 bool wxResourceManager::IsBitmapResourceUsed(char *resourceName
)
1515 m_resourceTable
.BeginFind();
1517 while (node
= m_resourceTable
.Next())
1519 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1520 wxString
resType(res
->GetType());
1521 if (resType
== "wxDialog")
1523 wxNode
*node1
= res
->GetChildren().First();
1526 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1527 wxString
childResType(child
->GetType());
1529 if ((childResType
== "wxMessage" || childResType
== "wxButton") &&
1530 child
->GetValue4() &&
1531 (strcmp(child
->GetValue4(), resourceName
) == 0))
1533 node1
= node1
->Next();
1540 // Given a wxButton or wxMessage, find the corresponding bitmap filename.
1541 char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource
*resource
)
1543 if (!resource
|| !resource
->GetValue4())
1545 wxItemResource
*bitmapResource
= m_resourceTable
.FindResource(resource
->GetValue4());
1546 if (!bitmapResource
)
1549 wxNode
*node
= bitmapResource
->GetChildren().First();
1552 // Eventually augment this to return a bitmap of the right kind or something...
1553 // Maybe the root of the filename remains the same, so it doesn't matter which we
1554 // pick up. Otherwise how do we specify multiple filenames... too boring...
1555 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1556 return child
->GetName();
1558 node
= node
->Next();
1563 wxItemResource
*wxResourceManager::FindBitmapResourceByFilename(char *filename
)
1565 m_resourceTable
.BeginFind();
1567 while (node
= m_resourceTable
.Next())
1569 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1570 wxString
resType(res
->GetType());
1571 if (resType
== "wxBitmap")
1573 wxNode
*node1
= res
->GetChildren().First();
1576 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1577 if (child
->GetName() && (strcmp(child
->GetName(), filename
) == 0))
1579 node1
= node1
->Next();
1586 // Is this window identifier symbol in use?
1587 // Let's assume that we can't have 2 names for the same integer id.
1588 // Therefore we can tell by the integer id whether the symbol is
1590 bool wxResourceManager::IsSymbolUsed(wxItemResource
* thisResource
, wxWindowID id
)
1592 m_resourceTable
.BeginFind();
1594 while (node
= m_resourceTable
.Next())
1596 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1598 wxString
resType(res
->GetType());
1599 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1601 if ((res
!= thisResource
) && (res
->GetId() == id
))
1604 wxNode
*node1
= res
->GetChildren().First();
1607 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1608 if ((child
!= thisResource
) && (child
->GetId() == id
))
1610 node1
= node1
->Next();
1617 // Is this window identifier compatible with the given name? (i.e.
1618 // does it already exist under a different name)
1619 bool wxResourceManager::IsIdentifierOK(const wxString
& name
, wxWindowID id
)
1621 if (m_symbolTable
.SymbolExists(name
))
1623 int foundId
= m_symbolTable
.GetIdForSymbol(name
);
1630 // Change all integer ids that match oldId, to newId.
1631 // This is necessary if an id is changed for one resource - all resources
1633 void wxResourceManager::ChangeIds(int oldId
, int newId
)
1635 m_resourceTable
.BeginFind();
1637 while (node
= m_resourceTable
.Next())
1639 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1641 wxString
resType(res
->GetType());
1642 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1644 if (res
->GetId() == oldId
)
1647 wxNode
*node1
= res
->GetChildren().First();
1650 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1651 if (child
->GetId() == oldId
)
1652 child
->SetId(newId
);
1654 node1
= node1
->Next();
1660 // If any resource ids were missing (or their symbol was missing),
1661 // repair them i.e. give them new ids. Returns TRUE if any resource
1662 // needed repairing.
1663 bool wxResourceManager::RepairResourceIds()
1665 bool repaired
= FALSE
;
1667 m_resourceTable
.BeginFind();
1669 while (node
= m_resourceTable
.Next())
1671 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1672 wxString
resType(res
->GetType());
1673 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1676 if ( (res
->GetId() == 0) || ((res
->GetId() > 0) && !m_symbolTable
.IdExists(res
->GetId())) )
1678 wxString newSymbolName
;
1679 int newId
= GenerateWindowId("ID_DIALOG", newSymbolName
) ;
1681 if (res
->GetId() == 0)
1684 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1688 m_symbolTable
.AddSymbol(newSymbolName
, res
->GetId());
1694 wxNode
*node1
= res
->GetChildren().First();
1697 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1699 if ( (child
->GetId() == 0) || ((child
->GetId() > 0) && !m_symbolTable
.IdExists(child
->GetId())) )
1701 wxString newSymbolName
;
1702 int newId
= GenerateWindowId("ID_CONTROL", newSymbolName
) ;
1704 if (child
->GetId() == 0)
1706 child
->SetId(newId
);
1707 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1711 m_symbolTable
.AddSymbol(newSymbolName
, child
->GetId());
1717 node1
= node1
->Next();
1725 // Deletes 'win' and creates a new window from the resource that
1726 // was associated with it. E.g. if you can't change properties on the
1727 // fly, you'll need to delete the window and create it again.
1728 wxWindow
*wxResourceManager::RecreateWindowFromResource(wxWindow
*win
, wxWindowPropertyInfo
*info
)
1730 wxItemResource
*resource
= FindResourceForWindow(win
);
1732 // Put the current window properties into the wxItemResource object
1734 wxWindowPropertyInfo
*newInfo
= NULL
;
1737 newInfo
= CreatePropertyInfoForWindow(win
);
1741 info
->InstantiateResource(resource
);
1743 wxWindow
*newWin
= NULL
;
1744 wxWindow
*parent
= win
->GetParent();
1746 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1749 newWin
= FindWindowForResource(resource
);
1753 DisassociateResource(resource
);
1754 if (win
->GetEventHandler() != win
)
1755 win
->PopEventHandler(TRUE
);
1758 newWin
= m_resourceTable
.CreateItem((wxPanel
*)parent
, resource
);
1759 newWin
->PushEventHandler(new wxResourceEditorControlHandler((wxControl
*) newWin
, (wxControl
*) newWin
));
1760 AssociateResource(resource
, newWin
);
1761 UpdateResourceList();
1765 info
->SetPropertyWindow(newWin
);
1773 // Delete resource highlighted in the listbox
1774 bool wxResourceManager::DeleteSelection()
1776 int sel
= m_editorResourceTree
->GetSelection();
1779 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
1780 wxWindow
*win
= FindWindowForResource(res
);
1783 DeleteResource(win
);
1785 UpdateResourceList();
1794 // Delete resource highlighted in the listbox
1795 bool wxResourceManager::RecreateSelection()
1797 wxNode
*node
= GetSelections().First();
1800 wxControl
*item
= (wxControl
*)node
->Data();
1801 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1802 wxNode
*next
= node
->Next();
1803 childHandler
->SelectItem(FALSE
);
1805 RemoveSelection(item
);
1807 RecreateWindowFromResource(item
);
1814 bool wxResourceManager::EditDialog(wxDialog
*dialog
, wxWindow
*parent
)
1819 // Ensures that all currently shown windows are saved to resources,
1820 // e.g. just before writing to a .wxr file.
1821 bool wxResourceManager::InstantiateAllResourcesFromWindows()
1823 m_resourceTable
.BeginFind();
1825 while (node
= m_resourceTable
.Next())
1827 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1828 wxString
resType(res
->GetType());
1830 if (resType
== "wxDialog")
1832 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1834 InstantiateResourceFromWindow(res
, win
, TRUE
);
1836 else if (resType
== "wxPanel")
1838 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1840 InstantiateResourceFromWindow(res
, win
, TRUE
);
1846 bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource
*resource
, wxWindow
*window
, bool recurse
)
1848 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(window
);
1849 info
->SetResource(resource
);
1850 info
->InstantiateResource(resource
);
1855 wxNode
*node
= resource
->GetChildren().First();
1858 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1859 wxWindow
*childWindow
= FindWindowForResource(child
);
1864 sprintf(buf
, "Could not find window %s", child
->GetName());
1865 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
1868 InstantiateResourceFromWindow(child
, childWindow
, recurse
);
1869 node
= node
->Next();
1876 // Create a window information object for the give window
1877 wxWindowPropertyInfo
*wxResourceManager::CreatePropertyInfoForWindow(wxWindow
*win
)
1879 wxWindowPropertyInfo
*info
= NULL
;
1880 if (win
->IsKindOf(CLASSINFO(wxScrollBar
)))
1882 info
= new wxScrollBarPropertyInfo(win
);
1884 else if (win
->IsKindOf(CLASSINFO(wxStaticBox
)))
1886 info
= new wxGroupBoxPropertyInfo(win
);
1888 else if (win
->IsKindOf(CLASSINFO(wxCheckBox
)))
1890 info
= new wxCheckBoxPropertyInfo(win
);
1892 else if (win
->IsKindOf(CLASSINFO(wxSlider
)))
1894 info
= new wxSliderPropertyInfo(win
);
1896 else if (win
->IsKindOf(CLASSINFO(wxGauge
)))
1898 info
= new wxGaugePropertyInfo(win
);
1900 else if (win
->IsKindOf(CLASSINFO(wxListBox
)))
1902 info
= new wxListBoxPropertyInfo(win
);
1904 else if (win
->IsKindOf(CLASSINFO(wxRadioBox
)))
1906 info
= new wxRadioBoxPropertyInfo(win
);
1908 else if (win
->IsKindOf(CLASSINFO(wxRadioButton
)))
1910 info
= new wxRadioButtonPropertyInfo(win
);
1912 else if (win
->IsKindOf(CLASSINFO(wxChoice
)))
1914 info
= new wxChoicePropertyInfo(win
);
1916 else if (win
->IsKindOf(CLASSINFO(wxComboBox
)))
1918 info
= new wxComboBoxPropertyInfo(win
);
1920 else if (win
->IsKindOf(CLASSINFO(wxButton
)))
1922 info
= new wxButtonPropertyInfo(win
);
1924 else if (win
->IsKindOf(CLASSINFO(wxBitmapButton
)))
1926 info
= new wxBitmapButtonPropertyInfo(win
);
1928 else if (win
->IsKindOf(CLASSINFO(wxStaticText
)))
1930 info
= new wxStaticTextPropertyInfo(win
);
1932 else if (win
->IsKindOf(CLASSINFO(wxStaticBitmap
)))
1934 info
= new wxStaticBitmapPropertyInfo(win
);
1936 else if (win
->IsKindOf(CLASSINFO(wxTextCtrl
)))
1938 info
= new wxTextPropertyInfo(win
);
1940 else if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1942 info
= new wxPanelPropertyInfo(win
);
1946 info
= new wxWindowPropertyInfo(win
);
1951 // Edit the given window
1952 void wxResourceManager::EditWindow(wxWindow
*win
)
1954 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(win
);
1957 info
->SetResource(FindResourceForWindow(win
));
1958 wxString
str("Editing ");
1959 str
+= win
->GetClassInfo()->GetClassName();
1961 if (win
->GetName() != "")
1962 str
+= win
->GetName();
1964 str
+= "properties";
1965 info
->Edit(NULL
, str
);
1969 // Generate a window id and a first stab at a name
1970 int wxResourceManager::GenerateWindowId(const wxString
& prefix
, wxString
& idName
)
1972 m_symbolIdCounter
++;
1973 while (m_symbolTable
.IdExists(m_symbolIdCounter
))
1974 m_symbolIdCounter
++;
1976 int nameId
= m_symbolIdCounter
;
1979 str
.Printf("%d", nameId
);
1980 idName
= prefix
+ str
;
1982 while (m_symbolTable
.SymbolExists(idName
))
1985 str
.Printf("%d", nameId
);
1986 idName
= prefix
+ str
;
1989 return m_symbolIdCounter
;
1994 * Resource editor frame
1997 IMPLEMENT_CLASS(wxResourceEditorFrame
, wxFrame
)
1999 BEGIN_EVENT_TABLE(wxResourceEditorFrame
, wxFrame
)
2000 EVT_MENU(wxID_NEW
, wxResourceEditorFrame::OnNew
)
2001 EVT_MENU(RESED_NEW_DIALOG
, wxResourceEditorFrame::OnNewDialog
)
2002 EVT_MENU(wxID_OPEN
, wxResourceEditorFrame::OnOpen
)
2003 EVT_MENU(RESED_CLEAR
, wxResourceEditorFrame::OnClear
)
2004 EVT_MENU(wxID_SAVE
, wxResourceEditorFrame::OnSave
)
2005 EVT_MENU(wxID_SAVEAS
, wxResourceEditorFrame::OnSaveAs
)
2006 EVT_MENU(wxID_EXIT
, wxResourceEditorFrame::OnExit
)
2007 EVT_MENU(wxID_ABOUT
, wxResourceEditorFrame::OnAbout
)
2008 EVT_MENU(RESED_CONTENTS
, wxResourceEditorFrame::OnContents
)
2009 EVT_MENU(RESED_DELETE
, wxResourceEditorFrame::OnDeleteSelection
)
2010 EVT_MENU(RESED_RECREATE
, wxResourceEditorFrame::OnRecreateSelection
)
2011 EVT_MENU(RESED_TEST
, wxResourceEditorFrame::OnTest
)
2014 wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager
*resMan
, wxFrame
*parent
, const wxString
& title
,
2015 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
2016 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
2021 wxResourceEditorFrame::~wxResourceEditorFrame()
2025 void wxResourceEditorFrame::OnNew(wxCommandEvent
& WXUNUSED(event
))
2027 manager
->New(FALSE
);
2030 void wxResourceEditorFrame::OnNewDialog(wxCommandEvent
& WXUNUSED(event
))
2032 manager
->CreateNewPanel();
2035 void wxResourceEditorFrame::OnOpen(wxCommandEvent
& WXUNUSED(event
))
2040 void wxResourceEditorFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
2042 manager
->Clear(TRUE
, FALSE
);
2045 void wxResourceEditorFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
2050 void wxResourceEditorFrame::OnSaveAs(wxCommandEvent
& WXUNUSED(event
))
2055 void wxResourceEditorFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
2057 manager
->Clear(TRUE
, FALSE
) ;
2061 void wxResourceEditorFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
2064 sprintf(buf
, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart J.Smart@ed.ac.uk\nJulian Smart (c) 1996", wxDIALOG_EDITOR_VERSION
);
2065 wxMessageBox(buf
, "About Dialog Editor", wxOK
|wxCENTRE
);
2068 void wxResourceEditorFrame::OnTest(wxCommandEvent
& WXUNUSED(event
))
2070 manager
->TestCurrentDialog(this);
2073 void wxResourceEditorFrame::OnContents(wxCommandEvent
& WXUNUSED(event
))
2076 wxBeginBusyCursor();
2077 manager
->GetHelpController()->LoadFile();
2078 manager
->GetHelpController()->DisplayContents();
2083 void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent
& WXUNUSED(event
))
2085 manager
->DeleteSelection();
2088 void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent
& WXUNUSED(event
))
2090 manager
->RecreateSelection();
2093 bool wxResourceEditorFrame::OnClose()
2095 if (manager
->Modified())
2097 if (!manager
->Clear(TRUE
, FALSE
))
2105 manager
->m_resourceEditorWindowSize
.width
= w
;
2106 manager
->m_resourceEditorWindowSize
.height
= h
;
2109 GetPosition(&x
, &y
);
2111 manager
->m_resourceEditorWindowSize
.x
= x
;
2112 manager
->m_resourceEditorWindowSize
.y
= y
;
2114 manager
->SetEditorFrame(NULL
);
2115 manager
->SetEditorToolBar(NULL
);
2121 * Resource editor window that contains the dialog/panel being edited
2124 BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow
, wxScrolledWindow
)
2125 EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll
)
2126 EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint
)
2129 wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow
*parent
, const wxPoint
& pos
, const wxSize
& size
,
2131 wxScrolledWindow(parent
, -1, pos
, size
, style
)
2135 m_childWindow
= NULL
;
2138 wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
2142 void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent
& event
)
2144 wxScrolledWindow::OnScroll(event
);
2147 ViewStart(& x
, & y
);
2150 m_childWindow
->Move(m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10));
2153 void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
2160 void wxResourceEditorScrolledWindow::DrawTitle(wxDC
& dc
)
2164 wxItemResource
* res
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_childWindow
);
2167 wxString
str(res
->GetTitle());
2169 ViewStart(& x
, & y
);
2171 wxFont
font(10, wxSWISS
, wxNORMAL
, wxBOLD
);
2173 dc
.SetBackgroundMode(wxTRANSPARENT
);
2174 dc
.SetTextForeground(wxColour(0, 0, 0));
2177 dc
.GetTextExtent(str
, & w
, & h
);
2179 dc
.DrawText(str
, m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10) - h
- 5);
2184 // Popup menu callback
2185 void ObjectMenuProc(wxMenu
& menu
, wxCommandEvent
& event
)
2187 wxWindow
*data
= (wxWindow
*)menu
.GetClientData();
2191 switch (event
.GetInt())
2193 case OBJECT_MENU_EDIT
:
2195 wxResourceManager::GetCurrentResourceManager()->EditWindow(data
);
2198 case OBJECT_MENU_DELETE
:
2200 wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data
);
2201 wxResourceManager::GetCurrentResourceManager()->DeleteResource(data
);
2202 wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data
);
2215 #ifdef __WXGTK__ // I don't dare to delete it...
2217 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2222 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2223 EVT_PAINT(EditorToolBar::OnPaint
)
2228 EditorToolBar::EditorToolBar(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
,
2230 wxToolBar(frame
, -1, pos
, size
, style
)
2234 bool EditorToolBar::OnLeftClick(int toolIndex
, bool toggled
)
2236 wxResourceManager
*manager
= wxResourceManager::GetCurrentResourceManager();
2240 case TOOLBAR_LOAD_FILE
:
2247 manager
->CreateNewPanel();
2250 case TOOLBAR_SAVE_FILE
:
2258 wxBeginBusyCursor();
2259 manager
->GetHelpController()->LoadFile();
2260 manager
->GetHelpController()->DisplayContents();
2265 case TOOLBAR_FORMAT_HORIZ
:
2267 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ
);
2270 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2272 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
);
2275 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2277 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
);
2280 case TOOLBAR_FORMAT_VERT
:
2282 manager
->AlignItems(TOOLBAR_FORMAT_VERT
);
2285 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2287 manager
->AlignItems(TOOLBAR_FORMAT_VERT_TOP_ALIGN
);
2290 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2292 manager
->AlignItems(TOOLBAR_FORMAT_VERT_BOT_ALIGN
);
2295 case TOOLBAR_COPY_SIZE
:
2297 manager
->CopySize();
2300 case TOOLBAR_TO_BACK
:
2302 manager
->ToBackOrFront(TRUE
);
2305 case TOOLBAR_TO_FRONT
:
2307 manager
->ToBackOrFront(FALSE
);
2316 void EditorToolBar::OnMouseEnter(int toolIndex
)
2318 wxFrame
*frame
= (wxFrame
*)GetParent();
2326 case TOOLBAR_LOAD_FILE
:
2327 frame
->SetStatusText("Load project file");
2329 case TOOLBAR_SAVE_FILE
:
2330 frame
->SetStatusText("Save project file");
2333 frame
->SetStatusText("Create a new resource");
2335 case TOOLBAR_FORMAT_HORIZ
:
2336 frame
->SetStatusText("Align items horizontally");
2338 case TOOLBAR_FORMAT_VERT
:
2339 frame
->SetStatusText("Align items vertically");
2341 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2342 frame
->SetStatusText("Left-align items");
2344 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2345 frame
->SetStatusText("Right-align items");
2347 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2348 frame
->SetStatusText("Top-align items");
2350 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2351 frame
->SetStatusText("Bottom-align items");
2353 case TOOLBAR_COPY_SIZE
:
2354 frame
->SetStatusText("Copy size from first selection");
2356 case TOOLBAR_TO_FRONT
:
2357 frame
->SetStatusText("Put image to front");
2359 case TOOLBAR_TO_BACK
:
2360 frame
->SetStatusText("Put image to back");
2363 frame
->SetStatusText("Display help contents");
2369 else frame
->SetStatusText("");