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"
48 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
51 #include <strstream.h>
71 static void ObjectMenuProc(wxMenu
& menu
, wxCommandEvent
& event
);
72 wxResourceManager
*wxResourceManager::sm_currentResourceManager
= NULL
;
75 #include "bitmaps/load.xpm"
76 #include "bitmaps/save.xpm"
77 #include "bitmaps/new.xpm"
78 #include "bitmaps/vert.xpm"
79 #include "bitmaps/alignt.xpm"
80 #include "bitmaps/alignb.xpm"
81 #include "bitmaps/horiz.xpm"
82 #include "bitmaps/alignl.xpm"
83 #include "bitmaps/alignr.xpm"
84 #include "bitmaps/copysize.xpm"
85 #include "bitmaps/tofront.xpm"
86 #include "bitmaps/toback.xpm"
87 #include "bitmaps/help.xpm"
88 #include "bitmaps/wxwin.xpm"
95 wxResourceManager::wxResourceManager():
96 m_imageList(16, 16, TRUE
)
98 sm_currentResourceManager
= this;
100 m_editorPanel
= NULL
;
102 m_editorResourceTree
= NULL
;
103 m_editorControlList
= NULL
;
105 m_symbolIdCounter
= 99;
107 m_currentFilename
= "";
108 m_symbolFilename
= "";
109 m_editorToolBar
= NULL
;
111 // Default window positions
112 m_resourceEditorWindowSize
.width
= 500;
113 m_resourceEditorWindowSize
.height
= 450;
115 m_resourceEditorWindowSize
.x
= 0;
116 m_resourceEditorWindowSize
.y
= 0;
118 m_propertyWindowSize
.width
= 300;
119 m_propertyWindowSize
.height
= 300;
122 m_helpController
= NULL
;
125 m_bitmapImage
= NULL
;
126 m_rootDialogItem
= 0;
129 wxResourceManager::~wxResourceManager()
131 sm_currentResourceManager
= NULL
;
135 if (m_helpController
)
137 m_helpController
->Quit();
138 delete m_helpController
;
139 m_helpController
= NULL
;
143 delete m_bitmapImage
;
147 bool wxResourceManager::Initialize()
149 // Set up the resource filename for each platform.
151 // dialoged.ini in the Windows directory
153 GetWindowsDirectory(buf
, 256);
154 strcat(buf
, "\\dialoged.ini");
155 m_optionsResourceFilename
= buf
;
156 #elif defined(__WXGTK__)
157 wxGetHomeDir( &m_optionsResourceFilename
);
158 m_optionsResourceFilename
+= "/.dialogedrc";
160 #error "Unsupported platform."
166 m_helpController
= new wxHelpController
;
167 m_helpController
->Initialize("dialoged");
170 m_popupMenu
= new wxMenu("", (wxFunction
)ObjectMenuProc
);
171 m_popupMenu
->Append(OBJECT_MENU_EDIT
, "Edit properties");
172 m_popupMenu
->Append(OBJECT_MENU_DELETE
, "Delete object");
177 m_bitmapImage
= new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE
);
180 m_bitmapImage
= new wxBitmap( wxwin_xpm
);
184 // Initialize the image list icons
186 wxIcon
icon1("DIALOG_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
187 wxIcon
icon2("FOLDER1_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
188 wxIcon
icon3("FOLDER2_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
189 wxIcon
icon4("BUTTONSM_ICON", wxBITMAP_TYPE_ICO_RESOURCE
, 16, 16);
190 m_imageList
.Add(icon1
);
191 m_imageList
.Add(icon2
);
192 m_imageList
.Add(icon3
);
193 m_imageList
.Add(icon4
);
196 m_symbolTable
.AddStandardSymbols();
201 bool wxResourceManager::LoadOptions()
203 wxConfig
config("DialogEd", "wxWindows");
205 config
.Read("editorWindowX", &m_resourceEditorWindowSize
.x
);
206 config
.Read("editorWindowY", &m_resourceEditorWindowSize
.y
);
207 config
.Read("editorWindowWidth", &m_resourceEditorWindowSize
.width
);
208 config
.Read("editorWindowHeight", &m_resourceEditorWindowSize
.height
);
209 config
.Read("propertyWindowX", &m_propertyWindowSize
.x
);
210 config
.Read("propertyWindowY", &m_propertyWindowSize
.y
);
211 config
.Read("propertyWindowWidth", &m_propertyWindowSize
.width
);
212 config
.Read("propertyWindowHeight", &m_propertyWindowSize
.height
);
215 wxGetResource("DialogEd", "editorWindowX", &m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
216 wxGetResource("DialogEd", "editorWindowY", &m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
217 wxGetResource("DialogEd", "editorWindowWidth", &m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
218 wxGetResource("DialogEd", "editorWindowHeight", &m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
219 wxGetResource("DialogEd", "propertyWindowX", &m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
220 wxGetResource("DialogEd", "propertyWindowY", &m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
221 wxGetResource("DialogEd", "propertyWindowWidth", &m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
222 wxGetResource("DialogEd", "propertyWindowHeight", &m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
227 bool wxResourceManager::SaveOptions()
229 wxConfig
config("DialogEd", "wxWindows");
231 config
.Write("editorWindowX", m_resourceEditorWindowSize
.x
);
232 config
.Write("editorWindowY", m_resourceEditorWindowSize
.y
);
233 config
.Write("editorWindowWidth", m_resourceEditorWindowSize
.width
);
234 config
.Write("editorWindowHeight", m_resourceEditorWindowSize
.height
);
235 config
.Write("propertyWindowX", m_propertyWindowSize
.x
);
236 config
.Write("propertyWindowY", m_propertyWindowSize
.y
);
237 config
.Write("propertyWindowWidth", m_propertyWindowSize
.width
);
238 config
.Write("propertyWindowHeight", m_propertyWindowSize
.height
);
240 wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
241 wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
242 wxWriteResource("DialogEd", "editorWindowWidth", m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
243 wxWriteResource("DialogEd", "editorWindowHeight", m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
245 wxWriteResource("DialogEd", "propertyWindowX", m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
246 wxWriteResource("DialogEd", "propertyWindowY", m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
247 wxWriteResource("DialogEd", "propertyWindowWidth", m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
248 wxWriteResource("DialogEd", "propertyWindowHeight", m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
254 // Show or hide the resource editor frame, which displays a list
255 // of resources with ability to edit them.
256 bool wxResourceManager::ShowResourceEditor(bool show
, wxWindow
*WXUNUSED(parent
), const char *title
)
262 m_editorFrame
->Iconize(FALSE
);
263 m_editorFrame
->Show(TRUE
);
266 m_editorFrame
= OnCreateEditorFrame(title
);
268 wxMenuBar
*menuBar
= OnCreateEditorMenuBar(m_editorFrame
);
269 m_editorFrame
->SetMenuBar(menuBar
);
271 m_editorToolBar
= (EditorToolBar
*)OnCreateToolBar(m_editorFrame
);
272 m_editorControlList
= new wxResourceEditorControlList(m_editorFrame
, IDC_LISTCTRL
, wxPoint(0, 0), wxSize(-1, -1));
273 m_editorResourceTree
= new wxResourceEditorProjectTree(m_editorFrame
, IDC_TREECTRL
, wxPoint(0, 0), wxSize(-1, -1),
275 m_editorPanel
= OnCreateEditorPanel(m_editorFrame
);
277 m_editorResourceTree
->SetImageList(& m_imageList
);
279 // Constraints for toolbar
280 wxLayoutConstraints
*c
= new wxLayoutConstraints
;
281 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
282 c
->top
.SameAs (m_editorFrame
, wxTop
, 0);
283 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
284 c
->bottom
.Unconstrained();
285 c
->width
.Unconstrained();
286 c
->height
.Absolute(28);
287 m_editorToolBar
->SetConstraints(c
);
289 // Constraints for listbox
290 c
= new wxLayoutConstraints
;
291 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
292 c
->top
.SameAs (m_editorToolBar
, wxBottom
, 0);
293 c
->right
.Absolute (150);
294 c
->bottom
.SameAs (m_editorControlList
, wxTop
, 0);
295 c
->width
.Unconstrained();
296 c
->height
.Unconstrained();
297 m_editorResourceTree
->SetConstraints(c
);
299 // Constraints for panel
300 c
= new wxLayoutConstraints
;
301 c
->left
.SameAs (m_editorResourceTree
, wxRight
, 0);
302 c
->top
.SameAs (m_editorToolBar
, wxBottom
, 0);
303 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
304 c
->bottom
.SameAs (m_editorControlList
, wxTop
, 0);
305 c
->width
.Unconstrained();
306 c
->height
.Unconstrained();
307 m_editorPanel
->SetConstraints(c
);
309 // Constraints for control list (bottom window)
310 c
= new wxLayoutConstraints
;
311 c
->left
.SameAs (m_editorFrame
, wxLeft
, 0);
312 c
->right
.SameAs (m_editorFrame
, wxRight
, 0);
313 c
->bottom
.SameAs (m_editorFrame
, wxBottom
, 0);
314 c
->width
.Unconstrained();
316 c
->height
.Absolute(140);
318 c
->height
.Absolute(60);
321 m_editorControlList
->SetConstraints(c
);
323 m_editorFrame
->SetAutoLayout(TRUE
);
325 UpdateResourceList();
327 m_editorFrame
->Show(TRUE
);
332 wxFrame
*fr
= m_editorFrame
;
333 if (m_editorFrame
->OnClose())
337 m_editorFrame
= NULL
;
338 m_editorPanel
= NULL
;
344 void wxResourceManager::SetFrameTitle(const wxString
& filename
)
348 if (filename
== wxString(""))
349 m_editorFrame
->SetTitle("wxWindows Dialog Editor - untitled");
352 wxString
str("wxWindows Dialog Editor - ");
353 wxString
str2(wxFileNameFromPath(WXSTRINGCAST filename
));
355 m_editorFrame
->SetTitle(str
);
360 bool wxResourceManager::Save()
362 if (m_currentFilename
== wxString(""))
365 return Save(m_currentFilename
);
368 bool wxResourceManager::Save(const wxString
& filename
)
370 // Ensure all visible windows are saved to their resources
371 m_currentFilename
= filename
;
372 SetFrameTitle(m_currentFilename
);
373 InstantiateAllResourcesFromWindows();
374 if (m_resourceTable
.Save(filename
))
376 m_symbolTable
.WriteIncludeFile(m_symbolFilename
);
384 bool wxResourceManager::SaveAs()
386 wxString
s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename
), wxFileNameFromPath(WXSTRINGCAST m_currentFilename
),
387 "wxr", "*.wxr", wxSAVE
| wxOVERWRITE_PROMPT
));
389 if (s
.IsNull() || s
== "")
392 m_currentFilename
= s
;
393 wxStripExtension(m_currentFilename
);
394 m_currentFilename
+= ".wxr";
396 // Construct include filename from this file
397 m_symbolFilename
= m_currentFilename
;
399 wxStripExtension(m_symbolFilename
);
400 m_symbolFilename
+= ".h";
402 Save(m_currentFilename
);
406 bool wxResourceManager::SaveIfModified()
413 bool wxResourceManager::Load(const wxString
& filename
)
415 return New(TRUE
, filename
);
418 bool wxResourceManager::New(bool loadFromFile
, const wxString
& filename
)
420 if (!Clear(TRUE
, FALSE
))
423 m_symbolTable
.AddStandardSymbols();
427 wxString str
= filename
;
428 if (str
== wxString(""))
430 wxString
f(wxFileSelector("Open resource file", NULL
, NULL
, "wxr", "*.wxr", 0, NULL
));
431 if (!f
.IsNull() && f
!= "")
437 if (!m_resourceTable
.ParseResourceFile(WXSTRINGCAST str
))
439 wxMessageBox("Could not read file.", "Resource file load error", wxOK
| wxICON_EXCLAMATION
);
442 m_currentFilename
= str
;
444 SetFrameTitle(m_currentFilename
);
446 UpdateResourceList();
448 // Construct include filename from this file
449 m_symbolFilename
= m_currentFilename
;
451 wxStripExtension(m_symbolFilename
);
452 m_symbolFilename
+= ".h";
454 if (!m_symbolTable
.ReadIncludeFile(m_symbolFilename
))
456 wxString
str("Could not find include file ");
457 str
+= m_symbolFilename
;
458 str
+= ".\nDialog Editor maintains a header file containing id symbols to be used in the application.\n";
459 str
+= "The next time this .wxr file is saved, a header file will be saved also.";
460 wxMessageBox(str
, "Dialog Editor Warning", wxOK
);
462 m_symbolIdCounter
= 99;
466 // Set the id counter to the last known id
467 m_symbolIdCounter
= m_symbolTable
.FindHighestId();
470 // Now check in case some (or all) resources don't have resource ids, or they
471 // don't match the .h file, or something of that nature.
472 bool altered
= RepairResourceIds();
475 wxMessageBox("Some resources have had new identifiers associated with them, since they were missing.",
476 "Dialog Editor Warning", wxOK
);
487 m_currentFilename
= "";
494 bool wxResourceManager::Clear(bool WXUNUSED(deleteWindows
), bool force
)
496 if (!force
&& Modified())
498 int ans
= wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO
| wxCANCEL
);
502 if (!SaveIfModified())
508 ClearCurrentDialog();
509 DisassociateWindows();
511 m_symbolTable
.Clear();
512 m_resourceTable
.ClearTable();
513 UpdateResourceList();
518 bool wxResourceManager::DisassociateWindows()
520 m_resourceTable
.BeginFind();
522 while ((node
= m_resourceTable
.Next()))
524 wxItemResource
*res
= (wxItemResource
*)node
->Data();
525 DisassociateResource(res
);
531 void wxResourceManager::AssociateResource(wxItemResource
*resource
, wxWindow
*win
)
533 if (!m_resourceAssociations
.Get((long)resource
))
534 m_resourceAssociations
.Put((long)resource
, win
);
536 wxNode
*node
= resource
->GetChildren().First();
539 wxItemResource
*child
= (wxItemResource
*)node
->Data();
540 wxWindow
*childWindow
= (wxWindow
*)m_resourceAssociations
.Get((long)child
);
542 childWindow
= win
->FindWindow(child
->GetName());
544 AssociateResource(child
, childWindow
);
548 sprintf(buf
, "AssociateResource: cannot find child window %s", child
->GetName() ? (const char*) child
->GetName() : "(unnamed)");
549 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
556 bool wxResourceManager::DisassociateResource(wxItemResource
*resource
)
558 wxWindow
*win
= FindWindowForResource(resource
);
562 // Disassociate children of window
563 if (win
->GetChildren())
565 wxNode
*node
= win
->GetChildren()->First();
568 wxWindow
*child
= (wxWindow
*)node
->Data();
569 if (child
->IsKindOf(CLASSINFO(wxControl
)))
570 DisassociateResource(child
);
575 RemoveSelection(win
);
576 m_resourceAssociations
.Delete((long)resource
);
580 bool wxResourceManager::DisassociateResource(wxWindow
*win
)
582 wxItemResource
*res
= FindResourceForWindow(win
);
584 return DisassociateResource(res
);
589 // Saves the window info into the resource, and deletes the
590 // handler. Doesn't actually disassociate the window from
591 // the resources. Replaces OnClose.
592 bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow
* win
)
594 wxItemResource
*res
= FindResourceForWindow(win
);
596 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
598 wxResourceEditorDialogHandler
* handler
= (wxResourceEditorDialogHandler
*) win
->GetEventHandler();
599 win
->PopEventHandler();
601 // Now reset all child event handlers
602 wxNode
*node
= win
->GetChildren()->First();
605 wxWindow
*child
= (wxWindow
*)node
->Data();
606 wxEvtHandler
*childHandler
= child
->GetEventHandler();
607 if ( child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
!= child
)
609 child
->PopEventHandler(TRUE
);
617 win
->PopEventHandler(TRUE
);
620 // Save the information
621 InstantiateResourceFromWindow(res
, win
, TRUE
);
623 // DisassociateResource(win);
628 // Destroys the window. If this is the 'current' panel, NULLs the
630 bool wxResourceManager::DeleteWindow(wxWindow
* win
)
632 bool clearDisplay
= FALSE
;
633 if (m_editorPanel
->m_childWindow
== win
)
635 m_editorPanel
->m_childWindow
= NULL
;
642 m_editorPanel
->Clear();
647 wxItemResource
*wxResourceManager::FindResourceForWindow(wxWindow
*win
)
649 m_resourceAssociations
.BeginFind();
651 while ((node
= m_resourceAssociations
.Next()))
653 wxWindow
*w
= (wxWindow
*)node
->Data();
656 return (wxItemResource
*)node
->key
.integer
;
662 wxWindow
*wxResourceManager::FindWindowForResource(wxItemResource
*resource
)
664 return (wxWindow
*)m_resourceAssociations
.Get((long)resource
);
668 void wxResourceManager::MakeUniqueName(char *prefix
, char *buf
)
672 sprintf(buf
, "%s%d", prefix
, m_nameCounter
);
675 if (!m_resourceTable
.FindResource(buf
))
680 wxFrame
*wxResourceManager::OnCreateEditorFrame(const char *title
)
683 int frameWidth = 420;
684 int frameHeight = 300;
687 wxResourceEditorFrame
*frame
= new wxResourceEditorFrame(this, NULL
, title
,
688 wxPoint(m_resourceEditorWindowSize
.x
, m_resourceEditorWindowSize
.y
),
689 wxSize(m_resourceEditorWindowSize
.width
, m_resourceEditorWindowSize
.height
),
690 wxDEFAULT_FRAME_STYLE
);
692 frame
->CreateStatusBar(1);
694 frame
->SetAutoLayout(TRUE
);
696 frame
->SetIcon(wxIcon("DIALOGEDICON"));
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
);
965 resource
->SetResourceStyle(wxRESOURCE_USE_DEFAULTS
);
966 resource
->SetResourceStyle(wxRESOURCE_DIALOG_UNITS
);
969 int id
= GenerateWindowId("ID_DIALOG", newIdName
);
972 // This is now guaranteed to be unique, so just add to symbol table
973 m_symbolTable
.AddSymbol(newIdName
, id
);
975 m_resourceTable
.AddResource(resource
);
977 wxSize
size(400, 300);
979 wxPanel
*panel
= new wxPanel(m_editorPanel
, -1,
980 wxPoint(m_editorPanel
->GetMarginX(), m_editorPanel
->GetMarginY()),
981 size
, wxRAISED_BORDER
|wxDEFAULT_DIALOG_STYLE
, buf
);
982 m_editorPanel
->m_childWindow
= panel
;
984 resource
->SetStyle(panel
->GetWindowStyleFlag());
986 // Store dialog units in resource
987 size
= panel
->ConvertPixelsToDialog(size
);
989 resource
->SetSize(10, 10, size
.x
, size
.y
);
991 // For editing in situ we will need to use the hash table to ensure
992 // we don't dereference invalid pointers.
993 // resourceWindowTable.Put((long)resource, panel);
995 wxResourceEditorDialogHandler
*handler
= new wxResourceEditorDialogHandler(panel
, resource
, panel
->GetEventHandler(),
997 panel
->PushEventHandler(handler
);
999 AssociateResource(resource
, panel
);
1000 UpdateResourceList();
1003 m_editorPanel
->m_childWindow
->Refresh();
1005 // panel->Refresh();
1007 wxClientDC
dc(m_editorPanel
);
1008 m_editorPanel
->DrawTitle(dc
);
1013 bool wxResourceManager::CreatePanelItem(wxItemResource
*panelResource
, wxPanel
*panel
, char *iType
, int x
, int y
, bool isBitmap
)
1016 if (!panel
->IsKindOf(CLASSINFO(wxPanel
)) && !panel
->IsKindOf(CLASSINFO(wxDialog
)))
1021 wxItemResource
*res
= new wxItemResource
;
1022 wxControl
*newItem
= NULL
;
1024 if ((panelResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
1026 wxPoint pt
= panel
->ConvertPixelsToDialog(pt
);
1027 res
->SetSize(pt
.x
, pt
.y
, -1, -1);
1029 else res
->SetSize(x
, y
, -1, -1);
1031 res
->SetType(iType
);
1035 wxString
itemType(iType
);
1037 if (itemType
== "wxButton")
1039 prefix
= "ID_BUTTON";
1040 MakeUniqueName("button", buf
);
1043 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1045 newItem
= new wxButton(panel
, -1, "Button", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1047 if (itemType
== "wxBitmapButton")
1049 prefix
= "ID_BITMAPBUTTON";
1050 MakeUniqueName("button", buf
);
1052 newItem
= new wxBitmapButton(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1054 else if (itemType
== "wxMessage" || itemType
== "wxStaticText")
1056 prefix
= "ID_STATIC";
1057 MakeUniqueName("statictext", buf
);
1060 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(0, 0), 0, buf
);
1062 newItem
= new wxStaticText(panel
, -1, "Static", wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1064 else if (itemType
== "wxStaticBitmap")
1066 prefix
= "ID_STATICBITMAP";
1067 MakeUniqueName("static", buf
);
1069 newItem
= new wxStaticBitmap(panel
, -1, m_bitmapImage
, wxPoint(x
, y
), wxSize(-1, -1), 0, buf
);
1071 else if (itemType
== "wxCheckBox")
1073 prefix
= "ID_CHECKBOX";
1074 MakeUniqueName("checkbox", buf
);
1076 newItem
= new wxCheckBox(panel
, -1, "Checkbox", wxPoint(x
, y
), wxSize(-1, -1), 0, wxDefaultValidator
, buf
);
1078 else if (itemType
== "wxListBox")
1080 prefix
= "ID_LISTBOX";
1081 MakeUniqueName("listbox", buf
);
1083 newItem
= new wxListBox(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1085 else if (itemType
== "wxRadioBox")
1087 prefix
= "ID_RADIOBOX";
1088 MakeUniqueName("radiobox", buf
);
1090 wxString names
[] = { "One", "Two" };
1091 newItem
= new wxRadioBox(panel
, -1, "Radiobox", wxPoint(x
, y
), wxSize(-1, -1), 2, names
, 2,
1092 wxHORIZONTAL
, wxDefaultValidator
, buf
);
1093 res
->SetStringValues(wxStringList("One", "Two", NULL
));
1095 else if (itemType
== "wxRadioButton")
1097 prefix
= "ID_RADIOBUTTON";
1098 MakeUniqueName("radiobutton", buf
);
1100 wxString names
[] = { "One", "Two" };
1101 newItem
= new wxRadioButton(panel
, -1, "Radiobutton", wxPoint(x
, y
), wxSize(-1, -1),
1102 0, wxDefaultValidator
, buf
);
1104 else if (itemType
== "wxChoice")
1106 prefix
= "ID_CHOICE";
1107 MakeUniqueName("choice", buf
);
1109 newItem
= new wxChoice(panel
, -1, wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, 0, wxDefaultValidator
, buf
);
1111 else if (itemType
== "wxComboBox")
1113 prefix
= "ID_COMBOBOX";
1114 MakeUniqueName("combobox", buf
);
1116 newItem
= new wxComboBox(panel
, -1, "", wxPoint(x
, y
), wxSize(-1, -1), 0, NULL
, wxCB_DROPDOWN
, wxDefaultValidator
, buf
);
1118 else if (itemType
== "wxGroupBox" || itemType
== "wxStaticBox")
1120 prefix
= "ID_STATICBOX";
1121 MakeUniqueName("staticbox", buf
);
1123 newItem
= new wxStaticBox(panel
, -1, "Static", wxPoint(x
, y
), wxSize(200, 200), 0, buf
);
1125 else if (itemType
== "wxGauge")
1127 prefix
= "ID_GAUGE";
1128 MakeUniqueName("gauge", buf
);
1130 newItem
= new wxGauge(panel
, -1, 10, wxPoint(x
, y
), wxSize(80, 30), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1132 else if (itemType
== "wxSlider")
1134 prefix
= "ID_SLIDER";
1135 MakeUniqueName("slider", buf
);
1137 newItem
= new wxSlider(panel
, -1, 1, 1, 10, wxPoint(x
, y
), wxSize(120, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1139 else if (itemType
== "wxText" || itemType
== "wxTextCtrl (single-line)")
1141 prefix
= "ID_TEXTCTRL";
1142 MakeUniqueName("textctrl", buf
);
1144 res
->SetType("wxTextCtrl");
1145 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, -1), 0, wxDefaultValidator
, buf
);
1147 else if (itemType
== "wxMultiText" || itemType
== "wxTextCtrl (multi-line)")
1149 prefix
= "ID_TEXTCTRL";
1150 MakeUniqueName("textctrl", buf
);
1152 res
->SetType("wxTextCtrl");
1153 newItem
= new wxTextCtrl(panel
, -1, "", wxPoint(x
, y
), wxSize(120, 100), wxTE_MULTILINE
, wxDefaultValidator
, buf
);
1155 else if (itemType
== "wxScrollBar")
1157 prefix
= "ID_SCROLLBAR";
1158 MakeUniqueName("scrollbar", buf
);
1160 newItem
= new wxScrollBar(panel
, -1, wxPoint(x
, y
), wxSize(140, -1), wxHORIZONTAL
, wxDefaultValidator
, buf
);
1166 int id
= GenerateWindowId(prefix
, newIdName
);
1169 // This is now guaranteed to be unique, so just add to symbol table
1170 m_symbolTable
.AddSymbol(newIdName
, id
);
1172 newItem
->PushEventHandler(new wxResourceEditorControlHandler(newItem
, newItem
));
1174 res
->SetStyle(newItem
->GetWindowStyleFlag());
1175 AssociateResource(res
, newItem
);
1176 panelResource
->GetChildren().Append(res
);
1178 UpdateResourceList();
1183 void wxResourceManager::ClearCurrentDialog()
1185 if (m_editorPanel
->m_childWindow
)
1187 SaveInfoAndDeleteHandler(m_editorPanel
->m_childWindow
);
1188 DisassociateResource(m_editorPanel
->m_childWindow
);
1189 DeleteWindow(m_editorPanel
->m_childWindow
);
1190 m_editorPanel
->m_childWindow
= NULL
;
1191 m_editorPanel
->Clear();
1195 bool wxResourceManager::TestCurrentDialog(wxWindow
* parent
)
1197 if (m_editorPanel
->m_childWindow
)
1199 wxItemResource
* item
= FindResourceForWindow(m_editorPanel
->m_childWindow
);
1203 // Make sure the resources are up-to-date w.r.t. the window
1204 InstantiateResourceFromWindow(item
, m_editorPanel
->m_childWindow
, TRUE
);
1206 wxDialog
* dialog
= new wxDialog
;
1207 bool success
= FALSE
;
1208 if (dialog
->LoadFromResource(parent
, item
->GetName(), & m_resourceTable
))
1211 dialog
->ShowModal();
1219 // Find the first dialog or panel for which
1220 // there is a selected panel item.
1221 wxWindow
*wxResourceManager::FindParentOfSelection()
1223 m_resourceTable
.BeginFind();
1225 while ((node
= m_resourceTable
.Next()))
1227 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1228 wxWindow
*win
= FindWindowForResource(res
);
1231 wxNode
*node1
= win
->GetChildren()->First();
1234 wxControl
*item
= (wxControl
*)node1
->Data();
1235 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1236 if (item
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
->IsSelected())
1238 node1
= node1
->Next();
1245 // Format the panel items according to 'flag'
1246 void wxResourceManager::AlignItems(int flag
)
1248 wxWindow
*win
= FindParentOfSelection();
1252 wxNode
*node
= GetSelections().First();
1256 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1257 if (firstSelection
->GetParent() != win
)
1262 firstSelection
->GetPosition(&firstX
, &firstY
);
1263 firstSelection
->GetSize(&firstW
, &firstH
);
1264 int centreX
= (int)(firstX
+ (firstW
/ 2));
1265 int centreY
= (int)(firstY
+ (firstH
/ 2));
1267 while ((node
= node
->Next()))
1269 wxControl
*item
= (wxControl
*)node
->Data();
1270 if (item
->GetParent() == win
)
1273 item
->GetPosition(&x
, &y
);
1274 item
->GetSize(&w
, &h
);
1280 case TOOLBAR_FORMAT_HORIZ
:
1283 newY
= (int)(centreY
- (h
/2.0));
1286 case TOOLBAR_FORMAT_VERT
:
1288 newX
= (int)(centreX
- (w
/2.0));
1292 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
1298 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
1304 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
1306 newX
= firstX
+ firstW
- w
;
1310 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
1313 newY
= firstY
+ firstH
- h
;
1321 item
->SetSize(newX
, newY
, w
, h
);
1327 // Copy the first image's size to subsequent images
1328 void wxResourceManager::CopySize()
1330 wxWindow
*win
= FindParentOfSelection();
1334 wxNode
*node
= GetSelections().First();
1338 wxControl
*firstSelection
= (wxControl
*)node
->Data();
1339 if (firstSelection
->GetParent() != win
)
1344 firstSelection
->GetPosition(&firstX
, &firstY
);
1345 firstSelection
->GetSize(&firstW
, &firstH
);
1347 while ((node
= node
->Next()))
1349 wxControl
*item
= (wxControl
*)node
->Data();
1350 if (item
->GetParent() == win
)
1351 item
->SetSize(-1, -1, firstW
, firstH
);
1356 void wxResourceManager::ToBackOrFront(bool toBack
)
1358 wxWindow
*win
= FindParentOfSelection();
1361 wxItemResource
*winResource
= FindResourceForWindow(win
);
1363 wxNode
*node
= GetSelections().First();
1366 wxControl
*item
= (wxControl
*)node
->Data();
1367 wxItemResource
*itemResource
= FindResourceForWindow(item
);
1368 if (item
->GetParent() == win
)
1370 win
->GetChildren()->DeleteObject(item
);
1372 winResource
->GetChildren().DeleteObject(itemResource
);
1375 win
->GetChildren()->Insert(item
);
1377 winResource
->GetChildren().Insert(itemResource
);
1381 win
->GetChildren()->Append(item
);
1383 winResource
->GetChildren().Append(itemResource
);
1386 node
= node
->Next();
1391 void wxResourceManager::AddSelection(wxWindow
*win
)
1393 if (!m_selections
.Member(win
))
1394 m_selections
.Append(win
);
1397 void wxResourceManager::RemoveSelection(wxWindow
*win
)
1399 m_selections
.DeleteObject(win
);
1402 // Need to search through resource table removing this from
1403 // any resource which has this as a parent.
1404 bool wxResourceManager::RemoveResourceFromParent(wxItemResource
*res
)
1406 m_resourceTable
.BeginFind();
1408 while ((node
= m_resourceTable
.Next()))
1410 wxItemResource
*thisRes
= (wxItemResource
*)node
->Data();
1411 if (thisRes
->GetChildren().Member(res
))
1413 thisRes
->GetChildren().DeleteObject(res
);
1420 bool wxResourceManager::DeleteResource(wxItemResource
*res
)
1425 RemoveResourceFromParent(res
);
1427 wxNode
*node
= res
->GetChildren().First();
1430 wxNode
*next
= node
->Next();
1431 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1432 DeleteResource(child
);
1436 // If this is a button or message resource, delete the
1437 // associate bitmap resource if not being used.
1438 wxString
resType(res
->GetType());
1440 /* shouldn't have to do this now bitmaps are ref-counted
1441 if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4())
1443 PossiblyDeleteBitmapResource(res->GetValue4());
1447 // Remove symbol from table if appropriate
1448 if (!IsSymbolUsed(res
, res
->GetId()))
1450 m_symbolTable
.RemoveSymbol(res
->GetId());
1453 m_resourceTable
.Delete(res
->GetName());
1459 bool wxResourceManager::DeleteResource(wxWindow
*win
)
1461 if (win
->IsKindOf(CLASSINFO(wxControl
)))
1463 // Deselect and refresh window in case we leave selection
1465 wxControl
*item
= (wxControl
*)win
;
1466 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1467 if (childHandler
->IsSelected())
1469 RemoveSelection(item
);
1470 childHandler
->SelectItem(FALSE
);
1472 item
->GetParent()->Refresh();
1477 wxItemResource
*res
= FindResourceForWindow(win
);
1479 DisassociateResource(res
);
1480 DeleteResource(res
);
1481 UpdateResourceList();
1486 // Will eventually have bitmap type information, for different
1488 wxString
wxResourceManager::AddBitmapResource(const wxString
& filename
)
1490 wxItemResource
*resource
= FindBitmapResourceByFilename(filename
);
1494 MakeUniqueName("bitmap", buf
);
1495 resource
= new wxItemResource
;
1496 resource
->SetType("wxBitmap");
1497 resource
->SetName(buf
);
1499 // A bitmap resource has one or more children, specifying
1500 // alternative bitmaps.
1501 wxItemResource
*child
= new wxItemResource
;
1502 child
->SetType("wxBitmap");
1503 child
->SetName(filename
);
1504 child
->SetValue1(wxBITMAP_TYPE_BMP
);
1505 child
->SetValue2(RESOURCE_PLATFORM_ANY
);
1506 child
->SetValue3(0); // Depth
1507 child
->SetSize(0,0,0,0);
1508 resource
->GetChildren().Append(child
);
1510 m_resourceTable
.AddResource(resource
);
1512 UpdateResourceList();
1515 return resource
->GetName();
1517 return wxEmptyString
;
1520 // Delete the bitmap resource if it isn't being used by another resource.
1521 void wxResourceManager::PossiblyDeleteBitmapResource(const wxString
& resourceName
)
1523 if (!IsBitmapResourceUsed(resourceName
))
1525 wxItemResource
*res
= m_resourceTable
.FindResource(resourceName
);
1526 DeleteResource(res
);
1527 UpdateResourceList();
1531 bool wxResourceManager::IsBitmapResourceUsed(const wxString
& resourceName
)
1533 m_resourceTable
.BeginFind();
1535 while ((node
= m_resourceTable
.Next()))
1537 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1538 wxString
resType(res
->GetType());
1539 if (resType
== "wxDialog")
1541 wxNode
*node1
= res
->GetChildren().First();
1544 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1545 wxString
childResType(child
->GetType());
1547 if ((childResType
== "wxMessage" || childResType
== "wxButton") &&
1548 child
->GetValue4() &&
1549 (strcmp(child
->GetValue4(), resourceName
) == 0))
1551 node1
= node1
->Next();
1558 // Given a wxButton or wxMessage, find the corresponding bitmap filename.
1559 wxString
wxResourceManager::FindBitmapFilenameForResource(wxItemResource
*resource
)
1561 if (!resource
|| (resource
->GetValue4() == ""))
1562 return wxEmptyString
;
1563 wxItemResource
*bitmapResource
= m_resourceTable
.FindResource(resource
->GetValue4());
1564 if (!bitmapResource
)
1565 return wxEmptyString
;
1567 wxNode
*node
= bitmapResource
->GetChildren().First();
1570 // Eventually augment this to return a bitmap of the right kind or something...
1571 // Maybe the root of the filename remains the same, so it doesn't matter which we
1572 // pick up. Otherwise how do we specify multiple filenames... too boring...
1573 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1574 return child
->GetName();
1576 node
= node
->Next();
1578 return wxEmptyString
;
1581 wxItemResource
*wxResourceManager::FindBitmapResourceByFilename(const wxString
& filename
)
1583 m_resourceTable
.BeginFind();
1585 while ((node
= m_resourceTable
.Next()))
1587 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1588 wxString
resType(res
->GetType());
1589 if (resType
== "wxBitmap")
1591 wxNode
*node1
= res
->GetChildren().First();
1594 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1595 if (child
->GetName() && (strcmp(child
->GetName(), filename
) == 0))
1597 node1
= node1
->Next();
1604 // Is this window identifier symbol in use?
1605 // Let's assume that we can't have 2 names for the same integer id.
1606 // Therefore we can tell by the integer id whether the symbol is
1608 bool wxResourceManager::IsSymbolUsed(wxItemResource
* thisResource
, wxWindowID id
)
1610 m_resourceTable
.BeginFind();
1612 while ((node
= m_resourceTable
.Next()))
1614 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1616 wxString
resType(res
->GetType());
1617 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1619 if ((res
!= thisResource
) && (res
->GetId() == id
))
1622 wxNode
*node1
= res
->GetChildren().First();
1625 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1626 if ((child
!= thisResource
) && (child
->GetId() == id
))
1628 node1
= node1
->Next();
1635 // Is this window identifier compatible with the given name? (i.e.
1636 // does it already exist under a different name)
1637 bool wxResourceManager::IsIdentifierOK(const wxString
& name
, wxWindowID id
)
1639 if (m_symbolTable
.SymbolExists(name
))
1641 int foundId
= m_symbolTable
.GetIdForSymbol(name
);
1648 // Change all integer ids that match oldId, to newId.
1649 // This is necessary if an id is changed for one resource - all resources
1651 void wxResourceManager::ChangeIds(int oldId
, int newId
)
1653 m_resourceTable
.BeginFind();
1655 while ((node
= m_resourceTable
.Next()))
1657 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1659 wxString
resType(res
->GetType());
1660 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1662 if (res
->GetId() == oldId
)
1665 wxNode
*node1
= res
->GetChildren().First();
1668 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1669 if (child
->GetId() == oldId
)
1670 child
->SetId(newId
);
1672 node1
= node1
->Next();
1678 // If any resource ids were missing (or their symbol was missing),
1679 // repair them i.e. give them new ids. Returns TRUE if any resource
1680 // needed repairing.
1681 bool wxResourceManager::RepairResourceIds()
1683 bool repaired
= FALSE
;
1685 m_resourceTable
.BeginFind();
1687 while ((node
= m_resourceTable
.Next()))
1689 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1690 wxString
resType(res
->GetType());
1691 if (resType
== "wxDialog" || resType
== "wxDialogBox" || resType
== "wxPanel")
1694 if ( (res
->GetId() == 0) || ((res
->GetId() > 0) && !m_symbolTable
.IdExists(res
->GetId())) )
1696 wxString newSymbolName
;
1697 int newId
= GenerateWindowId("ID_DIALOG", newSymbolName
) ;
1699 if (res
->GetId() == 0)
1702 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1706 m_symbolTable
.AddSymbol(newSymbolName
, res
->GetId());
1712 wxNode
*node1
= res
->GetChildren().First();
1715 wxItemResource
*child
= (wxItemResource
*)node1
->Data();
1717 if ( (child
->GetId() == 0) || ((child
->GetId() > 0) && !m_symbolTable
.IdExists(child
->GetId())) )
1719 wxString newSymbolName
;
1720 int newId
= GenerateWindowId("ID_CONTROL", newSymbolName
) ;
1722 if (child
->GetId() == 0)
1724 child
->SetId(newId
);
1725 m_symbolTable
.AddSymbol(newSymbolName
, newId
);
1729 m_symbolTable
.AddSymbol(newSymbolName
, child
->GetId());
1735 node1
= node1
->Next();
1743 // Deletes 'win' and creates a new window from the resource that
1744 // was associated with it. E.g. if you can't change properties on the
1745 // fly, you'll need to delete the window and create it again.
1746 wxWindow
*wxResourceManager::RecreateWindowFromResource(wxWindow
*win
, wxWindowPropertyInfo
*info
)
1748 wxItemResource
*resource
= FindResourceForWindow(win
);
1750 // Put the current window properties into the wxItemResource object
1752 wxWindowPropertyInfo
*newInfo
= NULL
;
1755 newInfo
= CreatePropertyInfoForWindow(win
);
1759 info
->InstantiateResource(resource
);
1761 wxWindow
*newWin
= NULL
;
1762 wxWindow
*parent
= win
->GetParent();
1763 wxItemResource
* parentResource
= NULL
;
1765 FindResourceForWindow(parent
);
1767 if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1770 newWin
= FindWindowForResource(resource
);
1774 DisassociateResource(resource
);
1775 if (win
->GetEventHandler() != win
)
1776 win
->PopEventHandler(TRUE
);
1779 newWin
= m_resourceTable
.CreateItem((wxPanel
*)parent
, resource
, parentResource
);
1780 newWin
->PushEventHandler(new wxResourceEditorControlHandler((wxControl
*) newWin
, (wxControl
*) newWin
));
1781 AssociateResource(resource
, newWin
);
1782 UpdateResourceList();
1786 info
->SetPropertyWindow(newWin
);
1794 // Delete resource highlighted in the listbox
1795 bool wxResourceManager::DeleteSelection()
1797 int sel
= m_editorResourceTree
->GetSelection();
1800 wxItemResource
*res
= (wxItemResource
*)m_editorResourceTree
->GetItemData(sel
);
1801 wxWindow
*win
= FindWindowForResource(res
);
1804 DeleteResource(win
);
1806 UpdateResourceList();
1815 // Delete resource highlighted in the listbox
1816 bool wxResourceManager::RecreateSelection()
1818 wxNode
*node
= GetSelections().First();
1821 wxControl
*item
= (wxControl
*)node
->Data();
1822 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
1823 wxNode
*next
= node
->Next();
1824 childHandler
->SelectItem(FALSE
);
1826 RemoveSelection(item
);
1828 RecreateWindowFromResource(item
);
1835 bool wxResourceManager::EditDialog(wxDialog
*WXUNUSED(dialog
), wxWindow
*WXUNUSED(parent
))
1840 // Ensures that all currently shown windows are saved to resources,
1841 // e.g. just before writing to a .wxr file.
1842 bool wxResourceManager::InstantiateAllResourcesFromWindows()
1844 m_resourceTable
.BeginFind();
1846 while ((node
= m_resourceTable
.Next()))
1848 wxItemResource
*res
= (wxItemResource
*)node
->Data();
1849 wxString
resType(res
->GetType());
1851 if (resType
== "wxDialog")
1853 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1855 InstantiateResourceFromWindow(res
, win
, TRUE
);
1857 else if (resType
== "wxPanel")
1859 wxWindow
*win
= (wxWindow
*)FindWindowForResource(res
);
1861 InstantiateResourceFromWindow(res
, win
, TRUE
);
1867 bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource
*resource
, wxWindow
*window
, bool recurse
)
1869 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(window
);
1870 info
->SetResource(resource
);
1871 info
->InstantiateResource(resource
);
1876 wxNode
*node
= resource
->GetChildren().First();
1879 wxItemResource
*child
= (wxItemResource
*)node
->Data();
1880 wxWindow
*childWindow
= FindWindowForResource(child
);
1885 sprintf(buf
, "Could not find window %s", (const char*) child
->GetName());
1886 wxMessageBox(buf
, "Dialog Editor problem", wxOK
);
1889 InstantiateResourceFromWindow(child
, childWindow
, recurse
);
1890 node
= node
->Next();
1897 // Create a window information object for the give window
1898 wxWindowPropertyInfo
*wxResourceManager::CreatePropertyInfoForWindow(wxWindow
*win
)
1900 wxWindowPropertyInfo
*info
= NULL
;
1901 if (win
->IsKindOf(CLASSINFO(wxScrollBar
)))
1903 info
= new wxScrollBarPropertyInfo(win
);
1905 else if (win
->IsKindOf(CLASSINFO(wxStaticBox
)))
1907 info
= new wxGroupBoxPropertyInfo(win
);
1909 else if (win
->IsKindOf(CLASSINFO(wxCheckBox
)))
1911 info
= new wxCheckBoxPropertyInfo(win
);
1913 else if (win
->IsKindOf(CLASSINFO(wxSlider
)))
1915 info
= new wxSliderPropertyInfo(win
);
1917 else if (win
->IsKindOf(CLASSINFO(wxGauge
)))
1919 info
= new wxGaugePropertyInfo(win
);
1921 else if (win
->IsKindOf(CLASSINFO(wxListBox
)))
1923 info
= new wxListBoxPropertyInfo(win
);
1925 else if (win
->IsKindOf(CLASSINFO(wxRadioBox
)))
1927 info
= new wxRadioBoxPropertyInfo(win
);
1929 else if (win
->IsKindOf(CLASSINFO(wxRadioButton
)))
1931 info
= new wxRadioButtonPropertyInfo(win
);
1933 else if (win
->IsKindOf(CLASSINFO(wxChoice
)))
1935 info
= new wxChoicePropertyInfo(win
);
1937 else if (win
->IsKindOf(CLASSINFO(wxComboBox
)))
1939 info
= new wxComboBoxPropertyInfo(win
);
1941 else if (win
->IsKindOf(CLASSINFO(wxButton
)))
1943 info
= new wxButtonPropertyInfo(win
);
1945 else if (win
->IsKindOf(CLASSINFO(wxBitmapButton
)))
1947 info
= new wxBitmapButtonPropertyInfo(win
);
1949 else if (win
->IsKindOf(CLASSINFO(wxStaticText
)))
1951 info
= new wxStaticTextPropertyInfo(win
);
1953 else if (win
->IsKindOf(CLASSINFO(wxStaticBitmap
)))
1955 info
= new wxStaticBitmapPropertyInfo(win
);
1957 else if (win
->IsKindOf(CLASSINFO(wxTextCtrl
)))
1959 info
= new wxTextPropertyInfo(win
);
1961 else if (win
->IsKindOf(CLASSINFO(wxPanel
)))
1963 info
= new wxPanelPropertyInfo(win
);
1967 info
= new wxWindowPropertyInfo(win
);
1972 // Edit the given window
1973 void wxResourceManager::EditWindow(wxWindow
*win
)
1975 wxWindowPropertyInfo
*info
= CreatePropertyInfoForWindow(win
);
1978 info
->SetResource(FindResourceForWindow(win
));
1979 wxString
str("Editing ");
1980 str
+= win
->GetClassInfo()->GetClassName();
1982 if (win
->GetName() != "")
1983 str
+= win
->GetName();
1985 str
+= "properties";
1986 info
->Edit(NULL
, str
);
1990 // Generate a window id and a first stab at a name
1991 int wxResourceManager::GenerateWindowId(const wxString
& prefix
, wxString
& idName
)
1993 m_symbolIdCounter
++;
1994 while (m_symbolTable
.IdExists(m_symbolIdCounter
))
1995 m_symbolIdCounter
++;
1997 int nameId
= m_symbolIdCounter
;
2000 str
.Printf("%d", nameId
);
2001 idName
= prefix
+ str
;
2003 while (m_symbolTable
.SymbolExists(idName
))
2006 str
.Printf("%d", nameId
);
2007 idName
= prefix
+ str
;
2010 return m_symbolIdCounter
;
2015 * Resource editor frame
2018 IMPLEMENT_CLASS(wxResourceEditorFrame
, wxFrame
)
2020 BEGIN_EVENT_TABLE(wxResourceEditorFrame
, wxFrame
)
2021 EVT_MENU(wxID_NEW
, wxResourceEditorFrame::OnNew
)
2022 EVT_MENU(RESED_NEW_DIALOG
, wxResourceEditorFrame::OnNewDialog
)
2023 EVT_MENU(wxID_OPEN
, wxResourceEditorFrame::OnOpen
)
2024 EVT_MENU(RESED_CLEAR
, wxResourceEditorFrame::OnClear
)
2025 EVT_MENU(wxID_SAVE
, wxResourceEditorFrame::OnSave
)
2026 EVT_MENU(wxID_SAVEAS
, wxResourceEditorFrame::OnSaveAs
)
2027 EVT_MENU(wxID_EXIT
, wxResourceEditorFrame::OnExit
)
2028 EVT_MENU(wxID_ABOUT
, wxResourceEditorFrame::OnAbout
)
2029 EVT_MENU(RESED_CONTENTS
, wxResourceEditorFrame::OnContents
)
2030 EVT_MENU(RESED_DELETE
, wxResourceEditorFrame::OnDeleteSelection
)
2031 EVT_MENU(RESED_RECREATE
, wxResourceEditorFrame::OnRecreateSelection
)
2032 EVT_MENU(RESED_TEST
, wxResourceEditorFrame::OnTest
)
2035 wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager
*resMan
, wxFrame
*parent
, const wxString
& title
,
2036 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
2037 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
2042 wxResourceEditorFrame::~wxResourceEditorFrame()
2046 void wxResourceEditorFrame::OnNew(wxCommandEvent
& WXUNUSED(event
))
2048 manager
->New(FALSE
);
2051 void wxResourceEditorFrame::OnNewDialog(wxCommandEvent
& WXUNUSED(event
))
2053 manager
->CreateNewPanel();
2056 void wxResourceEditorFrame::OnOpen(wxCommandEvent
& WXUNUSED(event
))
2061 void wxResourceEditorFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
2063 manager
->Clear(TRUE
, FALSE
);
2066 void wxResourceEditorFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
2071 void wxResourceEditorFrame::OnSaveAs(wxCommandEvent
& WXUNUSED(event
))
2076 void wxResourceEditorFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
2078 manager
->Clear(TRUE
, FALSE
) ;
2082 void wxResourceEditorFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
2085 sprintf(buf
, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart J.Smart@ed.ac.uk\nJulian Smart (c) 1996", wxDIALOG_EDITOR_VERSION
);
2086 wxMessageBox(buf
, "About Dialog Editor", wxOK
|wxCENTRE
);
2089 void wxResourceEditorFrame::OnTest(wxCommandEvent
& WXUNUSED(event
))
2091 manager
->TestCurrentDialog(this);
2094 void wxResourceEditorFrame::OnContents(wxCommandEvent
& WXUNUSED(event
))
2097 wxBeginBusyCursor();
2098 manager
->GetHelpController()->LoadFile();
2099 manager
->GetHelpController()->DisplayContents();
2104 void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent
& WXUNUSED(event
))
2106 manager
->DeleteSelection();
2109 void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent
& WXUNUSED(event
))
2111 manager
->RecreateSelection();
2114 bool wxResourceEditorFrame::OnClose()
2116 if (manager
->Modified())
2118 if (!manager
->Clear(TRUE
, FALSE
))
2126 manager
->m_resourceEditorWindowSize
.width
= w
;
2127 manager
->m_resourceEditorWindowSize
.height
= h
;
2130 GetPosition(&x
, &y
);
2132 manager
->m_resourceEditorWindowSize
.x
= x
;
2133 manager
->m_resourceEditorWindowSize
.y
= y
;
2135 manager
->SetEditorFrame(NULL
);
2136 manager
->SetEditorToolBar(NULL
);
2142 * Resource editor window that contains the dialog/panel being edited
2145 BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow
, wxScrolledWindow
)
2146 EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll
)
2147 EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint
)
2150 wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow
*parent
, const wxPoint
& pos
, const wxSize
& size
,
2152 wxScrolledWindow(parent
, -1, pos
, size
, style
)
2156 m_childWindow
= NULL
;
2159 wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
2163 void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent
& event
)
2165 wxScrolledWindow::OnScroll(event
);
2168 ViewStart(& x
, & y
);
2171 m_childWindow
->Move(m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10));
2174 void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
2181 void wxResourceEditorScrolledWindow::DrawTitle(wxDC
& dc
)
2185 wxItemResource
* res
= wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_childWindow
);
2188 wxString
str(res
->GetTitle());
2190 ViewStart(& x
, & y
);
2192 wxFont
font(10, wxSWISS
, wxNORMAL
, wxBOLD
);
2194 dc
.SetBackgroundMode(wxTRANSPARENT
);
2195 dc
.SetTextForeground(wxColour(0, 0, 0));
2198 dc
.GetTextExtent(str
, & w
, & h
);
2200 dc
.DrawText(str
, m_marginX
+ (- x
* 10), m_marginY
+ (- y
* 10) - h
- 5);
2205 // Popup menu callback
2206 void ObjectMenuProc(wxMenu
& menu
, wxCommandEvent
& event
)
2208 wxWindow
*data
= (wxWindow
*)menu
.GetClientData();
2212 switch (event
.GetInt())
2214 case OBJECT_MENU_EDIT
:
2216 wxResourceManager::GetCurrentResourceManager()->EditWindow(data
);
2219 case OBJECT_MENU_DELETE
:
2221 wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data
);
2222 wxResourceManager::GetCurrentResourceManager()->DeleteResource(data
);
2223 wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data
);
2236 #ifdef __WXGTK__ // I don't dare to delete it...
2238 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2243 BEGIN_EVENT_TABLE(EditorToolBar
, wxToolBar
)
2244 EVT_PAINT(EditorToolBar::OnPaint
)
2249 EditorToolBar::EditorToolBar(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
,
2251 wxToolBar(frame
, -1, pos
, size
, style
)
2255 bool EditorToolBar::OnLeftClick(int toolIndex
, bool WXUNUSED(toggled
))
2257 wxResourceManager
*manager
= wxResourceManager::GetCurrentResourceManager();
2261 case TOOLBAR_LOAD_FILE
:
2268 manager
->CreateNewPanel();
2271 case TOOLBAR_SAVE_FILE
:
2279 wxBeginBusyCursor();
2280 manager
->GetHelpController()->LoadFile();
2281 manager
->GetHelpController()->DisplayContents();
2286 case TOOLBAR_FORMAT_HORIZ
:
2288 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ
);
2291 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2293 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
);
2296 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2298 manager
->AlignItems(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
);
2301 case TOOLBAR_FORMAT_VERT
:
2303 manager
->AlignItems(TOOLBAR_FORMAT_VERT
);
2306 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2308 manager
->AlignItems(TOOLBAR_FORMAT_VERT_TOP_ALIGN
);
2311 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2313 manager
->AlignItems(TOOLBAR_FORMAT_VERT_BOT_ALIGN
);
2316 case TOOLBAR_COPY_SIZE
:
2318 manager
->CopySize();
2321 case TOOLBAR_TO_BACK
:
2323 manager
->ToBackOrFront(TRUE
);
2326 case TOOLBAR_TO_FRONT
:
2328 manager
->ToBackOrFront(FALSE
);
2337 void EditorToolBar::OnMouseEnter(int toolIndex
)
2339 wxFrame
*frame
= (wxFrame
*)GetParent();
2347 case TOOLBAR_LOAD_FILE
:
2348 frame
->SetStatusText("Load project file");
2350 case TOOLBAR_SAVE_FILE
:
2351 frame
->SetStatusText("Save project file");
2354 frame
->SetStatusText("Create a new resource");
2356 case TOOLBAR_FORMAT_HORIZ
:
2357 frame
->SetStatusText("Align items horizontally");
2359 case TOOLBAR_FORMAT_VERT
:
2360 frame
->SetStatusText("Align items vertically");
2362 case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN
:
2363 frame
->SetStatusText("Left-align items");
2365 case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN
:
2366 frame
->SetStatusText("Right-align items");
2368 case TOOLBAR_FORMAT_VERT_TOP_ALIGN
:
2369 frame
->SetStatusText("Top-align items");
2371 case TOOLBAR_FORMAT_VERT_BOT_ALIGN
:
2372 frame
->SetStatusText("Bottom-align items");
2374 case TOOLBAR_COPY_SIZE
:
2375 frame
->SetStatusText("Copy size from first selection");
2377 case TOOLBAR_TO_FRONT
:
2378 frame
->SetStatusText("Put image to front");
2380 case TOOLBAR_TO_BACK
:
2381 frame
->SetStatusText("Put image to back");
2384 frame
->SetStatusText("Display help contents");
2390 else frame
->SetStatusText("");