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__)
156 buf += "/.dialogedrc";
157 m_optionsResourceFilename = buf;
159 m_optionsResourceFilename
= ".dialoged.rc";
161 #error "Unsupported platform."
167 m_helpController
= new wxHelpController
;
168 m_helpController
->Initialize("dialoged");
171 m_popupMenu
= new wxMenu("", (wxFunction
)ObjectMenuProc
);
172 m_popupMenu
->Append(OBJECT_MENU_EDIT
, "Edit properties");
173 m_popupMenu
->Append(OBJECT_MENU_DELETE
, "Delete object");
178 m_bitmapImage
= new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE
);
181 m_bitmapImage
= new wxBitmap( wxwin_xpm
);
185 // Initialize the image list icons
187 wxIcon
icon1("DIALOG_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
188 wxIcon
icon2("FOLDER1_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
189 wxIcon
icon3("FOLDER2_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
190 wxIcon
icon4("BUTTONSM_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
191 m_imageList
.Add(icon1
);
192 m_imageList
.Add(icon2
);
193 m_imageList
.Add(icon3
);
194 m_imageList
.Add(icon4
);
197 m_symbolTable
.AddStandardSymbols();
202 bool wxResourceManager::LoadOptions()
204 wxConfig
config("DialogEd", "wxWindows");
206 config
.Read("editorWindowX", &m_resourceEditorWindowSize
.x
);
207 config
.Read("editorWindowY", &m_resourceEditorWindowSize
.y
);
208 config
.Read("editorWindowWidth", &m_resourceEditorWindowSize
.width
);
209 config
.Read("editorWindowHeight", &m_resourceEditorWindowSize
.height
);
210 config
.Read("propertyWindowX", &m_propertyWindowSize
.x
);
211 config
.Read("propertyWindowY", &m_propertyWindowSize
.y
);
212 config
.Read("propertyWindowWidth", &m_propertyWindowSize
.width
);
213 config
.Read("propertyWindowHeight", &m_propertyWindowSize
.height
);
216 wxGetResource("DialogEd", "editorWindowX", &m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
217 wxGetResource("DialogEd", "editorWindowY", &m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
218 wxGetResource("DialogEd", "editorWindowWidth", &m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
219 wxGetResource("DialogEd", "editorWindowHeight", &m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
220 wxGetResource("DialogEd", "propertyWindowX", &m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
221 wxGetResource("DialogEd", "propertyWindowY", &m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
222 wxGetResource("DialogEd", "propertyWindowWidth", &m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
223 wxGetResource("DialogEd", "propertyWindowHeight", &m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
228 bool wxResourceManager::SaveOptions()
230 wxConfig
config("DialogEd", "wxWindows");
232 config
.Write("editorWindowX", m_resourceEditorWindowSize
.x
);
233 config
.Write("editorWindowY", m_resourceEditorWindowSize
.y
);
234 config
.Write("editorWindowWidth", m_resourceEditorWindowSize
.width
);
235 config
.Write("editorWindowHeight", m_resourceEditorWindowSize
.height
);
236 config
.Write("propertyWindowX", m_propertyWindowSize
.x
);
237 config
.Write("propertyWindowY", m_propertyWindowSize
.y
);
238 config
.Write("propertyWindowWidth", m_propertyWindowSize
.width
);
239 config
.Write("propertyWindowHeight", m_propertyWindowSize
.height
);
241 wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
242 wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
243 wxWriteResource("DialogEd", "editorWindowWidth", m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
244 wxWriteResource("DialogEd", "editorWindowHeight", m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
246 wxWriteResource("DialogEd", "propertyWindowX", m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
247 wxWriteResource("DialogEd", "propertyWindowY", m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
248 wxWriteResource("DialogEd", "propertyWindowWidth", m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
249 wxWriteResource("DialogEd", "propertyWindowHeight", m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
255 // Show or hide the resource editor frame, which displays a list
256 // of resources with ability to edit them.
257 bool wxResourceManager::ShowResourceEditor(bool show
, wxWindow
*WXUNUSED(parent
), const char *title
)
263 m_editorFrame
->Iconize(FALSE
);
264 m_editorFrame
->Show(TRUE
);
267 m_editorFrame
= OnCreateEditorFrame(title
);
269 wxMenuBar
*menuBar
= OnCreateEditorMenuBar(m_editorFrame
);
270 m_editorFrame
->SetMenuBar(menuBar
);
272 m_editorToolBar
= (EditorToolBar
*)OnCreateToolBar(m_editorFrame
);
273 m_editorControlList
= new wxResourceEditorControlList(m_editorFrame
, IDC_LISTCTRL
, wxPoint(0, 0), wxSize(-1, -1));
274 m_editorResourceTree
= new wxResourceEditorProjectTree(m_editorFrame
, IDC_TREECTRL
, wxPoint(0, 0), wxSize(-1, -1),
276 m_editorPanel
= OnCreateEditorPanel(m_editorFrame
);
278 m_editorResourceTree
->SetImageList(& m_imageList
);
280 // Constraints for toolbar
281 wxLayoutConstraints
*c
= new wxLayoutConstraints
;
282 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
283 c
->top
.SameAs (m_editorFrame
, wxTop
, 0);
284 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
285 c
->bottom
.Unconstrained();
286 c
->width
.Unconstrained();
287 c
->height
.Absolute(28);
288 m_editorToolBar
->SetConstraints(c
);
290 // Constraints for listbox
291 c
= new wxLayoutConstraints
;
292 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
293 c
->top
.SameAs (m_editorToolBar
, wxBottom
, 0);
294 c
->right
.Absolute (150);
295 c
->bottom
.SameAs (m_editorControlList
, wxTop
, 0);
296 c
->width
.Unconstrained();
297 c
->height
.Unconstrained();
298 m_editorResourceTree
->SetConstraints(c
);
300 // Constraints for panel
301 c
= new wxLayoutConstraints
;
302 c
->left
.SameAs (m_editorResourceTree
, wxRight
, 0);
303 c
->top
.SameAs (m_editorToolBar
, wxBottom
, 0);
304 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
305 c
->bottom
.SameAs (m_editorControlList
, wxTop
, 0);
306 c
->width
.Unconstrained();
307 c
->height
.Unconstrained();
308 m_editorPanel
->SetConstraints(c
);
310 // Constraints for control list (bottom window)
311 c
= new wxLayoutConstraints
;
312 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
313 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
314 c
->bottom
.SameAs (m_editorFrame
, wxBottom
, 0);
315 c
->width
.Unconstrained();
317 c
->height
.Absolute(140);
319 c
->height
.Absolute(60);
322 m_editorControlList
->SetConstraints(c
);
324 m_editorFrame
->SetAutoLayout(TRUE
);
326 UpdateResourceList();
328 m_editorFrame
->Show(TRUE
);
333 wxFrame
*fr
= m_editorFrame
;
334 if (m_editorFrame
->OnClose())
338 m_editorFrame
= NULL
;
339 m_editorPanel
= NULL
;
345 void wxResourceManager::SetFrameTitle(const wxString
& filename
)
349 if (filename
== wxString(""))
350 m_editorFrame
->SetTitle("wxWindows Dialog Editor - untitled");
353 wxString
str("wxWindows Dialog Editor - ");
354 wxString
str2(wxFileNameFromPath(WXSTRINGCAST filename
));
356 m_editorFrame
->SetTitle(str
);
361 bool wxResourceManager::Save()
363 if (m_currentFilename
== wxString(""))
366 return Save(m_currentFilename
);
369 bool wxResourceManager::Save(const wxString
& filename
)
371 // Ensure all visible windows are saved to their resources
372 m_currentFilename
= filename
;
373 SetFrameTitle(m_currentFilename
);
374 InstantiateAllResourcesFromWindows();
375 if (m_resourceTable
.Save(filename
))
377 m_symbolTable
.WriteIncludeFile(m_symbolFilename
);
385 bool wxResourceManager::SaveAs()
387 wxString
s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename
), wxFileNameFromPath(WXSTRINGCAST m_currentFilename
),
388 "wxr", "*.wxr", wxSAVE
| wxOVERWRITE_PROMPT
));
390 if (s
.IsNull() || s
== "")
393 m_currentFilename
= s
;
394 wxStripExtension(m_currentFilename
);
395 m_currentFilename
+= ".wxr";
397 // Construct include filename from this file
398 m_symbolFilename
= m_currentFilename
;
400 wxStripExtension(m_symbolFilename
);
401 m_symbolFilename
+= ".h";
403 Save(m_currentFilename
);
407 bool wxResourceManager::SaveIfModified()
414 bool wxResourceManager::Load(const wxString
& filename
)
416 return New(TRUE
, filename
);
419 bool wxResourceManager::New(bool loadFromFile
, const wxString
& filename
)
421 if (!Clear(TRUE
, FALSE
))
424 m_symbolTable
.AddStandardSymbols();
428 wxString str
= filename
;
429 if (str
== wxString(""))
431 wxString
f(wxFileSelector("Open resource file", NULL
, NULL
, "wxr", "*.wxr", 0, NULL
));
432 if (!f
.IsNull() && f
!= "")
438 if (!m_resourceTable
.ParseResourceFile(WXSTRINGCAST str
))
440 wxMessageBox("Could not read file.", "Resource file load error", wxOK
| wxICON_EXCLAMATION
);
443 m_currentFilename
= str
;
445 SetFrameTitle(m_currentFilename
);
447 UpdateResourceList();
449 // Construct include filename from this file
450 m_symbolFilename
= m_currentFilename
;
452 wxStripExtension(m_symbolFilename
);
453 m_symbolFilename
+= ".h";
455 if (!m_symbolTable
.ReadIncludeFile(m_symbolFilename
))
457 wxString
str("Could not find include file ");
458 str
+= m_symbolFilename
;
459 str
+= ".\nDialog Editor maintains a header file containing id symbols to be used in the application.\n";
460 str
+= "The next time this .wxr file is saved, a header file will be saved also.";
461 wxMessageBox(str
, "Dialog Editor Warning", wxOK
);
463 m_symbolIdCounter
= 99;
467 // Set the id counter to the last known id
468 m_symbolIdCounter
= m_symbolTable
.FindHighestId();
471 // Now check in case some (or all) resources don't have resource ids, or they
472 // don't match the .h file, or something of that nature.
473 bool altered
= RepairResourceIds();
476 wxMessageBox("Some resources have had new identifiers associated with them, since they were missing.",
477 "Dialog Editor Warning", wxOK
);
488 m_currentFilename
= "";
495 bool wxResourceManager::Clear(bool WXUNUSED(deleteWindows
), bool force
)
497 if (!force
&& Modified())
499 int ans
= wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO
| wxCANCEL
);
503 if (!SaveIfModified())
509 ClearCurrentDialog();
510 DisassociateWindows();
512 m_symbolTable
.Clear();
513 m_resourceTable
.ClearTable();
514 UpdateResourceList();
519 bool wxResourceManager::DisassociateWindows()
521 m_resourceTable
.BeginFind();
523 while (node
= m_resourceTable
.Next())
525 wxItemResource
*res
= (wxItemResource
*)node
->Data();
526 DisassociateResource(res
);
532 void wxResourceManager::AssociateResource(wxItemResource
*resource
, wxWindow
*win
)
534 if (!m_resourceAssociations
.Get((long)resource
))
535 m_resourceAssociations
.Put((long)resource
, win
);
537 wxNode
*node
= resource
->GetChildren().First();
540 wxItemResource
*child
= (wxItemResource
*)node
->Data();
541 wxWindow
*childWindow
= (wxWindow
*)m_resourceAssociations
.Get((long)child
);
543 childWindow
= win
->FindWindow(child
->GetName());
545 AssociateResource(child
, childWindow
);
549 sprintf(buf
, "AssociateResource: cannot find child window %s", child
->GetName() ? child
->GetName() : "(unnamed)");
550 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
557 bool wxResourceManager::DisassociateResource(wxItemResource
*resource
)
559 wxWindow
*win
= FindWindowForResource(resource
);
563 // Disassociate children of window
564 if (win
->GetChildren())
566 wxNode
*node
= win
->GetChildren()->First();
569 wxWindow
*child
= (wxWindow
*)node
->Data();
570 if (child
->IsKindOf(CLASSINFO(wxControl
)))
571 DisassociateResource(child
);
576 RemoveSelection(win
);
577 m_resourceAssociations
.Delete((long)resource
);
581 bool wxResourceManager::DisassociateResource(wxWindow
*win
)
583 wxItemResource
*res
= FindResourceForWindow(win
);
585 return DisassociateResource(res
);
590 // Saves the window info into the resource, and deletes the
591 // handler. Doesn't actually disassociate the window from
592 // the resources. Replaces OnClose.
593 bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow
* win
)
595 wxItemResource
*res
= FindResourceForWindow(win
);
597 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
599 wxResourceEditorDialogHandler
* handler
= (wxResourceEditorDialogHandler
*) win
->GetEventHandler();
600 win
->PopEventHandler();
602 // Now reset all child event handlers
603 wxNode
*node
= win
->GetChildren()->First();
606 wxWindow
*child
= (wxWindow
*)node
->Data();
607 wxEvtHandler
*childHandler
= child
->GetEventHandler();
608 if ( child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
!= child
)
610 child
->PopEventHandler(TRUE
);
618 win
->PopEventHandler(TRUE
);
621 // Save the information
622 InstantiateResourceFromWindow(res
, win
, TRUE
);
624 // DisassociateResource(win);
629 // Destroys the window. If this is the 'current' panel, NULLs the
631 bool wxResourceManager::DeleteWindow(wxWindow
* win
)
633 bool clearDisplay
= FALSE
;
634 if (m_editorPanel
->m_childWindow
== win
)
636 m_editorPanel
->m_childWindow
= NULL
;
643 m_editorPanel
->Clear();
648 wxItemResource
*wxResourceManager::FindResourceForWindow(wxWindow
*win
)
650 m_resourceAssociations
.BeginFind();
652 while (node
= m_resourceAssociations
.Next())
654 wxWindow
*w
= (wxWindow
*)node
->Data();
657 return (wxItemResource
*)node
->key
.integer
;
663 wxWindow
*wxResourceManager::FindWindowForResource(wxItemResource
*resource
)
665 return (wxWindow
*)m_resourceAssociations
.Get((long)resource
);
669 void wxResourceManager::MakeUniqueName(char *prefix
, char *buf
)
673 sprintf(buf
, "%s%d", prefix
, m_nameCounter
);
676 if (!m_resourceTable
.FindResource(buf
))
681 wxFrame
*wxResourceManager::OnCreateEditorFrame(const char *title
)
683 int frameWidth
= 420;
684 int frameHeight
= 300;
686 wxResourceEditorFrame
*frame
= new wxResourceEditorFrame(this, NULL
, title
,
687 wxPoint(m_resourceEditorWindowSize
.x
, m_resourceEditorWindowSize
.y
),
688 wxSize(m_resourceEditorWindowSize
.width
, m_resourceEditorWindowSize
.height
),
689 wxDEFAULT_FRAME_STYLE
);
691 frame
->CreateStatusBar(1);
693 frame
->SetAutoLayout(TRUE
);
695 wxIcon
*icon
= new wxIcon("DIALOGEDICON");
696 frame
->SetIcon(icon
);
701 wxMenuBar
*wxResourceManager::OnCreateEditorMenuBar(wxFrame
*WXUNUSED(parent
))
703 wxMenuBar
*menuBar
= new wxMenuBar
;
705 wxMenu
*fileMenu
= new wxMenu
;
706 fileMenu
->Append(RESED_NEW_DIALOG
, "New &dialog", "Create a new dialog");
707 fileMenu
->AppendSeparator();
708 fileMenu
->Append(wxID_NEW
, "&New project", "Clear the current project");
709 fileMenu
->Append(wxID_OPEN
, "&Open...", "Load a resource file");
710 fileMenu
->Append(wxID_SAVE
, "&Save", "Save a resource file");
711 fileMenu
->Append(wxID_SAVEAS
, "Save &As...", "Save a resource file as...");
712 fileMenu
->Append(RESED_CLEAR
, "&Clear", "Clear current resources");
713 fileMenu
->AppendSeparator();
714 fileMenu
->Append(wxID_EXIT
, "E&xit", "Exit resource editor");
716 wxMenu
*editMenu
= new wxMenu
;
717 editMenu
->Append(RESED_TEST
, "&Test Dialog", "Test dialog");
718 editMenu
->Append(RESED_RECREATE
, "&Recreate", "Recreate the selected resource(s)");
719 editMenu
->Append(RESED_DELETE
, "&Delete", "Delete the selected resource(s)");
721 wxMenu
*helpMenu
= new wxMenu
;
722 helpMenu
->Append(RESED_CONTENTS
, "&Help topics", "Invokes the on-line help");
723 helpMenu
->AppendSeparator();
724 helpMenu
->Append(wxID_ABOUT
, "&About", "About wxWindows Dialog Editor");
726 menuBar
->Append(fileMenu
, "&File");
727 menuBar
->Append(editMenu
, "&Edit");
728 menuBar
->Append(helpMenu
, "&Help");
733 wxResourceEditorScrolledWindow
*wxResourceManager::OnCreateEditorPanel(wxFrame
*parent
)
735 wxResourceEditorScrolledWindow
*panel
= new wxResourceEditorScrolledWindow(parent
, wxDefaultPosition
, wxDefaultSize
,
736 // wxSUNKEN_BORDER|wxCLIP_CHILDREN);
739 panel
->SetScrollbars(10, 10, 100, 100);
744 wxToolBar
*wxResourceManager::OnCreateToolBar(wxFrame
*parent
)
746 // Load palette bitmaps
748 wxBitmap
ToolbarLoadBitmap("LOADTOOL");
749 wxBitmap
ToolbarSaveBitmap("SAVETOOL");
750 wxBitmap
ToolbarNewBitmap("NEWTOOL");
751 wxBitmap
ToolbarVertBitmap("VERTTOOL");
752 wxBitmap
ToolbarAlignTBitmap("ALIGNTTOOL");
753 wxBitmap
ToolbarAlignBBitmap("ALIGNBTOOL");
754 wxBitmap
ToolbarHorizBitmap("HORIZTOOL");
755 wxBitmap
ToolbarAlignLBitmap("ALIGNLTOOL");
756 wxBitmap
ToolbarAlignRBitmap("ALIGNRTOOL");
757 wxBitmap
ToolbarCopySizeBitmap("COPYSIZETOOL");
758 wxBitmap
ToolbarToBackBitmap("TOBACKTOOL");
759 wxBitmap
ToolbarToFrontBitmap("TOFRONTTOOL");
760 wxBitmap
ToolbarHelpBitmap("HELPTOOL");
763 wxBitmap
ToolbarLoadBitmap( load_xpm
);
764 wxBitmap
ToolbarSaveBitmap( save_xpm
);
765 wxBitmap
ToolbarNewBitmap( new_xpm
);
766 wxBitmap
ToolbarVertBitmap( vert_xpm
);
767 wxBitmap
ToolbarAlignTBitmap( alignt_xpm
);
768 wxBitmap
ToolbarAlignBBitmap( alignb_xpm
);
769 wxBitmap
ToolbarHorizBitmap( horiz_xpm
);
770 wxBitmap
ToolbarAlignLBitmap( alignl_xpm
);
771 wxBitmap
ToolbarAlignRBitmap( alignr_xpm
);
772 wxBitmap
ToolbarCopySizeBitmap( copysize_xpm
);
773 wxBitmap
ToolbarToBackBitmap( toback_xpm
);
774 wxBitmap
ToolbarToFrontBitmap( tofront_xpm
);
775 wxBitmap
ToolbarHelpBitmap( help_xpm
);
778 // Create the toolbar
779 EditorToolBar
*toolbar
= new EditorToolBar(parent
, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER
|wxTB_HORIZONTAL
);
780 toolbar
->SetMargins(2, 2);
787 int width
= 24; // ToolbarLoadBitmap->GetWidth(); ???
792 toolbar
->AddSeparator();
793 toolbar
->AddTool(TOOLBAR_NEW
, ToolbarNewBitmap
, (wxBitmap
*)NULL
,
794 FALSE
, (float)currentX
, -1, NULL
, "New dialog");
795 currentX
+= width
+ dx
;
796 toolbar
->AddTool(TOOLBAR_LOAD_FILE
, ToolbarLoadBitmap
, (wxBitmap
*)NULL
,
797 FALSE
, (float)currentX
, -1, NULL
, "Load");
798 currentX
+= width
+ dx
;
799 toolbar
->AddTool(TOOLBAR_SAVE_FILE
, ToolbarSaveBitmap
, (wxBitmap
*)NULL
,
800 FALSE
, (float)currentX
, -1, NULL
, "Save");
801 currentX
+= width
+ dx
+ gap
;
802 toolbar
->AddSeparator();
803 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ
, ToolbarVertBitmap
, (wxBitmap
*)NULL
,
804 FALSE
, (float)currentX
, -1, NULL
, "Horizontal align");
805 currentX
+= width
+ dx
;
806 toolbar
->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN
, ToolbarAlignTBitmap
, (wxBitmap
*)NULL
,
807 FALSE
, (float)currentX
, -1, NULL
, "Top align");
808 currentX
+= width
+ dx
;
809 toolbar
->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN
, ToolbarAlignBBitmap
, (wxBitmap
*)NULL
,
810 FALSE
, (float)currentX
, -1, NULL
, "Bottom align");
811 currentX
+= width
+ dx
;
812 toolbar
->AddTool(TOOLBAR_FORMAT_VERT
, ToolbarHorizBitmap
, (wxBitmap
*)NULL
,
813 FALSE
, (float)currentX
, -1, NULL
, "Vertical align");
814 currentX
+= width
+ dx
;
815 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
, ToolbarAlignLBitmap
, (wxBitmap
*)NULL
,
816 FALSE
, (float)currentX
, -1, NULL
, "Left align");
817 currentX
+= width
+ dx
;
818 toolbar
->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
, ToolbarAlignRBitmap
, (wxBitmap
*)NULL
,
819 FALSE
, (float)currentX
, -1, NULL
, "Right align");
820 currentX
+= width
+ dx
;
821 toolbar
->AddTool(TOOLBAR_COPY_SIZE
, ToolbarCopySizeBitmap
, (wxBitmap
*)NULL
,
822 FALSE
, (float)currentX
, -1, NULL
, "Copy size");
823 currentX
+= width
+ dx
+ gap
;
824 toolbar
->AddSeparator();
825 toolbar
->AddTool(TOOLBAR_TO_FRONT
, ToolbarToFrontBitmap
, (wxBitmap
*)NULL
,
826 FALSE
, (float)currentX
, -1, NULL
, "To front");
827 currentX
+= width
+ dx
;
828 toolbar
->AddTool(TOOLBAR_TO_BACK
, ToolbarToBackBitmap
, (wxBitmap
*)NULL
,
829 FALSE
, (float)currentX
, -1, NULL
, "To back");
830 currentX
+= width
+ dx
+ gap
;
832 toolbar
->AddSeparator();
833 toolbar
->AddTool(TOOLBAR_HELP
, ToolbarHelpBitmap
, (wxBitmap
*)NULL
,
834 FALSE
, (float)currentX
, -1, NULL
, "Help");
835 currentX
+= width
+ dx
;
842 void wxResourceManager::UpdateResourceList()
844 if (!m_editorResourceTree
)
847 m_editorResourceTree
->SetInvalid(TRUE
);
848 m_editorResourceTree
->DeleteAllItems();
850 long id
= m_editorResourceTree
->InsertItem(0, "Dialogs"
856 m_resourceTable
.BeginFind();
858 while (node
= m_resourceTable
.Next())
860 wxItemResource
*res
= (wxItemResource
*)node
->Data();
861 wxString
resType(res
->GetType());
862 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel" || resType
== "wxBitmap")
864 AddItemsRecursively(id
, res
);
867 m_editorResourceTree
->ExpandItem(id
, wxTREE_EXPAND_EXPAND
);
868 m_editorResourceTree
->SetInvalid(FALSE
);
871 void wxResourceManager::AddItemsRecursively(long parent
, wxItemResource
*resource
)
873 wxString
theString("");
874 theString
= resource
->GetName();
877 wxString
resType(resource
->GetType());
878 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
883 long id
= m_editorResourceTree
->InsertItem(parent
, theString
889 m_editorResourceTree
->SetItemData(id
, (long) resource
);
891 if (strcmp(resource
->GetType(), "wxBitmap") != 0)
893 wxNode
*node
= resource
->GetChildren().First();
896 wxItemResource
*res
= (wxItemResource
*)node
->Data();
897 AddItemsRecursively(id
, res
);
901 m_editorResourceTree
->ExpandItem(id
, wxTREE_EXPAND_EXPAND
);
904 bool wxResourceManager::EditSelectedResource()
906 int sel
= m_editorResourceTree
->GetSelection();
909 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
915 bool wxResourceManager::Edit(wxItemResource
*res
)
917 ClearCurrentDialog();
919 wxString
resType(res
->GetType());
920 wxPanel
*panel
= (wxPanel
*)FindWindowForResource(res
);
924 wxMessageBox("Should not find panel in wxResourceManager::Edit");
929 long style
= res
->GetStyle();
930 res
->SetStyle(style
|wxRAISED_BORDER
);
932 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, res
, panel
->GetEventHandler(),
935 panel
->LoadFromResource(m_editorPanel
, res
->GetName(), &m_resourceTable
);
937 panel
->PushEventHandler(handler
);
939 res
->SetStyle(style
);
940 handler
->AddChildHandlers(); // Add event handlers for all controls
941 AssociateResource(res
, panel
);
943 m_editorPanel
->m_childWindow
= panel
;
944 panel
->Move(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY());
948 wxClientDC
dc(m_editorPanel
);
949 m_editorPanel
->DrawTitle(dc
);
954 bool wxResourceManager::CreateNewPanel()
956 ClearCurrentDialog();
959 MakeUniqueName("dialog", buf
);
961 wxItemResource
*resource
= new wxItemResource
;
962 resource
->SetType("wxDialog");
963 resource
->SetName(buf
);
964 resource
->SetTitle(buf
);
967 int id
= GenerateWindowId("ID_DIALOG", newIdName
);
970 // This is now guaranteed to be unique, so just add to symbol table
971 m_symbolTable
.AddSymbol(newIdName
, id
);
973 m_resourceTable
.AddResource(resource
);
975 wxPanel
*panel
= new wxPanel(m_editorPanel
, -1,
976 wxPoint(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY()),
977 wxSize(400, 300), wxRAISED_BORDER
|wxDEFAULT_DIALOG_STYLE
, buf
);
978 m_editorPanel
->m_childWindow
= panel
;
980 resource
->SetStyle(panel
->GetWindowStyleFlag());
981 resource
->SetSize(10, 10, 400, 300);
983 // For editing in situ we will need to use the hash table to ensure
984 // we don't dereference invalid pointers.
985 // resourceWindowTable.Put((long)resource, panel);
987 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, resource
, panel
->GetEventHandler(),
989 panel
->PushEventHandler(handler
);
991 AssociateResource(resource
, panel
);
992 UpdateResourceList();
995 m_editorPanel
->m_childWindow
->Refresh();
999 wxClientDC
dc(m_editorPanel
);
1000 m_editorPanel
->DrawTitle(dc
);
1005 bool wxResourceManager::CreatePanelItem(wxItemResource
*panelResource
, wxPanel
*panel
, char *iType
, int x
, int y
, bool isBitmap
)
1008 if (!panel
->IsKindOf(CLASSINFO(wxPanel
)) && !panel
->IsKindOf(CLASSINFO(wxDialog
)))
1013 wxItemResource
*res
= new wxItemResource
;
1014 wxControl
*newItem
= NULL
;
1015 res
->SetSize(x
, y
, -1, -1);
1016 res
->SetType(iType
);
1020 wxString
itemType(iType
);
1022 if (itemType
== "wxButton")
1024 prefix
= "ID_BUTTON";
1025 MakeUniqueName("button", buf
);
1028 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1030 newItem
= new wxButton(panel
, -1, "Button", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1032 if (itemType
== "wxBitmapButton")
1034 prefix
= "ID_BITMAPBUTTON";
1035 MakeUniqueName("button", buf
);
1037 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1039 else if (itemType
== "wxMessage" || itemType
== "wxStaticText")
1041 prefix
= "ID_STATIC";
1042 MakeUniqueName("statictext", buf
);
1045 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(0, 0), 0, buf
);
1047 newItem
= new wxStaticText(panel
, -1, "Static", wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1049 else if (itemType
== "wxStaticBitmap")
1051 prefix
= "ID_STATICBITMAP";
1052 MakeUniqueName("static", buf
);
1054 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1056 else if (itemType
== "wxCheckBox")
1058 prefix
= "ID_CHECKBOX";
1059 MakeUniqueName("checkbox", buf
);
1061 newItem
= new wxCheckBox(panel
, -1, "Checkbox", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1063 else if (itemType
== "wxListBox")
1065 prefix
= "ID_LISTBOX";
1066 MakeUniqueName("listbox", buf
);
1068 newItem
= new wxListBox(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1070 else if (itemType
== "wxRadioBox")
1072 prefix
= "ID_RADIOBOX";
1073 MakeUniqueName("radiobox", buf
);
1075 wxString names
[] = { "One", "Two" };
1076 newItem
= new wxRadioBox(panel
, -1, "Radiobox", wxPoint(x
, y
), wxSize(-1, -1), 2, names
, 2,
1077 wxHORIZONTAL
, wxDefaultValidator
, buf
);
1078 res
->SetStringValues(new wxStringList("One", "Two", NULL
));
1080 else if (itemType
== "wxRadioButton")
1082 prefix
= "ID_RADIOBUTTON";
1083 MakeUniqueName("radiobutton", buf
);
1085 wxString names
[] = { "One", "Two" };
1086 newItem
= new wxRadioButton(panel
, -1, "Radiobutton", wxPoint(x
, y
), wxSize(-1, -1),
1087 0, wxDefaultValidator
, buf
);
1089 else if (itemType
== "wxChoice")
1091 prefix
= "ID_CHOICE";
1092 MakeUniqueName("choice", buf
);
1094 newItem
= new wxChoice(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1096 else if (itemType
== "wxComboBox")
1098 prefix
= "ID_COMBOBOX";
1099 MakeUniqueName("combobox", buf
);
1101 newItem
= new wxComboBox(panel
, -1, "", wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, wxCB_DROPDOWN
, wxDefaultValidator
, buf
);
1103 else if (itemType
== "wxGroupBox" || itemType
== "wxStaticBox")
1105 prefix
= "ID_STATICBOX";
1106 MakeUniqueName("staticbox", buf
);
1108 newItem
= new wxStaticBox(panel
, -1, "Static", wxPoint(x
, y
), wxSize(200, 200), 0, buf
);
1110 else if (itemType
== "wxGauge")
1112 prefix
= "ID_GAUGE";
1113 MakeUniqueName("gauge", buf
);
1115 newItem
= new wxGauge(panel
, -1, 10, wxPoint(x
, y
), wxSize(80, 30), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1117 else if (itemType
== "wxSlider")
1119 prefix
= "ID_SLIDER";
1120 MakeUniqueName("slider", buf
);
1122 newItem
= new wxSlider(panel
, -1, 1, 1, 10, wxPoint(x
, y
), wxSize(120, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1124 else if (itemType
== "wxText" || itemType
== "wxTextCtrl (single-line)")
1126 prefix
= "ID_TEXTCTRL";
1127 MakeUniqueName("textctrl", buf
);
1129 res
->SetType("wxTextCtrl");
1130 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, -1), 0, wxDefaultValidator
, buf
);
1132 else if (itemType
== "wxMultiText" || itemType
== "wxTextCtrl (multi-line)")
1134 prefix
= "ID_TEXTCTRL";
1135 MakeUniqueName("textctrl", buf
);
1137 res
->SetType("wxTextCtrl");
1138 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, 100), wxTE_MULTILINE
, wxDefaultValidator
, buf
);
1140 else if (itemType
== "wxScrollBar")
1142 prefix
= "ID_SCROLLBAR";
1143 MakeUniqueName("scrollbar", buf
);
1145 newItem
= new wxScrollBar(panel
, -1, wxPoint(x
, y
), wxSize(140, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1151 int id
= GenerateWindowId(prefix
, newIdName
);
1154 // This is now guaranteed to be unique, so just add to symbol table
1155 m_symbolTable
.AddSymbol(newIdName
, id
);
1157 newItem
->PushEventHandler(new wxResourceEditorControlHandler(newItem
, newItem
));
1159 res
->SetStyle(newItem
->GetWindowStyleFlag());
1160 AssociateResource(res
, newItem
);
1161 panelResource
->GetChildren().Append(res
);
1163 UpdateResourceList();
1168 void wxResourceManager::ClearCurrentDialog()
1170 if (m_editorPanel
->m_childWindow
)
1172 SaveInfoAndDeleteHandler(m_editorPanel
->m_childWindow
);
1173 DisassociateResource(m_editorPanel
->m_childWindow
);
1174 DeleteWindow(m_editorPanel
->m_childWindow
);
1175 m_editorPanel
->m_childWindow
= NULL
;
1176 m_editorPanel
->Clear();
1180 bool wxResourceManager::TestCurrentDialog(wxWindow
* parent
)
1182 if (m_editorPanel
->m_childWindow
)
1184 wxItemResource
* item
= FindResourceForWindow(m_editorPanel
->m_childWindow
);
1188 // Make sure the resources are up-to-date w.r.t. the window
1189 InstantiateResourceFromWindow(item
, m_editorPanel
->m_childWindow
, TRUE
);
1191 wxDialog
* dialog
= new wxDialog
;
1192 long oldStyle
= item
->GetStyle();
1193 bool success
= FALSE
;
1194 // item->SetStyle(wxDEFAULT_DIALOG_STYLE);
1195 if (dialog
->LoadFromResource(parent
, item
->GetName(), & m_resourceTable
))
1198 dialog
->ShowModal();
1201 // item->SetStyle(oldStyle);
1207 // Find the first dialog or panel for which
1208 // there is a selected panel item.
1209 wxWindow
*wxResourceManager::FindParentOfSelection()
1211 m_resourceTable
.BeginFind();
1213 while (node
= m_resourceTable
.Next())
1215 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1216 wxWindow
*win
= FindWindowForResource(res
);
1219 wxNode
*node1
= win
->GetChildren()->First();
1222 wxControl
*item
= (wxControl
*)node1
->Data();
1223 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1224 if (item
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
->IsSelected())
1226 node1
= node1
->Next();
1233 // Format the panel items according to 'flag'
1234 void wxResourceManager::AlignItems(int flag
)
1236 wxWindow
*win
= FindParentOfSelection();
1240 wxNode
*node
= GetSelections().First();
1244 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1245 if (firstSelection
->GetParent() != win
)
1250 firstSelection
->GetPosition(&firstX
, &firstY
);
1251 firstSelection
->GetSize(&firstW
, &firstH
);
1252 int centreX
= (int)(firstX
+ (firstW
/ 2));
1253 int centreY
= (int)(firstY
+ (firstH
/ 2));
1255 while (node
= node
->Next())
1257 wxControl
*item
= (wxControl
*)node
->Data();
1258 if (item
->GetParent() == win
)
1261 item
->GetPosition(&x
, &y
);
1262 item
->GetSize(&w
, &h
);
1268 case TOOLBAR_FORMAT_HORIZ
:
1271 newY
= (int)(centreY
- (h
/2.0));
1274 case TOOLBAR_FORMAT_VERT
:
1276 newX
= (int)(centreX
- (w
/2.0));
1280 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
1286 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
1292 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
1294 newX
= firstX
+ firstW
- w
;
1298 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
1301 newY
= firstY
+ firstH
- h
;
1309 item
->SetSize(newX
, newY
, w
, h
);
1315 // Copy the first image's size to subsequent images
1316 void wxResourceManager::CopySize()
1318 wxWindow
*win
= FindParentOfSelection();
1322 wxNode
*node
= GetSelections().First();
1326 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1327 if (firstSelection
->GetParent() != win
)
1332 firstSelection
->GetPosition(&firstX
, &firstY
);
1333 firstSelection
->GetSize(&firstW
, &firstH
);
1334 int centreX
= (int)(firstX
+ (firstW
/ 2));
1335 int centreY
= (int)(firstY
+ (firstH
/ 2));
1337 while (node
= node
->Next())
1339 wxControl
*item
= (wxControl
*)node
->Data();
1340 if (item
->GetParent() == win
)
1341 item
->SetSize(-1, -1, firstW
, firstH
);
1346 void wxResourceManager::ToBackOrFront(bool toBack
)
1348 wxWindow
*win
= FindParentOfSelection();
1351 wxItemResource
*winResource
= FindResourceForWindow(win
);
1353 wxNode
*node
= GetSelections().First();
1356 wxControl
*item
= (wxControl
*)node
->Data();
1357 wxItemResource
*itemResource
= FindResourceForWindow(item
);
1358 if (item
->GetParent() == win
)
1360 win
->GetChildren()->DeleteObject(item
);
1362 winResource
->GetChildren().DeleteObject(itemResource
);
1365 win
->GetChildren()->Insert(item
);
1367 winResource
->GetChildren().Insert(itemResource
);
1371 win
->GetChildren()->Append(item
);
1373 winResource
->GetChildren().Append(itemResource
);
1376 node
= node
->Next();
1381 void wxResourceManager::AddSelection(wxWindow
*win
)
1383 if (!m_selections
.Member(win
))
1384 m_selections
.Append(win
);
1387 void wxResourceManager::RemoveSelection(wxWindow
*win
)
1389 m_selections
.DeleteObject(win
);
1392 // Need to search through resource table removing this from
1393 // any resource which has this as a parent.
1394 bool wxResourceManager::RemoveResourceFromParent(wxItemResource
*res
)
1396 m_resourceTable
.BeginFind();
1398 while (node
= m_resourceTable
.Next())
1400 wxItemResource
*thisRes
= (wxItemResource
*)node
->Data();
1401 if (thisRes
->GetChildren().Member(res
))
1403 thisRes
->GetChildren().DeleteObject(res
);
1410 bool wxResourceManager::DeleteResource(wxItemResource
*res
)
1415 RemoveResourceFromParent(res
);
1417 wxNode
*node
= res
->GetChildren().First();
1420 wxNode
*next
= node
->Next();
1421 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1422 DeleteResource(child
);
1426 // If this is a button or message resource, delete the
1427 // associate bitmap resource if not being used.
1428 wxString
resType(res
->GetType());
1430 if ((resType
== "wxMessage" || resType
== "wxStaticBitmap" || resType
== "wxButton" || resType
== "wxBitmapButton") && res
->GetValue4())
1432 PossiblyDeleteBitmapResource(res
->GetValue4());
1435 // Remove symbol from table if appropriate
1436 if (!IsSymbolUsed(res
, res
->GetId()))
1438 m_symbolTable
.RemoveSymbol(res
->GetId());
1441 m_resourceTable
.Delete(res
->GetName());
1447 bool wxResourceManager::DeleteResource(wxWindow
*win
)
1449 if (win
->IsKindOf(CLASSINFO(wxControl
)))
1451 // Deselect and refresh window in case we leave selection
1453 wxControl
*item
= (wxControl
*)win
;
1454 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1455 if (childHandler
->IsSelected())
1457 RemoveSelection(item
);
1458 childHandler
->SelectItem(FALSE
);
1459 item
->GetParent()->Refresh();
1463 wxItemResource
*res
= FindResourceForWindow(win
);
1465 DisassociateResource(res
);
1466 DeleteResource(res
);
1467 UpdateResourceList();
1472 // Will eventually have bitmap type information, for different
1474 char *wxResourceManager::AddBitmapResource(char *filename
)
1476 wxItemResource
*resource
= FindBitmapResourceByFilename(filename
);
1480 MakeUniqueName("bitmap", buf
);
1481 resource
= new wxItemResource
;
1482 resource
->SetType("wxBitmap");
1483 resource
->SetName(buf
);
1485 // A bitmap resource has one or more children, specifying
1486 // alternative bitmaps.
1487 wxItemResource
*child
= new wxItemResource
;
1488 child
->SetType("wxBitmap");
1489 child
->SetName(filename
);
1490 child
->SetValue1(wxBITMAP_TYPE_BMP
);
1491 child
->SetValue2(RESOURCE_PLATFORM_ANY
);
1492 child
->SetValue3(0); // Depth
1493 child
->SetSize(0,0,0,0);
1494 resource
->GetChildren().Append(child
);
1496 m_resourceTable
.AddResource(resource
);
1498 UpdateResourceList();
1501 return resource
->GetName();
1506 // Delete the bitmap resource if it isn't being used by another resource.
1507 void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName
)
1509 if (!IsBitmapResourceUsed(resourceName
))
1511 wxItemResource
*res
= m_resourceTable
.FindResource(resourceName
);
1512 DeleteResource(res
);
1513 UpdateResourceList();
1517 bool wxResourceManager::IsBitmapResourceUsed(char *resourceName
)
1519 m_resourceTable
.BeginFind();
1521 while (node
= m_resourceTable
.Next())
1523 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1524 wxString
resType(res
->GetType());
1525 if (resType
== "wxDialog")
1527 wxNode
*node1
= res
->GetChildren().First();
1530 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1531 wxString
childResType(child
->GetType());
1533 if ((childResType
== "wxMessage" || childResType
== "wxButton") &&
1534 child
->GetValue4() &&
1535 (strcmp(child
->GetValue4(), resourceName
) == 0))
1537 node1
= node1
->Next();
1544 // Given a wxButton or wxMessage, find the corresponding bitmap filename.
1545 char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource
*resource
)
1547 if (!resource
|| !resource
->GetValue4())
1549 wxItemResource
*bitmapResource
= m_resourceTable
.FindResource(resource
->GetValue4());
1550 if (!bitmapResource
)
1553 wxNode
*node
= bitmapResource
->GetChildren().First();
1556 // Eventually augment this to return a bitmap of the right kind or something...
1557 // Maybe the root of the filename remains the same, so it doesn't matter which we
1558 // pick up. Otherwise how do we specify multiple filenames... too boring...
1559 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1560 return child
->GetName();
1562 node
= node
->Next();
1567 wxItemResource
*wxResourceManager::FindBitmapResourceByFilename(char *filename
)
1569 m_resourceTable
.BeginFind();
1571 while (node
= m_resourceTable
.Next())
1573 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1574 wxString
resType(res
->GetType());
1575 if (resType
== "wxBitmap")
1577 wxNode
*node1
= res
->GetChildren().First();
1580 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1581 if (child
->GetName() && (strcmp(child
->GetName(), filename
) == 0))
1583 node1
= node1
->Next();
1590 // Is this window identifier symbol in use?
1591 // Let's assume that we can't have 2 names for the same integer id.
1592 // Therefore we can tell by the integer id whether the symbol is
1594 bool wxResourceManager::IsSymbolUsed(wxItemResource
* thisResource
, wxWindowID id
)
1596 m_resourceTable
.BeginFind();
1598 while (node
= m_resourceTable
.Next())
1600 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1602 wxString
resType(res
->GetType());
1603 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1605 if ((res
!= thisResource
) && (res
->GetId() == id
))
1608 wxNode
*node1
= res
->GetChildren().First();
1611 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1612 if ((child
!= thisResource
) && (child
->GetId() == id
))
1614 node1
= node1
->Next();
1621 // Is this window identifier compatible with the given name? (i.e.
1622 // does it already exist under a different name)
1623 bool wxResourceManager::IsIdentifierOK(const wxString
& name
, wxWindowID id
)
1625 if (m_symbolTable
.SymbolExists(name
))
1627 int foundId
= m_symbolTable
.GetIdForSymbol(name
);
1634 // Change all integer ids that match oldId, to newId.
1635 // This is necessary if an id is changed for one resource - all resources
1637 void wxResourceManager::ChangeIds(int oldId
, int newId
)
1639 m_resourceTable
.BeginFind();
1641 while (node
= m_resourceTable
.Next())
1643 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1645 wxString
resType(res
->GetType());
1646 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1648 if (res
->GetId() == oldId
)
1651 wxNode
*node1
= res
->GetChildren().First();
1654 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1655 if (child
->GetId() == oldId
)
1656 child
->SetId(newId
);
1658 node1
= node1
->Next();
1664 // If any resource ids were missing (or their symbol was missing),
1665 // repair them i.e. give them new ids. Returns TRUE if any resource
1666 // needed repairing.
1667 bool wxResourceManager::RepairResourceIds()
1669 bool repaired
= FALSE
;
1671 m_resourceTable
.BeginFind();
1673 while (node
= m_resourceTable
.Next())
1675 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1676 wxString
resType(res
->GetType());
1677 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1680 if ( (res
->GetId() == 0) || ((res
->GetId() > 0) && !m_symbolTable
.IdExists(res
->GetId())) )
1682 wxString newSymbolName
;
1683 int newId
= GenerateWindowId("ID_DIALOG", newSymbolName
) ;
1685 if (res
->GetId() == 0)
1688 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1692 m_symbolTable
.AddSymbol(newSymbolName
, res
->GetId());
1698 wxNode
*node1
= res
->GetChildren().First();
1701 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1703 if ( (child
->GetId() == 0) || ((child
->GetId() > 0) && !m_symbolTable
.IdExists(child
->GetId())) )
1705 wxString newSymbolName
;
1706 int newId
= GenerateWindowId("ID_CONTROL", newSymbolName
) ;
1708 if (child
->GetId() == 0)
1710 child
->SetId(newId
);
1711 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1715 m_symbolTable
.AddSymbol(newSymbolName
, child
->GetId());
1721 node1
= node1
->Next();
1729 // Deletes 'win' and creates a new window from the resource that
1730 // was associated with it. E.g. if you can't change properties on the
1731 // fly, you'll need to delete the window and create it again.
1732 wxWindow
*wxResourceManager::RecreateWindowFromResource(wxWindow
*win
, wxWindowPropertyInfo
*info
)
1734 wxItemResource
*resource
= FindResourceForWindow(win
);
1736 // Put the current window properties into the wxItemResource object
1738 wxWindowPropertyInfo
*newInfo
= NULL
;
1741 newInfo
= CreatePropertyInfoForWindow(win
);
1745 info
->InstantiateResource(resource
);
1747 wxWindow
*newWin
= NULL
;
1748 wxWindow
*parent
= win
->GetParent();
1750 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1753 newWin
= FindWindowForResource(resource
);
1757 DisassociateResource(resource
);
1758 if (win
->GetEventHandler() != win
)
1759 win
->PopEventHandler(TRUE
);
1762 newWin
= m_resourceTable
.CreateItem((wxPanel
*)parent
, resource
);
1763 newWin
->PushEventHandler(new wxResourceEditorControlHandler((wxControl
*) newWin
, (wxControl
*) newWin
));
1764 AssociateResource(resource
, newWin
);
1765 UpdateResourceList();
1769 info
->SetPropertyWindow(newWin
);
1777 // Delete resource highlighted in the listbox
1778 bool wxResourceManager::DeleteSelection()
1780 int sel
= m_editorResourceTree
->GetSelection();
1783 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
1784 wxWindow
*win
= FindWindowForResource(res
);
1787 DeleteResource(win
);
1789 UpdateResourceList();
1798 // Delete resource highlighted in the listbox
1799 bool wxResourceManager::RecreateSelection()
1801 wxNode
*node
= GetSelections().First();
1804 wxControl
*item
= (wxControl
*)node
->Data();
1805 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1806 wxNode
*next
= node
->Next();
1807 childHandler
->SelectItem(FALSE
);
1809 RemoveSelection(item
);
1811 RecreateWindowFromResource(item
);
1818 bool wxResourceManager::EditDialog(wxDialog
*dialog
, wxWindow
*parent
)
1823 // Ensures that all currently shown windows are saved to resources,
1824 // e.g. just before writing to a .wxr file.
1825 bool wxResourceManager::InstantiateAllResourcesFromWindows()
1827 m_resourceTable
.BeginFind();
1829 while (node
= m_resourceTable
.Next())
1831 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1832 wxString
resType(res
->GetType());
1834 if (resType
== "wxDialog")
1836 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1838 InstantiateResourceFromWindow(res
, win
, TRUE
);
1840 else if (resType
== "wxPanel")
1842 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1844 InstantiateResourceFromWindow(res
, win
, TRUE
);
1850 bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource
*resource
, wxWindow
*window
, bool recurse
)
1852 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(window
);
1853 info
->SetResource(resource
);
1854 info
->InstantiateResource(resource
);
1859 wxNode
*node
= resource
->GetChildren().First();
1862 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1863 wxWindow
*childWindow
= FindWindowForResource(child
);
1868 sprintf(buf
, "Could not find window %s", child
->GetName());
1869 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
1872 InstantiateResourceFromWindow(child
, childWindow
, recurse
);
1873 node
= node
->Next();
1880 // Create a window information object for the give window
1881 wxWindowPropertyInfo
*wxResourceManager::CreatePropertyInfoForWindow(wxWindow
*win
)
1883 wxWindowPropertyInfo
*info
= NULL
;
1884 if (win
->IsKindOf(CLASSINFO(wxScrollBar
)))
1886 info
= new wxScrollBarPropertyInfo(win
);
1888 else if (win
->IsKindOf(CLASSINFO(wxStaticBox
)))
1890 info
= new wxGroupBoxPropertyInfo(win
);
1892 else if (win
->IsKindOf(CLASSINFO(wxCheckBox
)))
1894 info
= new wxCheckBoxPropertyInfo(win
);
1896 else if (win
->IsKindOf(CLASSINFO(wxSlider
)))
1898 info
= new wxSliderPropertyInfo(win
);
1900 else if (win
->IsKindOf(CLASSINFO(wxGauge
)))
1902 info
= new wxGaugePropertyInfo(win
);
1904 else if (win
->IsKindOf(CLASSINFO(wxListBox
)))
1906 info
= new wxListBoxPropertyInfo(win
);
1908 else if (win
->IsKindOf(CLASSINFO(wxRadioBox
)))
1910 info
= new wxRadioBoxPropertyInfo(win
);
1912 else if (win
->IsKindOf(CLASSINFO(wxRadioButton
)))
1914 info
= new wxRadioButtonPropertyInfo(win
);
1916 else if (win
->IsKindOf(CLASSINFO(wxChoice
)))
1918 info
= new wxChoicePropertyInfo(win
);
1920 else if (win
->IsKindOf(CLASSINFO(wxComboBox
)))
1922 info
= new wxComboBoxPropertyInfo(win
);
1924 else if (win
->IsKindOf(CLASSINFO(wxButton
)))
1926 info
= new wxButtonPropertyInfo(win
);
1928 else if (win
->IsKindOf(CLASSINFO(wxBitmapButton
)))
1930 info
= new wxBitmapButtonPropertyInfo(win
);
1932 else if (win
->IsKindOf(CLASSINFO(wxStaticText
)))
1934 info
= new wxStaticTextPropertyInfo(win
);
1936 else if (win
->IsKindOf(CLASSINFO(wxStaticBitmap
)))
1938 info
= new wxStaticBitmapPropertyInfo(win
);
1940 else if (win
->IsKindOf(CLASSINFO(wxTextCtrl
)))
1942 info
= new wxTextPropertyInfo(win
);
1944 else if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1946 info
= new wxPanelPropertyInfo(win
);
1950 info
= new wxWindowPropertyInfo(win
);
1955 // Edit the given window
1956 void wxResourceManager::EditWindow(wxWindow
*win
)
1958 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(win
);
1961 info
->SetResource(FindResourceForWindow(win
));
1962 wxString
str("Editing ");
1963 str
+= win
->GetClassInfo()->GetClassName();
1965 if (win
->GetName() != "")
1966 str
+= win
->GetName();
1968 str
+= "properties";
1969 info
->Edit(NULL
, str
);
1973 // Generate a window id and a first stab at a name
1974 int wxResourceManager::GenerateWindowId(const wxString
& prefix
, wxString
& idName
)
1976 m_symbolIdCounter
++;
1977 while (m_symbolTable
.IdExists(m_symbolIdCounter
))
1978 m_symbolIdCounter
++;
1980 int nameId
= m_symbolIdCounter
;
1983 str
.Printf("%d", nameId
);
1984 idName
= prefix
+ str
;
1986 while (m_symbolTable
.SymbolExists(idName
))
1989 str
.Printf("%d", nameId
);
1990 idName
= prefix
+ str
;
1993 return m_symbolIdCounter
;
1998 * Resource editor frame
2001 IMPLEMENT_CLASS(wxResourceEditorFrame
, wxFrame
)
2003 BEGIN_EVENT_TABLE(wxResourceEditorFrame
, wxFrame
)
2004 EVT_MENU(wxID_NEW
, wxResourceEditorFrame::OnNew
)
2005 EVT_MENU(RESED_NEW_DIALOG
, wxResourceEditorFrame::OnNewDialog
)
2006 EVT_MENU(wxID_OPEN
, wxResourceEditorFrame::OnOpen
)
2007 EVT_MENU(RESED_CLEAR
, wxResourceEditorFrame::OnClear
)
2008 EVT_MENU(wxID_SAVE
, wxResourceEditorFrame::OnSave
)
2009 EVT_MENU(wxID_SAVEAS
, wxResourceEditorFrame::OnSaveAs
)
2010 EVT_MENU(wxID_EXIT
, wxResourceEditorFrame::OnExit
)
2011 EVT_MENU(wxID_ABOUT
, wxResourceEditorFrame::OnAbout
)
2012 EVT_MENU(RESED_CONTENTS
, wxResourceEditorFrame::OnContents
)
2013 EVT_MENU(RESED_DELETE
, wxResourceEditorFrame::OnDeleteSelection
)
2014 EVT_MENU(RESED_RECREATE
, wxResourceEditorFrame::OnRecreateSelection
)
2015 EVT_MENU(RESED_TEST
, wxResourceEditorFrame::OnTest
)
2018 wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager
*resMan
, wxFrame
*parent
, const wxString
& title
,
2019 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
2020 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
2025 wxResourceEditorFrame::~wxResourceEditorFrame()
2029 void wxResourceEditorFrame::OnNew(wxCommandEvent
& WXUNUSED(event
))
2031 manager
->New(FALSE
);
2034 void wxResourceEditorFrame::OnNewDialog(wxCommandEvent
& WXUNUSED(event
))
2036 manager
->CreateNewPanel();
2039 void wxResourceEditorFrame::OnOpen(wxCommandEvent
& WXUNUSED(event
))
2044 void wxResourceEditorFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
2046 manager
->Clear(TRUE
, FALSE
);
2049 void wxResourceEditorFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
2054 void wxResourceEditorFrame::OnSaveAs(wxCommandEvent
& WXUNUSED(event
))
2059 void wxResourceEditorFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
2061 manager
->Clear(TRUE
, FALSE
) ;
2065 void wxResourceEditorFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
2068 sprintf(buf
, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart J.Smart@ed.ac.uk\nJulian Smart (c) 1996", wxDIALOG_EDITOR_VERSION
);
2069 wxMessageBox(buf
, "About Dialog Editor", wxOK
|wxCENTRE
);
2072 void wxResourceEditorFrame::OnTest(wxCommandEvent
& WXUNUSED(event
))
2074 manager
->TestCurrentDialog(this);
2077 void wxResourceEditorFrame::OnContents(wxCommandEvent
& WXUNUSED(event
))
2080 wxBeginBusyCursor();
2081 manager
->GetHelpController()->LoadFile();
2082 manager
->GetHelpController()->DisplayContents();
2087 void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent
& WXUNUSED(event
))
2089 manager
->DeleteSelection();
2092 void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent
& WXUNUSED(event
))
2094 manager
->RecreateSelection();
2097 bool wxResourceEditorFrame::OnClose()
2099 if (manager
->Modified())
2101 if (!manager
->Clear(TRUE
, FALSE
))
2109 manager
->m_resourceEditorWindowSize
.width
= w
;
2110 manager
->m_resourceEditorWindowSize
.height
= h
;
2113 GetPosition(&x
, &y
);
2115 manager
->m_resourceEditorWindowSize
.x
= x
;
2116 manager
->m_resourceEditorWindowSize
.y
= y
;
2118 manager
->SetEditorFrame(NULL
);
2119 manager
->SetEditorToolBar(NULL
);
2125 * Resource editor window that contains the dialog/panel being edited
2128 BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow
, wxScrolledWindow
)
2129 EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll
)
2130 EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint
)
2133 wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow
*parent
, const wxPoint
& pos
, const wxSize
& size
,
2135 wxScrolledWindow(parent
, -1, pos
, size
, style
)
2139 m_childWindow
= NULL
;
2142 wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
2146 void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent
& event
)
2148 wxScrolledWindow::OnScroll(event
);
2151 ViewStart(& x
, & y
);
2154 m_childWindow
->Move(m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10));
2157 void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
2164 void wxResourceEditorScrolledWindow::DrawTitle(wxDC
& dc
)
2168 wxItemResource
* res
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_childWindow
);
2171 wxString
str(res
->GetTitle());
2173 ViewStart(& x
, & y
);
2175 wxFont
font(10, wxSWISS
, wxNORMAL
, wxBOLD
);
2177 dc
.SetBackgroundMode(wxTRANSPARENT
);
2178 dc
.SetTextForeground(wxColour(0, 0, 0));
2181 dc
.GetTextExtent(str
, & w
, & h
);
2183 dc
.DrawText(str
, m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10) - h
- 5);
2188 // Popup menu callback
2189 void ObjectMenuProc(wxMenu
& menu
, wxCommandEvent
& event
)
2191 wxWindow
*data
= (wxWindow
*)menu
.GetClientData();
2195 switch (event
.GetInt())
2197 case OBJECT_MENU_EDIT
:
2199 wxResourceManager::GetCurrentResourceManager()->EditWindow(data
);
2202 case OBJECT_MENU_DELETE
:
2204 wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data
);
2205 wxResourceManager::GetCurrentResourceManager()->DeleteResource(data
);
2206 wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data
);
2219 #ifdef __WXGTK__ // I don't dare to delete it...
2221 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2226 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2227 EVT_PAINT(EditorToolBar::OnPaint
)
2232 EditorToolBar::EditorToolBar(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
,
2234 wxToolBar(frame
, -1, pos
, size
, style
)
2238 bool EditorToolBar::OnLeftClick(int toolIndex
, bool toggled
)
2240 wxResourceManager
*manager
= wxResourceManager::GetCurrentResourceManager();
2244 case TOOLBAR_LOAD_FILE
:
2251 manager
->CreateNewPanel();
2254 case TOOLBAR_SAVE_FILE
:
2262 wxBeginBusyCursor();
2263 manager
->GetHelpController()->LoadFile();
2264 manager
->GetHelpController()->DisplayContents();
2269 case TOOLBAR_FORMAT_HORIZ
:
2271 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ
);
2274 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2276 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
);
2279 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2281 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
);
2284 case TOOLBAR_FORMAT_VERT
:
2286 manager
->AlignItems(TOOLBAR_FORMAT_VERT
);
2289 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2291 manager
->AlignItems(TOOLBAR_FORMAT_VERT_TOP_ALIGN
);
2294 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2296 manager
->AlignItems(TOOLBAR_FORMAT_VERT_BOT_ALIGN
);
2299 case TOOLBAR_COPY_SIZE
:
2301 manager
->CopySize();
2304 case TOOLBAR_TO_BACK
:
2306 manager
->ToBackOrFront(TRUE
);
2309 case TOOLBAR_TO_FRONT
:
2311 manager
->ToBackOrFront(FALSE
);
2320 void EditorToolBar::OnMouseEnter(int toolIndex
)
2322 wxFrame
*frame
= (wxFrame
*)GetParent();
2330 case TOOLBAR_LOAD_FILE
:
2331 frame
->SetStatusText("Load project file");
2333 case TOOLBAR_SAVE_FILE
:
2334 frame
->SetStatusText("Save project file");
2337 frame
->SetStatusText("Create a new resource");
2339 case TOOLBAR_FORMAT_HORIZ
:
2340 frame
->SetStatusText("Align items horizontally");
2342 case TOOLBAR_FORMAT_VERT
:
2343 frame
->SetStatusText("Align items vertically");
2345 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2346 frame
->SetStatusText("Left-align items");
2348 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2349 frame
->SetStatusText("Right-align items");
2351 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2352 frame
->SetStatusText("Top-align items");
2354 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2355 frame
->SetStatusText("Bottom-align items");
2357 case TOOLBAR_COPY_SIZE
:
2358 frame
->SetStatusText("Copy size from first selection");
2360 case TOOLBAR_TO_FRONT
:
2361 frame
->SetStatusText("Put image to front");
2363 case TOOLBAR_TO_BACK
:
2364 frame
->SetStatusText("Put image to back");
2367 frame
->SetStatusText("Display help contents");
2373 else frame
->SetStatusText("");