diff --git a/utils/dialoged/docs/body.tex b/utils/dialoged/docs/body.tex index c88202c1ac..db941abadf 100644 --- a/utils/dialoged/docs/body.tex +++ b/utils/dialoged/docs/body.tex @@ -41,12 +41,15 @@ all dialogs in a particular directory. \subsection{File menu} \begin{twocollist}\itemsep=0pt -\twocolitem{New dialog}{Creates a new dialog resource.} -\twocolitem{New project}{Creates a new project (clears index and resets project name).} -\twocolitem{Open}{Opens an existing resource file.} +\twocolitem{New Dialog}{Creates a new dialog resource.} +\twocolitem{New Project}{Creates a new project (clears index and resets project name).} +\twocolitem{Open...}{Opens an existing resource file.} \twocolitem{Save}{Saves the current resources.} \twocolitem{Save As...}{Saves the current resources in a named file.} \twocolitem{Clear}{Clears the current resources.} +\twocolitem{Convert Old Resources...}{Takes a directory of wxWindows 1.68 dialog resources, +and converts them to wxWindows 2 resources, in a separate directory. See +\helpref{Converting old files}{convertingoldfiles}.} \twocolitem{Exit}{Exits the program.} \end{twocollist} @@ -63,7 +66,7 @@ item.} \subsection{Help menu} \begin{twocollist}\itemsep=0pt -\twocolitem{Help topics}{Displays on-line help at the contents page.} +\twocolitem{Help Topics}{Displays on-line help at the contents page.} \twocolitem{About}{Displays an dialog showing the Dialog Editor version and author.} \end{twocollist} @@ -76,15 +79,21 @@ The command toolbar consists of the following tools: \twocolitem{\icon{new.eps}{New}}{Clears the project.} \twocolitem{\icon{open.eps}{Open}}{Opens an existing resource file.} \twocolitem{\icon{save.eps}{Save}}{Saves the current resources.} -\twocolitem{\icon{vert.eps}{Horizontal align}}{Aligns the centre of the selected items horizontally.} -\twocolitem{\icon{alignt.eps}{Horizontal top-align}}{Aligns the top sides of the selected items horizontally.} -\twocolitem{\icon{alignb.eps}{Horizontal bottom-align}}{Aligns the bottom sides of the selected items horizontally.} -\twocolitem{\icon{horiz.eps}{Vertical align}}{Aligns the centre of the selected items vertically.} -\twocolitem{\icon{alignl.eps}{Vertical left-align}}{Aligns the left sides of the selected items vertically.} -\twocolitem{\icon{alignr.eps}{Vertical right-align}}{Aligns the right sides of the selected items vertically.} -\twocolitem{\icon{copysize.eps}{Copy size}}{Copies the size of the first selected item to the subsequently selected item(s).} -\twocolitem{\icon{tofront.eps}{To front}}{Puts the selected item(s) to the front of the display list.} -\twocolitem{\icon{toback.eps}{To back}}{Puts the selected item(s) to the back of the display list.} +\twocolitem{\icon{vert.eps}{Horizontal align}}{Aligns the centre of the selected controls horizontally.} +\twocolitem{\icon{alignt.eps}{Horizontal top-align}}{Aligns the top sides of the selected controls horizontally.} +\twocolitem{\icon{alignb.eps}{Horizontal bottom-align}}{Aligns the bottom sides of the selected controls horizontally.} +\twocolitem{\icon{horiz.eps}{Vertical align}}{Aligns the centre of the selected controls vertically.} +\twocolitem{\icon{alignl.eps}{Vertical left-align}}{Aligns the left sides of the selected controls vertically.} +\twocolitem{\icon{alignr.eps}{Vertical right-align}}{Aligns the right sides of the selected controls vertically.} +\twocolitem{\icon{copysize.eps}{Copy size}}{Copies the size of the first selected control to the subsequently selected control(s).} +\twocolitem{\icon{copywdth.eps}{Copy width}}{Copies the width of the first selected control to the subsequently selected control(s).} +\twocolitem{\icon{copyhght.eps}{Copy height}}{Copies the height of the first selected control to the subsequently selected control(s).} +\twocolitem{\icon{disthor.eps}{Distribute horizontally}}{Evenly distributes the space between the selected controls, horizontally. Note that the controls +should be selected in order from left to right.} +\twocolitem{\icon{distvert.eps}{Distribute vertically}}{Evenly distributes the space between the selected controls, vertically. Note that the controls +should be selected in order from top to bottom.} +\twocolitem{\icon{tofront.eps}{To front}}{Puts the selected control(s) to the front of the display list.} +\twocolitem{\icon{toback.eps}{To back}}{Puts the selected control(s) to the back of the display list.} \twocolitem{\icon{help.eps}{Help}}{Invokes Dialog Editor help.} \end{twocollist} @@ -198,3 +207,28 @@ resource files for different platforms, with spacing modified to suit each environment. The best thing is to try your dialog resource on several platforms and see whether tweaking is required for some platforms. +\section{Converting old files}\label{convertingoldfiles} + +Dialog Editor can make an attempt at converting dialog resources created with Dialog Editor for wxWindows 1.68. +The command is {\bf Convert Old Resources...} on the {\bf File} menu. + +You need to specify two directories, an input and an output directory. Dialog Editor will +do the following conversions: + +\begin{enumerate}\itemsep=0pt +\item wxMultiText becomes a wxTextCtrl with wxTE\_MULTILINE style. +\item wxText becomes a wxTextCtrl. +\item wxMessage becomes either a wxStaticText or wxStaticBitmap. +\item wxButton becomes a wxBitmapButton if necessary. +\item wxGroupBox becomes wxStaticBox. +\item Controls that no longer have labels, such as wxTextCtrl and wxListBox, +have a separate wxStaticText control created for them at approximately the correct +position. The label's window name becomes ControlName_Label where ControlName is +the name of the control that formerly had the label. +\item Identifiers are allocated. +\item Font sizes are reduced to counter the decreased font size now created by wxWindows +for a given point size. +\item The dialog height is reduced slightly to compensate for the fact that the dialog caption +is no longer included in the size. +\end{enumerate} + diff --git a/utils/dialoged/docs/changes.tex b/utils/dialoged/docs/changes.tex index fbe44245ff..b091a6f5a1 100644 --- a/utils/dialoged/docs/changes.tex +++ b/utils/dialoged/docs/changes.tex @@ -2,6 +2,15 @@ \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}% \setfooter{\thepage}{}{}{}{}{\thepage}% +April 22nd, 2000 Version 2.1 + +\begin{itemize}\itemsep=0pt +\item Various bug fixes. +\item Added buttons for distributing space horizontally and vertically, and +for copying width and height independently. +\item Added 'Convert old resources' facility. +\end{itemize} + December 31st 1998, Version 2.0 \begin{itemize}\itemsep=0pt diff --git a/utils/dialoged/docs/copyhght.bmp b/utils/dialoged/docs/copyhght.bmp new file mode 100644 index 0000000000..9ee3fd1807 Binary files /dev/null and b/utils/dialoged/docs/copyhght.bmp differ diff --git a/utils/dialoged/docs/copyhght.gif b/utils/dialoged/docs/copyhght.gif new file mode 100644 index 0000000000..965cd2b428 Binary files /dev/null and b/utils/dialoged/docs/copyhght.gif differ diff --git a/utils/dialoged/docs/copywdth.bmp b/utils/dialoged/docs/copywdth.bmp new file mode 100644 index 0000000000..0366fb655c Binary files /dev/null and b/utils/dialoged/docs/copywdth.bmp differ diff --git a/utils/dialoged/docs/copywdth.gif b/utils/dialoged/docs/copywdth.gif new file mode 100644 index 0000000000..76642631be Binary files /dev/null and b/utils/dialoged/docs/copywdth.gif differ diff --git a/utils/dialoged/docs/dialoged.tex b/utils/dialoged/docs/dialoged.tex index 441b3d238c..6107540e8f 100644 --- a/utils/dialoged/docs/dialoged.tex +++ b/utils/dialoged/docs/dialoged.tex @@ -4,9 +4,9 @@ %\special{!/@scaleunit 1 def} \parskip=10pt \parindent=0pt -\title{User Manual for Dialog Editor Version 2.0} +\title{User Manual for Dialog Editor Version 2.1} \winhelpignore{\author{Julian Smart, Anthemion Software} -\date{December 1998} +\date{April 2000} } \makeindex \begin{document} @@ -23,7 +23,7 @@ \setfooter{\thepage}{}{}{}{}{\thepage}% \begin{center} -Copyright (c) 1998 Julian Smart, Anthemion Software +Copyright (c) 2000 Julian Smart, Anthemion Software \end{center} Please see the wxWindows licence for conditions of use. diff --git a/utils/dialoged/docs/disthor.bmp b/utils/dialoged/docs/disthor.bmp new file mode 100644 index 0000000000..dcd3c8fde8 Binary files /dev/null and b/utils/dialoged/docs/disthor.bmp differ diff --git a/utils/dialoged/docs/disthor.gif b/utils/dialoged/docs/disthor.gif new file mode 100644 index 0000000000..70fbbf96b2 Binary files /dev/null and b/utils/dialoged/docs/disthor.gif differ diff --git a/utils/dialoged/docs/distvert.bmp b/utils/dialoged/docs/distvert.bmp new file mode 100644 index 0000000000..9f50a39dd2 Binary files /dev/null and b/utils/dialoged/docs/distvert.bmp differ diff --git a/utils/dialoged/docs/distvert.gif b/utils/dialoged/docs/distvert.gif new file mode 100644 index 0000000000..81cdd9486f Binary files /dev/null and b/utils/dialoged/docs/distvert.gif differ diff --git a/utils/dialoged/src/bitmaps/copyhght.bmp b/utils/dialoged/src/bitmaps/copyhght.bmp new file mode 100644 index 0000000000..9ee3fd1807 Binary files /dev/null and b/utils/dialoged/src/bitmaps/copyhght.bmp differ diff --git a/utils/dialoged/src/bitmaps/copyhght.xpm b/utils/dialoged/src/bitmaps/copyhght.xpm new file mode 100644 index 0000000000..c91cb9dadd --- /dev/null +++ b/utils/dialoged/src/bitmaps/copyhght.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * copyhght_xpm[] = { +"16 15 3 1", +" c #c0c0c0", +". c Black", +"X c Yellow", +" . ", +" ............. ", +" ", +" ...... ...... ", +" .XXXX. .XXXX. ", +" .XXXX. .XXXX. ", +" .XXXX. .XXXX. ", +" .XXXX. .XXXX. ", +" .XXXX. .XXXX. ", +" .XXXX. .XXXX. ", +" .XXXX. .XXXX. ", +" ...... ...... ", +" ", +" ............. ", +" . "}; diff --git a/utils/dialoged/src/bitmaps/copywdth.bmp b/utils/dialoged/src/bitmaps/copywdth.bmp new file mode 100644 index 0000000000..0366fb655c Binary files /dev/null and b/utils/dialoged/src/bitmaps/copywdth.bmp differ diff --git a/utils/dialoged/src/bitmaps/copywdth.xpm b/utils/dialoged/src/bitmaps/copywdth.xpm new file mode 100644 index 0000000000..9e0c0aa73f --- /dev/null +++ b/utils/dialoged/src/bitmaps/copywdth.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * copywdth_xpm[] = { +"16 15 3 1", +" c #c0c0c0", +". c Black", +"X c Yellow", +" ", +" . ........ . ", +" . .XXXXXX. . ", +" . .XXXXXX. . ", +" . .XXXXXX. . ", +" . .XXXXXX. . ", +" . ........ . ", +" .. .. ", +" . ........ . ", +" . .XXXXXX. . ", +" . .XXXXXX. . ", +" . .XXXXXX. . ", +" . .XXXXXX. . ", +" . ........ . ", +" "}; diff --git a/utils/dialoged/src/bitmaps/disthor.bmp b/utils/dialoged/src/bitmaps/disthor.bmp new file mode 100644 index 0000000000..dcd3c8fde8 Binary files /dev/null and b/utils/dialoged/src/bitmaps/disthor.bmp differ diff --git a/utils/dialoged/src/bitmaps/disthor.xpm b/utils/dialoged/src/bitmaps/disthor.xpm new file mode 100644 index 0000000000..befa8fd0dd --- /dev/null +++ b/utils/dialoged/src/bitmaps/disthor.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * disthor_xpm[] = { +"16 15 3 1", +" c #c0c0c0", +". c Black", +"X c Yellow", +" ", +" ... ... ... ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" .X. .X. .X. ", +" ... ... ... ", +" "}; diff --git a/utils/dialoged/src/bitmaps/distvert.bmp b/utils/dialoged/src/bitmaps/distvert.bmp new file mode 100644 index 0000000000..9f50a39dd2 Binary files /dev/null and b/utils/dialoged/src/bitmaps/distvert.bmp differ diff --git a/utils/dialoged/src/bitmaps/distvert.xpm b/utils/dialoged/src/bitmaps/distvert.xpm new file mode 100644 index 0000000000..d6c39e40d7 --- /dev/null +++ b/utils/dialoged/src/bitmaps/distvert.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * distvert_xpm[] = { +"16 15 3 1", +" c #c0c0c0", +". c Black", +"X c Yellow", +" ", +" .............. ", +" .XXXXXXXXXXXX. ", +" .............. ", +" ", +" ", +" .............. ", +" .XXXXXXXXXXXX. ", +" .............. ", +" ", +" ", +" .............. ", +" .XXXXXXXXXXXX. ", +" .............. ", +" "}; diff --git a/utils/dialoged/src/dialoged.cpp b/utils/dialoged/src/dialoged.cpp index 776852971d..d59b19d8f1 100644 --- a/utils/dialoged/src/dialoged.cpp +++ b/utils/dialoged/src/dialoged.cpp @@ -28,8 +28,8 @@ IMPLEMENT_APP(MyApp) BEGIN_EVENT_TABLE(MyApp, wxApp) - EVT_MENU(OBJECT_MENU_EDIT, MyApp::OnObjectPopupMenu) - EVT_MENU(OBJECT_MENU_DELETE, MyApp::OnObjectPopupMenu) +EVT_MENU(OBJECT_MENU_EDIT, MyApp::OnObjectPopupMenu) +EVT_MENU(OBJECT_MENU_DELETE, MyApp::OnObjectPopupMenu) END_EVENT_TABLE() MyApp::MyApp(void) @@ -44,14 +44,14 @@ bool MyApp::OnInit(void) { theResourceManager = new wxResourceManager; theResourceManager->Initialize(); - + theResourceManager->ShowResourceEditor(TRUE); - + if (argc > 1) theResourceManager->Load(argv[1]); - + SetTopWindow(theResourceManager->GetEditorFrame()); - + return TRUE; } diff --git a/utils/dialoged/src/dialoged.h b/utils/dialoged/src/dialoged.h index 72abac89c1..458733bc17 100644 --- a/utils/dialoged/src/dialoged.h +++ b/utils/dialoged/src/dialoged.h @@ -26,16 +26,16 @@ class MyChild; // Define a new application class MyApp: public wxApp { - public: +public: MyApp(void); bool OnInit(void); int OnExit(void); - + void OnObjectPopupMenu(wxCommandEvent& event) { ObjectMenuProc((wxMenu *)event.GetEventObject(), event); } - + private: DECLARE_EVENT_TABLE() }; diff --git a/utils/dialoged/src/dialoged.rc b/utils/dialoged/src/dialoged.rc index e931061123..693b33821c 100644 --- a/utils/dialoged/src/dialoged.rc +++ b/utils/dialoged/src/dialoged.rc @@ -57,6 +57,10 @@ HELPTOOL BITMAP "bitmaps/help.bmp" COPYSIZETOOL BITMAP "bitmaps/copysize.bmp" TOFRONTTOOL BITMAP "bitmaps/tofront.bmp" TOBACKTOOL BITMAP "bitmaps/toback.bmp" +COPYWIDTHTOOL BITMAP "bitmaps/copywdth.bmp" +COPYHEIGHTTOOL BITMAP "bitmaps/copyhght.bmp" +DISTHORIZTOOL BITMAP "bitmaps/disthor.bmp" +DISTVERTTOOL BITMAP "bitmaps/distvert.bmp" WXWINBMP BITMAP "bitmaps/wxwin.bmp" diff --git a/utils/dialoged/src/dlghndlr.cpp b/utils/dialoged/src/dlghndlr.cpp index f669cddbf0..e6760ed49e 100644 --- a/utils/dialoged/src/dlghndlr.cpp +++ b/utils/dialoged/src/dlghndlr.cpp @@ -38,38 +38,38 @@ IMPLEMENT_CLASS(wxResourceEditorDialogHandler, wxEvtHandler) IMPLEMENT_CLASS(wxResourceEditorControlHandler, wxEvtHandler) BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler, wxEvtHandler) - EVT_PAINT(wxResourceEditorDialogHandler::OnPaint) - EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent) - EVT_SIZE(wxResourceEditorDialogHandler::OnSize) +EVT_PAINT(wxResourceEditorDialogHandler::OnPaint) +EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent) +EVT_SIZE(wxResourceEditorDialogHandler::OnSize) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxResourceEditorControlHandler, wxEvtHandler) - EVT_MOUSE_EVENTS(wxResourceEditorControlHandler::OnMouseEvent) +EVT_MOUSE_EVENTS(wxResourceEditorControlHandler::OnMouseEvent) END_EVENT_TABLE() /* - * Dialog box event handler - */ +* Dialog box event handler +*/ wxResourceEditorDialogHandler::wxResourceEditorDialogHandler(wxPanel *dialog, wxItemResource *resource, - wxEvtHandler *oldHandler, wxResourceManager *manager) + wxEvtHandler *oldHandler, wxResourceManager *manager) { - handlerDialog = dialog; - handlerResource = resource; - handlerOldHandler = oldHandler; - resourceManager = manager; - - dragMode = wxDRAG_MODE_NONE; - dragType = wxDRAG_TYPE_NONE; - dragItem = NULL; - firstDragX = 0; - firstDragY = 0; - oldDragX = 0; - oldDragY = 0; - dragTolerance = 3; - checkTolerance = TRUE; - m_mouseCaptured = FALSE; -// m_treeItem = 0; + handlerDialog = dialog; + handlerResource = resource; + handlerOldHandler = oldHandler; + resourceManager = manager; + + dragMode = wxDRAG_MODE_NONE; + dragType = wxDRAG_TYPE_NONE; + dragItem = NULL; + firstDragX = 0; + firstDragY = 0; + oldDragX = 0; + oldDragY = 0; + dragTolerance = 3; + checkTolerance = TRUE; + m_mouseCaptured = FALSE; + // m_treeItem = 0; } wxResourceEditorDialogHandler::~wxResourceEditorDialogHandler(void) @@ -78,227 +78,227 @@ wxResourceEditorDialogHandler::~wxResourceEditorDialogHandler(void) void wxResourceEditorDialogHandler::OnItemSelect(wxControl *item, bool select) { - if (select) - resourceManager->AddSelection(item); - else - resourceManager->RemoveSelection(item); + if (select) + resourceManager->AddSelection(item); + else + resourceManager->RemoveSelection(item); } void wxResourceEditorDialogHandler::OnPaint(wxPaintEvent& WXUNUSED(event)) { - wxPaintDC dc(handlerDialog); - - PaintSelectionHandles(dc); + wxPaintDC dc(handlerDialog); + + PaintSelectionHandles(dc); } // Add event handlers for all children void wxResourceEditorDialogHandler::AddChildHandlers(void) { - wxNode *node = handlerDialog->GetChildren().First(); - while ( node ) - { - wxControl *child = (wxControl *)node->Data(); - wxEvtHandler *childHandler = child->GetEventHandler(); - if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler == child ) - child->PushEventHandler(new wxResourceEditorControlHandler(child, childHandler)); - node = node->Next(); - } + wxNode *node = handlerDialog->GetChildren().First(); + while ( node ) + { + wxControl *child = (wxControl *)node->Data(); + wxEvtHandler *childHandler = child->GetEventHandler(); + if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler == child ) + child->PushEventHandler(new wxResourceEditorControlHandler(child, childHandler)); + node = node->Next(); + } } void wxResourceEditorDialogHandler::OnLeftClick(int x, int y, int keys) { - if (keys & wxKEY_CTRL) - { - wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog); - return; - } - - // Deselect all items if click on panel - if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER) - { - int needsRefresh = 0; - wxNode *node = handlerDialog->GetChildren().First(); - while (node) + if (keys & wxKEY_CTRL) { - wxControl *item = (wxControl *)node->Data(); - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected()) - { - needsRefresh ++; - OnItemSelect(item, FALSE); - childHandler->SelectItem(FALSE); - } - node = node->Next(); + wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog); + return; } - if (needsRefresh > 0) + + // Deselect all items if click on panel + if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER) { - wxClientDC dc(handlerDialog); - dc.Clear(); - handlerDialog->Refresh(); + int needsRefresh = 0; + wxNode *node = handlerDialog->GetChildren().First(); + while (node) + { + wxControl *item = (wxControl *)node->Data(); + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected()) + { + needsRefresh ++; + OnItemSelect(item, FALSE); + childHandler->SelectItem(FALSE); + } + node = node->Next(); + } + if (needsRefresh > 0) + { + wxClientDC dc(handlerDialog); + dc.Clear(); + handlerDialog->Refresh(); + } + return; } - return; - } - - // Round down to take account of dialog units - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog); - if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { + + // Round down to take account of dialog units + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { wxPoint pt = handlerDialog->ConvertPixelsToDialog(wxPoint(x, y)); - + // Convert back so we've rounded down pt = handlerDialog->ConvertDialogToPixels(pt); pt = handlerDialog->ConvertPixelsToDialog(pt); pt = handlerDialog->ConvertDialogToPixels(pt); x = pt.x; y = pt.y; - } - - switch (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection()) - { - case RESED_BUTTON: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y); - break; - case RESED_BMPBUTTON: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxBitmapButton", x, y, TRUE); - break; - case RESED_STATICTEXT: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticText", x, y); - break; - case RESED_STATICBMP: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBitmap", x, y, TRUE); - break; - case RESED_TEXTCTRL_SINGLE: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (single-line)", x, y); - break; - case RESED_TEXTCTRL_MULTIPLE: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (multi-line)", x, y); - break; - case RESED_CHOICE: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y); - break; - case RESED_COMBOBOX: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxComboBox", x, y); - break; - case RESED_CHECKBOX: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y); - break; - case RESED_RADIOBOX: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioBox", x, y); - break; - case RESED_RADIOBUTTON: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioButton", x, y); - break; - case RESED_LISTBOX: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxListBox", x, y); - break; - case RESED_SLIDER: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxSlider", x, y); - break; - case RESED_GAUGE: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxGauge", x, y); - break; - case RESED_STATICBOX: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBox", x, y); - break; - case RESED_SCROLLBAR: - resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxScrollBar", x, y); - break; - default: - break; - } - - // Now switch pointer on. - if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() != RESED_POINTER) - { - wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->SetItemState(RESED_POINTER, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); - } + } + + switch (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection()) + { + case RESED_BUTTON: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y); + break; + case RESED_BMPBUTTON: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxBitmapButton", x, y, TRUE); + break; + case RESED_STATICTEXT: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticText", x, y); + break; + case RESED_STATICBMP: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBitmap", x, y, TRUE); + break; + case RESED_TEXTCTRL_SINGLE: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (single-line)", x, y); + break; + case RESED_TEXTCTRL_MULTIPLE: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (multi-line)", x, y); + break; + case RESED_CHOICE: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y); + break; + case RESED_COMBOBOX: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxComboBox", x, y); + break; + case RESED_CHECKBOX: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y); + break; + case RESED_RADIOBOX: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioBox", x, y); + break; + case RESED_RADIOBUTTON: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioButton", x, y); + break; + case RESED_LISTBOX: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxListBox", x, y); + break; + case RESED_SLIDER: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxSlider", x, y); + break; + case RESED_GAUGE: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxGauge", x, y); + break; + case RESED_STATICBOX: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBox", x, y); + break; + case RESED_SCROLLBAR: + resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxScrollBar", x, y); + break; + default: + break; + } + + // Now switch pointer on. + if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() != RESED_POINTER) + { + wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->SetItemState(RESED_POINTER, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + } } void wxResourceEditorDialogHandler::OnRightClick(int x, int y, int WXUNUSED(keys)) { - wxMenu *menu = resourceManager->GetPopupMenu(); - menu->SetClientData((char *)handlerDialog); - handlerDialog->PopupMenu(menu, x, y); + wxMenu *menu = resourceManager->GetPopupMenu(); + menu->SetClientData((char *)handlerDialog); + handlerDialog->PopupMenu(menu, x, y); } void wxResourceEditorDialogHandler::OnItemLeftClick(wxControl *item, int WXUNUSED(x), int WXUNUSED(y), int keys) { - if (keys & wxKEY_CTRL) - { - wxResourceManager::GetCurrentResourceManager()->EditWindow(item); - return; - } - -/* - // If this is a wxStaticBox and the pointer isn't an arrow, chances - // are that we really meant to place an item on the panel. - // Fake this event. - if ((item->GetClassInfo() == CLASSINFO(wxStaticBox)) && resourceManager->GetEditorPalette()->currentlySelected != PALETTE_ARROW) - { + if (keys & wxKEY_CTRL) + { + wxResourceManager::GetCurrentResourceManager()->EditWindow(item); + return; + } + + /* + // If this is a wxStaticBox and the pointer isn't an arrow, chances + // are that we really meant to place an item on the panel. + // Fake this event. + if ((item->GetClassInfo() == CLASSINFO(wxStaticBox)) && resourceManager->GetEditorPalette()->currentlySelected != PALETTE_ARROW) + { OnLeftClick(x, y, keys); return; - } -*/ - - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - - if (childHandler->IsSelected()) - { - childHandler->SelectItem(FALSE); - OnItemSelect(item, FALSE); - - wxClientDC dc(handlerDialog); - dc.Clear(); - handlerDialog->Refresh(); - } - else - { - childHandler->SelectItem(TRUE); - OnItemSelect(item, TRUE); + } + */ - // Deselect other items if shift is not pressed - int needsRefresh = 0; - if (!(keys & wxKEY_SHIFT)) + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + + if (childHandler->IsSelected()) { - wxNode *node = item->GetParent()->GetChildren().First(); - while (node) - { - wxControl *child = (wxControl *)node->Data(); - wxResourceEditorControlHandler *childHandler2 = (wxResourceEditorControlHandler *)child->GetEventHandler(); - if (child->IsKindOf(CLASSINFO(wxControl)) && childHandler2->IsSelected() && child != item) + childHandler->SelectItem(FALSE); + OnItemSelect(item, FALSE); + + wxClientDC dc(handlerDialog); + dc.Clear(); + handlerDialog->Refresh(); + } + else + { + childHandler->SelectItem(TRUE); + OnItemSelect(item, TRUE); + + // Deselect other items if shift is not pressed + int needsRefresh = 0; + if (!(keys & wxKEY_SHIFT)) { - childHandler2->SelectItem(FALSE); - OnItemSelect(child, FALSE); - needsRefresh ++; + wxNode *node = item->GetParent()->GetChildren().First(); + while (node) + { + wxControl *child = (wxControl *)node->Data(); + wxResourceEditorControlHandler *childHandler2 = (wxResourceEditorControlHandler *)child->GetEventHandler(); + if (child->IsKindOf(CLASSINFO(wxControl)) && childHandler2->IsSelected() && child != item) + { + childHandler2->SelectItem(FALSE); + OnItemSelect(child, FALSE); + needsRefresh ++; + } + node = node->Next(); + } + } + + wxClientDC dc(handlerDialog); + childHandler->DrawSelectionHandles(dc); + + if (needsRefresh > 0) + { + dc.Clear(); + handlerDialog->Refresh(); } - node = node->Next(); - } } - - wxClientDC dc(handlerDialog); - childHandler->DrawSelectionHandles(dc); - - if (needsRefresh > 0) - { - dc.Clear(); - handlerDialog->Refresh(); - } - } } void wxResourceEditorDialogHandler::OnItemRightClick(wxControl *item, int x, int y, int WXUNUSED(keys)) { /* - if (keys & wxKEY_CTRL) - { - wxDebugMsg("Item %s, selected = %d\n", item->GetName(), item->IsSelected()); - return; - } -*/ - - wxMenu *menu = resourceManager->GetPopupMenu(); - menu->SetClientData((char *)item); - handlerDialog->PopupMenu(menu, x, y); +if (keys & wxKEY_CTRL) +{ +wxDebugMsg("Item %s, selected = %d\n", item->GetName(), item->IsSelected()); +return; +} + */ + + wxMenu *menu = resourceManager->GetPopupMenu(); + menu->SetClientData((char *)item); + handlerDialog->PopupMenu(menu, x, y); } // Under Windows 95, you can resize a panel interactively depending on @@ -308,7 +308,7 @@ void wxResourceEditorDialogHandler::OnSize(wxSizeEvent& event) // Update the associated resource int w, h; handlerDialog->GetClientSize(& w, & h); - + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog); if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { @@ -321,328 +321,328 @@ void wxResourceEditorDialogHandler::OnSize(wxSizeEvent& event) // An event outside any items: may be a drag event. void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event) { - if (GetEvtHandlerEnabled()) - { - // If we're dragging an item or selection handle, - // continue dragging. - if (dragMode != wxDRAG_MODE_NONE) + if (GetEvtHandlerEnabled()) { - ProcessItemEvent(dragItem, event, dragType); - return; - } - - wxCoord x, y; - event.GetPosition(&x, &y); - - // Find which selection handle we're on, if any - wxNode *node = handlerDialog->GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (win->IsKindOf(CLASSINFO(wxControl))) - { - wxControl *item = (wxControl *)win; - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - int selHandle = childHandler->SelectionHandleHitTest(x, y); - if (selHandle > 0) + // If we're dragging an item or selection handle, + // continue dragging. + if (dragMode != wxDRAG_MODE_NONE) { - ProcessItemEvent(item, event, selHandle); - return; + ProcessItemEvent(dragItem, event, dragType); + return; } - } - node = node->Next(); - } - - // We're not on an item or selection handle. - // so... check for a left or right click event - // to send to the application. - int keys = 0; - if (event.ShiftDown()) keys = keys | wxKEY_SHIFT; - if (event.ControlDown()) keys = keys | wxKEY_CTRL; - - if (event.LeftUp()) - { - if (m_mouseCaptured) + + wxCoord x, y; + event.GetPosition(&x, &y); + + // Find which selection handle we're on, if any + wxNode *node = handlerDialog->GetChildren().First(); + while (node) { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; + wxWindow *win = (wxWindow *)node->Data(); + if (win->IsKindOf(CLASSINFO(wxControl))) + { + wxControl *item = (wxControl *)win; + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + int selHandle = childHandler->SelectionHandleHitTest(x, y); + if (selHandle > 0) + { + ProcessItemEvent(item, event, selHandle); + return; + } + } + node = node->Next(); } - - OnLeftClick(x, y, keys); - } - else if (event.RightDown()) - { - if (m_mouseCaptured) + + // We're not on an item or selection handle. + // so... check for a left or right click event + // to send to the application. + int keys = 0; + if (event.ShiftDown()) keys = keys | wxKEY_SHIFT; + if (event.ControlDown()) keys = keys | wxKEY_CTRL; + + if (event.LeftUp()) { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + + OnLeftClick(x, y, keys); } - - OnRightClick(x, y, keys); - } - else if (event.LeftDClick()) - { - if (m_mouseCaptured) + else if (event.RightDown()) { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + + OnRightClick(x, y, keys); + } + else if (event.LeftDClick()) + { + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog); } - wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog); } - } - else - event.Skip(); + else + event.Skip(); } void wxResourceEditorDialogHandler::OnItemEvent(wxControl *item, wxMouseEvent& event) { - if (!GetEvtHandlerEnabled()) - return; - - // Not a selection handle event: just a normal item event. - // Transform to panel coordinates. - wxCoord x, y; - item->GetPosition(&x, &y); - - event.m_x = event.m_x + x; - event.m_y = event.m_y + y; - - ProcessItemEvent(item, event, dragType); + if (!GetEvtHandlerEnabled()) + return; + + // Not a selection handle event: just a normal item event. + // Transform to panel coordinates. + wxCoord x, y; + item->GetPosition(&x, &y); + + event.m_x = event.m_x + x; + event.m_y = event.m_y + y; + + ProcessItemEvent(item, event, dragType); } void wxResourceEditorDialogHandler::ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle) { - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - - wxCoord x, y; - event.GetPosition(&x, &y); - int keys = 0; - if (event.ShiftDown()) keys = keys | wxKEY_SHIFT; - if (event.ControlDown()) keys = keys | wxKEY_CTRL; - bool dragging = event.Dragging(); - if (dragging) - { - int dx = (int)abs((x - firstDragX)); - int dy = (int)abs((y - firstDragY)); - if (checkTolerance && (dx <= dragTolerance) && (dy <= dragTolerance)) + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + + wxCoord x, y; + event.GetPosition(&x, &y); + int keys = 0; + if (event.ShiftDown()) keys = keys | wxKEY_SHIFT; + if (event.ControlDown()) keys = keys | wxKEY_CTRL; + bool dragging = event.Dragging(); + if (dragging) { - return; + int dx = (int)abs((x - firstDragX)); + int dy = (int)abs((y - firstDragY)); + if (checkTolerance && (dx <= dragTolerance) && (dy <= dragTolerance)) + { + return; + } + else + // If we've ignored the tolerance once, then ALWAYS ignore + // tolerance in this drag, even if we come back within + // the tolerance range. + { + checkTolerance = FALSE; + } } - else - // If we've ignored the tolerance once, then ALWAYS ignore - // tolerance in this drag, even if we come back within - // the tolerance range. - { - checkTolerance = FALSE; - } - } - if (event.LeftDClick()) - { - if (m_mouseCaptured) - { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; - } - - wxResourceManager::GetCurrentResourceManager()->EditWindow(item); - } - else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_LEFT) - { - dragMode = wxDRAG_MODE_CONTINUE_LEFT; - wxClientDC dc(handlerDialog); - childHandler->OnDragBegin(x, y, keys, dc, selectionHandle); - oldDragX = x; oldDragY = y; - if (!m_mouseCaptured) + if (event.LeftDClick()) { - handlerDialog->CaptureMouse(); - m_mouseCaptured = TRUE; + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + + wxResourceManager::GetCurrentResourceManager()->EditWindow(item); } - } - else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT) - { - wxClientDC dc(handlerDialog); - childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle); - childHandler->OnDragContinue(TRUE, x, y, keys, dc, selectionHandle); - oldDragX = x; oldDragY = y; - } - else if (event.LeftUp() && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT) - { - wxClientDC dc(handlerDialog); - dragMode = wxDRAG_MODE_NONE; - checkTolerance = TRUE; - - childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle); - childHandler->OnDragEnd(x, y, keys, dc, selectionHandle); - - dragItem = NULL; - dragType = wxDRAG_TYPE_NONE; - - if (m_mouseCaptured) + else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_LEFT) { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; + dragMode = wxDRAG_MODE_CONTINUE_LEFT; + wxClientDC dc(handlerDialog); + childHandler->OnDragBegin(x, y, keys, dc, selectionHandle); + oldDragX = x; oldDragY = y; + if (!m_mouseCaptured) + { + handlerDialog->CaptureMouse(); + m_mouseCaptured = TRUE; + } } - } - else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_RIGHT) - { - wxClientDC dc(handlerDialog); - dragMode = wxDRAG_MODE_CONTINUE_RIGHT; - childHandler->OnDragBegin(x, y, keys, dc, selectionHandle); - oldDragX = x; oldDragY = y; - - if (!m_mouseCaptured) - { - handlerDialog->CaptureMouse(); - m_mouseCaptured = TRUE; + else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT) + { + wxClientDC dc(handlerDialog); + childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle); + childHandler->OnDragContinue(TRUE, x, y, keys, dc, selectionHandle); + oldDragX = x; oldDragY = y; } - } - else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT) - { - oldDragX = x; oldDragY = y; - } - // Obsolete; no longer try to right-drag - else if (event.RightUp() && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT) - { - dragMode = wxDRAG_MODE_NONE; - checkTolerance = TRUE; - dragItem = NULL; - dragType = wxDRAG_TYPE_NONE; - - if (m_mouseCaptured) + else if (event.LeftUp() && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT) { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; + wxClientDC dc(handlerDialog); + dragMode = wxDRAG_MODE_NONE; + checkTolerance = TRUE; + + childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle); + childHandler->OnDragEnd(x, y, keys, dc, selectionHandle); + + dragItem = NULL; + dragType = wxDRAG_TYPE_NONE; + + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } } - } - else if (event.IsButton()) - { - checkTolerance = TRUE; - - if (event.LeftDown()) + else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_RIGHT) { - dragItem = item; - dragMode = wxDRAG_MODE_START_LEFT; - firstDragX = x; - firstDragY = y; - dragType = selectionHandle; - - if (!m_mouseCaptured) - { - handlerDialog->CaptureMouse(); - m_mouseCaptured = TRUE; - } + wxClientDC dc(handlerDialog); + dragMode = wxDRAG_MODE_CONTINUE_RIGHT; + childHandler->OnDragBegin(x, y, keys, dc, selectionHandle); + oldDragX = x; oldDragY = y; + + if (!m_mouseCaptured) + { + handlerDialog->CaptureMouse(); + m_mouseCaptured = TRUE; + } } - else if (event.RightDown()) + else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT) + { + oldDragX = x; oldDragY = y; + } + // Obsolete; no longer try to right-drag + else if (event.RightUp() && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT) { - if (m_mouseCaptured) - { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; - } - - if (item) + dragMode = wxDRAG_MODE_NONE; + checkTolerance = TRUE; + dragItem = NULL; + dragType = wxDRAG_TYPE_NONE; + + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + } + else if (event.IsButton()) + { + checkTolerance = TRUE; + + if (event.LeftDown()) + { + dragItem = item; + dragMode = wxDRAG_MODE_START_LEFT; + firstDragX = x; + firstDragY = y; + dragType = selectionHandle; + + if (!m_mouseCaptured) + { + handlerDialog->CaptureMouse(); + m_mouseCaptured = TRUE; + } + } + else if (event.RightDown()) + { + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + + if (item) + childHandler->OnRightClick(x, y, keys); + else + OnRightClick(x, y, keys); + + dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE; + + /* + dragItem = item; + dragMode = wxDRAG_MODE_START_RIGHT; + firstDragX = x; + firstDragY = y; + dragType = selectionHandle; + + if (!m_mouseCaptured) + { + handlerDialog->CaptureMouse(); + m_mouseCaptured = TRUE; + } + */ + } + else if (event.LeftUp()) + { + if (dragItem) + childHandler->OnLeftClick(x, y, keys); + else + OnLeftClick(x, y, keys); + + dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE; + + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + } + else if (event.RightUp()) + { + /* + if (dragItem) childHandler->OnRightClick(x, y, keys); - else + else OnRightClick(x, y, keys); - - dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE; - - /* - dragItem = item; - dragMode = wxDRAG_MODE_START_RIGHT; - firstDragX = x; - firstDragY = y; - dragType = selectionHandle; - - if (!m_mouseCaptured) - { - handlerDialog->CaptureMouse(); - m_mouseCaptured = TRUE; - } - */ + + dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE; + + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + */ + } } - else if (event.LeftUp()) - { - if (dragItem) - childHandler->OnLeftClick(x, y, keys); - else - OnLeftClick(x, y, keys); - - dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE; - - if (m_mouseCaptured) - { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; - } - } - else if (event.RightUp()) - { - /* - if (dragItem) - childHandler->OnRightClick(x, y, keys); - else - OnRightClick(x, y, keys); - - dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE; - - if (m_mouseCaptured) - { - handlerDialog->ReleaseMouse(); - m_mouseCaptured = FALSE; - } - */ - } - } } // Calls DrawSelectionHandles for all items if // edit mode is on. void wxResourceEditorDialogHandler::PaintSelectionHandles(wxDC& dc) { - if (!GetEvtHandlerEnabled()) - return; - - dc.BeginDrawing(); - - wxNode *node = handlerDialog->GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (win->IsKindOf(CLASSINFO(wxControl))) + if (!GetEvtHandlerEnabled()) + return; + + dc.BeginDrawing(); + + wxNode *node = handlerDialog->GetChildren().First(); + while (node) { - wxControl *item = (wxControl *)win; - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - - // Don't draw handles for an item that's being moved: it'll - // smear. - if (childHandler->IsSelected() && (item != dragItem)) - childHandler->DrawSelectionHandles(dc); + wxWindow *win = (wxWindow *)node->Data(); + if (win->IsKindOf(CLASSINFO(wxControl))) + { + wxControl *item = (wxControl *)win; + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + + // Don't draw handles for an item that's being moved: it'll + // smear. + if (childHandler->IsSelected() && (item != dragItem)) + childHandler->DrawSelectionHandles(dc); + } + node = node->Next(); } - node = node->Next(); - } - dc.EndDrawing(); + dc.EndDrawing(); } /* - * Event handler for controls - */ +* Event handler for controls +*/ int wxResourceEditorControlHandler::dragOffsetX = 0; int wxResourceEditorControlHandler::dragOffsetY = 0; wxResourceEditorControlHandler::wxResourceEditorControlHandler(wxControl *control, - wxEvtHandler *oldHandler) + wxEvtHandler *oldHandler) { - handlerControl = control; - handlerOldHandler = oldHandler; - - handleSize = 6; - handleMargin = 1; - isSelected = FALSE; - dragOffsetX = 0; - dragOffsetY = 0; -// m_treeItem = 0; + handlerControl = control; + handlerOldHandler = oldHandler; + + handleSize = 6; + handleMargin = 1; + isSelected = FALSE; + dragOffsetX = 0; + dragOffsetY = 0; + // m_treeItem = 0; } wxResourceEditorControlHandler::~wxResourceEditorControlHandler(void) @@ -650,484 +650,484 @@ wxResourceEditorControlHandler::~wxResourceEditorControlHandler(void) } /* - * Manipulation and drawing of items in Edit Mode - */ - +* Manipulation and drawing of items in Edit Mode +*/ + void wxResourceEditorControlHandler::SelectItem(bool select) { - isSelected = select; + isSelected = select; } // Returns TRUE or FALSE bool wxResourceEditorControlHandler::HitTest(int x, int y) { - int xpos, ypos, width, height; - handlerControl->GetPosition(&xpos, &ypos); - handlerControl->GetSize(&width, &height); - - return ((x >= xpos) && (x <= (xpos + width)) && (y >= ypos) && (y <= (ypos + height))); + int xpos, ypos, width, height; + handlerControl->GetPosition(&xpos, &ypos); + handlerControl->GetSize(&width, &height); + + return ((x >= xpos) && (x <= (xpos + width)) && (y >= ypos) && (y <= (ypos + height))); } // Calculate position of the 8 handles void wxResourceEditorControlHandler::CalcSelectionHandles(int *hx, int *hy) { - int xpos, ypos, width, height; - handlerControl->GetPosition(&xpos, &ypos); - handlerControl->GetSize(&width, &height); - int middleX = (xpos + (width/2)); - int middleY = (ypos + (height/2)); - - // Start from top middle, clockwise. -/* - 7 0 1 - - 6 2 - - 5 4 3 -*/ - - hx[0] = (int)(middleX - (handleSize/2)); - hy[0] = ypos - handleSize - handleMargin; - - hx[1] = xpos + width + handleMargin; - hy[1] = ypos - handleSize - handleMargin; - - hx[2] = xpos + width + handleMargin; - hy[2] = (int)(middleY - (handleSize/2)); - - hx[3] = xpos + width + handleMargin; - hy[3] = ypos + height + handleMargin; - - hx[4] = (int)(middleX - (handleSize/2)); - hy[4] = ypos + height + handleMargin; - - hx[5] = xpos - handleSize - handleMargin; - hy[5] = ypos + height + handleMargin; - - hx[6] = xpos - handleSize - handleMargin; - hy[6] = (int)(middleY - (handleSize/2)); - - hx[7] = xpos - handleSize - handleMargin; - hy[7] = ypos - handleSize - handleMargin; + int xpos, ypos, width, height; + handlerControl->GetPosition(&xpos, &ypos); + handlerControl->GetSize(&width, &height); + int middleX = (xpos + (width/2)); + int middleY = (ypos + (height/2)); + + // Start from top middle, clockwise. + /* + 7 0 1 + + 6 2 + + 5 4 3 + */ + + hx[0] = (int)(middleX - (handleSize/2)); + hy[0] = ypos - handleSize - handleMargin; + + hx[1] = xpos + width + handleMargin; + hy[1] = ypos - handleSize - handleMargin; + + hx[2] = xpos + width + handleMargin; + hy[2] = (int)(middleY - (handleSize/2)); + + hx[3] = xpos + width + handleMargin; + hy[3] = ypos + height + handleMargin; + + hx[4] = (int)(middleX - (handleSize/2)); + hy[4] = ypos + height + handleMargin; + + hx[5] = xpos - handleSize - handleMargin; + hy[5] = ypos + height + handleMargin; + + hx[6] = xpos - handleSize - handleMargin; + hy[6] = (int)(middleY - (handleSize/2)); + + hx[7] = xpos - handleSize - handleMargin; + hy[7] = ypos - handleSize - handleMargin; } // Returns 0 (no hit), 1 - 8 for which selection handle // (clockwise from top middle) int wxResourceEditorControlHandler::SelectionHandleHitTest(int x, int y) { - // Handle positions - int hx[8]; - int hy[8]; - CalcSelectionHandles(hx, hy); - - int i; - for (i = 0; i < 8; i++) - { - if ((x >= hx[i]) && (x <= (hx[i] + handleSize)) && (y >= hy[i]) && (y <= (hy[i] + handleSize))) - return (i + 1); - } - return 0; + // Handle positions + int hx[8]; + int hy[8]; + CalcSelectionHandles(hx, hy); + + int i; + for (i = 0; i < 8; i++) + { + if ((x >= hx[i]) && (x <= (hx[i] + handleSize)) && (y >= hy[i]) && (y <= (hy[i] + handleSize))) + return (i + 1); + } + return 0; } void wxResourceEditorControlHandler::DrawSelectionHandles(wxDC& dc, bool WXUNUSED(erase)) { - dc.SetOptimization(FALSE); - - dc.SetLogicalFunction(wxCOPY); - dc.SetPen(* wxBLACK_PEN); - dc.SetBrush(* wxBLACK_BRUSH); - - dc.SetOptimization(TRUE); - - // Handle positions - int hx[8]; - int hy[8]; - CalcSelectionHandles(hx, hy); - - int i; - for (i = 0; i < 8; i++) - { - dc.DrawRectangle(hx[i], hy[i], handleSize, handleSize); - } + dc.SetOptimization(FALSE); + + dc.SetLogicalFunction(wxCOPY); + dc.SetPen(* wxBLACK_PEN); + dc.SetBrush(* wxBLACK_BRUSH); + + dc.SetOptimization(TRUE); + + // Handle positions + int hx[8]; + int hy[8]; + CalcSelectionHandles(hx, hy); + + int i; + for (i = 0; i < 8; i++) + { + dc.DrawRectangle(hx[i], hy[i], handleSize, handleSize); + } } void wxResourceEditorControlHandler::DrawBoundingBox(wxDC& dc, int x, int y, int w, int h) { - dc.DrawRectangle(x, y, w, h); + dc.DrawRectangle(x, y, w, h); } // If selectionHandle is zero, not dragging the selection handle. void wxResourceEditorControlHandler::OnDragBegin(int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle) { - int xpos, ypos, width, height; - handlerControl->GetPosition(&xpos, &ypos); - handlerControl->GetSize(&width, &height); - - dc.BeginDrawing(); - -// dc.DestroyClippingRegion(); - - wxPanel *panel = (wxPanel *)handlerControl->GetParent(); - - // Erase selection handles -// DrawSelectionHandles(dc, TRUE); - - dc.SetOptimization(FALSE); - - dc.SetLogicalFunction(wxINVERT); - - wxPen pen(wxColour(0, 0, 0), 1, wxDOT); - dc.SetPen(pen); - dc.SetBrush(* wxTRANSPARENT_BRUSH); - - dc.SetOptimization(TRUE); - - if (selectionHandle > 0) - { - panel->Refresh(); - - DrawBoundingBox(dc, xpos, ypos, width, height); - } - else - { - panel->Refresh(); - - dragOffsetX = (x - xpos); - dragOffsetY = (y - ypos); - - DrawBoundingBox(dc, xpos, ypos, width, height); - - // Also draw bounding boxes for other selected items - wxNode *node = panel->GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (win->IsKindOf(CLASSINFO(wxControl))) + int xpos, ypos, width, height; + handlerControl->GetPosition(&xpos, &ypos); + handlerControl->GetSize(&width, &height); + + dc.BeginDrawing(); + + // dc.DestroyClippingRegion(); + + wxPanel *panel = (wxPanel *)handlerControl->GetParent(); + + // Erase selection handles + // DrawSelectionHandles(dc, TRUE); + + dc.SetOptimization(FALSE); + + dc.SetLogicalFunction(wxINVERT); + + wxPen pen(wxColour(0, 0, 0), 1, wxDOT); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + dc.SetOptimization(TRUE); + + if (selectionHandle > 0) + { + panel->Refresh(); + + DrawBoundingBox(dc, xpos, ypos, width, height); + } + else + { + panel->Refresh(); + + dragOffsetX = (x - xpos); + dragOffsetY = (y - ypos); + + DrawBoundingBox(dc, xpos, ypos, width, height); + + // Also draw bounding boxes for other selected items + wxNode *node = panel->GetChildren().First(); + while (node) { - wxControl *item = (wxControl *)win; - wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - if ((item != handlerControl) && handler->IsSelected()) - { - int x1, y1, w1, h1; - item->GetPosition(&x1, &y1); - item->GetSize(&w1, &h1); - handler->DrawBoundingBox(dc, x1, y1, w1, h1); - } + wxWindow *win = (wxWindow *)node->Data(); + if (win->IsKindOf(CLASSINFO(wxControl))) + { + wxControl *item = (wxControl *)win; + wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + if ((item != handlerControl) && handler->IsSelected()) + { + int x1, y1, w1, h1; + item->GetPosition(&x1, &y1); + item->GetSize(&w1, &h1); + handler->DrawBoundingBox(dc, x1, y1, w1, h1); + } + } + node = node->Next(); } - node = node->Next(); - } - } - dc.EndDrawing(); + } + dc.EndDrawing(); } void wxResourceEditorControlHandler::OnDragContinue(bool WXUNUSED(paintIt), int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle) { - wxPanel *panel = (wxPanel *)handlerControl->GetParent(); - int xpos, ypos, width, height; - handlerControl->GetPosition(&xpos, &ypos); - handlerControl->GetSize(&width, &height); - - if (selectionHandle > 0) - { -/* - 8 1 2 - - 7 3 - - 6 5 4 -*/ - - int x1, y1, width1, height1; - - switch (selectionHandle) + wxPanel *panel = (wxPanel *)handlerControl->GetParent(); + int xpos, ypos, width, height; + handlerControl->GetPosition(&xpos, &ypos); + handlerControl->GetSize(&width, &height); + + if (selectionHandle > 0) { - case 1: - x1 = xpos; - y1 = y; - width1 = width; - height1 = (ypos + height) - y; - break; - case 5: - x1 = xpos; - y1 = ypos; - width1 = width; - height1 = (y - ypos); - break; - case 3: - x1 = xpos; - y1 = ypos; - width1 = (x - xpos); - height1 = height; - break; - case 7: - x1 = x; - y1 = ypos; - width1 = (xpos + width) - x; - height1 = height; - break; - case 2: - x1 = xpos; - y1 = y; - width1 = (x - xpos); - height1 = (ypos + height) - y; - break; - case 4: - x1 = xpos; - y1 = ypos; - width1 = (x - xpos); - height1 = (y - ypos); - break; - case 6: - x1 = x; - y1 = ypos; - width1 = (xpos + width) - x; - height1 = y - ypos; - break; - case 8: - x1 = x; - y1 = y; - width1 = (xpos + width) - x; - height1 = (ypos + height) - y; - break; - } - dc.BeginDrawing(); - - dc.SetLogicalFunction(wxINVERT); - wxPen pen(wxColour(0, 0, 0), 1, wxDOT); - dc.SetPen(pen); - dc.SetBrush(* wxTRANSPARENT_BRUSH); - - DrawBoundingBox(dc, x1, y1, width1, height1); - - dc.EndDrawing(); - } - else - { - dc.BeginDrawing(); - dc.SetLogicalFunction(wxINVERT); - wxPen pen(wxColour(0, 0, 0), 1, wxDOT); - dc.SetPen(pen); - dc.SetBrush(* wxTRANSPARENT_BRUSH); - - DrawBoundingBox(dc, (int)(x - dragOffsetX), (int)(y - dragOffsetY), width, height); - - // Also draw bounding boxes for other selected items - wxNode *node = panel->GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (win->IsKindOf(CLASSINFO(wxControl))) + /* + 8 1 2 + + 7 3 + + 6 5 4 + */ + + int x1, y1, width1, height1; + + switch (selectionHandle) { - wxControl *item = (wxControl *)win; - wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - if ((item != handlerControl) && handler->IsSelected()) - { - int x1, y1, w1, h1; - item->GetPosition(&x1, &y1); - item->GetSize(&w1, &h1); - int x2 = (int)(x1 + (x - dragOffsetX) - xpos); - int y2 = (int)(y1 + (y - dragOffsetY) - ypos); - handler->DrawBoundingBox(dc, x2, y2, w1, h1); - } + case 1: + x1 = xpos; + y1 = y; + width1 = width; + height1 = (ypos + height) - y; + break; + case 5: + x1 = xpos; + y1 = ypos; + width1 = width; + height1 = (y - ypos); + break; + case 3: + x1 = xpos; + y1 = ypos; + width1 = (x - xpos); + height1 = height; + break; + case 7: + x1 = x; + y1 = ypos; + width1 = (xpos + width) - x; + height1 = height; + break; + case 2: + x1 = xpos; + y1 = y; + width1 = (x - xpos); + height1 = (ypos + height) - y; + break; + case 4: + x1 = xpos; + y1 = ypos; + width1 = (x - xpos); + height1 = (y - ypos); + break; + case 6: + x1 = x; + y1 = ypos; + width1 = (xpos + width) - x; + height1 = y - ypos; + break; + case 8: + x1 = x; + y1 = y; + width1 = (xpos + width) - x; + height1 = (ypos + height) - y; + break; } - node = node->Next(); - } - dc.EndDrawing(); - } + dc.BeginDrawing(); + + dc.SetLogicalFunction(wxINVERT); + wxPen pen(wxColour(0, 0, 0), 1, wxDOT); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + DrawBoundingBox(dc, x1, y1, width1, height1); + + dc.EndDrawing(); + } + else + { + dc.BeginDrawing(); + dc.SetLogicalFunction(wxINVERT); + wxPen pen(wxColour(0, 0, 0), 1, wxDOT); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + DrawBoundingBox(dc, (int)(x - dragOffsetX), (int)(y - dragOffsetY), width, height); + + // Also draw bounding boxes for other selected items + wxNode *node = panel->GetChildren().First(); + while (node) + { + wxWindow *win = (wxWindow *)node->Data(); + if (win->IsKindOf(CLASSINFO(wxControl))) + { + wxControl *item = (wxControl *)win; + wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + if ((item != handlerControl) && handler->IsSelected()) + { + int x1, y1, w1, h1; + item->GetPosition(&x1, &y1); + item->GetSize(&w1, &h1); + int x2 = (int)(x1 + (x - dragOffsetX) - xpos); + int y2 = (int)(y1 + (y - dragOffsetY) - ypos); + handler->DrawBoundingBox(dc, x2, y2, w1, h1); + } + } + node = node->Next(); + } + dc.EndDrawing(); + } } void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle) { - wxPanel *panel = (wxPanel *)handlerControl->GetParent(); - - dc.BeginDrawing(); - - int xpos, ypos, width, height; - handlerControl->GetPosition(&xpos, &ypos); - handlerControl->GetSize(&width, &height); - - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl); - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl->GetParent()); - - if (selectionHandle > 0) - { - int x1, y1, width1, height1; - - switch (selectionHandle) + wxPanel *panel = (wxPanel *)handlerControl->GetParent(); + + dc.BeginDrawing(); + + int xpos, ypos, width, height; + handlerControl->GetPosition(&xpos, &ypos); + handlerControl->GetSize(&width, &height); + + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl); + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl->GetParent()); + + if (selectionHandle > 0) { - case 1: - x1 = xpos; - y1 = y; - width1 = width; - height1 = (ypos + height) - y; - break; - case 5: - x1 = xpos; - y1 = ypos; - width1 = width; - height1 = (y - ypos); - break; - case 3: - x1 = xpos; - y1 = ypos; - width1 = (x - xpos); - height1 = height; - break; - case 7: - x1 = x; - y1 = ypos; - width1 = (xpos + width) - x; - height1 = height; - break; - case 2: - x1 = xpos; - y1 = y; - width1 = (x - xpos); - height1 = (ypos + height) - y; - break; - case 4: - x1 = xpos; - y1 = ypos; - width1 = (x - xpos); - height1 = (y - ypos); - break; - case 6: - x1 = x; - y1 = ypos; - width1 = (xpos + width) - x; - height1 = y - ypos; - break; - case 8: - x1 = x; - y1 = y; - width1 = (xpos + width) - x; - height1 = (ypos + height) - y; - break; - } - // Update the associated resource - // We need to convert to dialog units if this is not a dialog or panel, but - // the parent resource specifies dialog units. - int resourceX = x1; - int resourceY = y1; - int resourceWidth = width1; - int resourceHeight = height1; - - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(x1, y1)); - wxSize sz = handlerControl->GetParent()->ConvertPixelsToDialog(wxSize(width1, height1)); - - // Convert back so we've rounded down - sz = handlerControl->GetParent()->ConvertDialogToPixels(sz); - sz = handlerControl->GetParent()->ConvertPixelsToDialog(sz); - resourceWidth = sz.x; resourceHeight = sz.y; - - sz = handlerControl->GetParent()->ConvertDialogToPixels(sz); - width1 = sz.x; - height1 = sz.y; - - pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); - pt = handlerControl->GetParent()->ConvertPixelsToDialog(pt); - resourceX = pt.x; resourceY = pt.y; - - pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); - x1 = pt.x; - y1 = pt.y; - } - handlerControl->SetSize(x1, y1, width1, height1); - resource->SetSize(resourceX, resourceY, resourceWidth, resourceHeight); - } - else - { - // Correction 31/12/98. We need to round down the values to take into account - // the fact that several pixels map to the same dialog unit. - - int newX = (int)(x - dragOffsetX); - int newY = (int)(y - dragOffsetY); - int resourceX = newX; - int resourceY = newY; - - // Update the associated resource - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY)); - pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); - pt = handlerControl->GetParent()->ConvertPixelsToDialog(pt); - resourceX = pt.x; resourceY = pt.y; - pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); - - // Having converted it several times, we know it'll map to dialog units exactly. - newX = pt.x; - newY = pt.y; - } - handlerControl->Move(newX, newY); - OldOnMove(newX, newY); - - resource->SetSize(resourceX, resourceY, resource->GetWidth(), resource->GetHeight()); - - // Also move other selected items - wxNode *node = panel->GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (win->IsKindOf(CLASSINFO(wxControl))) - { - wxControl *item = (wxControl *)win; - wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - if ((item != handlerControl) && handler->IsSelected()) + int x1, y1, width1, height1; + + switch (selectionHandle) { - int x1, y1; - item->GetPosition(&x1, &y1); - int x2 = (int)(x1 + (x - dragOffsetX) - xpos); - int y2 = (int)(y1 + (y - dragOffsetY) - ypos); - - resourceX = x2; - resourceY = y2; - - // Update the associated resource - resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(x2, y2)); - pt = item->GetParent()->ConvertDialogToPixels(pt); - pt = item->GetParent()->ConvertPixelsToDialog(pt); - + case 1: + x1 = xpos; + y1 = y; + width1 = width; + height1 = (ypos + height) - y; + break; + case 5: + x1 = xpos; + y1 = ypos; + width1 = width; + height1 = (y - ypos); + break; + case 3: + x1 = xpos; + y1 = ypos; + width1 = (x - xpos); + height1 = height; + break; + case 7: + x1 = x; + y1 = ypos; + width1 = (xpos + width) - x; + height1 = height; + break; + case 2: + x1 = xpos; + y1 = y; + width1 = (x - xpos); + height1 = (ypos + height) - y; + break; + case 4: + x1 = xpos; + y1 = ypos; + width1 = (x - xpos); + height1 = (y - ypos); + break; + case 6: + x1 = x; + y1 = ypos; + width1 = (xpos + width) - x; + height1 = y - ypos; + break; + case 8: + x1 = x; + y1 = y; + width1 = (xpos + width) - x; + height1 = (ypos + height) - y; + break; + } + // Update the associated resource + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + int resourceX = x1; + int resourceY = y1; + int resourceWidth = width1; + int resourceHeight = height1; + + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(x1, y1)); + wxSize sz = handlerControl->GetParent()->ConvertPixelsToDialog(wxSize(width1, height1)); + + // Convert back so we've rounded down + sz = handlerControl->GetParent()->ConvertDialogToPixels(sz); + sz = handlerControl->GetParent()->ConvertPixelsToDialog(sz); + resourceWidth = sz.x; resourceHeight = sz.y; + + sz = handlerControl->GetParent()->ConvertDialogToPixels(sz); + width1 = sz.x; + height1 = sz.y; + + pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); + pt = handlerControl->GetParent()->ConvertPixelsToDialog(pt); + resourceX = pt.x; resourceY = pt.y; + + pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); + x1 = pt.x; + y1 = pt.y; + } + handlerControl->SetSize(x1, y1, width1, height1); + resource->SetSize(resourceX, resourceY, resourceWidth, resourceHeight); + } + else + { + // Correction 31/12/98. We need to round down the values to take into account + // the fact that several pixels map to the same dialog unit. + + int newX = (int)(x - dragOffsetX); + int newY = (int)(y - dragOffsetY); + int resourceX = newX; + int resourceY = newY; + + // Update the associated resource + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY)); + pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); + pt = handlerControl->GetParent()->ConvertPixelsToDialog(pt); resourceX = pt.x; resourceY = pt.y; pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); - - // Having converted it several times, we know it'll map to dialog units exactly - x2 = pt.x; - y2 = pt.y; - } - - item->Move(x2, y2); - ((wxResourceEditorControlHandler *)item->GetEventHandler())->OldOnMove(x2, y2); - ((wxResourceEditorControlHandler *)item->GetEventHandler())->DrawSelectionHandles(dc); - - resource->SetSize(resourceX, resourceY, resource->GetWidth(), resource->GetHeight()); - + + // Having converted it several times, we know it'll map to dialog units exactly. + newX = pt.x; + newY = pt.y; + } + handlerControl->Move(newX, newY); + OldOnMove(newX, newY); + + resource->SetSize(resourceX, resourceY, resource->GetWidth(), resource->GetHeight()); + + // Also move other selected items + wxNode *node = panel->GetChildren().First(); + while (node) + { + wxWindow *win = (wxWindow *)node->Data(); + if (win->IsKindOf(CLASSINFO(wxControl))) + { + wxControl *item = (wxControl *)win; + wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + if ((item != handlerControl) && handler->IsSelected()) + { + int x1, y1; + item->GetPosition(&x1, &y1); + int x2 = (int)(x1 + (x - dragOffsetX) - xpos); + int y2 = (int)(y1 + (y - dragOffsetY) - ypos); + + resourceX = x2; + resourceY = y2; + + // Update the associated resource + resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(x2, y2)); + pt = item->GetParent()->ConvertDialogToPixels(pt); + pt = item->GetParent()->ConvertPixelsToDialog(pt); + + resourceX = pt.x; resourceY = pt.y; + pt = handlerControl->GetParent()->ConvertDialogToPixels(pt); + + // Having converted it several times, we know it'll map to dialog units exactly + x2 = pt.x; + y2 = pt.y; + } + + item->Move(x2, y2); + ((wxResourceEditorControlHandler *)item->GetEventHandler())->OldOnMove(x2, y2); + ((wxResourceEditorControlHandler *)item->GetEventHandler())->DrawSelectionHandles(dc); + + resource->SetSize(resourceX, resourceY, resource->GetWidth(), resource->GetHeight()); + + } + } + node = node->Next(); } - } - node = node->Next(); } - } - dc.SetOptimization(FALSE); - - dc.SetLogicalFunction(wxCOPY); - dc.SetPen(* wxBLACK_PEN); - dc.SetBrush(* wxBLACK_BRUSH); - - dc.SetOptimization(TRUE); - - // Force it to repaint the selection handles (if any) - // since the panel thinks we're still within a drag and - // won't paint the handles. - if (IsSelected()) - DrawSelectionHandles(dc); - - dc.EndDrawing(); - - panel->Refresh(); + dc.SetOptimization(FALSE); + + dc.SetLogicalFunction(wxCOPY); + dc.SetPen(* wxBLACK_PEN); + dc.SetBrush(* wxBLACK_BRUSH); + + dc.SetOptimization(TRUE); + + // Force it to repaint the selection handles (if any) + // since the panel thinks we're still within a drag and + // won't paint the handles. + if (IsSelected()) + DrawSelectionHandles(dc); + + dc.EndDrawing(); + + panel->Refresh(); } // These functions call OnItemEvent, OnItemMove and OnItemSize @@ -1135,71 +1135,71 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), void wxResourceEditorControlHandler::OnMouseEvent(wxMouseEvent& event) { /* - if ((event.m_eventType == wxEVENT_TYPE_LEFT_DCLICK) || - (event.m_eventType == wxEVENT_TYPE_RIGHT_DCLICK)) - return; -*/ - wxWindow *panel = handlerControl->GetParent(); - if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) - return; - wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); - if ( !panelHandler->GetEvtHandlerEnabled() ) - { - event.Skip(); - return; - } +if ((event.m_eventType == wxEVENT_TYPE_LEFT_DCLICK) || +(event.m_eventType == wxEVENT_TYPE_RIGHT_DCLICK)) +return; + */ + wxWindow *panel = handlerControl->GetParent(); + if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) + return; + wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); + if ( !panelHandler->GetEvtHandlerEnabled() ) + { + event.Skip(); + return; + } - panelHandler->OnItemEvent(handlerControl, event); + panelHandler->OnItemEvent(handlerControl, event); } void wxResourceEditorControlHandler::OldOnMove(int x, int y) { - wxWindow *panel = handlerControl->GetParent(); - if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) - return; - - wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); - panelHandler->OnItemMove(handlerControl, x, y); + wxWindow *panel = handlerControl->GetParent(); + if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) + return; + + wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); + panelHandler->OnItemMove(handlerControl, x, y); } void wxResourceEditorControlHandler::OldOnSize(int w, int h) { - wxWindow *panel = handlerControl->GetParent(); - if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) - return; - - wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); - panelHandler->OnItemSize(handlerControl, w, h); + wxWindow *panel = handlerControl->GetParent(); + if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) + return; + + wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); + panelHandler->OnItemSize(handlerControl, w, h); } void wxResourceEditorControlHandler::OnSelect(bool select) { - wxWindow *panel = handlerControl->GetParent(); - if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) - return; - - wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); - panelHandler->OnItemSelect(handlerControl, select); + wxWindow *panel = handlerControl->GetParent(); + if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) + return; + + wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); + panelHandler->OnItemSelect(handlerControl, select); } void wxResourceEditorControlHandler::OnLeftClick(int x, int y, int keys) { - wxWindow *panel = handlerControl->GetParent(); - if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) - return; - - wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); - panelHandler->OnItemLeftClick(handlerControl, x, y, keys); + wxWindow *panel = handlerControl->GetParent(); + if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) + return; + + wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); + panelHandler->OnItemLeftClick(handlerControl, x, y, keys); } void wxResourceEditorControlHandler::OnRightClick(int x, int y, int keys) { - wxWindow *panel = handlerControl->GetParent(); - if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) - return; - - wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); - panelHandler->OnItemRightClick(handlerControl, x, y, keys); + wxWindow *panel = handlerControl->GetParent(); + if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) ) + return; + + wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler(); + panelHandler->OnItemRightClick(handlerControl, x, y, keys); } diff --git a/utils/dialoged/src/dlghndlr.h b/utils/dialoged/src/dlghndlr.h index 80a9cf5ac8..e54ba36097 100644 --- a/utils/dialoged/src/dlghndlr.h +++ b/utils/dialoged/src/dlghndlr.h @@ -25,114 +25,125 @@ class wxResourceEditorDialogHandler: public wxEvtHandler { -DECLARE_CLASS(wxResourceEditorDialogHandler) - public: - wxResourceManager *resourceManager; - wxPanel *handlerDialog; - wxItemResource *handlerResource; - wxEvtHandler *handlerOldHandler; - - wxControl *dragItem; - int dragMode; - int dragType; - int dragTolerance; - bool checkTolerance; - int firstDragX; - int firstDragY; - int oldDragX; - int oldDragY; - bool m_mouseCaptured; -// long m_treeItem; - - wxResourceEditorDialogHandler(wxPanel *dialog, wxItemResource *resource, wxEvtHandler *oldHandler, - wxResourceManager *manager); - ~wxResourceEditorDialogHandler(void); - - void OnPaint(wxPaintEvent& event); - void OnMouseEvent(wxMouseEvent& event); - void OnSize(wxSizeEvent& event); - - virtual void OnItemEvent(wxControl *win, wxMouseEvent& event); - virtual void OnLeftClick(int x, int y, int keys); - virtual void OnRightClick(int x, int y, int keys); - virtual void OnItemLeftClick(wxControl *item, int x, int y, int keys); - virtual void OnItemRightClick(wxControl *item, int x, int y, int keys); - virtual void OnItemSelect(wxControl *item, bool select); - virtual void OnItemMove( - wxControl *WXUNUSED(item), int WXUNUSED(x), int WXUNUSED(y) ) {}; - virtual void OnItemSize( - wxControl *WXUNUSED(item), int WXUNUSED(w), int WXUNUSED(h) ) {}; - - void AddChildHandlers(void); - void PaintSelectionHandles(wxDC& dc); - void ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle); - -// Accessors -/* - inline long GetTreeItem() const { return m_treeItem; } - inline void SetTreeItem(long item) { m_treeItem = item; } -*/ - -DECLARE_EVENT_TABLE() + DECLARE_CLASS(wxResourceEditorDialogHandler) +public: + wxResourceManager *resourceManager; + wxPanel *handlerDialog; + wxItemResource *handlerResource; + wxEvtHandler *handlerOldHandler; + + wxControl *dragItem; + int dragMode; + int dragType; + int dragTolerance; + bool checkTolerance; + int firstDragX; + int firstDragY; + int oldDragX; + int oldDragY; + bool m_mouseCaptured; + // long m_treeItem; + + wxResourceEditorDialogHandler(wxPanel *dialog, wxItemResource *resource, wxEvtHandler *oldHandler, + wxResourceManager *manager); + ~wxResourceEditorDialogHandler(void); + + void OnPaint(wxPaintEvent& event); + void OnMouseEvent(wxMouseEvent& event); + void OnSize(wxSizeEvent& event); + + virtual void OnItemEvent(wxControl *win, wxMouseEvent& event); + virtual void OnLeftClick(int x, int y, int keys); + virtual void OnRightClick(int x, int y, int keys); + virtual void OnItemLeftClick(wxControl *item, int x, int y, int keys); + virtual void OnItemRightClick(wxControl *item, int x, int y, int keys); + virtual void OnItemSelect(wxControl *item, bool select); + virtual void OnItemMove( + wxControl *WXUNUSED(item), int WXUNUSED(x), int WXUNUSED(y) ) {}; + virtual void OnItemSize( + wxControl *WXUNUSED(item), int WXUNUSED(w), int WXUNUSED(h) ) {}; + + void AddChildHandlers(void); + void PaintSelectionHandles(wxDC& dc); + void ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle); + + // Accessors + /* + inline long GetTreeItem() const { return m_treeItem; } + inline void SetTreeItem(long item) { m_treeItem = item; } + */ + + DECLARE_EVENT_TABLE() }; class wxResourceEditorControlHandler: public wxEvtHandler { -DECLARE_CLASS(wxResourceEditorControlHandler) - public: -// wxResourceManager *resourceManager; - wxControl *handlerControl; -// wxItemResource *handlerResource; - wxEvtHandler *handlerOldHandler; + DECLARE_CLASS(wxResourceEditorControlHandler) +public: + // wxResourceManager *resourceManager; + wxControl *handlerControl; + // wxItemResource *handlerResource; + wxEvtHandler *handlerOldHandler; + + bool isSelected; + int handleSize; // selection handle size + int handleMargin; // Distance between item edge and handle edge + long m_treeItem; + static int dragOffsetX; // Distance between pointer at start of drag and + static int dragOffsetY; // top-left of item + + wxResourceEditorControlHandler(wxControl *control, wxEvtHandler *oldHandler); + ~wxResourceEditorControlHandler(void); + + void OnMouseEvent(wxMouseEvent& event); + + // Manipulation and drawing of items in Edit Mode + + // Calculate position of the 8 handles + virtual void CalcSelectionHandles(int *hx, int *hy); + virtual void DrawSelectionHandles(wxDC& dc, bool erase = FALSE); + virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h); + virtual void SelectItem(bool select); + virtual inline bool IsSelected(void) { return isSelected; } + + // Returns TRUE or FALSE + virtual bool HitTest(int x, int y); + + // Returns 0 (no hit), 1 - 8 for which selection handle + // (clockwise from top middle) + virtual int SelectionHandleHitTest(int x, int y); + + // If selectionHandle is zero, not dragging the selection handle. + virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle); + virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle); + virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle); + + // These functions call panel functions + // by default. + virtual void OldOnMove(int x, int y); + virtual void OldOnSize(int w, int h); + virtual void OnLeftClick(int x, int y, int keys); + virtual void OnRightClick(int x, int y, int keys); + virtual void OnSelect(bool select); + + // Accessors + /* + inline long GetTreeItem() const { return m_treeItem; } + inline void SetTreeItem(long item) { m_treeItem = item; } + */ + + DECLARE_EVENT_TABLE() +}; - bool isSelected; - int handleSize; // selection handle size - int handleMargin; // Distance between item edge and handle edge - long m_treeItem; - static int dragOffsetX; // Distance between pointer at start of drag and - static int dragOffsetY; // top-left of item - - wxResourceEditorControlHandler(wxControl *control, wxEvtHandler *oldHandler); - ~wxResourceEditorControlHandler(void); - - void OnMouseEvent(wxMouseEvent& event); - - // Manipulation and drawing of items in Edit Mode - - // Calculate position of the 8 handles - virtual void CalcSelectionHandles(int *hx, int *hy); - virtual void DrawSelectionHandles(wxDC& dc, bool erase = FALSE); - virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h); - virtual void SelectItem(bool select); - virtual inline bool IsSelected(void) { return isSelected; } - - // Returns TRUE or FALSE - virtual bool HitTest(int x, int y); - - // Returns 0 (no hit), 1 - 8 for which selection handle - // (clockwise from top middle) - virtual int SelectionHandleHitTest(int x, int y); - - // If selectionHandle is zero, not dragging the selection handle. - virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle); - virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle); - virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle); - - // These functions call panel functions - // by default. - virtual void OldOnMove(int x, int y); - virtual void OldOnSize(int w, int h); - virtual void OnLeftClick(int x, int y, int keys); - virtual void OnRightClick(int x, int y, int keys); - virtual void OnSelect(bool select); - -// Accessors -/* - inline long GetTreeItem() const { return m_treeItem; } - inline void SetTreeItem(long item) { m_treeItem = item; } -*/ - -DECLARE_EVENT_TABLE() +// This dialog, for testing dialogs, has to intercept commands before +// they go up the hierarchy and accidentally set off arbitrary +// Dialog Editor functionality +class ResourceEditorDialogTester: public wxDialog +{ +public: + ResourceEditorDialogTester() {} + + bool ProcessEvent(wxEvent& event); }; #endif diff --git a/utils/dialoged/src/edlist.cpp b/utils/dialoged/src/edlist.cpp index 087736aaf4..205a6fd153 100644 --- a/utils/dialoged/src/edlist.cpp +++ b/utils/dialoged/src/edlist.cpp @@ -41,8 +41,8 @@ BEGIN_EVENT_TABLE(wxResourceEditorControlList, wxListCtrl) END_EVENT_TABLE() wxResourceEditorControlList::wxResourceEditorControlList(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - long style): - wxListCtrl(parent, id, pos, size, style), m_imageList(16, 16, TRUE) + long style): +wxListCtrl(parent, id, pos, size, style), m_imageList(16, 16, TRUE) { Initialize(); } @@ -74,7 +74,7 @@ void wxResourceEditorControlList::Initialize() wxIcon icon16("RADIOBTN_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); wxIcon icon17("SCROLBAR_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); #else - + #include "bitmaps/arrow.xpm" wxIcon icon1( arrow_xpm ); #include "bitmaps/button.xpm" @@ -110,7 +110,7 @@ void wxResourceEditorControlList::Initialize() #include "bitmaps/scrolbar.xpm" wxIcon icon17( scrolbar_xpm ); #endif - + m_imageList.Add(icon1); m_imageList.Add(icon2); m_imageList.Add(icon3); @@ -130,7 +130,7 @@ void wxResourceEditorControlList::Initialize() m_imageList.Add(icon17); SetImageList(& m_imageList, wxIMAGE_LIST_SMALL); - + long id = InsertItem(0, "Pointer", 0); id = InsertItem(1, "wxButton", 1); id = InsertItem(2, "wxBitmapButton", 2); @@ -148,14 +148,14 @@ void wxResourceEditorControlList::Initialize() id = InsertItem(14, "wxRadioBox", 14); id = InsertItem(15, "wxRadioButton", 15); id = InsertItem(16, "wxScrollBar", 16); - -/* + + /* InsertItem(RESED_TREECTRL, "wxTreeCtrl", 16); InsertItem(RESED_LISTCTRL, "wxListCtrl", 17); InsertItem(RESED_SPINBUTTON, "wxSpinButton", 18); -*/ - -// SetColumnWidth(-1, 80); + */ + + // SetColumnWidth(-1, 80); } // Get selection, or -1 diff --git a/utils/dialoged/src/edlist.h b/utils/dialoged/src/edlist.h index 9777c01355..6ab9369f1f 100644 --- a/utils/dialoged/src/edlist.h +++ b/utils/dialoged/src/edlist.h @@ -21,15 +21,15 @@ public: wxResourceEditorControlList(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style = wxLC_SMALL_ICON|wxLC_AUTOARRANGE|wxLC_SINGLE_SEL); ~wxResourceEditorControlList(); - + // Load icons and add to the list void Initialize(); - + // Get selection, or -1 long GetSelection() const; - -DECLARE_EVENT_TABLE() - + + DECLARE_EVENT_TABLE() + protected: wxImageList m_imageList; }; diff --git a/utils/dialoged/src/edtree.cpp b/utils/dialoged/src/edtree.cpp index 00086583d8..168fa100cd 100644 --- a/utils/dialoged/src/edtree.cpp +++ b/utils/dialoged/src/edtree.cpp @@ -38,13 +38,13 @@ #include "reseditr.h" BEGIN_EVENT_TABLE(wxResourceEditorProjectTree, wxTreeCtrl) - EVT_LEFT_DCLICK(wxResourceEditorProjectTree::LeftDClick) - EVT_TREE_SEL_CHANGED(IDC_TREECTRL, wxResourceEditorProjectTree::OnSelChanged) +EVT_LEFT_DCLICK(wxResourceEditorProjectTree::LeftDClick) +EVT_TREE_SEL_CHANGED(IDC_TREECTRL, wxResourceEditorProjectTree::OnSelChanged) END_EVENT_TABLE() wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - long style): - wxTreeCtrl(parent, id, pos, size, style) + long style): +wxTreeCtrl(parent, id, pos, size, style) { } @@ -54,18 +54,18 @@ void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event)) long sel = GetSelection(); if (sel == -1) return; - + if (GetItemData(sel) == 0) return; - + wxItemResource* res = (wxResourceTreeData *)GetItemData(sel)->GetResource(); wxString resType(res->GetType()); if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel") return; - + wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent(); wxResourceManager *manager = frame->manager; - + manager->EditSelectedResource(); #endif } @@ -75,18 +75,18 @@ void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event)) long sel = GetSelection(); if (sel == -1) return; - + if (GetItemData(sel) == 0) return; - + if (m_invalid) return; - + wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource(); wxString resType(res->GetType()); if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel") return; - + wxResourceManager::GetCurrentResourceManager()->Edit(res); } diff --git a/utils/dialoged/src/edtree.h b/utils/dialoged/src/edtree.h index 3928c5aa7d..37b05dcd59 100644 --- a/utils/dialoged/src/edtree.h +++ b/utils/dialoged/src/edtree.h @@ -19,17 +19,17 @@ class wxResourceEditorProjectTree: public wxTreeCtrl public: wxResourceEditorProjectTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style = wxTR_HAS_BUTTONS); - + void LeftDClick(wxMouseEvent& event); void OnSelChanged(wxTreeEvent& event); - + inline void SetInvalid(bool invalid) { m_invalid = invalid; } - + protected: bool m_invalid; // While TRUE, don't respond to selections etc. - -DECLARE_EVENT_TABLE() - + + DECLARE_EVENT_TABLE() + }; #endif diff --git a/utils/dialoged/src/reseditr.cpp b/utils/dialoged/src/reseditr.cpp index e6bd5f43a6..cb883092d6 100644 --- a/utils/dialoged/src/reseditr.cpp +++ b/utils/dialoged/src/reseditr.cpp @@ -38,6 +38,8 @@ #include "wx/scrolbar.h" #include "wx/config.h" +#include "wx/dir.h" +#include "wx/progdlg.h" #include #include @@ -71,6 +73,10 @@ wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL; #include "bitmaps/toback.xpm" #include "bitmaps/help.xpm" #include "bitmaps/wxwin.xpm" +#include "bitmaps/distvert.xpm" +#include "bitmaps/disthor.xpm" +#include "bitmaps/copywdth.xpm" +#include "bitmaps/copyhght.xpm" #include "bitmaps/dialog.xpm" #include "bitmaps/folder1.xpm" @@ -79,529 +85,508 @@ wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL; #endif /* - * Resource manager - */ +* Resource manager +*/ wxResourceManager::wxResourceManager(): - m_imageList(16, 16, TRUE) +m_imageList(16, 16, TRUE) { - sm_currentResourceManager = this; - m_editorFrame = NULL; - m_editorPanel = NULL; - m_popupMenu = NULL; - m_editorResourceTree = NULL; - m_editorControlList = NULL; - m_nameCounter = 1; - m_symbolIdCounter = 99; - m_modified = FALSE; - m_currentFilename = ""; - m_symbolFilename = ""; - m_editorToolBar = NULL; - - // Default window positions - m_resourceEditorWindowSize.width = 500; - m_resourceEditorWindowSize.height = 450; - - m_resourceEditorWindowSize.x = 0; - m_resourceEditorWindowSize.y = 0; - - m_propertyWindowSize.width = 300; - m_propertyWindowSize.height = 300; - + sm_currentResourceManager = this; + m_editorFrame = NULL; + m_editorPanel = NULL; + m_popupMenu = NULL; + m_editorResourceTree = NULL; + m_editorControlList = NULL; + m_nameCounter = 1; + m_symbolIdCounter = 99; + m_modified = FALSE; + m_currentFilename = ""; + m_symbolFilename = ""; + m_editorToolBar = NULL; + + // Default window positions + m_resourceEditorWindowSize.width = 500; + m_resourceEditorWindowSize.height = 450; + + m_resourceEditorWindowSize.x = 0; + m_resourceEditorWindowSize.y = 0; + + m_propertyWindowSize.width = 300; + m_propertyWindowSize.height = 300; + #ifdef __WXMSW__ - m_helpController = NULL; + m_helpController = NULL; #endif - - m_bitmapImage = NULL; - m_rootDialogItem = 0; + + m_bitmapImage = NULL; + m_rootDialogItem = 0; } wxResourceManager::~wxResourceManager() { - sm_currentResourceManager = NULL; - SaveOptions(); - + sm_currentResourceManager = NULL; + SaveOptions(); + #ifdef __WXMSW__ - if (m_helpController) - { - m_helpController->Quit(); - delete m_helpController; - m_helpController = NULL; - } + if (m_helpController) + { + m_helpController->Quit(); + delete m_helpController; + m_helpController = NULL; + } #endif - - delete m_bitmapImage; - delete m_popupMenu; + + delete m_bitmapImage; + delete m_popupMenu; } bool wxResourceManager::Initialize() { - // Set up the resource filename for each platform. - // TODO: This shold be replaced by wxConfig usage. + // Set up the resource filename for each platform. + // TODO: This shold be replaced by wxConfig usage. #ifdef __WXMSW__ - // dialoged.ini in the Windows directory - wxString windowsDir = wxGetOSDirectory(); - windowsDir += "\\dialoged.ini" ; - - m_optionsResourceFilename = windowsDir; + // dialoged.ini in the Windows directory + wxString windowsDir = wxGetOSDirectory(); + windowsDir += "\\dialoged.ini" ; + + m_optionsResourceFilename = windowsDir; #elif defined(__WXGTK__) || defined(__WXMOTIF__) - wxGetHomeDir( &m_optionsResourceFilename ); - m_optionsResourceFilename += "/.dialogedrc"; + wxGetHomeDir( &m_optionsResourceFilename ); + m_optionsResourceFilename += "/.dialogedrc"; #else #error "Unsupported platform." #endif - - LoadOptions(); - + + LoadOptions(); + #ifdef __WXMSW__ - m_helpController = new wxHelpController; - m_helpController->Initialize("dialoged"); + m_helpController = new wxHelpController; + m_helpController->Initialize("dialoged"); #endif - - m_popupMenu = new wxMenu; - m_popupMenu->Append(OBJECT_MENU_EDIT, "Edit properties"); - m_popupMenu->Append(OBJECT_MENU_DELETE, "Delete object"); - - if (!m_bitmapImage) - { + + m_popupMenu = new wxMenu; + m_popupMenu->Append(OBJECT_MENU_EDIT, "Edit properties"); + m_popupMenu->Append(OBJECT_MENU_DELETE, "Delete object"); + + if (!m_bitmapImage) + { #ifdef __WXMSW__ - m_bitmapImage = new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE); + m_bitmapImage = new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE); #endif #if defined(__WXGTK__) || defined(__WXMOTIF__) - m_bitmapImage = new wxBitmap( wxwin_xpm ); + m_bitmapImage = new wxBitmap( wxwin_xpm ); #endif - } - - // Initialize the image list icons + } + + // Initialize the image list icons #ifdef __WXMSW__ - wxIcon icon1("DIALOG_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); - wxIcon icon2("FOLDER1_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); - wxIcon icon3("FOLDER2_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); - wxIcon icon4("BUTTONSM_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); + wxIcon icon1("DIALOG_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); + wxIcon icon2("FOLDER1_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); + wxIcon icon3("FOLDER2_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); + wxIcon icon4("BUTTONSM_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); #else - wxIcon icon1( dialog_xpm ); - wxIcon icon2( folder1_xpm ); - wxIcon icon3( folder2_xpm ); - wxIcon icon4( buttonsm_xpm ); + wxIcon icon1( dialog_xpm ); + wxIcon icon2( folder1_xpm ); + wxIcon icon3( folder2_xpm ); + wxIcon icon4( buttonsm_xpm ); #endif - m_imageList.Add(icon1); - m_imageList.Add(icon2); - m_imageList.Add(icon3); - m_imageList.Add(icon4); - - m_symbolTable.AddStandardSymbols(); - - return TRUE; + m_imageList.Add(icon1); + m_imageList.Add(icon2); + m_imageList.Add(icon3); + m_imageList.Add(icon4); + + m_symbolTable.AddStandardSymbols(); + + return TRUE; } bool wxResourceManager::LoadOptions() { - wxConfig config("DialogEd", "wxWindows"); + wxConfig config("DialogEd", "wxWindows"); + + config.Read("editorWindowX", &m_resourceEditorWindowSize.x); + config.Read("editorWindowY", &m_resourceEditorWindowSize.y); + config.Read("editorWindowWidth", &m_resourceEditorWindowSize.width); + config.Read("editorWindowHeight", &m_resourceEditorWindowSize.height); + config.Read("propertyWindowX", &m_propertyWindowSize.x); + config.Read("propertyWindowY", &m_propertyWindowSize.y); + config.Read("propertyWindowWidth", &m_propertyWindowSize.width); + config.Read("propertyWindowHeight", &m_propertyWindowSize.height); - config.Read("editorWindowX", &m_resourceEditorWindowSize.x); - config.Read("editorWindowY", &m_resourceEditorWindowSize.y); - config.Read("editorWindowWidth", &m_resourceEditorWindowSize.width); - config.Read("editorWindowHeight", &m_resourceEditorWindowSize.height); - config.Read("propertyWindowX", &m_propertyWindowSize.x); - config.Read("propertyWindowY", &m_propertyWindowSize.y); - config.Read("propertyWindowWidth", &m_propertyWindowSize.width); - config.Read("propertyWindowHeight", &m_propertyWindowSize.height); - - /* - wxGetResource("DialogEd", "editorWindowX", &m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "editorWindowY", &m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "editorWindowWidth", &m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "editorWindowHeight", &m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "propertyWindowX", &m_propertyWindowSize.x, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "propertyWindowY", &m_propertyWindowSize.y, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "propertyWindowWidth", &m_propertyWindowSize.width, m_optionsResourceFilename.GetData()); - wxGetResource("DialogEd", "propertyWindowHeight", &m_propertyWindowSize.height, m_optionsResourceFilename.GetData()); - */ - return TRUE; + return TRUE; } bool wxResourceManager::SaveOptions() { - wxConfig config("DialogEd", "wxWindows"); - - config.Write("editorWindowX", (long) m_resourceEditorWindowSize.x); - config.Write("editorWindowY", (long) m_resourceEditorWindowSize.y); - config.Write("editorWindowWidth", (long) m_resourceEditorWindowSize.width); - config.Write("editorWindowHeight", (long) m_resourceEditorWindowSize.height); - config.Write("propertyWindowX", (long) m_propertyWindowSize.x); - config.Write("propertyWindowY", (long) m_propertyWindowSize.y); - config.Write("propertyWindowWidth", (long) m_propertyWindowSize.width); - config.Write("propertyWindowHeight", (long) m_propertyWindowSize.height); - /* - wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData()); - wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData()); - wxWriteResource("DialogEd", "editorWindowWidth", m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData()); - wxWriteResource("DialogEd", "editorWindowHeight", m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData()); - - wxWriteResource("DialogEd", "propertyWindowX", m_propertyWindowSize.x, m_optionsResourceFilename.GetData()); - wxWriteResource("DialogEd", "propertyWindowY", m_propertyWindowSize.y, m_optionsResourceFilename.GetData()); - wxWriteResource("DialogEd", "propertyWindowWidth", m_propertyWindowSize.width, m_optionsResourceFilename.GetData()); - wxWriteResource("DialogEd", "propertyWindowHeight", m_propertyWindowSize.height, m_optionsResourceFilename.GetData()); - */ - - return TRUE; + wxConfig config("DialogEd", "wxWindows"); + + config.Write("editorWindowX", (long) m_resourceEditorWindowSize.x); + config.Write("editorWindowY", (long) m_resourceEditorWindowSize.y); + config.Write("editorWindowWidth", (long) m_resourceEditorWindowSize.width); + config.Write("editorWindowHeight", (long) m_resourceEditorWindowSize.height); + config.Write("propertyWindowX", (long) m_propertyWindowSize.x); + config.Write("propertyWindowY", (long) m_propertyWindowSize.y); + config.Write("propertyWindowWidth", (long) m_propertyWindowSize.width); + config.Write("propertyWindowHeight", (long) m_propertyWindowSize.height); + + return TRUE; } // Show or hide the resource editor frame, which displays a list // of resources with ability to edit them. bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent), const char *title) { - if (show) - { - if (m_editorFrame) + if (show) { - m_editorFrame->Iconize(FALSE); - m_editorFrame->Show(TRUE); - return TRUE; - } - m_editorFrame = OnCreateEditorFrame(title); - SetFrameTitle(""); - wxMenuBar *menuBar = OnCreateEditorMenuBar(m_editorFrame); - m_editorFrame->SetMenuBar(menuBar); - - m_editorToolBar = (EditorToolBar *)OnCreateToolBar(m_editorFrame); - m_editorControlList = new wxResourceEditorControlList(m_editorFrame, IDC_LISTCTRL, wxPoint(0, 0), wxSize(-1, -1)); - m_editorResourceTree = new wxResourceEditorProjectTree(m_editorFrame, IDC_TREECTRL, wxPoint(0, 0), wxSize(-1, -1), - wxTR_HAS_BUTTONS); - m_editorPanel = OnCreateEditorPanel(m_editorFrame); - - m_editorResourceTree->SetImageList(& m_imageList); - - // Constraints for toolbar - wxLayoutConstraints *c = new wxLayoutConstraints; - c->left.SameAs (m_editorFrame, wxLeft, 0); - c->top.SameAs (m_editorFrame, wxTop, 0); - c->right.SameAs (m_editorFrame, wxRight, 0); - c->bottom.Unconstrained(); - c->width.Unconstrained(); - c->height.Absolute(28); - m_editorToolBar->SetConstraints(c); - - // Constraints for listbox - c = new wxLayoutConstraints; - c->left.SameAs (m_editorFrame, wxLeft, 0); - c->top.SameAs (m_editorToolBar, wxBottom, 0); - c->right.Absolute (150); - c->bottom.SameAs (m_editorControlList, wxTop, 0); - c->width.Unconstrained(); - c->height.Unconstrained(); - m_editorResourceTree->SetConstraints(c); - - // Constraints for panel - c = new wxLayoutConstraints; - c->left.SameAs (m_editorResourceTree, wxRight, 0); - c->top.SameAs (m_editorToolBar, wxBottom, 0); - c->right.SameAs (m_editorFrame, wxRight, 0); - c->bottom.SameAs (m_editorControlList, wxTop, 0); - c->width.Unconstrained(); - c->height.Unconstrained(); - m_editorPanel->SetConstraints(c); - - // Constraints for control list (bottom window) - c = new wxLayoutConstraints; - c->left.SameAs (m_editorFrame, wxLeft, 0); - c->right.SameAs (m_editorFrame, wxRight, 0); - c->bottom.SameAs (m_editorFrame, wxBottom, 0); - c->width.Unconstrained(); + if (m_editorFrame) + { + m_editorFrame->Iconize(FALSE); + m_editorFrame->Show(TRUE); + return TRUE; + } + m_editorFrame = OnCreateEditorFrame(title); + SetFrameTitle(""); + wxMenuBar *menuBar = OnCreateEditorMenuBar(m_editorFrame); + m_editorFrame->SetMenuBar(menuBar); + + m_editorToolBar = (EditorToolBar *)OnCreateToolBar(m_editorFrame); + m_editorControlList = new wxResourceEditorControlList(m_editorFrame, IDC_LISTCTRL, wxPoint(0, 0), wxSize(-1, -1)); + m_editorResourceTree = new wxResourceEditorProjectTree(m_editorFrame, IDC_TREECTRL, wxPoint(0, 0), wxSize(-1, -1), + wxTR_HAS_BUTTONS); + m_editorPanel = OnCreateEditorPanel(m_editorFrame); + + m_editorResourceTree->SetImageList(& m_imageList); + + // Constraints for toolbar + wxLayoutConstraints *c = new wxLayoutConstraints; + c->left.SameAs (m_editorFrame, wxLeft, 0); + c->top.SameAs (m_editorFrame, wxTop, 0); + c->right.SameAs (m_editorFrame, wxRight, 0); + c->bottom.Unconstrained(); + c->width.Unconstrained(); + c->height.Absolute(28); + m_editorToolBar->SetConstraints(c); + + // Constraints for listbox + c = new wxLayoutConstraints; + c->left.SameAs (m_editorFrame, wxLeft, 0); + c->top.SameAs (m_editorToolBar, wxBottom, 0); + c->right.Absolute (150); + c->bottom.SameAs (m_editorControlList, wxTop, 0); + c->width.Unconstrained(); + c->height.Unconstrained(); + m_editorResourceTree->SetConstraints(c); + + // Constraints for panel + c = new wxLayoutConstraints; + c->left.SameAs (m_editorResourceTree, wxRight, 0); + c->top.SameAs (m_editorToolBar, wxBottom, 0); + c->right.SameAs (m_editorFrame, wxRight, 0); + c->bottom.SameAs (m_editorControlList, wxTop, 0); + c->width.Unconstrained(); + c->height.Unconstrained(); + m_editorPanel->SetConstraints(c); + + // Constraints for control list (bottom window) + c = new wxLayoutConstraints; + c->left.SameAs (m_editorFrame, wxLeft, 0); + c->right.SameAs (m_editorFrame, wxRight, 0); + c->bottom.SameAs (m_editorFrame, wxBottom, 0); + c->width.Unconstrained(); #if defined(__WXGTK__) || defined(__WXMOTIF__) - c->height.Absolute(120); + c->height.Absolute(120); #else - c->height.Absolute(60); + c->height.Absolute(60); #endif - - m_editorControlList->SetConstraints(c); - - m_editorFrame->SetAutoLayout(TRUE); - - UpdateResourceList(); - - m_editorFrame->Show(TRUE); - return TRUE; - } - else - { - if (m_editorFrame->Close()) - { - m_editorFrame = NULL; - m_editorPanel = NULL; + + m_editorControlList->SetConstraints(c); + + m_editorFrame->SetAutoLayout(TRUE); + + UpdateResourceList(); + + m_editorFrame->Show(TRUE); + return TRUE; } - } - return TRUE; + else + { + if (m_editorFrame->Close()) + { + m_editorFrame = NULL; + m_editorPanel = NULL; + } + } + return TRUE; } void wxResourceManager::SetFrameTitle(const wxString& filename) { - if (m_editorFrame) - { - if (filename == wxString("")) - m_editorFrame->SetTitle("wxWindows Dialog Editor - untitled"); - else + if (m_editorFrame) { - wxString str("wxWindows Dialog Editor - "); - wxString str2(wxFileNameFromPath(WXSTRINGCAST filename)); - str += str2; - m_editorFrame->SetTitle(str); + if (filename == wxString("")) + m_editorFrame->SetTitle("wxWindows Dialog Editor - untitled"); + else + { + wxString str("wxWindows Dialog Editor - "); + wxString str2(wxFileNameFromPath(WXSTRINGCAST filename)); + str += str2; + m_editorFrame->SetTitle(str); + } } - } } bool wxResourceManager::Save() { - if (m_currentFilename == wxString("")) - return SaveAs(); - else - return Save(m_currentFilename); + if (m_currentFilename == wxString("")) + return SaveAs(); + else + return Save(m_currentFilename); } bool wxResourceManager::Save(const wxString& filename) { - // Ensure all visible windows are saved to their resources - m_currentFilename = filename; - SetFrameTitle(m_currentFilename); - InstantiateAllResourcesFromWindows(); - if (m_resourceTable.Save(filename)) - { - m_symbolTable.WriteIncludeFile(m_symbolFilename); - Modify(FALSE); - return TRUE; - } - else - return FALSE; + // Ensure all visible windows are saved to their resources + m_currentFilename = filename; + SetFrameTitle(m_currentFilename); + InstantiateAllResourcesFromWindows(); + if (m_resourceTable.Save(filename)) + { + m_symbolTable.WriteIncludeFile(m_symbolFilename); + Modify(FALSE); + return TRUE; + } + else + return FALSE; } bool wxResourceManager::SaveAs() { - wxString s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename), wxFileNameFromPath(WXSTRINGCAST m_currentFilename), - "wxr", "*.wxr", wxSAVE | wxOVERWRITE_PROMPT, wxTheApp->GetTopWindow())); + wxString s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename), wxFileNameFromPath(WXSTRINGCAST m_currentFilename), + "wxr", "*.wxr", wxSAVE | wxOVERWRITE_PROMPT, wxTheApp->GetTopWindow())); - if (s.IsNull() || s == "") - return FALSE; + if (s.IsNull() || s == "") + return FALSE; - m_currentFilename = s; - wxStripExtension(m_currentFilename); - m_currentFilename += ".wxr"; - - // Construct include filename from this file - m_symbolFilename = m_currentFilename; - - wxStripExtension(m_symbolFilename); - m_symbolFilename += ".h"; - - Save(m_currentFilename); - return TRUE; + m_currentFilename = s; + wxStripExtension(m_currentFilename); + m_currentFilename += ".wxr"; + + // Construct include filename from this file + m_symbolFilename = m_currentFilename; + + wxStripExtension(m_symbolFilename); + m_symbolFilename += ".h"; + + Save(m_currentFilename); + return TRUE; } bool wxResourceManager::SaveIfModified() { - if (Modified()) - return Save(); - else return TRUE; + if (Modified()) + return Save(); + else return TRUE; } bool wxResourceManager::Load(const wxString& filename) { - return New(TRUE, filename); + return New(TRUE, filename); } bool wxResourceManager::New(bool loadFromFile, const wxString& filename) { - if (!Clear(TRUE, FALSE)) - return FALSE; - - m_symbolTable.AddStandardSymbols(); - - if (loadFromFile) - { - wxString str = filename; - if (str == wxString("")) - { - wxString f(wxFileSelector("Open resource file", wxGetCwd(), wxEmptyString, "wxr", "*.wxr", 0, wxTheApp->GetTopWindow())); - if (!f.IsNull() && f != "") - str = f; - else + if (!Clear(TRUE, FALSE)) return FALSE; - } - if (!m_resourceTable.ParseResourceFile(str)) + m_symbolTable.AddStandardSymbols(); + + if (loadFromFile) { - wxMessageBox("Could not read file.", "Resource file load error", wxOK | wxICON_EXCLAMATION); - return FALSE; - } - m_currentFilename = str; - - SetFrameTitle(m_currentFilename); - - UpdateResourceList(); - - // Construct include filename from this file - m_symbolFilename = m_currentFilename; - - wxStripExtension(m_symbolFilename); - m_symbolFilename += ".h"; - - if (!m_symbolTable.ReadIncludeFile(m_symbolFilename)) - { - wxString str("Could not find include file "); - str += m_symbolFilename; - str += ".\nDialog Editor maintains a header file containing id symbols to be used in the application.\n"; - str += "The next time this .wxr file is saved, a header file will be saved also."; - wxMessageBox(str, "Dialog Editor Warning", wxOK ); - - m_symbolIdCounter = 99; + wxString str = filename; + if (str == wxString("")) + { + wxString f(wxFileSelector("Open resource file", wxGetCwd(), wxEmptyString, "wxr", "*.wxr", 0, wxTheApp->GetTopWindow())); + if (!f.IsNull() && f != "") + str = f; + else + return FALSE; + } + + if (!m_resourceTable.ParseResourceFile(str)) + { + wxMessageBox("Could not read file.", "Resource file load error", wxOK | wxICON_EXCLAMATION); + return FALSE; + } + m_currentFilename = str; + + SetFrameTitle(m_currentFilename); + + UpdateResourceList(); + + // Construct include filename from this file + m_symbolFilename = m_currentFilename; + + wxStripExtension(m_symbolFilename); + m_symbolFilename += ".h"; + + if (!m_symbolTable.ReadIncludeFile(m_symbolFilename)) + { + wxString str("Could not find include file "); + str += m_symbolFilename; + str += ".\nDialog Editor maintains a header file containing id symbols to be used in the application.\n"; + str += "The next time this .wxr file is saved, a header file will be saved also."; + wxMessageBox(str, "Dialog Editor Warning", wxOK ); + + m_symbolIdCounter = 99; + } + else + { + // Set the id counter to the last known id + m_symbolIdCounter = m_symbolTable.FindHighestId(); + } + + // Now check in case some (or all) resources don't have resource ids, or they + // don't match the .h file, or something of that nature. + bool altered = RepairResourceIds(); + if (altered) + { + wxMessageBox("Some resources have had new identifiers associated with them, since they were missing.", + "Dialog Editor Warning", wxOK ); + Modify(TRUE); + } + else + Modify(FALSE); + + return TRUE; } else { - // Set the id counter to the last known id - m_symbolIdCounter = m_symbolTable.FindHighestId(); + SetFrameTitle(""); + m_currentFilename = ""; } - - // Now check in case some (or all) resources don't have resource ids, or they - // don't match the .h file, or something of that nature. - bool altered = RepairResourceIds(); - if (altered) - { - wxMessageBox("Some resources have had new identifiers associated with them, since they were missing.", - "Dialog Editor Warning", wxOK ); - Modify(TRUE); - } - else - Modify(FALSE); - + Modify(FALSE); + return TRUE; - } - else - { - SetFrameTitle(""); - m_currentFilename = ""; - } - Modify(FALSE); - - return TRUE; } bool wxResourceManager::Clear(bool WXUNUSED(deleteWindows), bool force) { - wxPropertyInfo::CloseWindow(); - - if (!force && Modified()) - { - int ans = wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO | wxCANCEL); - if (ans == wxCANCEL) - return FALSE; - if (ans == wxYES) - if (!SaveIfModified()) - return FALSE; - if (ans == wxNO) - Modify(FALSE); - } - - ClearCurrentDialog(); - DisassociateWindows(); - - m_symbolTable.Clear(); - m_resourceTable.ClearTable(); - UpdateResourceList(); - - return TRUE; + wxPropertyInfo::CloseWindow(); + + if (!force && Modified()) + { + int ans = wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO | wxCANCEL); + if (ans == wxCANCEL) + return FALSE; + if (ans == wxYES) + if (!SaveIfModified()) + return FALSE; + if (ans == wxNO) + Modify(FALSE); + } + + ClearCurrentDialog(); + DisassociateWindows(); + + m_symbolTable.Clear(); + m_resourceTable.ClearTable(); + UpdateResourceList(); + + return TRUE; } bool wxResourceManager::DisassociateWindows() { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - DisassociateResource(res); - } - - return TRUE; + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) + { + wxItemResource *res = (wxItemResource *)node->Data(); + DisassociateResource(res); + } + + return TRUE; } void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *win) { - if (!m_resourceAssociations.Get((long)resource)) - m_resourceAssociations.Put((long)resource, win); - - wxNode *node = resource->GetChildren().First(); - wxNode* node2 = win->GetChildren().First(); - while (node && node2) - { - wxItemResource *child = (wxItemResource *)node->Data(); - wxWindow* childWindow = (wxWindow*) node2->Data(); - - if (child->GetId() != childWindow->GetId()) + if (!m_resourceAssociations.Get((long)resource)) + m_resourceAssociations.Put((long)resource, win); + + wxNode *node = resource->GetChildren().First(); + wxNode* node2 = win->GetChildren().First(); + while (node && node2) { - wxString msg; - msg.Printf("AssociateResource: error when associating child window %ld with resource %ld", child->GetId(), childWindow->GetId()); - wxMessageBox(msg, "Dialog Editor problem", wxOK); - } - else if (childWindow->GetName() != child->GetName()) - { - wxString msg; - msg.Printf("AssociateResource: error when associating child window with resource %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)"); - wxMessageBox(msg, "Dialog Editor problem", wxOK); - } - else - { - AssociateResource(child, childWindow); - } - - // New code to avoid the problem of duplicate ids and names. We simply - // traverse the child windows and child resources in parallel, - // checking for any mismatch. + wxItemResource *child = (wxItemResource *)node->Data(); + wxWindow* childWindow = (wxWindow*) node2->Data(); + + if (child->GetId() != childWindow->GetId()) + { + wxString msg; + msg.Printf("AssociateResource: error when associating child window %ld with resource %ld", child->GetId(), childWindow->GetId()); + wxMessageBox(msg, "Dialog Editor problem", wxOK); + } + else if (childWindow->GetName() != child->GetName()) + { + wxString msg; + msg.Printf("AssociateResource: error when associating child window with resource %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)"); + wxMessageBox(msg, "Dialog Editor problem", wxOK); + } + else + { + AssociateResource(child, childWindow); + } + + // New code to avoid the problem of duplicate ids and names. We simply + // traverse the child windows and child resources in parallel, + // checking for any mismatch. #if 0 - wxWindow *childWindow = (wxWindow *)m_resourceAssociations.Get((long)child); - if (!childWindow) - // childWindow = win->FindWindow(child->GetName()); - childWindow = win->FindWindow(child->GetId()); - if (childWindow) - AssociateResource(child, childWindow); - else - { - wxString msg; - msg.Printf("AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)"); - wxMessageBox(msg, "Dialog Editor problem", wxOK); - } + wxWindow *childWindow = (wxWindow *)m_resourceAssociations.Get((long)child); + if (!childWindow) + // childWindow = win->FindWindow(child->GetName()); + childWindow = win->FindWindow(child->GetId()); + if (childWindow) + AssociateResource(child, childWindow); + else + { + wxString msg; + msg.Printf("AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)"); + wxMessageBox(msg, "Dialog Editor problem", wxOK); + } #endif - node = node->Next(); - node2 = node2->Next(); - } + node = node->Next(); + node2 = node2->Next(); + } } bool wxResourceManager::DisassociateResource(wxItemResource *resource) { - wxWindow *win = FindWindowForResource(resource); - if (!win) - return FALSE; - - // Disassociate children of window - wxNode *node = win->GetChildren().First(); - while (node) - { - wxWindow *child = (wxWindow *)node->Data(); - if (child->IsKindOf(CLASSINFO(wxControl))) - DisassociateResource(child); - node = node->Next(); - } - - RemoveSelection(win); - m_resourceAssociations.Delete((long)resource); - return TRUE; + wxWindow *win = FindWindowForResource(resource); + if (!win) + return FALSE; + + // Disassociate children of window + wxNode *node = win->GetChildren().First(); + while (node) + { + wxWindow *child = (wxWindow *)node->Data(); + if (child->IsKindOf(CLASSINFO(wxControl))) + DisassociateResource(child); + node = node->Next(); + } + + RemoveSelection(win); + m_resourceAssociations.Delete((long)resource); + return TRUE; } bool wxResourceManager::DisassociateResource(wxWindow *win) { - wxItemResource *res = FindResourceForWindow(win); - if (res) - return DisassociateResource(res); - else - return FALSE; + wxItemResource *res = FindResourceForWindow(win); + if (res) + return DisassociateResource(res); + else + return FALSE; } // Saves the window info into the resource, and deletes the @@ -610,23 +595,23 @@ bool wxResourceManager::DisassociateResource(wxWindow *win) bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow* win) { wxItemResource *res = FindResourceForWindow(win); - + if (win->IsKindOf(CLASSINFO(wxPanel))) { wxResourceEditorDialogHandler* handler = (wxResourceEditorDialogHandler*) win->GetEventHandler(); win->PopEventHandler(); - + // Now reset all child event handlers wxNode *node = win->GetChildren().First(); while ( node ) { - wxWindow *child = (wxWindow *)node->Data(); - wxEvtHandler *childHandler = child->GetEventHandler(); - if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler != child ) - { - child->PopEventHandler(TRUE); - } - node = node->Next(); + wxWindow *child = (wxWindow *)node->Data(); + wxEvtHandler *childHandler = child->GetEventHandler(); + if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler != child ) + { + child->PopEventHandler(TRUE); + } + node = node->Next(); } delete handler; } @@ -634,12 +619,12 @@ bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow* win) { win->PopEventHandler(TRUE); } - + // Save the information InstantiateResourceFromWindow(res, win, TRUE); - -// DisassociateResource(win); - + + // DisassociateResource(win); + return TRUE; } @@ -653,813 +638,948 @@ bool wxResourceManager::DeleteWindow(wxWindow* win) m_editorPanel->m_childWindow = NULL; clearDisplay = TRUE; } - + win->Destroy(); - + if (clearDisplay) m_editorPanel->Clear(); - + return TRUE; } wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win) { - m_resourceAssociations.BeginFind(); - wxNode *node; - while ((node = m_resourceAssociations.Next())) - { - wxWindow *w = (wxWindow *)node->Data(); - if (w == win) + m_resourceAssociations.BeginFind(); + wxNode *node; + while ((node = m_resourceAssociations.Next())) { - return (wxItemResource *)node->GetKeyInteger(); + wxWindow *w = (wxWindow *)node->Data(); + if (w == win) + { + return (wxItemResource *)node->GetKeyInteger(); + } } - } - return NULL; + return NULL; } wxWindow *wxResourceManager::FindWindowForResource(wxItemResource *resource) { - return (wxWindow *)m_resourceAssociations.Get((long)resource); + return (wxWindow *)m_resourceAssociations.Get((long)resource); } void wxResourceManager::MakeUniqueName(char *prefix, char *buf) { - while (TRUE) - { - sprintf(buf, "%s%d", prefix, m_nameCounter); - m_nameCounter ++; - - if (!m_resourceTable.FindResource(buf)) - return; - } + while (TRUE) + { + sprintf(buf, "%s%d", prefix, m_nameCounter); + m_nameCounter ++; + + if (!m_resourceTable.FindResource(buf)) + return; + } } wxFrame *wxResourceManager::OnCreateEditorFrame(const char *title) { - /* - int frameWidth = 420; - int frameHeight = 300; - */ - - wxResourceEditorFrame *frame = new wxResourceEditorFrame(this, NULL, title, - wxPoint(m_resourceEditorWindowSize.x, m_resourceEditorWindowSize.y), - wxSize(m_resourceEditorWindowSize.width, m_resourceEditorWindowSize.height), - wxDEFAULT_FRAME_STYLE); - - frame->CreateStatusBar(1); - - frame->SetAutoLayout(TRUE); + wxResourceEditorFrame *frame = new wxResourceEditorFrame(this, NULL, title, + wxPoint(m_resourceEditorWindowSize.x, m_resourceEditorWindowSize.y), + wxSize(m_resourceEditorWindowSize.width, m_resourceEditorWindowSize.height), + wxDEFAULT_FRAME_STYLE); + + frame->CreateStatusBar(1); + + frame->SetAutoLayout(TRUE); #ifdef __WXMSW__ - frame->SetIcon(wxIcon("DIALOGEDICON")); + frame->SetIcon(wxIcon("DIALOGEDICON")); #endif - return frame; + return frame; } wxMenuBar *wxResourceManager::OnCreateEditorMenuBar(wxFrame *WXUNUSED(parent)) { - wxMenuBar *menuBar = new wxMenuBar; - - wxMenu *fileMenu = new wxMenu; - fileMenu->Append(RESED_NEW_DIALOG, "New &dialog", "Create a new dialog"); - fileMenu->AppendSeparator(); - fileMenu->Append(wxID_NEW, "&New project", "Clear the current project"); - fileMenu->Append(wxID_OPEN, "&Open...", "Load a resource file"); - fileMenu->Append(wxID_SAVE, "&Save", "Save a resource file"); - fileMenu->Append(wxID_SAVEAS, "Save &As...", "Save a resource file as..."); - fileMenu->Append(RESED_CLEAR, "&Clear", "Clear current resources"); - fileMenu->AppendSeparator(); - fileMenu->Append(wxID_EXIT, "E&xit", "Exit resource editor"); - - wxMenu *editMenu = new wxMenu; - editMenu->Append(RESED_TEST, "&Test Dialog", "Test dialog"); - editMenu->Append(RESED_RECREATE, "&Recreate", "Recreate the selected resource(s)"); - editMenu->Append(RESED_DELETE, "&Delete", "Delete the selected resource(s)"); - - wxMenu *helpMenu = new wxMenu; - helpMenu->Append(RESED_CONTENTS, "&Help topics", "Invokes the on-line help"); - helpMenu->AppendSeparator(); - helpMenu->Append(wxID_ABOUT, "&About", "About wxWindows Dialog Editor"); - - menuBar->Append(fileMenu, "&File"); - menuBar->Append(editMenu, "&Edit"); - menuBar->Append(helpMenu, "&Help"); - - return menuBar; + wxMenuBar *menuBar = new wxMenuBar; + + wxMenu *fileMenu = new wxMenu; + fileMenu->Append(RESED_NEW_DIALOG, "New &Dialog", "Create a new dialog"); + fileMenu->AppendSeparator(); + fileMenu->Append(wxID_NEW, "&New Project", "Clear the current project"); + fileMenu->Append(wxID_OPEN, "&Open...", "Load a resource file"); + fileMenu->Append(wxID_SAVE, "&Save", "Save a resource file"); + fileMenu->Append(wxID_SAVEAS, "Save &As...", "Save a resource file as..."); + fileMenu->Append(RESED_CLEAR, "&Clear", "Clear current resources"); + fileMenu->AppendSeparator(); + fileMenu->Append(RESED_CONVERT_WXRS, "Convert Old &Resources...", "Convert old resources to new"); + fileMenu->AppendSeparator(); + fileMenu->Append(wxID_EXIT, "E&xit", "Exit resource editor"); + + wxMenu *editMenu = new wxMenu; + editMenu->Append(RESED_TEST, "&Test Dialog", "Test dialog"); + editMenu->Append(RESED_RECREATE, "&Recreate", "Recreate the selected resource(s)"); + editMenu->Append(RESED_DELETE, "&Delete", "Delete the selected resource(s)"); + + wxMenu *helpMenu = new wxMenu; + helpMenu->Append(RESED_CONTENTS, "&Help Topics", "Invokes the on-line help"); + helpMenu->AppendSeparator(); + helpMenu->Append(wxID_ABOUT, "&About", "About wxWindows Dialog Editor"); + + menuBar->Append(fileMenu, "&File"); + menuBar->Append(editMenu, "&Edit"); + menuBar->Append(helpMenu, "&Help"); + + return menuBar; } wxResourceEditorScrolledWindow *wxResourceManager::OnCreateEditorPanel(wxFrame *parent) { - wxResourceEditorScrolledWindow *panel = new wxResourceEditorScrolledWindow(parent, wxDefaultPosition, wxDefaultSize, -// wxSUNKEN_BORDER|wxCLIP_CHILDREN); + wxResourceEditorScrolledWindow *panel = new wxResourceEditorScrolledWindow(parent, wxDefaultPosition, wxDefaultSize, + // wxSUNKEN_BORDER|wxCLIP_CHILDREN); #ifdef __WXMOTIF__ - wxBORDER); + wxBORDER); #else wxSUNKEN_BORDER); #endif - - panel->SetScrollbars(10, 10, 100, 100); - - return panel; + + panel->SetScrollbars(10, 10, 100, 100); + + return panel; } wxToolBar *wxResourceManager::OnCreateToolBar(wxFrame *parent) { - // Load palette bitmaps + // Load palette bitmaps #ifdef __WXMSW__ - wxBitmap ToolbarLoadBitmap("LOADTOOL"); - wxBitmap ToolbarSaveBitmap("SAVETOOL"); - wxBitmap ToolbarNewBitmap("NEWTOOL"); - wxBitmap ToolbarVertBitmap("VERTTOOL"); - wxBitmap ToolbarAlignTBitmap("ALIGNTTOOL"); - wxBitmap ToolbarAlignBBitmap("ALIGNBTOOL"); - wxBitmap ToolbarHorizBitmap("HORIZTOOL"); - wxBitmap ToolbarAlignLBitmap("ALIGNLTOOL"); - wxBitmap ToolbarAlignRBitmap("ALIGNRTOOL"); - wxBitmap ToolbarCopySizeBitmap("COPYSIZETOOL"); - wxBitmap ToolbarToBackBitmap("TOBACKTOOL"); - wxBitmap ToolbarToFrontBitmap("TOFRONTTOOL"); - wxBitmap ToolbarHelpBitmap("HELPTOOL"); + wxBitmap ToolbarLoadBitmap("LOADTOOL"); + wxBitmap ToolbarSaveBitmap("SAVETOOL"); + wxBitmap ToolbarNewBitmap("NEWTOOL"); + wxBitmap ToolbarVertBitmap("VERTTOOL"); + wxBitmap ToolbarAlignTBitmap("ALIGNTTOOL"); + wxBitmap ToolbarAlignBBitmap("ALIGNBTOOL"); + wxBitmap ToolbarHorizBitmap("HORIZTOOL"); + wxBitmap ToolbarAlignLBitmap("ALIGNLTOOL"); + wxBitmap ToolbarAlignRBitmap("ALIGNRTOOL"); + wxBitmap ToolbarCopySizeBitmap("COPYSIZETOOL"); + wxBitmap ToolbarToBackBitmap("TOBACKTOOL"); + wxBitmap ToolbarToFrontBitmap("TOFRONTTOOL"); + wxBitmap ToolbarHelpBitmap("HELPTOOL"); + wxBitmap ToolbarCopyWidthBitmap("COPYWIDTHTOOL"); + wxBitmap ToolbarCopyHeightBitmap("COPYHEIGHTTOOL"); + wxBitmap ToolbarDistributeHorizBitmap("DISTHORIZTOOL"); + wxBitmap ToolbarDistributeVertBitmap("DISTVERTTOOL"); #endif #if defined(__WXGTK__) || defined(__WXMOTIF__) - wxBitmap ToolbarLoadBitmap( load_xpm ); - wxBitmap ToolbarSaveBitmap( save_xpm); - wxBitmap ToolbarNewBitmap( new_xpm ); - wxBitmap ToolbarVertBitmap( vert_xpm ); - wxBitmap ToolbarAlignTBitmap( alignt_xpm ); - wxBitmap ToolbarAlignBBitmap( alignb_xpm ); - wxBitmap ToolbarHorizBitmap( horiz_xpm ); - wxBitmap ToolbarAlignLBitmap( alignl_xpm ); - wxBitmap ToolbarAlignRBitmap( alignr_xpm ); - wxBitmap ToolbarCopySizeBitmap( copysize_xpm ); - wxBitmap ToolbarToBackBitmap( toback_xpm ); - wxBitmap ToolbarToFrontBitmap( tofront_xpm ); - wxBitmap ToolbarHelpBitmap( help_xpm ); + wxBitmap ToolbarLoadBitmap( load_xpm ); + wxBitmap ToolbarSaveBitmap( save_xpm); + wxBitmap ToolbarNewBitmap( new_xpm ); + wxBitmap ToolbarVertBitmap( vert_xpm ); + wxBitmap ToolbarAlignTBitmap( alignt_xpm ); + wxBitmap ToolbarAlignBBitmap( alignb_xpm ); + wxBitmap ToolbarHorizBitmap( horiz_xpm ); + wxBitmap ToolbarAlignLBitmap( alignl_xpm ); + wxBitmap ToolbarAlignRBitmap( alignr_xpm ); + wxBitmap ToolbarCopySizeBitmap( copysize_xpm ); + wxBitmap ToolbarToBackBitmap( toback_xpm ); + wxBitmap ToolbarToFrontBitmap( tofront_xpm ); + wxBitmap ToolbarHelpBitmap( help_xpm ); + wxBitmap ToolbarCopyWidthBitmap(copywdth_xpm); + wxBitmap ToolbarCopyHeightBitmap(copyhght_xpm); + wxBitmap ToolbarDistributeHorizBitmap(disthor_xpm); + wxBitmap ToolbarDistributeVertBitmap(distvert_xpm); #endif - - // Create the toolbar - EditorToolBar *toolbar = new EditorToolBar(parent, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER|wxTB_HORIZONTAL); - toolbar->SetMargins(2, 2); - + + // Create the toolbar + EditorToolBar *toolbar = new EditorToolBar(parent, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER|wxTB_HORIZONTAL|wxTB_FLAT); + toolbar->SetMargins(2, 2); + #ifdef __WXMSW__ - int width = 24; - int dx = 2; - int gap = 6; + int width = 24; + int dx = 2; + int gap = 6; #else - int width = 24; // ToolbarLoadBitmap->GetWidth(); ??? - int dx = 2; - int gap = 6; + int width = 24; // ToolbarLoadBitmap->GetWidth(); ??? + int dx = 2; + int gap = 6; #endif - int currentX = gap; - toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_NEW, ToolbarNewBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "New dialog"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_LOAD_FILE, ToolbarLoadBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Load"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_SAVE_FILE, ToolbarSaveBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Save"); - currentX += width + dx + gap; - toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_FORMAT_HORIZ, ToolbarVertBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Horizontal align"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN, ToolbarAlignTBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Top align"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN, ToolbarAlignBBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Bottom align"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_VERT, ToolbarHorizBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Vertical align"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN, ToolbarAlignLBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Left align"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN, ToolbarAlignRBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Right align"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_COPY_SIZE, ToolbarCopySizeBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Copy size"); - currentX += width + dx + gap; - toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_TO_FRONT, ToolbarToFrontBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "To front"); - currentX += width + dx; - toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "To back"); - currentX += width + dx + gap; - - toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, wxNullBitmap, - FALSE, currentX, -1, NULL, "Help"); - currentX += width + dx; - - toolbar->Realize(); - - return toolbar; + int currentX = gap; + //toolbar->AddSeparator(); + toolbar->AddTool(TOOLBAR_NEW, ToolbarNewBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "New dialog"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_LOAD_FILE, ToolbarLoadBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Load"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_SAVE_FILE, ToolbarSaveBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Save"); + currentX += width + dx + gap; + toolbar->AddSeparator(); + toolbar->AddTool(TOOLBAR_FORMAT_HORIZ, ToolbarVertBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Horizontal align"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN, ToolbarAlignTBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Top align"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN, ToolbarAlignBBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Bottom align"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_FORMAT_VERT, ToolbarHorizBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Vertical align"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN, ToolbarAlignLBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Left align"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN, ToolbarAlignRBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Right align"); + currentX += width + dx + gap; + toolbar->AddSeparator(); + toolbar->AddTool(TOOLBAR_COPY_SIZE, ToolbarCopySizeBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Copy size"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_COPY_WIDTH, ToolbarCopyWidthBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Copy width"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_COPY_HEIGHT, ToolbarCopyHeightBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Copy height"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_DISTRIBUTE_HORIZ, ToolbarDistributeHorizBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Distribute horizontally"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_DISTRIBUTE_VERT, ToolbarDistributeVertBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Distribute vertically"); + currentX += width + dx + gap; + toolbar->AddSeparator(); + toolbar->AddTool(TOOLBAR_TO_FRONT, ToolbarToFrontBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "To front"); + currentX += width + dx; + toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "To back"); + currentX += width + dx + gap; + + toolbar->AddSeparator(); + toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, wxNullBitmap, + FALSE, currentX, -1, NULL, "Help"); + currentX += width + dx; + + toolbar->Realize(); + + return toolbar; } void wxResourceManager::UpdateResourceList() { - if (!m_editorResourceTree) - return; - - m_editorResourceTree->SetInvalid(TRUE); - m_editorResourceTree->DeleteAllItems(); - - long id = m_editorResourceTree->AddRoot("Dialogs", 1, 2); - - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - wxString resType(res->GetType()); - if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel" || resType == "wxBitmap") + if (!m_editorResourceTree) + return; + + m_editorResourceTree->SetInvalid(TRUE); + m_editorResourceTree->DeleteAllItems(); + + long id = m_editorResourceTree->AddRoot("Dialogs", 1, 2); + + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - AddItemsRecursively(id, res); + wxItemResource *res = (wxItemResource *)node->Data(); + wxString resType(res->GetType()); + if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel" || resType == "wxBitmap") + { + AddItemsRecursively(id, res); + } } - } - m_editorResourceTree->Expand(id); - m_editorResourceTree->SetInvalid(FALSE); + m_editorResourceTree->Expand(id); + m_editorResourceTree->SetInvalid(FALSE); } void wxResourceManager::AddItemsRecursively(long parent, wxItemResource *resource) { - wxString theString(""); - theString = resource->GetName(); - - int imageId = 0; - wxString resType(resource->GetType()); - if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") - imageId = 0; - else - imageId = 3; - - long id = m_editorResourceTree->AppendItem(parent, theString, imageId ); - - m_editorResourceTree->SetItemData(id, new wxResourceTreeData(resource)); - - if (strcmp(resource->GetType(), "wxBitmap") != 0) - { - wxNode *node = resource->GetChildren().First(); - while (node) + wxString theString(""); + theString = resource->GetName(); + + int imageId = 0; + wxString resType(resource->GetType()); + if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") + imageId = 0; + else + imageId = 3; + + long id = m_editorResourceTree->AppendItem(parent, theString, imageId ); + + m_editorResourceTree->SetItemData(id, new wxResourceTreeData(resource)); + + if (strcmp(resource->GetType(), "wxBitmap") != 0) { - wxItemResource *res = (wxItemResource *)node->Data(); - AddItemsRecursively(id, res); - node = node->Next(); + wxNode *node = resource->GetChildren().First(); + while (node) + { + wxItemResource *res = (wxItemResource *)node->Data(); + AddItemsRecursively(id, res); + node = node->Next(); + } } - } -// m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND); + // m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND); } bool wxResourceManager::EditSelectedResource() { - int sel = m_editorResourceTree->GetSelection(); - if (sel != 0) - { - wxResourceTreeData *data = (wxResourceTreeData *)m_editorResourceTree->GetItemData(sel); - wxItemResource *res = data->GetResource(); - return Edit(res); - } - return FALSE; + int sel = m_editorResourceTree->GetSelection(); + if (sel != 0) + { + wxResourceTreeData *data = (wxResourceTreeData *)m_editorResourceTree->GetItemData(sel); + wxItemResource *res = data->GetResource(); + return Edit(res); + } + return FALSE; } bool wxResourceManager::Edit(wxItemResource *res) { - wxPropertyInfo::CloseWindow(); - - ClearCurrentDialog(); - - wxString resType(res->GetType()); - wxPanel *panel = (wxPanel *)FindWindowForResource(res); - - if (panel) - { - wxMessageBox("Should not find panel in wxResourceManager::Edit"); - return FALSE; - } - else - { -// long style = res->GetStyle(); -// res->SetStyle(style|wxRAISED_BORDER); + wxPropertyInfo::CloseWindow(); + + ClearCurrentDialog(); + + wxString resType(res->GetType()); + wxPanel *panel = (wxPanel *)FindWindowForResource(res); + + if (panel) + { + wxMessageBox("Should not find panel in wxResourceManager::Edit"); + return FALSE; + } + else + { + // long style = res->GetStyle(); + // res->SetStyle(style|wxRAISED_BORDER); panel = new wxPanel; wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(panel, res, panel->GetEventHandler(), - this); - + this); + panel->LoadFromResource(m_editorPanel, res->GetName(), &m_resourceTable); - + panel->PushEventHandler(handler); - -// res->SetStyle(style); - handler->AddChildHandlers(); // Add event handlers for all controls + + // res->SetStyle(style); + handler->AddChildHandlers(); // Add event handlers for all controls AssociateResource(res, panel); - + m_editorPanel->m_childWindow = panel; panel->Move(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()); panel->Show(TRUE); panel->Refresh(); - + wxClientDC dc(m_editorPanel); m_editorPanel->DrawTitle(dc); - } - return FALSE; + } + return FALSE; } bool wxResourceManager::CreateNewPanel() { - wxPropertyInfo::CloseWindow(); - - ClearCurrentDialog(); - - char buf[256]; - MakeUniqueName("dialog", buf); - - wxItemResource *resource = new wxItemResource; - resource->SetType("wxDialog"); - resource->SetName(buf); - resource->SetTitle(buf); - resource->SetResourceStyle(wxRESOURCE_USE_DEFAULTS); - resource->SetResourceStyle(wxRESOURCE_DIALOG_UNITS); - - wxString newIdName; - int id = GenerateWindowId("ID_DIALOG", newIdName); - resource->SetId(id); - - // This is now guaranteed to be unique, so just add to symbol table - m_symbolTable.AddSymbol(newIdName, id); - - m_resourceTable.AddResource(resource); - - wxSize size(400, 300); - - wxPanel *panel = new wxPanel(m_editorPanel, -1, - wxPoint(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()), - size, wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf); - m_editorPanel->m_childWindow = panel; - - resource->SetStyle(panel->GetWindowStyleFlag()); - - // Store dialog units in resource - size = panel->ConvertPixelsToDialog(size); - - resource->SetSize(10, 10, size.x, size.y); - - // For editing in situ we will need to use the hash table to ensure - // we don't dereference invalid pointers. -// resourceWindowTable.Put((long)resource, panel); - - wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(panel, resource, panel->GetEventHandler(), - this); - panel->PushEventHandler(handler); - - AssociateResource(resource, panel); - UpdateResourceList(); - - Modify(TRUE); - m_editorPanel->m_childWindow->Refresh(); - -// panel->Refresh(); - - wxClientDC dc(m_editorPanel); - m_editorPanel->DrawTitle(dc); - - return TRUE; + wxPropertyInfo::CloseWindow(); + + ClearCurrentDialog(); + + char buf[256]; + MakeUniqueName("dialog", buf); + + wxItemResource *resource = new wxItemResource; + resource->SetType("wxDialog"); + resource->SetName(buf); + resource->SetTitle(buf); + resource->SetResourceStyle(wxRESOURCE_USE_DEFAULTS); + resource->SetResourceStyle(wxRESOURCE_DIALOG_UNITS); + + wxString newIdName; + int id = GenerateWindowId("ID_DIALOG", newIdName); + resource->SetId(id); + + // This is now guaranteed to be unique, so just add to symbol table + m_symbolTable.AddSymbol(newIdName, id); + + m_resourceTable.AddResource(resource); + + wxSize size(400, 300); + + wxPanel *panel = new wxPanel(m_editorPanel, -1, + wxPoint(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()), + size, wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf); + m_editorPanel->m_childWindow = panel; + + resource->SetStyle(panel->GetWindowStyleFlag()); + + // Store dialog units in resource + size = panel->ConvertPixelsToDialog(size); + + resource->SetSize(10, 10, size.x, size.y); + + // For editing in situ we will need to use the hash table to ensure + // we don't dereference invalid pointers. + // resourceWindowTable.Put((long)resource, panel); + + wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(panel, resource, panel->GetEventHandler(), + this); + panel->PushEventHandler(handler); + + AssociateResource(resource, panel); + UpdateResourceList(); + + Modify(TRUE); + m_editorPanel->m_childWindow->Refresh(); + + // panel->Refresh(); + + wxClientDC dc(m_editorPanel); + m_editorPanel->DrawTitle(dc); + + return TRUE; } bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *panel, char *iType, int x, int y, bool isBitmap) { - char buf[256]; - if (!panel->IsKindOf(CLASSINFO(wxPanel)) && !panel->IsKindOf(CLASSINFO(wxDialog))) - return FALSE; - - Modify(TRUE); - - wxItemResource *res = new wxItemResource; - wxControl *newItem = NULL; - - if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) - { - wxPoint pt = panel->ConvertPixelsToDialog(wxPoint(x, y)); - res->SetSize(pt.x, pt.y, -1, -1); - } - else res->SetSize(x, y, -1, -1); - - res->SetType(iType); - - wxString prefix; - - wxString itemType(iType); - - if (itemType == "wxButton") + char buf[256]; + if (!panel->IsKindOf(CLASSINFO(wxPanel)) && !panel->IsKindOf(CLASSINFO(wxDialog))) + return FALSE; + + Modify(TRUE); + + wxItemResource *res = new wxItemResource; + wxControl *newItem = NULL; + + if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) { - prefix = "ID_BUTTON"; - MakeUniqueName("button", buf); - res->SetName(buf); - if (isBitmap) + wxPoint pt = panel->ConvertPixelsToDialog(wxPoint(x, y)); + res->SetSize(pt.x, pt.y, -1, -1); + } + else res->SetSize(x, y, -1, -1); + + res->SetType(iType); + + wxString prefix; + + wxString itemType(iType); + + if (itemType == "wxButton") + { + prefix = "ID_BUTTON"; + MakeUniqueName("button", buf); + res->SetName(buf); + if (isBitmap) + newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), wxBU_AUTODRAW, wxDefaultValidator, buf); + else + newItem = new wxButton(panel, -1, "Button", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); + } + if (itemType == "wxBitmapButton") + { + prefix = "ID_BITMAPBUTTON"; + MakeUniqueName("button", buf); + res->SetName(buf); newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), wxBU_AUTODRAW, wxDefaultValidator, buf); - else - newItem = new wxButton(panel, -1, "Button", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); } - if (itemType == "wxBitmapButton") + else if (itemType == "wxMessage" || itemType == "wxStaticText") { - prefix = "ID_BITMAPBUTTON"; - MakeUniqueName("button", buf); - res->SetName(buf); - newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), wxBU_AUTODRAW, wxDefaultValidator, buf); + prefix = "ID_STATIC"; + MakeUniqueName("statictext", buf); + res->SetName(buf); + if (isBitmap) + newItem = new wxStaticBitmap(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf); + else + newItem = new wxStaticText(panel, -1, "Static", wxPoint(x, y), wxSize(-1, -1), 0, buf); } - else if (itemType == "wxMessage" || itemType == "wxStaticText") + else if (itemType == "wxStaticBitmap") { - prefix = "ID_STATIC"; - MakeUniqueName("statictext", buf); - res->SetName(buf); - if (isBitmap) - newItem = new wxStaticBitmap(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf); - else - newItem = new wxStaticText(panel, -1, "Static", wxPoint(x, y), wxSize(-1, -1), 0, buf); + prefix = "ID_STATICBITMAP"; + MakeUniqueName("static", buf); + res->SetName(buf); + newItem = new wxStaticBitmap(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf); } - else if (itemType == "wxStaticBitmap") + else if (itemType == "wxCheckBox") { - prefix = "ID_STATICBITMAP"; - MakeUniqueName("static", buf); - res->SetName(buf); - newItem = new wxStaticBitmap(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf); + prefix = "ID_CHECKBOX"; + MakeUniqueName("checkbox", buf); + res->SetName(buf); + newItem = new wxCheckBox(panel, -1, "Checkbox", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); } - else if (itemType == "wxCheckBox") + else if (itemType == "wxListBox") { - prefix = "ID_CHECKBOX"; - MakeUniqueName("checkbox", buf); - res->SetName(buf); - newItem = new wxCheckBox(panel, -1, "Checkbox", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); + prefix = "ID_LISTBOX"; + MakeUniqueName("listbox", buf); + res->SetName(buf); + newItem = new wxListBox(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf); } - else if (itemType == "wxListBox") + else if (itemType == "wxRadioBox") { - prefix = "ID_LISTBOX"; - MakeUniqueName("listbox", buf); - res->SetName(buf); - newItem = new wxListBox(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf); + prefix = "ID_RADIOBOX"; + MakeUniqueName("radiobox", buf); + res->SetName(buf); + wxString names[] = { "One", "Two" }; + newItem = new wxRadioBox(panel, -1, "Radiobox", wxPoint(x, y), wxSize(-1, -1), 2, names, 2, + wxHORIZONTAL, wxDefaultValidator, buf); + res->SetStringValues(wxStringList("One", "Two", NULL)); } - else if (itemType == "wxRadioBox") + else if (itemType == "wxRadioButton") { - prefix = "ID_RADIOBOX"; - MakeUniqueName("radiobox", buf); - res->SetName(buf); - wxString names[] = { "One", "Two" }; - newItem = new wxRadioBox(panel, -1, "Radiobox", wxPoint(x, y), wxSize(-1, -1), 2, names, 2, - wxHORIZONTAL, wxDefaultValidator, buf); - res->SetStringValues(wxStringList("One", "Two", NULL)); + prefix = "ID_RADIOBUTTON"; + MakeUniqueName("radiobutton", buf); + res->SetName(buf); + wxString names[] = { "One", "Two" }; + newItem = new wxRadioButton(panel, -1, "Radiobutton", wxPoint(x, y), wxSize(-1, -1), + 0, wxDefaultValidator, buf); } - else if (itemType == "wxRadioButton") + else if (itemType == "wxChoice") { - prefix = "ID_RADIOBUTTON"; - MakeUniqueName("radiobutton", buf); - res->SetName(buf); - wxString names[] = { "One", "Two" }; - newItem = new wxRadioButton(panel, -1, "Radiobutton", wxPoint(x, y), wxSize(-1, -1), - 0, wxDefaultValidator, buf); + prefix = "ID_CHOICE"; + MakeUniqueName("choice", buf); + res->SetName(buf); + newItem = new wxChoice(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf); } - else if (itemType == "wxChoice") + else if (itemType == "wxComboBox") { - prefix = "ID_CHOICE"; - MakeUniqueName("choice", buf); - res->SetName(buf); - newItem = new wxChoice(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf); + prefix = "ID_COMBOBOX"; + MakeUniqueName("combobox", buf); + res->SetName(buf); + newItem = new wxComboBox(panel, -1, "", wxPoint(x, y), wxSize(-1, -1), 0, NULL, wxCB_DROPDOWN, wxDefaultValidator, buf); } - else if (itemType == "wxComboBox") + else if (itemType == "wxGroupBox" || itemType == "wxStaticBox") { - prefix = "ID_COMBOBOX"; - MakeUniqueName("combobox", buf); - res->SetName(buf); - newItem = new wxComboBox(panel, -1, "", wxPoint(x, y), wxSize(-1, -1), 0, NULL, wxCB_DROPDOWN, wxDefaultValidator, buf); + prefix = "ID_STATICBOX"; + MakeUniqueName("staticbox", buf); + res->SetName(buf); + newItem = new wxStaticBox(panel, -1, "Static", wxPoint(x, y), wxSize(200, 200), 0, buf); } - else if (itemType == "wxGroupBox" || itemType == "wxStaticBox") + else if (itemType == "wxGauge") { - prefix = "ID_STATICBOX"; - MakeUniqueName("staticbox", buf); - res->SetName(buf); - newItem = new wxStaticBox(panel, -1, "Static", wxPoint(x, y), wxSize(200, 200), 0, buf); + prefix = "ID_GAUGE"; + MakeUniqueName("gauge", buf); + res->SetName(buf); + newItem = new wxGauge(panel, -1, 10, wxPoint(x, y), wxSize(80, 30), wxHORIZONTAL, wxDefaultValidator, buf); } - else if (itemType == "wxGauge") + else if (itemType == "wxSlider") { - prefix = "ID_GAUGE"; - MakeUniqueName("gauge", buf); - res->SetName(buf); - newItem = new wxGauge(panel, -1, 10, wxPoint(x, y), wxSize(80, 30), wxHORIZONTAL, wxDefaultValidator, buf); + prefix = "ID_SLIDER"; + MakeUniqueName("slider", buf); + res->SetName(buf); + newItem = new wxSlider(panel, -1, 1, 1, 10, wxPoint(x, y), wxSize(120, -1), wxHORIZONTAL, wxDefaultValidator, buf); } - else if (itemType == "wxSlider") + else if (itemType == "wxText" || itemType == "wxTextCtrl (single-line)") { - prefix = "ID_SLIDER"; - MakeUniqueName("slider", buf); - res->SetName(buf); - newItem = new wxSlider(panel, -1, 1, 1, 10, wxPoint(x, y), wxSize(120, -1), wxHORIZONTAL, wxDefaultValidator, buf); + prefix = "ID_TEXTCTRL"; + MakeUniqueName("textctrl", buf); + res->SetName(buf); + res->SetType("wxTextCtrl"); + newItem = new wxTextCtrl(panel, -1, "", wxPoint(x, y), wxSize(120, -1), 0, wxDefaultValidator, buf); } - else if (itemType == "wxText" || itemType == "wxTextCtrl (single-line)") + else if (itemType == "wxMultiText" || itemType == "wxTextCtrl (multi-line)") { - prefix = "ID_TEXTCTRL"; - MakeUniqueName("textctrl", buf); - res->SetName(buf); - res->SetType("wxTextCtrl"); - newItem = new wxTextCtrl(panel, -1, "", wxPoint(x, y), wxSize(120, -1), 0, wxDefaultValidator, buf); + prefix = "ID_TEXTCTRL"; + MakeUniqueName("textctrl", buf); + res->SetName(buf); + res->SetType("wxTextCtrl"); + newItem = new wxTextCtrl(panel, -1, "", wxPoint(x, y), wxSize(120, 100), wxTE_MULTILINE, wxDefaultValidator, buf); } - else if (itemType == "wxMultiText" || itemType == "wxTextCtrl (multi-line)") + else if (itemType == "wxScrollBar") { - prefix = "ID_TEXTCTRL"; - MakeUniqueName("textctrl", buf); - res->SetName(buf); - res->SetType("wxTextCtrl"); - newItem = new wxTextCtrl(panel, -1, "", wxPoint(x, y), wxSize(120, 100), wxTE_MULTILINE, wxDefaultValidator, buf); + prefix = "ID_SCROLLBAR"; + MakeUniqueName("scrollbar", buf); + res->SetName(buf); + newItem = new wxScrollBar(panel, -1, wxPoint(x, y), wxSize(140, -1), wxHORIZONTAL, wxDefaultValidator, buf); } - else if (itemType == "wxScrollBar") + if (!newItem) + return FALSE; + + int actualW, actualH; + newItem->GetSize(&actualW, &actualH); + wxSize actualSize(actualW, actualH); + + if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) { - prefix = "ID_SCROLLBAR"; - MakeUniqueName("scrollbar", buf); - res->SetName(buf); - newItem = new wxScrollBar(panel, -1, wxPoint(x, y), wxSize(140, -1), wxHORIZONTAL, wxDefaultValidator, buf); + actualSize = panel->ConvertPixelsToDialog(actualSize); } - if (!newItem) - return FALSE; - - int actualW, actualH; - newItem->GetSize(&actualW, &actualH); - wxSize actualSize(actualW, actualH); - - if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) - { - actualSize = panel->ConvertPixelsToDialog(actualSize); - } - res->SetSize(res->GetX(), res->GetY(), actualSize.x, actualSize.y); - - wxString newIdName; - int id = GenerateWindowId(prefix, newIdName); - res->SetId(id); - - // This is now guaranteed to be unique, so just add to symbol table - m_symbolTable.AddSymbol(newIdName, id); - - newItem->PushEventHandler(new wxResourceEditorControlHandler(newItem, newItem)); - - res->SetStyle(newItem->GetWindowStyleFlag()); - AssociateResource(res, newItem); - panelResource->GetChildren().Append(res); - - UpdateResourceList(); - - return TRUE; + res->SetSize(res->GetX(), res->GetY(), actualSize.x, actualSize.y); + + wxString newIdName; + int id = GenerateWindowId(prefix, newIdName); + res->SetId(id); + + // This is now guaranteed to be unique, so just add to symbol table + m_symbolTable.AddSymbol(newIdName, id); + + newItem->PushEventHandler(new wxResourceEditorControlHandler(newItem, newItem)); + + res->SetStyle(newItem->GetWindowStyleFlag()); + AssociateResource(res, newItem); + panelResource->GetChildren().Append(res); + + UpdateResourceList(); + + return TRUE; } void wxResourceManager::ClearCurrentDialog() { - if (m_editorPanel->m_childWindow) - { - SaveInfoAndDeleteHandler(m_editorPanel->m_childWindow); - DisassociateResource(m_editorPanel->m_childWindow); - DeleteWindow(m_editorPanel->m_childWindow); - m_editorPanel->m_childWindow = NULL; - m_editorPanel->Clear(); - } + if (m_editorPanel->m_childWindow) + { + SaveInfoAndDeleteHandler(m_editorPanel->m_childWindow); + DisassociateResource(m_editorPanel->m_childWindow); + DeleteWindow(m_editorPanel->m_childWindow); + m_editorPanel->m_childWindow = NULL; + m_editorPanel->Clear(); + } } bool wxResourceManager::TestCurrentDialog(wxWindow* parent) { - if (m_editorPanel->m_childWindow) - { - wxItemResource* item = FindResourceForWindow(m_editorPanel->m_childWindow); - if (!item) - return FALSE; - - // Make sure the resources are up-to-date w.r.t. the window - InstantiateResourceFromWindow(item, m_editorPanel->m_childWindow, TRUE); - - wxDialog* dialog = new wxDialog; - bool success = FALSE; - if (dialog->LoadFromResource(parent, item->GetName(), & m_resourceTable)) + if (m_editorPanel->m_childWindow) { - dialog->Centre(); - dialog->ShowModal(); - success = TRUE; + wxItemResource* item = FindResourceForWindow(m_editorPanel->m_childWindow); + if (!item) + return FALSE; + + // Make sure the resources are up-to-date w.r.t. the window + InstantiateResourceFromWindow(item, m_editorPanel->m_childWindow, TRUE); + + ResourceEditorDialogTester* dialog = new ResourceEditorDialogTester; + bool success = FALSE; + if (dialog->LoadFromResource(parent, item->GetName(), & m_resourceTable)) + { + dialog->Centre(); + dialog->ShowModal(); + success = TRUE; + } + return success; } - return success; - } - return FALSE; + return FALSE; } // Find the first dialog or panel for which // there is a selected panel item. wxWindow *wxResourceManager::FindParentOfSelection() { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - wxWindow *win = FindWindowForResource(res); - if (win) + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - wxNode *node1 = win->GetChildren().First(); - while (node1) - { - wxControl *item = (wxControl *)node1->Data(); - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected()) - return win; - node1 = node1->Next(); - } + wxItemResource *res = (wxItemResource *)node->Data(); + wxWindow *win = FindWindowForResource(res); + if (win) + { + wxNode *node1 = win->GetChildren().First(); + while (node1) + { + wxControl *item = (wxControl *)node1->Data(); + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected()) + return win; + node1 = node1->Next(); + } + } } - } - return NULL; + return NULL; } // Format the panel items according to 'flag' void wxResourceManager::AlignItems(int flag) { - wxWindow *win = FindParentOfSelection(); - if (!win) - return; - - wxNode *node = GetSelections().First(); - if (!node) - return; + wxWindow *win = FindParentOfSelection(); + if (!win) + return; - wxControl *firstSelection = (wxControl *)node->Data(); - if (firstSelection->GetParent() != win) - return; + wxNode *node = GetSelections().First(); + if (!node) + return; - int firstX, firstY; - int firstW, firstH; - firstSelection->GetPosition(&firstX, &firstY); - firstSelection->GetSize(&firstW, &firstH); - int centreX = (int)(firstX + (firstW / 2)); - int centreY = (int)(firstY + (firstH / 2)); - - while ((node = node->Next())) - { - wxControl *item = (wxControl *)node->Data(); - if (item->GetParent() == win) + wxControl *firstSelection = (wxControl *)node->Data(); + if (firstSelection->GetParent() != win) + return; + + int firstX, firstY; + int firstW, firstH; + firstSelection->GetPosition(&firstX, &firstY); + firstSelection->GetSize(&firstW, &firstH); + int centreX = (int)(firstX + (firstW / 2)); + int centreY = (int)(firstY + (firstH / 2)); + + while ((node = node->Next())) { - int x, y, w, h; - item->GetPosition(&x, &y); - item->GetSize(&w, &h); - - int newX, newY; - - switch (flag) - { - case TOOLBAR_FORMAT_HORIZ: + wxControl *item = (wxControl *)node->Data(); + if (item->GetParent() == win) { - newX = x; - newY = (int)(centreY - (h/2.0)); - break; + int x, y, w, h; + item->GetPosition(&x, &y); + item->GetSize(&w, &h); + + int newX, newY; + + switch (flag) + { + case TOOLBAR_FORMAT_HORIZ: + { + newX = x; + newY = (int)(centreY - (h/2.0)); + break; + } + case TOOLBAR_FORMAT_VERT: + { + newX = (int)(centreX - (w/2.0)); + newY = y; + break; + } + case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN: + { + newX = firstX; + newY = y; + break; + } + case TOOLBAR_FORMAT_VERT_TOP_ALIGN: + { + newX = x; + newY = firstY; + break; + } + case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN: + { + newX = firstX + firstW - w; + newY = y; + break; + } + case TOOLBAR_FORMAT_VERT_BOT_ALIGN: + { + newX = x; + newY = firstY + firstH - h; + break; + } + default: + newX = x; newY = y; + break; + } + + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent()); + + item->SetSize(newX, newY, w, h); + + // Also update the associated resource + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY)); + newX = pt.x; newY = pt.y; + wxSize sz = item->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + resource->SetSize(newX, newY, w, h); } - case TOOLBAR_FORMAT_VERT: - { - newX = (int)(centreX - (w/2.0)); - newY = y; - break; - } - case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN: - { - newX = firstX; - newY = y; - break; - } - case TOOLBAR_FORMAT_VERT_TOP_ALIGN: - { - newX = x; - newY = firstY; - break; - } - case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN: - { - newX = firstX + firstW - w; - newY = y; - break; - } - case TOOLBAR_FORMAT_VERT_BOT_ALIGN: - { - newX = x; - newY = firstY + firstH - h; - break; - } - default: - newX = x; newY = y; - break; - } - - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent()); - - item->SetSize(newX, newY, w, h); - - // Also update the associated resource - // We need to convert to dialog units if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY)); - newX = pt.x; newY = pt.y; - wxSize sz = item->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); - w = sz.x; h = sz.y; - } - resource->SetSize(newX, newY, w, h); } - } - win->Refresh(); + win->Refresh(); } // Copy the first image's size to subsequent images -void wxResourceManager::CopySize() +void wxResourceManager::CopySize(int command) { - wxWindow *win = FindParentOfSelection(); - if (!win) - return; - - wxNode *node = GetSelections().First(); - if (!node) - return; + bool copyWidth = (command == TOOLBAR_COPY_SIZE || command == TOOLBAR_COPY_WIDTH) ; + bool copyHeight = (command == TOOLBAR_COPY_SIZE || command == TOOLBAR_COPY_HEIGHT) ; - wxControl *firstSelection = (wxControl *)node->Data(); - if (firstSelection->GetParent() != win) - return; + wxWindow *win = FindParentOfSelection(); + if (!win) + return; - int firstX, firstY; - int firstW, firstH; - firstSelection->GetPosition(&firstX, &firstY); - firstSelection->GetSize(&firstW, &firstH); - - while ((node = node->Next())) - { - wxControl *item = (wxControl *)node->Data(); - if (item->GetParent() == win) - { - item->SetSize(-1, -1, firstW, firstH); - - int fw = firstW; - int fh = firstH; - - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent()); - - // Also update the associated resource - // We need to convert to dialog units if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxSize sz = item->GetParent()->ConvertPixelsToDialog(wxSize(firstW, firstH)); - fw = sz.x; fh = sz.y; - } - resource->SetSize(resource->GetX(), resource->GetY(), fw, fh); - - } - } - win->Refresh(); + wxNode *node = GetSelections().First(); + if (!node) + return; + + wxControl *firstSelection = (wxControl *)node->Data(); + if (firstSelection->GetParent() != win) + return; + + int firstX, firstY; + int firstW, firstH; + firstSelection->GetPosition(&firstX, &firstY); + firstSelection->GetSize(&firstW, &firstH); + + while ((node = node->Next())) + { + wxControl *item = (wxControl *)node->Data(); + if (item->GetParent() == win) + { + wxSize sz = item->GetSize(); + int widthToSet = (copyWidth ? firstW : sz.x); + int heightToSet = (copyHeight ? firstH : sz.y); + + item->SetSize(-1, -1, widthToSet, heightToSet); + + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent()); + + widthToSet = resource->GetWidth(); + heightToSet = resource->GetHeight(); + + // Also update the associated resource + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize convertedSize = item->GetParent()->ConvertPixelsToDialog(wxSize(firstW, firstH)); + if (copyWidth) + widthToSet = convertedSize.x; + if (copyHeight) + heightToSet = convertedSize.y; + } + resource->SetSize(resource->GetX(), resource->GetY(), widthToSet, heightToSet); + } + } + win->Refresh(); } void wxResourceManager::ToBackOrFront(bool toBack) { - wxWindow *win = FindParentOfSelection(); - if (!win) - return; - wxItemResource *winResource = FindResourceForWindow(win); - - wxNode *node = GetSelections().First(); - while (node) - { - wxControl *item = (wxControl *)node->Data(); - wxItemResource *itemResource = FindResourceForWindow(item); - if (item->GetParent() == win) + wxWindow *win = FindParentOfSelection(); + if (!win) + return; + wxItemResource *winResource = FindResourceForWindow(win); + + wxNode *node = GetSelections().First(); + while (node) { - win->GetChildren().DeleteObject(item); - if (winResource) - winResource->GetChildren().DeleteObject(itemResource); - if (toBack) - { - win->GetChildren().Insert(item); - if (winResource) - winResource->GetChildren().Insert(itemResource); - } - else - { - win->GetChildren().Append(item); - if (winResource) - winResource->GetChildren().Append(itemResource); - } + wxControl *item = (wxControl *)node->Data(); + wxItemResource *itemResource = FindResourceForWindow(item); + if (item->GetParent() == win) + { + win->GetChildren().DeleteObject(item); + if (winResource) + winResource->GetChildren().DeleteObject(itemResource); + if (toBack) + { + win->GetChildren().Insert(item); + if (winResource) + winResource->GetChildren().Insert(itemResource); + } + else + { + win->GetChildren().Append(item); + if (winResource) + winResource->GetChildren().Append(itemResource); + } + } + node = node->Next(); } - node = node->Next(); - } -// win->Refresh(); + // win->Refresh(); +} + +// Distribute controls evenly between first and last +void wxResourceManager::DistributePositions(int command) +{ + bool horizontal = (command == TOOLBAR_DISTRIBUTE_HORIZ) ; + + wxWindow *win = FindParentOfSelection(); + if (!win) + return; + + if (GetSelections().Number() < 3) + { + wxMessageBox(wxT("Sorry, distributing less than three controls does not make sense.")); + return; + } + + wxControl *firstSelection = (wxControl*) GetSelections().First()->Data(); + wxControl *lastSelection = (wxControl*) GetSelections().Last()->Data(); + + // For now, assume the ordering is correct (the user selected the controls in order). + // TODO: explicitly order the selections in terms of increading x or y position. + + // Find the total amount of space between all controls + int totalControlSpace = 0; // How much space the controls take up + + wxNode* node = GetSelections().First(); + while (node) + { + wxControl* control = (wxControl*) node->Data(); + + int x, y; + int w, h; + control->GetPosition(&x, &y); + control->GetSize(&w, &h); + + // Don't include the space taken up by the first and last controls. + if (control != firstSelection && control != lastSelection) + { + if (horizontal) + totalControlSpace += w; + else + totalControlSpace += h; + } + + node = node->Next(); + } + + + int firstX, firstY, lastX, lastY; + int firstW, firstH, lastW, lastH; + firstSelection->GetPosition(&firstX, &firstY); + firstSelection->GetSize(&firstW, &firstH); + + lastSelection->GetPosition(&lastX, &lastY); + lastSelection->GetSize(&lastW, &lastH); + + /* + + firstX lastX + |===| |====| |======| |==| + + */ + + int spacing, currentPos; + if (horizontal) + { + spacing = ((lastX - (firstX + firstW)) - totalControlSpace) / (GetSelections().Number() - 1); + currentPos = firstX + firstW + spacing; + } + else + { + spacing = ((lastY - (firstY + firstH)) - totalControlSpace) / (GetSelections().Number() - 1); + currentPos = firstY + firstH + spacing; + } + + node = GetSelections().First(); + + while ((node = node->Next())) + { + wxControl *item = (wxControl *)node->Data(); + wxSize sz = item->GetSize(); + wxPoint pos = item->GetPosition(); + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent()); + + int controlX = (horizontal ? currentPos : pos.x); + int controlY = (horizontal ? pos.y : currentPos); + + item->Move(controlX, controlY); + + int resX = resource->GetWidth(); + int resY = resource->GetHeight(); + + // Also update the associated resource + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint convertedPos = item->GetParent()->ConvertPixelsToDialog(wxPoint(pos.x, pos.y)); + resX = convertedPos.x; + resY = convertedPos.y; + } + resource->SetSize(resX, resY, resource->GetWidth(), resource->GetHeight()); + + currentPos += (horizontal ? (sz.x + spacing) : (sz.y + spacing)); + } + win->Refresh(); } void wxResourceManager::AddSelection(wxWindow *win) { - if (!m_selections.Member(win)) - m_selections.Append(win); + if (!m_selections.Member(win)) + m_selections.Append(win); } void wxResourceManager::RemoveSelection(wxWindow *win) { - m_selections.DeleteObject(win); + m_selections.DeleteObject(win); } void wxResourceManager::DeselectItemIfNecessary(wxWindow *win) @@ -1485,188 +1605,188 @@ void wxResourceManager::DeselectItemIfNecessary(wxWindow *win) // any resource which has this as a parent. bool wxResourceManager::RemoveResourceFromParent(wxItemResource *res) { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *thisRes = (wxItemResource *)node->Data(); - if (thisRes->GetChildren().Member(res)) + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - thisRes->GetChildren().DeleteObject(res); - return TRUE; + wxItemResource *thisRes = (wxItemResource *)node->Data(); + if (thisRes->GetChildren().Member(res)) + { + thisRes->GetChildren().DeleteObject(res); + return TRUE; + } } - } - return FALSE; + return FALSE; } bool wxResourceManager::DeleteResource(wxItemResource *res) { - if (!res) - return FALSE; - - RemoveResourceFromParent(res); - - wxNode *node = res->GetChildren().First(); - while (node) - { - wxNode *next = node->Next(); - wxItemResource *child = (wxItemResource *)node->Data(); - DeleteResource(child); - node = next; - } - - // If this is a button or message resource, delete the - // associate bitmap resource if not being used. - wxString resType(res->GetType()); - -/* shouldn't have to do this now bitmaps are ref-counted - if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4()) - { + if (!res) + return FALSE; + + RemoveResourceFromParent(res); + + wxNode *node = res->GetChildren().First(); + while (node) + { + wxNode *next = node->Next(); + wxItemResource *child = (wxItemResource *)node->Data(); + DeleteResource(child); + node = next; + } + + // If this is a button or message resource, delete the + // associate bitmap resource if not being used. + wxString resType(res->GetType()); + + /* shouldn't have to do this now bitmaps are ref-counted + if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4()) + { PossiblyDeleteBitmapResource(res->GetValue4()); - } -*/ - - // Remove symbol from table if appropriate - if (!IsSymbolUsed(res, res->GetId())) - { - m_symbolTable.RemoveSymbol(res->GetId()); - } - - m_resourceTable.Delete(res->GetName()); - delete res; - Modify(TRUE); - return TRUE; + } + */ + + // Remove symbol from table if appropriate + if (!IsSymbolUsed(res, res->GetId())) + { + m_symbolTable.RemoveSymbol(res->GetId()); + } + + m_resourceTable.Delete(res->GetName()); + delete res; + Modify(TRUE); + return TRUE; } bool wxResourceManager::DeleteResource(wxWindow *win) { - DeselectItemIfNecessary(win); - - wxItemResource *res = FindResourceForWindow(win); - - DisassociateResource(res); - DeleteResource(res); - UpdateResourceList(); - - return TRUE; + DeselectItemIfNecessary(win); + + wxItemResource *res = FindResourceForWindow(win); + + DisassociateResource(res); + DeleteResource(res); + UpdateResourceList(); + + return TRUE; } // Will eventually have bitmap type information, for different // kinds of bitmap. wxString wxResourceManager::AddBitmapResource(const wxString& filename) { - wxItemResource *resource = FindBitmapResourceByFilename(filename); - if (!resource) - { - char buf[256]; - MakeUniqueName("bitmap", buf); - resource = new wxItemResource; - resource->SetType("wxBitmap"); - resource->SetName(buf); - - // A bitmap resource has one or more children, specifying - // alternative bitmaps. - wxItemResource *child = new wxItemResource; - child->SetType("wxBitmap"); - child->SetName(filename); - child->SetValue1(wxBITMAP_TYPE_BMP); - child->SetValue2(RESOURCE_PLATFORM_ANY); - child->SetValue3(0); // Depth - child->SetSize(0,0,0,0); - resource->GetChildren().Append(child); - - m_resourceTable.AddResource(resource); - - UpdateResourceList(); - } - if (resource) - return resource->GetName(); - else - return wxEmptyString; + wxItemResource *resource = FindBitmapResourceByFilename(filename); + if (!resource) + { + char buf[256]; + MakeUniqueName("bitmap", buf); + resource = new wxItemResource; + resource->SetType("wxBitmap"); + resource->SetName(buf); + + // A bitmap resource has one or more children, specifying + // alternative bitmaps. + wxItemResource *child = new wxItemResource; + child->SetType("wxBitmap"); + child->SetName(filename); + child->SetValue1(wxBITMAP_TYPE_BMP); + child->SetValue2(RESOURCE_PLATFORM_ANY); + child->SetValue3(0); // Depth + child->SetSize(0,0,0,0); + resource->GetChildren().Append(child); + + m_resourceTable.AddResource(resource); + + UpdateResourceList(); + } + if (resource) + return resource->GetName(); + else + return wxEmptyString; } - // Delete the bitmap resource if it isn't being used by another resource. +// Delete the bitmap resource if it isn't being used by another resource. void wxResourceManager::PossiblyDeleteBitmapResource(const wxString& resourceName) { - if (!IsBitmapResourceUsed(resourceName)) - { - wxItemResource *res = m_resourceTable.FindResource(resourceName); - DeleteResource(res); - UpdateResourceList(); - } + if (!IsBitmapResourceUsed(resourceName)) + { + wxItemResource *res = m_resourceTable.FindResource(resourceName); + DeleteResource(res); + UpdateResourceList(); + } } bool wxResourceManager::IsBitmapResourceUsed(const wxString& resourceName) { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - wxString resType(res->GetType()); - if (resType == "wxDialog") + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - wxNode *node1 = res->GetChildren().First(); - while (node1) - { - wxItemResource *child = (wxItemResource *)node1->Data(); - wxString childResType(child->GetType()); - - if ((childResType == "wxMessage" || childResType == "wxButton") && - child->GetValue4() && - (strcmp(child->GetValue4(), resourceName) == 0)) - return TRUE; - node1 = node1->Next(); - } + wxItemResource *res = (wxItemResource *)node->Data(); + wxString resType(res->GetType()); + if (resType == "wxDialog") + { + wxNode *node1 = res->GetChildren().First(); + while (node1) + { + wxItemResource *child = (wxItemResource *)node1->Data(); + wxString childResType(child->GetType()); + + if ((childResType == "wxMessage" || childResType == "wxButton") && + child->GetValue4() && + (strcmp(child->GetValue4(), resourceName) == 0)) + return TRUE; + node1 = node1->Next(); + } + } } - } - return FALSE; + return FALSE; } // Given a wxButton or wxMessage, find the corresponding bitmap filename. wxString wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) { - if (!resource || (resource->GetValue4() == "")) - return wxEmptyString; - wxItemResource *bitmapResource = m_resourceTable.FindResource(resource->GetValue4()); - if (!bitmapResource) - return wxEmptyString; - - wxNode *node = bitmapResource->GetChildren().First(); - while (node) - { - // Eventually augment this to return a bitmap of the right kind or something... - // Maybe the root of the filename remains the same, so it doesn't matter which we - // pick up. Otherwise how do we specify multiple filenames... too boring... - wxItemResource *child = (wxItemResource *)node->Data(); - return child->GetName(); + if (!resource || (resource->GetValue4() == "")) + return wxEmptyString; + wxItemResource *bitmapResource = m_resourceTable.FindResource(resource->GetValue4()); + if (!bitmapResource) + return wxEmptyString; - //node = node->Next(); - } - return wxEmptyString; + wxNode *node = bitmapResource->GetChildren().First(); + while (node) + { + // Eventually augment this to return a bitmap of the right kind or something... + // Maybe the root of the filename remains the same, so it doesn't matter which we + // pick up. Otherwise how do we specify multiple filenames... too boring... + wxItemResource *child = (wxItemResource *)node->Data(); + return child->GetName(); + + //node = node->Next(); + } + return wxEmptyString; } wxItemResource *wxResourceManager::FindBitmapResourceByFilename(const wxString& filename) { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - wxString resType(res->GetType()); - if (resType == "wxBitmap") + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - wxNode *node1 = res->GetChildren().First(); - while (node1) - { - wxItemResource *child = (wxItemResource *)node1->Data(); - if (child->GetName() && (strcmp(child->GetName(), filename) == 0)) - return res; - node1 = node1->Next(); - } + wxItemResource *res = (wxItemResource *)node->Data(); + wxString resType(res->GetType()); + if (resType == "wxBitmap") + { + wxNode *node1 = res->GetChildren().First(); + while (node1) + { + wxItemResource *child = (wxItemResource *)node1->Data(); + if (child->GetName() && (strcmp(child->GetName(), filename) == 0)) + return res; + node1 = node1->Next(); + } + } } - } - return NULL; + return NULL; } // Is this window identifier symbol in use? @@ -1675,29 +1795,29 @@ wxItemResource *wxResourceManager::FindBitmapResourceByFilename(const wxString& // in use. bool wxResourceManager::IsSymbolUsed(wxItemResource* thisResource, wxWindowID id) { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - - wxString resType(res->GetType()); - if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - if ((res != thisResource) && (res->GetId() == id)) - return TRUE; - - wxNode *node1 = res->GetChildren().First(); - while (node1) - { - wxItemResource *child = (wxItemResource *)node1->Data(); - if ((child != thisResource) && (child->GetId() == id)) - return TRUE; - node1 = node1->Next(); - } + wxItemResource *res = (wxItemResource *)node->Data(); + + wxString resType(res->GetType()); + if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") + { + if ((res != thisResource) && (res->GetId() == id)) + return TRUE; + + wxNode *node1 = res->GetChildren().First(); + while (node1) + { + wxItemResource *child = (wxItemResource *)node1->Data(); + if ((child != thisResource) && (child->GetId() == id)) + return TRUE; + node1 = node1->Next(); + } + } } - } - return FALSE; + return FALSE; } // Is this window identifier compatible with the given name? (i.e. @@ -1718,29 +1838,29 @@ bool wxResourceManager::IsIdentifierOK(const wxString& name, wxWindowID id) // must be changed. void wxResourceManager::ChangeIds(int oldId, int newId) { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - - wxString resType(res->GetType()); - if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - if (res->GetId() == oldId) - res->SetId(newId); - - wxNode *node1 = res->GetChildren().First(); - while (node1) - { - wxItemResource *child = (wxItemResource *)node1->Data(); - if (child->GetId() == oldId) - child->SetId(newId); - - node1 = node1->Next(); - } + wxItemResource *res = (wxItemResource *)node->Data(); + + wxString resType(res->GetType()); + if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") + { + if (res->GetId() == oldId) + res->SetId(newId); + + wxNode *node1 = res->GetChildren().First(); + while (node1) + { + wxItemResource *child = (wxItemResource *)node1->Data(); + if (child->GetId() == oldId) + child->SetId(newId); + + node1 = node1->Next(); + } + } } - } } // If any resource ids were missing (or their symbol was missing), @@ -1748,314 +1868,314 @@ void wxResourceManager::ChangeIds(int oldId, int newId) // needed repairing. bool wxResourceManager::RepairResourceIds() { - bool repaired = FALSE; - - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - wxString resType(res->GetType()); - if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") + bool repaired = FALSE; + + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - - if ( (res->GetId() == 0) || ((res->GetId() > 0) && !m_symbolTable.IdExists(res->GetId())) ) - { - wxString newSymbolName; - int newId = GenerateWindowId("ID_DIALOG", newSymbolName) ; - - if (res->GetId() == 0) - { - res->SetId(newId); - m_symbolTable.AddSymbol(newSymbolName, newId); - } - else - { - m_symbolTable.AddSymbol(newSymbolName, res->GetId()); - } - - repaired = TRUE; - } - - wxNode *node1 = res->GetChildren().First(); - while (node1) - { - wxItemResource *child = (wxItemResource *)node1->Data(); - - if ( (child->GetId() == 0) || ((child->GetId() > 0) && !m_symbolTable.IdExists(child->GetId())) ) + wxItemResource *res = (wxItemResource *)node->Data(); + wxString resType(res->GetType()); + if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel") { - wxString newSymbolName; - int newId = GenerateWindowId("ID_CONTROL", newSymbolName) ; - - if (child->GetId() == 0) + + if ( (res->GetId() == 0) || ((res->GetId() > 0) && !m_symbolTable.IdExists(res->GetId())) ) { - child->SetId(newId); - m_symbolTable.AddSymbol(newSymbolName, newId); + wxString newSymbolName; + int newId = GenerateWindowId("ID_DIALOG", newSymbolName) ; + + if (res->GetId() == 0) + { + res->SetId(newId); + m_symbolTable.AddSymbol(newSymbolName, newId); + } + else + { + m_symbolTable.AddSymbol(newSymbolName, res->GetId()); + } + + repaired = TRUE; } - else + + wxNode *node1 = res->GetChildren().First(); + while (node1) { - m_symbolTable.AddSymbol(newSymbolName, child->GetId()); + wxItemResource *child = (wxItemResource *)node1->Data(); + + if ( (child->GetId() == 0) || ((child->GetId() > 0) && !m_symbolTable.IdExists(child->GetId())) ) + { + wxString newSymbolName; + int newId = GenerateWindowId("ID_CONTROL", newSymbolName) ; + + if (child->GetId() == 0) + { + child->SetId(newId); + m_symbolTable.AddSymbol(newSymbolName, newId); + } + else + { + m_symbolTable.AddSymbol(newSymbolName, child->GetId()); + } + + repaired = TRUE; + } + + node1 = node1->Next(); } - - repaired = TRUE; } - - node1 = node1->Next(); - } } - } - return repaired; + return repaired; } - // Deletes 'win' and creates a new window from the resource that - // was associated with it. E.g. if you can't change properties on the - // fly, you'll need to delete the window and create it again. +// Deletes 'win' and creates a new window from the resource that +// was associated with it. E.g. if you can't change properties on the +// fly, you'll need to delete the window and create it again. wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowPropertyInfo *info, bool instantiateFirst) { - wxItemResource *resource = FindResourceForWindow(win); - - // Put the current window properties into the wxItemResource object - - wxWindowPropertyInfo *newInfo = NULL; - if (!info) - { - newInfo = CreatePropertyInfoForWindow(win); - info = newInfo; - } - - // May not always want to copy values back from the resource - if (instantiateFirst) - info->InstantiateResource(resource); - - wxWindow *newWin = NULL; - wxWindow *parent = win->GetParent(); - wxItemResource* parentResource = NULL; - if (parent) - parentResource = FindResourceForWindow(parent); - - if (win->IsKindOf(CLASSINFO(wxPanel))) - { - Edit(resource); - newWin = FindWindowForResource(resource); - } - else - { - DisassociateResource(resource); - if (win->GetEventHandler() != win) - win->PopEventHandler(TRUE); - - DeleteWindow(win); - newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource, parentResource); - newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin)); - AssociateResource(resource, newWin); - UpdateResourceList(); - } - - if (info) - info->SetPropertyWindow(newWin); + wxItemResource *resource = FindResourceForWindow(win); - if (newInfo) - delete newInfo; - - return newWin; + // Put the current window properties into the wxItemResource object + + wxWindowPropertyInfo *newInfo = NULL; + if (!info) + { + newInfo = CreatePropertyInfoForWindow(win); + info = newInfo; + } + + // May not always want to copy values back from the resource + if (instantiateFirst) + info->InstantiateResource(resource); + + wxWindow *newWin = NULL; + wxWindow *parent = win->GetParent(); + wxItemResource* parentResource = NULL; + if (parent) + parentResource = FindResourceForWindow(parent); + + if (win->IsKindOf(CLASSINFO(wxPanel))) + { + Edit(resource); + newWin = FindWindowForResource(resource); + } + else + { + DisassociateResource(resource); + if (win->GetEventHandler() != win) + win->PopEventHandler(TRUE); + + DeleteWindow(win); + newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource, parentResource); + newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin)); + AssociateResource(resource, newWin); + UpdateResourceList(); + } + + if (info) + info->SetPropertyWindow(newWin); + + if (newInfo) + delete newInfo; + + return newWin; } // Delete resource highlighted in the listbox bool wxResourceManager::DeleteSelection() { - int sel = m_editorResourceTree->GetSelection(); - if (sel != 0) - { - wxResourceTreeData *data = (wxResourceTreeData *)m_editorResourceTree->GetItemData(sel); - wxItemResource *res = data->GetResource(); - wxWindow *win = FindWindowForResource(res); - if (win) + int sel = m_editorResourceTree->GetSelection(); + if (sel != 0) { - DeleteResource(win); - DeleteWindow(win); - UpdateResourceList(); - Modify(TRUE); + wxResourceTreeData *data = (wxResourceTreeData *)m_editorResourceTree->GetItemData(sel); + wxItemResource *res = data->GetResource(); + wxWindow *win = FindWindowForResource(res); + if (win) + { + DeleteResource(win); + DeleteWindow(win); + UpdateResourceList(); + Modify(TRUE); + } + return TRUE; } - return TRUE; - } - - return FALSE; + + return FALSE; } // Delete resource highlighted in the listbox bool wxResourceManager::RecreateSelection() { - wxNode *node = GetSelections().First(); - while (node) - { - wxControl *item = (wxControl *)node->Data(); - wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - wxNode *next = node->Next(); - childHandler->SelectItem(FALSE); - - RemoveSelection(item); - - RecreateWindowFromResource(item); - - node = next; - } - return TRUE; + wxNode *node = GetSelections().First(); + while (node) + { + wxControl *item = (wxControl *)node->Data(); + wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); + wxNode *next = node->Next(); + childHandler->SelectItem(FALSE); + + RemoveSelection(item); + + RecreateWindowFromResource(item); + + node = next; + } + return TRUE; } bool wxResourceManager::EditDialog(wxDialog *WXUNUSED(dialog), wxWindow *WXUNUSED(parent)) { - return FALSE; + return FALSE; } // Ensures that all currently shown windows are saved to resources, // e.g. just before writing to a .wxr file. bool wxResourceManager::InstantiateAllResourcesFromWindows() { - m_resourceTable.BeginFind(); - wxNode *node; - while ((node = m_resourceTable.Next())) - { - wxItemResource *res = (wxItemResource *)node->Data(); - wxString resType(res->GetType()); - - if (resType == "wxDialog") + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) { - wxWindow *win = (wxWindow *)FindWindowForResource(res); - if (win) - InstantiateResourceFromWindow(res, win, TRUE); + wxItemResource *res = (wxItemResource *)node->Data(); + wxString resType(res->GetType()); + + if (resType == "wxDialog") + { + wxWindow *win = (wxWindow *)FindWindowForResource(res); + if (win) + InstantiateResourceFromWindow(res, win, TRUE); + } + else if (resType == "wxPanel") + { + wxWindow *win = (wxWindow *)FindWindowForResource(res); + if (win) + InstantiateResourceFromWindow(res, win, TRUE); + } } - else if (resType == "wxPanel") - { - wxWindow *win = (wxWindow *)FindWindowForResource(res); - if (win) - InstantiateResourceFromWindow(res, win, TRUE); - } - } - return TRUE; + return TRUE; } bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource *resource, wxWindow *window, bool recurse) { - wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(window); - info->SetResource(resource); - info->InstantiateResource(resource); - delete info; - - if (recurse) - { - wxNode *node = resource->GetChildren().First(); - while (node) + wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(window); + info->SetResource(resource); + info->InstantiateResource(resource); + delete info; + + if (recurse) { - wxItemResource *child = (wxItemResource *)node->Data(); - wxWindow *childWindow = FindWindowForResource(child); - - if (!childWindow) - { - char buf[200]; - sprintf(buf, "Could not find window %s", (const char*) child->GetName()); - wxMessageBox(buf, "Dialog Editor problem", wxOK); - } - else - InstantiateResourceFromWindow(child, childWindow, recurse); - node = node->Next(); + wxNode *node = resource->GetChildren().First(); + while (node) + { + wxItemResource *child = (wxItemResource *)node->Data(); + wxWindow *childWindow = FindWindowForResource(child); + + if (!childWindow) + { + char buf[200]; + sprintf(buf, "Could not find window %s", (const char*) child->GetName()); + wxMessageBox(buf, "Dialog Editor problem", wxOK); + } + else + InstantiateResourceFromWindow(child, childWindow, recurse); + node = node->Next(); + } } - } - - return TRUE; + + return TRUE; } // Create a window information object for the give window wxWindowPropertyInfo *wxResourceManager::CreatePropertyInfoForWindow(wxWindow *win) { - wxWindowPropertyInfo *info = NULL; - if (win->IsKindOf(CLASSINFO(wxScrollBar))) - { - info = new wxScrollBarPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxStaticBox))) - { - info = new wxGroupBoxPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxCheckBox))) - { - info = new wxCheckBoxPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxSlider))) - { - info = new wxSliderPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxGauge))) - { - info = new wxGaugePropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxListBox))) - { - info = new wxListBoxPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxRadioBox))) - { - info = new wxRadioBoxPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxRadioButton))) - { - info = new wxRadioButtonPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxComboBox))) - { - info = new wxComboBoxPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxChoice))) - { - info = new wxChoicePropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxBitmapButton))) - { - info = new wxBitmapButtonPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxButton))) - { - info = new wxButtonPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxStaticBitmap))) - { - info = new wxStaticBitmapPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxStaticText))) - { - info = new wxStaticTextPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxTextCtrl))) - { - info = new wxTextPropertyInfo(win); - } - else if (win->IsKindOf(CLASSINFO(wxPanel))) - { - info = new wxPanelPropertyInfo(win); - } - else - { - info = new wxWindowPropertyInfo(win); - } - return info; + wxWindowPropertyInfo *info = NULL; + if (win->IsKindOf(CLASSINFO(wxScrollBar))) + { + info = new wxScrollBarPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxStaticBox))) + { + info = new wxGroupBoxPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxCheckBox))) + { + info = new wxCheckBoxPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxSlider))) + { + info = new wxSliderPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxGauge))) + { + info = new wxGaugePropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxListBox))) + { + info = new wxListBoxPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxRadioBox))) + { + info = new wxRadioBoxPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxRadioButton))) + { + info = new wxRadioButtonPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxComboBox))) + { + info = new wxComboBoxPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxChoice))) + { + info = new wxChoicePropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxBitmapButton))) + { + info = new wxBitmapButtonPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxButton))) + { + info = new wxButtonPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxStaticBitmap))) + { + info = new wxStaticBitmapPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxStaticText))) + { + info = new wxStaticTextPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxTextCtrl))) + { + info = new wxTextPropertyInfo(win); + } + else if (win->IsKindOf(CLASSINFO(wxPanel))) + { + info = new wxPanelPropertyInfo(win); + } + else + { + info = new wxWindowPropertyInfo(win); + } + return info; } // Edit the given window void wxResourceManager::EditWindow(wxWindow *win) { - wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(win); - if (info) - { - info->SetResource(FindResourceForWindow(win)); - wxString str("Editing "); - str += win->GetClassInfo()->GetClassName(); - str += ": "; - if (win->GetName() != "") - str += win->GetName(); - else - str += "properties"; - info->Edit(NULL, str); - } + wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(win); + if (info) + { + info->SetResource(FindResourceForWindow(win)); + wxString str("Editing "); + str += win->GetClassInfo()->GetClassName(); + str += ": "; + if (win->GetName() != "") + str += win->GetName(); + else + str += "properties"; + info->Edit(NULL, str); + } } // Generate a window id and a first stab at a name @@ -2064,98 +2184,104 @@ int wxResourceManager::GenerateWindowId(const wxString& prefix, wxString& idName m_symbolIdCounter ++; while (m_symbolTable.IdExists(m_symbolIdCounter)) m_symbolIdCounter ++; - + int nameId = m_symbolIdCounter; - + wxString str; str.Printf("%d", nameId); idName = prefix + str; - + while (m_symbolTable.SymbolExists(idName)) { nameId ++; str.Printf("%d", nameId); idName = prefix + str; } - + return m_symbolIdCounter; } /* - * Resource editor frame - */ +* Resource editor frame +*/ IMPLEMENT_CLASS(wxResourceEditorFrame, wxFrame) BEGIN_EVENT_TABLE(wxResourceEditorFrame, wxFrame) - EVT_MENU(wxID_NEW, wxResourceEditorFrame::OnNew) - EVT_MENU(RESED_NEW_DIALOG, wxResourceEditorFrame::OnNewDialog) - EVT_MENU(wxID_OPEN, wxResourceEditorFrame::OnOpen) - EVT_MENU(RESED_CLEAR, wxResourceEditorFrame::OnClear) - EVT_MENU(wxID_SAVE, wxResourceEditorFrame::OnSave) - EVT_MENU(wxID_SAVEAS, wxResourceEditorFrame::OnSaveAs) - EVT_MENU(wxID_EXIT, wxResourceEditorFrame::OnExit) - EVT_MENU(wxID_ABOUT, wxResourceEditorFrame::OnAbout) - EVT_MENU(RESED_CONTENTS, wxResourceEditorFrame::OnContents) - EVT_MENU(RESED_DELETE, wxResourceEditorFrame::OnDeleteSelection) - EVT_MENU(RESED_RECREATE, wxResourceEditorFrame::OnRecreateSelection) - EVT_MENU(RESED_TEST, wxResourceEditorFrame::OnTest) - EVT_CLOSE(wxResourceEditorFrame::OnCloseWindow) +EVT_MENU(wxID_NEW, wxResourceEditorFrame::OnNew) +EVT_MENU(RESED_NEW_DIALOG, wxResourceEditorFrame::OnNewDialog) +EVT_MENU(wxID_OPEN, wxResourceEditorFrame::OnOpen) +EVT_MENU(RESED_CLEAR, wxResourceEditorFrame::OnClear) +EVT_MENU(wxID_SAVE, wxResourceEditorFrame::OnSave) +EVT_MENU(wxID_SAVEAS, wxResourceEditorFrame::OnSaveAs) +EVT_MENU(wxID_EXIT, wxResourceEditorFrame::OnExit) +EVT_MENU(wxID_ABOUT, wxResourceEditorFrame::OnAbout) +EVT_MENU(RESED_CONTENTS, wxResourceEditorFrame::OnContents) +EVT_MENU(RESED_DELETE, wxResourceEditorFrame::OnDeleteSelection) +EVT_MENU(RESED_RECREATE, wxResourceEditorFrame::OnRecreateSelection) +EVT_MENU(RESED_TEST, wxResourceEditorFrame::OnTest) +EVT_MENU(RESED_CONVERT_WXRS, wxResourceEditorFrame::OnConvertWXRs) +EVT_CLOSE(wxResourceEditorFrame::OnCloseWindow) END_EVENT_TABLE() wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title, - const wxPoint& pos, const wxSize& size, long style, const wxString& name): - wxFrame(parent, -1, title, pos, size, style, name) + const wxPoint& pos, const wxSize& size, long style, const wxString& name): +wxFrame(parent, -1, title, pos, size, style, name) { - manager = resMan; + manager = resMan; } wxResourceEditorFrame::~wxResourceEditorFrame() { } +void wxResourceEditorFrame::OnConvertWXRs(wxCommandEvent& WXUNUSED(event)) +{ + manager->ConvertWXRs(); +} + void wxResourceEditorFrame::OnNew(wxCommandEvent& WXUNUSED(event)) { - manager->New(FALSE); + manager->New(FALSE); } void wxResourceEditorFrame::OnNewDialog(wxCommandEvent& WXUNUSED(event)) { - manager->CreateNewPanel(); + manager->CreateNewPanel(); } void wxResourceEditorFrame::OnOpen(wxCommandEvent& WXUNUSED(event)) { - manager->New(TRUE); + manager->New(TRUE); } void wxResourceEditorFrame::OnClear(wxCommandEvent& WXUNUSED(event)) { - manager->Clear(TRUE, FALSE); + manager->Clear(TRUE, FALSE); } void wxResourceEditorFrame::OnSave(wxCommandEvent& WXUNUSED(event)) { - manager->Save(); + manager->Save(); } void wxResourceEditorFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event)) { - manager->SaveAs(); + manager->SaveAs(); } void wxResourceEditorFrame::OnExit(wxCommandEvent& WXUNUSED(event)) { - manager->Clear(TRUE, FALSE) ; - this->Destroy(); + manager->Clear(TRUE, FALSE) ; + this->Destroy(); } void wxResourceEditorFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - char buf[300]; - sprintf(buf, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart \nJulian Smart (c) 1996-1999", wxDIALOG_EDITOR_VERSION); - wxMessageBox(buf, "About Dialog Editor", wxOK|wxCENTRE); + char buf[300]; + sprintf(buf, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart \nJulian Smart (c) 1996-1999", wxDIALOG_EDITOR_VERSION); + wxMessageBox(buf, "About Dialog Editor", wxOK|wxCENTRE); } void wxResourceEditorFrame::OnTest(wxCommandEvent& WXUNUSED(event)) @@ -2166,70 +2292,71 @@ void wxResourceEditorFrame::OnTest(wxCommandEvent& WXUNUSED(event)) void wxResourceEditorFrame::OnContents(wxCommandEvent& WXUNUSED(event)) { #ifdef __WXMSW__ - wxBeginBusyCursor(); - manager->GetHelpController()->LoadFile(); - manager->GetHelpController()->DisplayContents(); - wxEndBusyCursor(); + wxBeginBusyCursor(); + manager->GetHelpController()->LoadFile(); + manager->GetHelpController()->DisplayContents(); + wxEndBusyCursor(); #endif } void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent& WXUNUSED(event)) { - manager->DeleteSelection(); + manager->DeleteSelection(); } void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent& WXUNUSED(event)) { - manager->RecreateSelection(); + manager->RecreateSelection(); } void wxResourceEditorFrame::OnCloseWindow(wxCloseEvent& event) { - wxPropertyInfo::CloseWindow(); - if (manager->Modified()) - { - if (!manager->Clear(TRUE, FALSE)) - { - event.Veto(); - return; + wxPropertyInfo::CloseWindow(); + manager->ClearCurrentDialog(); + if (manager->Modified()) + { + if (!manager->Clear(TRUE, FALSE)) + { + event.Veto(); + return; + } } - } - if (!IsIconized()) - { - int w, h; - GetSize(&w, &h); - manager->m_resourceEditorWindowSize.width = w; - manager->m_resourceEditorWindowSize.height = h; - - int x, y; - GetPosition(&x, &y); - - manager->m_resourceEditorWindowSize.x = x; - manager->m_resourceEditorWindowSize.y = y; - } - manager->SetEditorFrame(NULL); - manager->SetEditorToolBar(NULL); - - this->Destroy(); + if (!IsIconized()) + { + int w, h; + GetSize(&w, &h); + manager->m_resourceEditorWindowSize.width = w; + manager->m_resourceEditorWindowSize.height = h; + + int x, y; + GetPosition(&x, &y); + + manager->m_resourceEditorWindowSize.x = x; + manager->m_resourceEditorWindowSize.y = y; + } + manager->SetEditorFrame(NULL); + manager->SetEditorToolBar(NULL); + + this->Destroy(); } /* - * Resource editor window that contains the dialog/panel being edited - */ +* Resource editor window that contains the dialog/panel being edited +*/ BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow, wxScrolledWindow) - EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint) +EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint) END_EVENT_TABLE() wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size, - long style): - wxScrolledWindow(parent, -1, pos, size, style) + long style): +wxScrolledWindow(parent, -1, pos, size, style) { m_marginX = 10; m_marginY = 40; m_childWindow = NULL; - + SetBackgroundColour(* wxWHITE); } @@ -2240,7 +2367,7 @@ wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow() void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); - + DrawTitle(dc); } @@ -2254,15 +2381,15 @@ void wxResourceEditorScrolledWindow::DrawTitle(wxDC& dc) wxString str(res->GetTitle()); int x, y; ViewStart(& x, & y); - + wxFont font(10, wxSWISS, wxNORMAL, wxBOLD); dc.SetFont(font); dc.SetBackgroundMode(wxTRANSPARENT); dc.SetTextForeground(wxColour(0, 0, 0)); - + long w, h; dc.GetTextExtent(str, & w, & h); - + dc.DrawText(str, m_marginX + (- x * 10), m_marginY + (- y * 10) - h - 5); } } @@ -2271,181 +2398,548 @@ void wxResourceEditorScrolledWindow::DrawTitle(wxDC& dc) // Popup menu callback void ObjectMenuProc(wxMenu *menu, wxCommandEvent& event) { - wxWindow *data = (wxWindow *)menu->GetClientData(); - if (!data) - return; - - switch (event.GetInt()) - { + wxWindow *data = (wxWindow *)menu->GetClientData(); + if (!data) + return; + + switch (event.GetInt()) + { case OBJECT_MENU_EDIT: - { - wxResourceManager::GetCurrentResourceManager()->EditWindow(data); - break; - } + { + wxResourceManager::GetCurrentResourceManager()->EditWindow(data); + break; + } case OBJECT_MENU_DELETE: - { - wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(data); - - wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data); - wxResourceManager::GetCurrentResourceManager()->DeleteResource(data); - wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data); - break; - } + { + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(data); + + wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data); + wxResourceManager::GetCurrentResourceManager()->DeleteResource(data); + wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data); + break; + } default: - break; - } + break; + } } /* - * Main toolbar - * - */ +* Main toolbar +* +*/ BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar) // EVT_PAINT(EditorToolBar::OnPaint) END_EVENT_TABLE() EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size, - long style): - wxToolBar(frame, -1, pos, size, style) + long style): +wxToolBar(frame, -1, pos, size, style) { } bool EditorToolBar::OnLeftClick(int toolIndex, bool WXUNUSED(toggled)) { - wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager(); - - switch (toolIndex) - { + wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager(); + + switch (toolIndex) + { case TOOLBAR_LOAD_FILE: - { - manager->New(TRUE); - break; - } + { + manager->New(TRUE); + break; + } case TOOLBAR_NEW: - { - manager->CreateNewPanel(); - break; - } + { + manager->CreateNewPanel(); + break; + } case TOOLBAR_SAVE_FILE: - { - manager->Save(); - break; - } + { + manager->Save(); + break; + } case TOOLBAR_HELP: - { + { #ifdef __WXMSW__ - wxBeginBusyCursor(); - manager->GetHelpController()->LoadFile(); - manager->GetHelpController()->DisplayContents(); - wxEndBusyCursor(); + wxBeginBusyCursor(); + manager->GetHelpController()->DisplayContents(); + wxEndBusyCursor(); #endif - break; - } + break; + } case TOOLBAR_FORMAT_HORIZ: - { - manager->AlignItems(TOOLBAR_FORMAT_HORIZ); - break; - } + { + manager->AlignItems(TOOLBAR_FORMAT_HORIZ); + break; + } case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN: - { - manager->AlignItems(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN); - break; - } + { + manager->AlignItems(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN); + break; + } case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN: - { - manager->AlignItems(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN); - break; - } + { + manager->AlignItems(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN); + break; + } case TOOLBAR_FORMAT_VERT: - { - manager->AlignItems(TOOLBAR_FORMAT_VERT); - break; - } + { + manager->AlignItems(TOOLBAR_FORMAT_VERT); + break; + } case TOOLBAR_FORMAT_VERT_TOP_ALIGN: - { - manager->AlignItems(TOOLBAR_FORMAT_VERT_TOP_ALIGN); - break; - } + { + manager->AlignItems(TOOLBAR_FORMAT_VERT_TOP_ALIGN); + break; + } case TOOLBAR_FORMAT_VERT_BOT_ALIGN: - { - manager->AlignItems(TOOLBAR_FORMAT_VERT_BOT_ALIGN); - break; - } + { + manager->AlignItems(TOOLBAR_FORMAT_VERT_BOT_ALIGN); + break; + } case TOOLBAR_COPY_SIZE: - { - manager->CopySize(); - break; - } + { + manager->CopySize(TOOLBAR_COPY_SIZE); + break; + } + case TOOLBAR_COPY_WIDTH: + { + manager->CopySize(TOOLBAR_COPY_WIDTH); + break; + } + case TOOLBAR_COPY_HEIGHT: + { + manager->CopySize(TOOLBAR_COPY_HEIGHT); + break; + } + case TOOLBAR_DISTRIBUTE_HORIZ: + { + manager->DistributePositions(TOOLBAR_DISTRIBUTE_HORIZ); + break; + } + case TOOLBAR_DISTRIBUTE_VERT: + { + manager->DistributePositions(TOOLBAR_DISTRIBUTE_VERT); + break; + } case TOOLBAR_TO_BACK: - { - manager->ToBackOrFront(TRUE); - break; - } + { + manager->ToBackOrFront(TRUE); + break; + } case TOOLBAR_TO_FRONT: - { - manager->ToBackOrFront(FALSE); - break; - } + { + manager->ToBackOrFront(FALSE); + break; + } default: - break; - } - return TRUE; + break; + } + return TRUE; } void EditorToolBar::OnMouseEnter(int toolIndex) { - wxFrame *frame = (wxFrame *)GetParent(); - - if (!frame) return; - - if (toolIndex > -1) - { - switch (toolIndex) - { + wxFrame *frame = (wxFrame *)GetParent(); + + if (!frame) return; + + if (toolIndex > -1) + { + switch (toolIndex) + { case TOOLBAR_LOAD_FILE: - frame->SetStatusText("Load project file"); - break; + frame->SetStatusText("Load project file"); + break; case TOOLBAR_SAVE_FILE: - frame->SetStatusText("Save project file"); - break; + frame->SetStatusText("Save project file"); + break; case TOOLBAR_NEW: - frame->SetStatusText("Create a new resource"); - break; + frame->SetStatusText("Create a new resource"); + break; case TOOLBAR_FORMAT_HORIZ: - frame->SetStatusText("Align items horizontally"); - break; + frame->SetStatusText("Align items horizontally"); + break; case TOOLBAR_FORMAT_VERT: - frame->SetStatusText("Align items vertically"); - break; + frame->SetStatusText("Align items vertically"); + break; case TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN: - frame->SetStatusText("Left-align items"); - break; + frame->SetStatusText("Left-align items"); + break; case TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN: - frame->SetStatusText("Right-align items"); - break; + frame->SetStatusText("Right-align items"); + break; case TOOLBAR_FORMAT_VERT_TOP_ALIGN: - frame->SetStatusText("Top-align items"); - break; + frame->SetStatusText("Top-align items"); + break; case TOOLBAR_FORMAT_VERT_BOT_ALIGN: - frame->SetStatusText("Bottom-align items"); - break; + frame->SetStatusText("Bottom-align items"); + break; case TOOLBAR_COPY_SIZE: - frame->SetStatusText("Copy size from first selection"); - break; + frame->SetStatusText("Copy size from first selection"); + break; case TOOLBAR_TO_FRONT: - frame->SetStatusText("Put image to front"); - break; + frame->SetStatusText("Put image to front"); + break; case TOOLBAR_TO_BACK: - frame->SetStatusText("Put image to back"); - break; + frame->SetStatusText("Put image to back"); + break; case TOOLBAR_HELP: - frame->SetStatusText("Display help contents"); - break; + frame->SetStatusText("Display help contents"); + break; default: - break; - } - } - else frame->SetStatusText(""); + break; + } + } + else frame->SetStatusText(""); } +bool ResourceEditorDialogTester::ProcessEvent(wxEvent& event) +{ + if (event.IsCommandEvent() && event.GetId() != wxID_OK && event.GetId() != wxID_CANCEL) + { + // Do nothing + return TRUE; + } + else + return wxDialog::ProcessEvent(event); +} + +static int gs_LabelInsertionCount = 0; + +// Convert old WXRs to new +bool wxResourceManager::ConvertWXRs() +{ + gs_LabelInsertionCount = 0; + m_symbolIdCounter = 20000; + + wxString currentPath = wxGetCwd(); + wxString oldWXRPath, newWXRPath; + + wxDirDialog dialog(NULL, wxT("Choose directory for old WXRs"), currentPath); + + if (dialog.ShowModal() == wxID_OK) + { + oldWXRPath = dialog.GetPath(); + } + else + return FALSE; + + wxDirDialog dialog2(NULL, wxT("Choose directory for new WXRs"), oldWXRPath); + + if (dialog2.ShowModal() == wxID_OK) + { + newWXRPath = dialog2.GetPath(); + } + else + return FALSE; + + if (newWXRPath == oldWXRPath) + { + wxMessageBox(wxT("Sorry, the directories must be different.")); + return FALSE; + } + + wxDir dir(oldWXRPath); + if (!dir.IsOpened()) + return FALSE; + + wxArrayString stringArray; + + wxString filename; + bool ok = dir.GetFirst(& filename, wxT("*.wxr")); + while (ok) + { + stringArray.Add(filename); + + ok = dir.GetNext(& filename); + } + + // Pop up a progress dialog + wxProgressDialog progressDialog(wxT("Converting WXR files"), wxT("Converting files...")); + + size_t i; + for (i = 0; i < stringArray.Count(); i++) + { + progressDialog.Update((int) (100.0 * ((double) i / (double) stringArray.Count()))); + + filename = stringArray[i]; + wxString oldPath = oldWXRPath + wxString(wxFILE_SEP_PATH) + filename; + wxString newPath = newWXRPath + wxString(wxFILE_SEP_PATH) + filename; + + DoConvertWXR(oldPath, newPath); + } + + wxString msg; + msg.Printf(wxT("Dialog Editor inserted %d labels."), gs_LabelInsertionCount); + wxMessageBox(msg); + + return TRUE; +} + +bool wxResourceManager::DoConvertWXR(const wxString& oldPath, const wxString& newPath) +{ + + if (!Clear(TRUE, FALSE)) + return FALSE; + + m_symbolTable.AddStandardSymbols(); + + if (!m_resourceTable.ParseResourceFile(oldPath)) + { + wxString msg; + msg.Printf(wxT("Could not read file %s"), (const char*) oldPath); + wxMessageBox(msg, "Resource file load error", wxOK | wxICON_EXCLAMATION); + return FALSE; + } + m_currentFilename = oldPath; + + //SetFrameTitle(m_currentFilename); + + //UpdateResourceList(); + + // Construct include filename from this file + m_symbolFilename = m_currentFilename; + + wxStripExtension(m_symbolFilename); + m_symbolFilename += wxT(".h"); + + if (!m_symbolTable.ReadIncludeFile(m_symbolFilename)) + { + } + else + { + // Set the id counter to the last known id + m_symbolIdCounter = m_symbolTable.FindHighestId(); + } + + // Now check in case some (or all) resources don't have resource ids, or they + // don't match the .h file, or something of that nature. + bool altered = RepairResourceIds(); + + // Do any necessary changes to the resources + m_resourceTable.BeginFind(); + wxNode *node; + while ((node = m_resourceTable.Next())) + { + wxItemResource *res = (wxItemResource *)node->Data(); + ChangeOldToNewResource(NULL, res); + } + + // Change the filename before saving + + m_currentFilename = newPath; + m_symbolFilename = m_currentFilename; + wxStripExtension(m_symbolFilename); + m_symbolFilename += wxT(".h"); + + Modify(TRUE); + + Save(); + + Clear(TRUE, TRUE); + + return TRUE; + +} + +bool wxResourceManager::ChangeOldToNewResource(wxItemResource* parent, wxItemResource* res) +{ + // Change these according to your needs + + // Change all fonts to use system defaults for fonts, colours etc. + static bool s_useSystemDefaultsAlways = FALSE; // TRUE; + + // Increase dialog height by this amount (wxWin 2 uses dialog client size now) + static int s_increaseDialogSize = -18; + + // How many points to decrease the font sizes by, since + // wxWin 2 fonts are larger in Windows + static int s_decreaseFontSize = 3; + + wxString itemType(res->GetType()); + + wxFont font = res->GetFont(); + + if ((s_decreaseFontSize) > 0 && font.Ok()) + { + wxFont newFont = wxFont(font.GetPointSize() - s_decreaseFontSize, + font.GetFamily(), font.GetStyle(), font.GetWeight(), + font.GetUnderlined(), font.GetFaceName()); + res->SetFont(newFont); + } + + if (itemType == wxT("wxDialogBox") || itemType == wxT("wxDialog") || itemType == wxT("wxPanel")) + { + if (itemType == wxT("wxDialogBox")) + res->SetType(wxT("wxDialog")); + + if (itemType == wxT("wxDialogBox") || itemType == wxT("wxDialog")) + res->SetSize(res->GetX(), res->GetY(), res->GetWidth(), res->GetHeight() + s_increaseDialogSize ); + + if (s_useSystemDefaultsAlways) + res->SetResourceStyle(res->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS); + + wxNode *node = res->GetChildren().First(); + while (node) + { + wxItemResource *child = (wxItemResource *)node->Data(); + + ChangeOldToNewResource(res, child); + node = node->Next(); + } + } + else if (itemType == wxT("wxMessage")) + { + // Figure out if this is a bitmap or text message + if (res->GetValue4().IsEmpty()) + res->SetType(wxT("wxStaticText")); + else + res->SetType(wxT("wxStaticBitmap")); + } + else if (itemType == wxT("wxButton")) + { + // Figure out if this is a bitmap or text message + if (res->GetValue4().IsEmpty()) + { + } + else + res->SetType(wxT("wxBitmapButton")); + } + else if (itemType == wxT("wxGroupBox")) + { + res->SetType(wxT("wxStaticBox")); + } + else if (itemType == wxT("wxText")) + { + res->SetType(wxT("wxTextCtrl")); + } + else if (itemType == wxT("wxMultiText")) + { + res->SetType(wxT("wxTextCtrl")); + res->SetStyle(res->GetStyle() | wxTE_MULTILINE); + } + + itemType = res->GetType(); + + if (!res->GetTitle().IsEmpty() && + (itemType == wxT("wxTextCtrl") || itemType == wxT("wxChoice") || + itemType == wxT("wxComboBox") || itemType == wxT("wxGauge") || + itemType == wxT("wxListBox"))) + { + // Insert a label control resource, adjusting the size of this + // resource accordingly. + InsertLabelResource(parent, res); + } + + return TRUE; +} + +// Insert a label control resource, adjusting the size of this +// resource accordingly. +bool wxResourceManager::InsertLabelResource(wxItemResource* parent, wxItemResource* res) +{ + gs_LabelInsertionCount ++; + + bool isHorizontal = TRUE; + + // Determine panel orientation + if (parent->GetResourceStyle() & wxRESOURCE_VERTICAL_LABEL) + { + isHorizontal = FALSE; + } + else if (parent->GetResourceStyle() & wxRESOURCE_HORIZONTAL_LABEL) + { + isHorizontal = TRUE; + } + + // Now override + if (res->GetResourceStyle() & wxRESOURCE_VERTICAL_LABEL) + { + isHorizontal = FALSE; + } + else if (res->GetResourceStyle() & wxRESOURCE_HORIZONTAL_LABEL) + { + isHorizontal = TRUE; + } + + int x = res->GetX(); + int y = res->GetY(); + int width = res->GetWidth(); + int height = res->GetHeight(); + + // Find the font specified + wxFont font; + if (res->GetFont().Ok()) + font = res->GetFont(); + else + font = parent->GetFont(); + + if (!font.Ok() || (parent->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS)) + font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + + int labelX, labelY; + wxCoord labelWidth, labelHeight; + wxScreenDC dc; + dc.SetFont(font); + dc.GetTextExtent(res->GetTitle(), & labelWidth, & labelHeight); + + // Vert/horizontal margin between controls + int margin = 3; + + labelX = x; + labelY = y; + //labelWidth += 1; + //labelHeight += 1; + + if (isHorizontal) + { + x += labelWidth + margin; + width -= (labelWidth + margin); + } + else + { + y += labelHeight + margin; + height -= (labelHeight + margin); + + // Fudge factors + if (res->GetType() == wxT("wxTextCtrl")) + { + height += 3; + } + else if (res->GetType() == wxT("wxChoice") || res->GetType() == wxT("wxComboBox")) + { + height -= 4; + } + } + + res->SetSize(x, y, width, height); + + wxItemResource* staticItem = new wxItemResource; + staticItem->SetSize(labelX, labelY, labelWidth, labelHeight); + staticItem->SetTitle(res->GetTitle()); + staticItem->SetFont(font); + staticItem->SetStyle(0); + staticItem->SetType(wxT("wxStaticText")); + + wxString newSymbolName; + int newId = GenerateWindowId(wxT("ID_STATICTEXT"), newSymbolName) ; + staticItem->SetId(newId); + + newSymbolName = res->GetName() + wxT("_Label"); + staticItem->SetName(newSymbolName); + m_symbolTable.AddSymbol(newSymbolName, newId); + + wxNode* node = parent->GetChildren().Member(res); + + wxASSERT( (node != NULL) ); + + parent->GetChildren().Insert(node, staticItem); + + // Remove the title from this resource since we've replaced it + // with a static text control + res->SetTitle(wxEmptyString); + + return TRUE; +} diff --git a/utils/dialoged/src/reseditr.h b/utils/dialoged/src/reseditr.h index 021b867195..89d108e1e0 100644 --- a/utils/dialoged/src/reseditr.h +++ b/utils/dialoged/src/reseditr.h @@ -12,7 +12,7 @@ #ifndef _RESEDITR_H_ #define _RESEDITR_H_ -#define wxDIALOG_EDITOR_VERSION 1.7 +#define wxDIALOG_EDITOR_VERSION 2.1 #ifdef __GNUG__ #pragma interface "reseditr.h" @@ -30,17 +30,18 @@ #include "symbtabl.h" #include "winstyle.h" -#define RESED_DELETE 1 -#define RESED_RECREATE 3 -#define RESED_CLEAR 4 -#define RESED_NEW_DIALOG 5 -#define RESED_NEW_PANEL 6 -#define RESED_TEST 10 +#define RESED_DELETE 301 +#define RESED_RECREATE 303 +#define RESED_CLEAR 304 +#define RESED_NEW_DIALOG 305 +#define RESED_NEW_PANEL 306 +#define RESED_TEST 310 +#define RESED_CONVERT_WXRS 311 // Convert old WXRs to new -#define RESED_CONTENTS 20 +#define RESED_CONTENTS 320 -#define IDC_TREECTRL 100 -#define IDC_LISTCTRL 101 +#define IDC_TREECTRL 500 +#define IDC_LISTCTRL 501 // For control list ('palette') #define RESED_POINTER 0 @@ -65,8 +66,8 @@ #define RESED_SPINBUTTON 19 /* - * Controls loading, saving, user interface of resource editor(s). - */ +* Controls loading, saving, user interface of resource editor(s). +*/ class wxResourceEditorFrame; class EditorToolBar; @@ -83,373 +84,365 @@ class wxResourceEditorControlList; class wxHelpController; /* - * The resourceTable contains a list of wxItemResources (which each may - * have further children, defining e.g. a dialog box with controls). - * - * We need to associate actual windows with each wxItemResource, - * instead of the current 'one current window' scheme. - * - * - We create a new dialog, create a wxItemResource, - * associate the dialog with wxItemResource via a hash table. - * Must be a hash table in case dialog is deleted without - * telling the resource manager. - * - When we save the resource after editing/closing the dialog, - * we check the wxItemResource/wxDialog and children for - * consistency (throw away items no longer in the wxDialog, - * create any new wxItemResources). - * - We save the wxItemResources via the wxPropertyInfo classes, - * so devolve the code to the appropriate class. - * This involves creating a new temporary wxPropertyInfo for - * the purpose. - * - * We currently assume we only create one instance of a window for - * each wxItemResource. We will need to relax this when we're editing - * in situ. - * - * - */ - +* The resourceTable contains a list of wxItemResources (which each may +* have further children, defining e.g. a dialog box with controls). +* +* We need to associate actual windows with each wxItemResource, +* instead of the current 'one current window' scheme. +* +* - We create a new dialog, create a wxItemResource, +* associate the dialog with wxItemResource via a hash table. +* Must be a hash table in case dialog is deleted without +* telling the resource manager. +* - When we save the resource after editing/closing the dialog, +* we check the wxItemResource/wxDialog and children for +* consistency (throw away items no longer in the wxDialog, +* create any new wxItemResources). +* - We save the wxItemResources via the wxPropertyInfo classes, +* so devolve the code to the appropriate class. +* This involves creating a new temporary wxPropertyInfo for +* the purpose. +* +* We currently assume we only create one instance of a window for +* each wxItemResource. We will need to relax this when we're editing +* in situ. +* +* +*/ + class wxResourceTableWithSaving: public wxResourceTable { - public: - wxResourceTableWithSaving():wxResourceTable() - { - // Add all known window styles - m_styleTable.Init(); - } - virtual bool Save(const wxString& filename); - virtual bool SaveResource(wxTextOutputStream& stream, wxItemResource* item, wxItemResource* parentItem); - - void GeneratePanelStyleString(long windowStyle, char *buf); - void GenerateDialogStyleString(long windowStyle, char *buf); - -/* - void GenerateRadioBoxStyleString(long windowStyle, char *buf); - void GenerateMessageStyleString(long windowStyle, char *buf); - void GenerateTextStyleString(long windowStyle, char *buf); - void GenerateButtonStyleString(long windowStyle, char *buf); - void GenerateCheckBoxStyleString(long windowStyle, char *buf); - void GenerateRadioButtonStyleString(long windowStyle, char *buf); - void GenerateListBoxStyleString(long windowStyle, char *buf); - void GenerateSliderStyleString(long windowStyle, char *buf); - void GenerateGroupBoxStyleString(long windowStyle, char *buf); - void GenerateGaugeStyleString(long windowStyle, char *buf); - void GenerateChoiceStyleString(long windowStyle, char *buf); - void GenerateComboBoxStyleString(long windowStyle, char *buf); - void GenerateScrollBarStyleString(long windowStyle, char *buf); -*/ - - void GenerateControlStyleString(const wxString& windowClass, long windowStyle, char *buf); - -/* - bool GenerateStyle(char *buf, long windowStyle, long flag, char *strStyle); -*/ - - void OutputFont(wxTextOutputStream& stream, const wxFont& font); - wxControl *CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource); - +public: + wxResourceTableWithSaving():wxResourceTable() + { + // Add all known window styles + m_styleTable.Init(); + } + virtual bool Save(const wxString& filename); + virtual bool SaveResource(wxTextOutputStream& stream, wxItemResource* item, wxItemResource* parentItem); + + void GeneratePanelStyleString(long windowStyle, char *buf); + void GenerateDialogStyleString(long windowStyle, char *buf); + + void GenerateControlStyleString(const wxString& windowClass, long windowStyle, char *buf); + + void OutputFont(wxTextOutputStream& stream, const wxFont& font); + wxControl *CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource); + protected: - wxWindowStyleTable m_styleTable; + wxWindowStyleTable m_styleTable; }; - + class wxResourceEditorScrolledWindow; class wxResourceManager: public wxObject { - friend class wxResourceEditorFrame; - + friend class wxResourceEditorFrame; + public: - wxResourceManager(); - ~wxResourceManager(); + wxResourceManager(); + ~wxResourceManager(); + + // Operations + + // Initializes the resource manager + bool Initialize(); + + // Load/save window size etc. + bool LoadOptions(); + bool SaveOptions(); + + // Show or hide the resource editor frame, which displays a list + // of resources with ability to edit them. + virtual bool ShowResourceEditor(bool show, wxWindow *parent = NULL, const char *title = "wxWindows Dialog Editor"); + + // Convert old WXRs to new + virtual bool ConvertWXRs(); + bool DoConvertWXR(const wxString& oldPath, const wxString& newPath); + bool ChangeOldToNewResource(wxItemResource* parent, wxItemResource* res); + bool InsertLabelResource(wxItemResource* parent, wxItemResource* res); -// Operations - - // Initializes the resource manager - bool Initialize(); - - // Load/save window size etc. - bool LoadOptions(); - bool SaveOptions(); - - // Show or hide the resource editor frame, which displays a list - // of resources with ability to edit them. - virtual bool ShowResourceEditor(bool show, wxWindow *parent = NULL, const char *title = "wxWindows Dialog Editor"); - - virtual bool Save(); - virtual bool SaveAs(); - virtual bool Save(const wxString& filename); - virtual bool Load(const wxString& filename); - virtual bool Clear(bool deleteWindows = TRUE, bool force = TRUE); - virtual void SetFrameTitle(const wxString& filename); - virtual void ClearCurrentDialog(); - virtual bool New(bool loadFromFile = TRUE, const wxString& filename = ""); - virtual bool SaveIfModified(); - virtual void AlignItems(int flag); - virtual void CopySize(); - virtual void ToBackOrFront(bool toBack); - virtual wxWindow *FindParentOfSelection(); - - virtual wxFrame *OnCreateEditorFrame(const char *title); - virtual wxMenuBar *OnCreateEditorMenuBar(wxFrame *parent); - virtual wxResourceEditorScrolledWindow *OnCreateEditorPanel(wxFrame *parent); - virtual wxToolBar *OnCreateToolBar(wxFrame *parent); - - // Create a window information object for the give window - wxWindowPropertyInfo* CreatePropertyInfoForWindow(wxWindow *win); - // Edit the given window - void EditWindow(wxWindow *win); - - virtual void UpdateResourceList(); - virtual void AddItemsRecursively(long parent, wxItemResource *resource); - virtual bool EditSelectedResource(); - virtual bool Edit(wxItemResource *res); - virtual bool CreateNewPanel(); - virtual bool CreatePanelItem(wxItemResource *panelResource, wxPanel *panel, char *itemType, int x = 10, int y = 10, bool isBitmap = FALSE); - virtual bool DeleteSelection(); - virtual bool TestCurrentDialog(wxWindow* parent); - - // Saves the window info into the resource, and deletes the - // handler. Doesn't actually disassociate the window from - // the resources. Replaces OnClose. - virtual bool SaveInfoAndDeleteHandler(wxWindow* win); - - // Destroys the window. If this is the 'current' panel, NULLs the - // variable. - virtual bool DeleteWindow(wxWindow* win); - virtual bool DeleteResource(wxItemResource *res); - virtual bool DeleteResource(wxWindow *win); - - // Add bitmap resource if there isn't already one with this filename. - virtual wxString AddBitmapResource(const wxString& filename); - - // Delete the bitmap resource if it isn't being used by another resource. - virtual void PossiblyDeleteBitmapResource(const wxString& resourceName); - - // Helper function for above - virtual bool IsBitmapResourceUsed(const wxString& resourceName); - - wxItemResource *FindBitmapResourceByFilename(const wxString& filename); - - wxString FindBitmapFilenameForResource(wxItemResource *resource); - - // Is this window identifier in use? - bool IsSymbolUsed(wxItemResource* thisResource, wxWindowID id) ; - - // Is this window identifier compatible with the given name? (i.e. - // does it already exist under a different name) - bool IsIdentifierOK(const wxString& name, wxWindowID id); - - // Change all integer ids that match oldId, to newId. - // This is necessary if an id is changed for one resource - all resources - // must be changed. - void ChangeIds(int oldId, int newId); - - // If any resource ids were missing (or their symbol was missing), - // repair them i.e. give them new ids. Returns TRUE if any resource - // needed repairing. - bool RepairResourceIds(); - - // Deletes 'win' and creates a new window from the resource that - // was associated with it. E.g. if you can't change properties on the - // fly, you'll need to delete the window and create it again. - virtual wxWindow *RecreateWindowFromResource(wxWindow *win, wxWindowPropertyInfo *info = NULL, bool instantiateFirst = TRUE); - - virtual bool RecreateSelection(); - - // Remove selection handles if this control is selected - void DeselectItemIfNecessary(wxWindow *win); - - // Need to search through resource table removing this from - // any resource which has this as a parent. - virtual bool RemoveResourceFromParent(wxItemResource *res); - - virtual bool EditDialog(wxDialog *dialog, wxWindow *parent); - - void AddSelection(wxWindow *win); - void RemoveSelection(wxWindow *win); - - virtual void MakeUniqueName(char *prefix, char *buf); - - // (Dis)associate resource<->physical window - // Doesn't delete any windows. - virtual void AssociateResource(wxItemResource *resource, wxWindow *win); - virtual bool DisassociateResource(wxItemResource *resource); - virtual bool DisassociateResource(wxWindow *win); - virtual bool DisassociateWindows(); - virtual wxItemResource *FindResourceForWindow(wxWindow *win); - virtual wxWindow *FindWindowForResource(wxItemResource *resource); - - virtual bool InstantiateAllResourcesFromWindows(); - virtual bool InstantiateResourceFromWindow(wxItemResource *resource, wxWindow *window, bool recurse = FALSE); - -// Accessors - inline void SetEditorFrame(wxFrame *fr) { m_editorFrame = fr; } - inline void SetEditorToolBar(EditorToolBar *tb) { m_editorToolBar = tb; } - inline wxFrame *GetEditorFrame() const { return m_editorFrame; } - inline wxResourceEditorProjectTree *GetEditorResourceTree() const { return m_editorResourceTree; } - inline wxResourceEditorControlList *GetEditorControlList() const { return m_editorControlList; } - inline wxList& GetSelections() { return m_selections; } - inline wxMenu *GetPopupMenu() const { return m_popupMenu; } + virtual bool Save(); + virtual bool SaveAs(); + virtual bool Save(const wxString& filename); + virtual bool Load(const wxString& filename); + virtual bool Clear(bool deleteWindows = TRUE, bool force = TRUE); + virtual void SetFrameTitle(const wxString& filename); + virtual void ClearCurrentDialog(); + virtual bool New(bool loadFromFile = TRUE, const wxString& filename = ""); + virtual bool SaveIfModified(); + virtual void AlignItems(int flag); + virtual void CopySize(int command); // Copy width, height or both from first control + virtual void ToBackOrFront(bool toBack); + virtual void DistributePositions(int command); // Distribute controls evenly between first and last + virtual wxWindow *FindParentOfSelection(); + + virtual wxFrame *OnCreateEditorFrame(const char *title); + virtual wxMenuBar *OnCreateEditorMenuBar(wxFrame *parent); + virtual wxResourceEditorScrolledWindow *OnCreateEditorPanel(wxFrame *parent); + virtual wxToolBar *OnCreateToolBar(wxFrame *parent); + + // Create a window information object for the give window + wxWindowPropertyInfo* CreatePropertyInfoForWindow(wxWindow *win); + // Edit the given window + void EditWindow(wxWindow *win); + + virtual void UpdateResourceList(); + virtual void AddItemsRecursively(long parent, wxItemResource *resource); + virtual bool EditSelectedResource(); + virtual bool Edit(wxItemResource *res); + virtual bool CreateNewPanel(); + virtual bool CreatePanelItem(wxItemResource *panelResource, wxPanel *panel, char *itemType, int x = 10, int y = 10, bool isBitmap = FALSE); + virtual bool DeleteSelection(); + virtual bool TestCurrentDialog(wxWindow* parent); + + // Saves the window info into the resource, and deletes the + // handler. Doesn't actually disassociate the window from + // the resources. Replaces OnClose. + virtual bool SaveInfoAndDeleteHandler(wxWindow* win); + + // Destroys the window. If this is the 'current' panel, NULLs the + // variable. + virtual bool DeleteWindow(wxWindow* win); + virtual bool DeleteResource(wxItemResource *res); + virtual bool DeleteResource(wxWindow *win); + + // Add bitmap resource if there isn't already one with this filename. + virtual wxString AddBitmapResource(const wxString& filename); + + // Delete the bitmap resource if it isn't being used by another resource. + virtual void PossiblyDeleteBitmapResource(const wxString& resourceName); + + // Helper function for above + virtual bool IsBitmapResourceUsed(const wxString& resourceName); + + wxItemResource *FindBitmapResourceByFilename(const wxString& filename); + + wxString FindBitmapFilenameForResource(wxItemResource *resource); + + // Is this window identifier in use? + bool IsSymbolUsed(wxItemResource* thisResource, wxWindowID id) ; + + // Is this window identifier compatible with the given name? (i.e. + // does it already exist under a different name) + bool IsIdentifierOK(const wxString& name, wxWindowID id); + + // Change all integer ids that match oldId, to newId. + // This is necessary if an id is changed for one resource - all resources + // must be changed. + void ChangeIds(int oldId, int newId); + + // If any resource ids were missing (or their symbol was missing), + // repair them i.e. give them new ids. Returns TRUE if any resource + // needed repairing. + bool RepairResourceIds(); + + // Deletes 'win' and creates a new window from the resource that + // was associated with it. E.g. if you can't change properties on the + // fly, you'll need to delete the window and create it again. + virtual wxWindow *RecreateWindowFromResource(wxWindow *win, wxWindowPropertyInfo *info = NULL, bool instantiateFirst = TRUE); + + virtual bool RecreateSelection(); + + // Remove selection handles if this control is selected + void DeselectItemIfNecessary(wxWindow *win); + + // Need to search through resource table removing this from + // any resource which has this as a parent. + virtual bool RemoveResourceFromParent(wxItemResource *res); + + virtual bool EditDialog(wxDialog *dialog, wxWindow *parent); + + void AddSelection(wxWindow *win); + void RemoveSelection(wxWindow *win); + + virtual void MakeUniqueName(char *prefix, char *buf); + + // (Dis)associate resource<->physical window + // Doesn't delete any windows. + virtual void AssociateResource(wxItemResource *resource, wxWindow *win); + virtual bool DisassociateResource(wxItemResource *resource); + virtual bool DisassociateResource(wxWindow *win); + virtual bool DisassociateWindows(); + virtual wxItemResource *FindResourceForWindow(wxWindow *win); + virtual wxWindow *FindWindowForResource(wxItemResource *resource); + + virtual bool InstantiateAllResourcesFromWindows(); + virtual bool InstantiateResourceFromWindow(wxItemResource *resource, wxWindow *window, bool recurse = FALSE); + + // Accessors + inline void SetEditorFrame(wxFrame *fr) { m_editorFrame = fr; } + inline void SetEditorToolBar(EditorToolBar *tb) { m_editorToolBar = tb; } + inline wxFrame *GetEditorFrame() const { return m_editorFrame; } + inline wxResourceEditorProjectTree *GetEditorResourceTree() const { return m_editorResourceTree; } + inline wxResourceEditorControlList *GetEditorControlList() const { return m_editorControlList; } + inline wxList& GetSelections() { return m_selections; } + inline wxMenu *GetPopupMenu() const { return m_popupMenu; } #ifdef __WXMSW__ - inline wxHelpController *GetHelpController() const { return m_helpController; } + inline wxHelpController *GetHelpController() const { return m_helpController; } #endif - - inline void Modify(bool mod = TRUE) { m_modified = mod; } - inline bool Modified() const { return m_modified; } - - inline wxResourceTable& GetResourceTable() { return m_resourceTable; } - inline wxHashTable& GetResourceAssociations() { return m_resourceAssociations; } - - inline wxString GetCurrentFilename() const { return m_currentFilename; } - static wxResourceManager* GetCurrentResourceManager() { return sm_currentResourceManager; } - - inline void SetSymbolFilename(const wxString& s) { m_symbolFilename = s; } - inline wxString GetSymbolFilename() const { return m_symbolFilename; } - - inline wxRect& GetPropertyWindowSize() { return m_propertyWindowSize; } - inline wxRect& GetResourceEditorWindowSize() { return m_resourceEditorWindowSize; } - - wxResourceSymbolTable& GetSymbolTable() { return m_symbolTable; } - - // Generate a window id and a first stab at a name - int GenerateWindowId(const wxString& prefix, wxString& idName) ; - -// Member variables + + inline void Modify(bool mod = TRUE) { m_modified = mod; } + inline bool Modified() const { return m_modified; } + + inline wxResourceTable& GetResourceTable() { return m_resourceTable; } + inline wxHashTable& GetResourceAssociations() { return m_resourceAssociations; } + + inline wxString GetCurrentFilename() const { return m_currentFilename; } + static wxResourceManager* GetCurrentResourceManager() { return sm_currentResourceManager; } + + inline void SetSymbolFilename(const wxString& s) { m_symbolFilename = s; } + inline wxString GetSymbolFilename() const { return m_symbolFilename; } + + inline wxRect& GetPropertyWindowSize() { return m_propertyWindowSize; } + inline wxRect& GetResourceEditorWindowSize() { return m_resourceEditorWindowSize; } + + wxResourceSymbolTable& GetSymbolTable() { return m_symbolTable; } + + // Generate a window id and a first stab at a name + int GenerateWindowId(const wxString& prefix, wxString& idName) ; + + // Member variables protected: #ifdef __WXMSW__ - wxHelpController* m_helpController; + wxHelpController* m_helpController; #endif - wxResourceTableWithSaving m_resourceTable; - wxFrame* m_editorFrame; - wxResourceEditorScrolledWindow* m_editorPanel; - wxMenu* m_popupMenu; - wxResourceEditorProjectTree* m_editorResourceTree; - wxResourceEditorControlList* m_editorControlList; - EditorToolBar* m_editorToolBar; - int m_nameCounter; - int m_symbolIdCounter; // For generating window ids - bool m_modified; - wxHashTable m_resourceAssociations; - wxList m_selections; - wxString m_currentFilename; - wxBitmap* m_bitmapImage; // Default for static bitmaps/buttons - - wxImageList m_imageList; - long m_rootDialogItem; // Root of dialog hierarchy in tree (unused) - - // Options to be saved/restored - wxString m_optionsResourceFilename; // e.g. dialoged.ini, .dialogrc - wxRect m_propertyWindowSize; - wxRect m_resourceEditorWindowSize; - static wxResourceManager* sm_currentResourceManager; - - // Symbol table with identifiers for controls - wxResourceSymbolTable m_symbolTable; - // Filename for include file, e.g. resource.h - wxString m_symbolFilename; + wxResourceTableWithSaving m_resourceTable; + wxFrame* m_editorFrame; + wxResourceEditorScrolledWindow* m_editorPanel; + wxMenu* m_popupMenu; + wxResourceEditorProjectTree* m_editorResourceTree; + wxResourceEditorControlList* m_editorControlList; + EditorToolBar* m_editorToolBar; + int m_nameCounter; + int m_symbolIdCounter; // For generating window ids + bool m_modified; + wxHashTable m_resourceAssociations; + wxList m_selections; + wxString m_currentFilename; + wxBitmap* m_bitmapImage; // Default for static bitmaps/buttons + + wxImageList m_imageList; + long m_rootDialogItem; // Root of dialog hierarchy in tree (unused) + + // Options to be saved/restored + wxString m_optionsResourceFilename; // e.g. dialoged.ini, .dialogrc + wxRect m_propertyWindowSize; + wxRect m_resourceEditorWindowSize; + static wxResourceManager* sm_currentResourceManager; + + // Symbol table with identifiers for controls + wxResourceSymbolTable m_symbolTable; + // Filename for include file, e.g. resource.h + wxString m_symbolFilename; }; class wxResourceEditorFrame: public wxFrame { - public: - DECLARE_CLASS(wxResourceEditorFrame) - - wxResourceManager *manager; - wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(600, 400), - long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); - ~wxResourceEditorFrame(); - - void OnCloseWindow(wxCloseEvent& event); - - void OnNew(wxCommandEvent& event); - void OnOpen(wxCommandEvent& event); - void OnNewDialog(wxCommandEvent& event); - void OnClear(wxCommandEvent& event); - void OnSave(wxCommandEvent& event); - void OnSaveAs(wxCommandEvent& event); - void OnExit(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - void OnContents(wxCommandEvent& event); - void OnDeleteSelection(wxCommandEvent& event); - void OnRecreateSelection(wxCommandEvent& event); - void OnTest(wxCommandEvent& event); - - DECLARE_EVENT_TABLE() +public: + DECLARE_CLASS(wxResourceEditorFrame) + + wxResourceManager *manager; + wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(600, 400), + long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); + ~wxResourceEditorFrame(); + + void OnCloseWindow(wxCloseEvent& event); + + void OnNew(wxCommandEvent& event); + void OnOpen(wxCommandEvent& event); + void OnNewDialog(wxCommandEvent& event); + void OnClear(wxCommandEvent& event); + void OnSave(wxCommandEvent& event); + void OnSaveAs(wxCommandEvent& event); + void OnExit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + void OnContents(wxCommandEvent& event); + void OnDeleteSelection(wxCommandEvent& event); + void OnRecreateSelection(wxCommandEvent& event); + void OnTest(wxCommandEvent& event); + void OnConvertWXRs(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() }; class wxResourceEditorScrolledWindow: public wxScrolledWindow { - public: - wxResourceEditorScrolledWindow(wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0); - ~wxResourceEditorScrolledWindow(); - - void OnPaint(wxPaintEvent& event); - - void DrawTitle(wxDC& dc); - -// Accessors - inline int GetMarginX() { return m_marginX; } - inline int GetMarginY() { return m_marginY; } - - public: - wxWindow* m_childWindow; - private: - int m_marginX, m_marginY; - - DECLARE_EVENT_TABLE() +public: + wxResourceEditorScrolledWindow(wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = 0); + ~wxResourceEditorScrolledWindow(); + + void OnPaint(wxPaintEvent& event); + + void DrawTitle(wxDC& dc); + + // Accessors + inline int GetMarginX() { return m_marginX; } + inline int GetMarginY() { return m_marginY; } + +public: + wxWindow* m_childWindow; +private: + int m_marginX, m_marginY; + + DECLARE_EVENT_TABLE() }; #define OBJECT_MENU_EDIT 1 #define OBJECT_MENU_DELETE 2 /* - * Main toolbar - * - */ - +* Main toolbar +* +*/ + class EditorToolBar: public wxToolBar { public: - EditorToolBar(wxFrame *frame, const wxPoint& pos = wxPoint(0, 0), const wxSize& size = wxSize(0, 0), - long style = wxTB_HORIZONTAL); - bool OnLeftClick(int toolIndex, bool toggled); - void OnMouseEnter(int toolIndex); - -DECLARE_EVENT_TABLE() + EditorToolBar(wxFrame *frame, const wxPoint& pos = wxPoint(0, 0), const wxSize& size = wxSize(0, 0), + long style = wxTB_HORIZONTAL); + bool OnLeftClick(int toolIndex, bool toggled); + void OnMouseEnter(int toolIndex); + + DECLARE_EVENT_TABLE() }; // Toolbar ids -#define TOOLBAR_LOAD_FILE 1 -#define TOOLBAR_SAVE_FILE 2 -#define TOOLBAR_NEW 3 -#define TOOLBAR_TREE 5 -#define TOOLBAR_HELP 6 +#define TOOLBAR_LOAD_FILE 101 +#define TOOLBAR_SAVE_FILE 102 +#define TOOLBAR_NEW 103 +#define TOOLBAR_TREE 105 +#define TOOLBAR_HELP 106 // Formatting tools -#define TOOLBAR_FORMAT_HORIZ 10 -#define TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN 11 -#define TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN 12 -#define TOOLBAR_FORMAT_VERT 13 -#define TOOLBAR_FORMAT_VERT_TOP_ALIGN 14 -#define TOOLBAR_FORMAT_VERT_BOT_ALIGN 15 +#define TOOLBAR_FORMAT_HORIZ 110 +#define TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN 111 +#define TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN 112 +#define TOOLBAR_FORMAT_VERT 113 +#define TOOLBAR_FORMAT_VERT_TOP_ALIGN 114 +#define TOOLBAR_FORMAT_VERT_BOT_ALIGN 115 -#define TOOLBAR_TO_FRONT 16 -#define TOOLBAR_TO_BACK 17 -#define TOOLBAR_COPY_SIZE 18 +#define TOOLBAR_TO_FRONT 116 +#define TOOLBAR_TO_BACK 117 +#define TOOLBAR_COPY_SIZE 118 +#define TOOLBAR_COPY_WIDTH 119 +#define TOOLBAR_COPY_HEIGHT 120 +#define TOOLBAR_DISTRIBUTE_HORIZ 121 +#define TOOLBAR_DISTRIBUTE_VERT 122 /* - * this class is used to store data associated with a tree item - */ +* this class is used to store data associated with a tree item +*/ class wxResourceTreeData : public wxTreeItemData { public: wxResourceTreeData(wxItemResource *resource) { m_resource = resource; } - + wxItemResource *GetResource() const { return m_resource; } - + private: wxItemResource *m_resource; }; diff --git a/utils/dialoged/src/reswrite.cpp b/utils/dialoged/src/reswrite.cpp index 8ae04f8623..8e5588fe92 100644 --- a/utils/dialoged/src/reswrite.cpp +++ b/utils/dialoged/src/reswrite.cpp @@ -43,480 +43,480 @@ char *SafeWord(const wxString& s); // us not to require unique window names. wxControl *wxResourceTableWithSaving::CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource) { - wxControl *item = wxResourceTable::CreateItem(panel, childResource, parentResource); - if (item) - wxResourceManager::GetCurrentResourceManager()->GetResourceAssociations().Put((long)childResource, item); - return item; + wxControl *item = wxResourceTable::CreateItem(panel, childResource, parentResource); + if (item) + wxResourceManager::GetCurrentResourceManager()->GetResourceAssociations().Put((long)childResource, item); + return item; } void wxResourceTableWithSaving::OutputFont(wxTextOutputStream& stream, const wxFont& font) { - stream << "[" << font.GetPointSize() << ", '"; - stream << font.GetFamilyString() << "', '"; - stream << font.GetStyleString() << "', '"; - stream << font.GetWeightString() << "', "; - stream << (int)font.GetUnderlined(); - if (font.GetFaceName() != "") - stream << ", '" << font.GetFaceName() << "'"; - stream << "]"; + stream << "[" << font.GetPointSize() << ", '"; + stream << font.GetFamilyString() << "', '"; + stream << font.GetStyleString() << "', '"; + stream << font.GetWeightString() << "', "; + stream << (int)font.GetUnderlined(); + if (font.GetFaceName() != "") + stream << ", '" << font.GetFaceName() << "'"; + stream << "]"; } /* - * Resource table with saving (basic one only has loading) - */ - +* Resource table with saving (basic one only has loading) +*/ + bool wxResourceTableWithSaving::Save(const wxString& filename) { - wxFileOutputStream file_output( filename ); - if (file_output.LastError()) - return FALSE; - - wxTextOutputStream stream( file_output ); - - BeginFind(); - wxNode *node = NULL; - while ((node = Next())) - { - wxItemResource *item = (wxItemResource *)node->Data(); - wxString resType(item->GetType()); - - if (resType == "wxDialogBox" || resType == "wxDialog" || resType == "wxPanel" || resType == "wxBitmap") - { - if (!SaveResource(stream, item, (wxItemResource*) NULL)) + wxFileOutputStream file_output( filename ); + if (file_output.LastError()) return FALSE; + + wxTextOutputStream stream( file_output ); + + BeginFind(); + wxNode *node = NULL; + while ((node = Next())) + { + wxItemResource *item = (wxItemResource *)node->Data(); + wxString resType(item->GetType()); + + if (resType == "wxDialogBox" || resType == "wxDialog" || resType == "wxPanel" || resType == "wxBitmap") + { + if (!SaveResource(stream, item, (wxItemResource*) NULL)) + return FALSE; + } } - } - return TRUE; + return TRUE; } bool wxResourceTableWithSaving::SaveResource(wxTextOutputStream& stream, wxItemResource* item, wxItemResource* parentItem) { - char styleBuf[400]; - wxString itemType(item->GetType()); - - if (itemType == "wxDialogBox" || itemType == "wxDialog" || itemType == "wxPanel") + char styleBuf[400]; + wxString itemType(item->GetType()); + + if (itemType == "wxDialogBox" || itemType == "wxDialog" || itemType == "wxPanel") { - if (itemType == "wxDialogBox" || itemType == "wxDialog") - { - stream << "static char *" << item->GetName() << " = \"dialog(name = '" << item->GetName() << "',\\\n"; - GenerateDialogStyleString(item->GetStyle(), styleBuf); - } - else - { - stream << "static char *" << item->GetName() << " = \"panel(name = '" << item->GetName() << "',\\\n"; - GenerateDialogStyleString(item->GetStyle(), styleBuf); - } - - stream << " style = '" << styleBuf << "',\\\n"; - stream << " title = " << SafeWord(item->GetTitle()) << ",\\\n"; - stream << " id = " << item->GetId() << ",\\\n"; - stream << " x = " << item->GetX() << ", y = " << item->GetY(); - stream << ", width = " << item->GetWidth() << ", height = " << item->GetHeight(); - - if (1) // item->GetStyle() & wxNO_3D) - { - if (item->GetBackgroundColour().Ok()) + if (itemType == "wxDialogBox" || itemType == "wxDialog") { - char buf[7]; - wxDecToHex(item->GetBackgroundColour().Red(), buf); - wxDecToHex(item->GetBackgroundColour().Green(), buf+2); - wxDecToHex(item->GetBackgroundColour().Blue(), buf+4); - buf[6] = 0; - - stream << ",\\\n " << "background_colour = '" << buf << "'"; + stream << "static char *" << item->GetName() << " = \"dialog(name = '" << item->GetName() << "',\\\n"; + GenerateDialogStyleString(item->GetStyle(), styleBuf); + } + else + { + stream << "static char *" << item->GetName() << " = \"panel(name = '" << item->GetName() << "',\\\n"; + GenerateDialogStyleString(item->GetStyle(), styleBuf); } - } - - int dialogUnits = 0; - int useDefaults = 0; - if ((item->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) - dialogUnits = 1; - if ((item->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) - useDefaults = 1; - - stream << ",\\\n " << "use_dialog_units = " << dialogUnits; - stream << ",\\\n " << "use_system_defaults = " << useDefaults; - - if (item->GetFont().Ok()) - { - stream << ",\\\n font = "; - OutputFont(stream, item->GetFont()); - } - - if (item->GetChildren().Number() > 0) - stream << ",\\\n"; - else - stream << "\\\n"; - wxNode *node = item->GetChildren().First(); - while (node) - { - wxItemResource *child = (wxItemResource *)node->Data(); - stream << " control = ["; + stream << " style = '" << styleBuf << "',\\\n"; + stream << " title = " << SafeWord(item->GetTitle()) << ",\\\n"; + stream << " id = " << item->GetId() << ",\\\n"; + stream << " x = " << item->GetX() << ", y = " << item->GetY(); + stream << ", width = " << item->GetWidth() << ", height = " << item->GetHeight(); - SaveResource(stream, child, item); - - stream << "]"; - - if (node->Next()) - stream << ",\\\n"; - node = node->Next(); - } - stream << ").\";\n\n"; - } - else if (itemType == "wxButton" || itemType == "wxBitmapButton") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - if (item->GetValue4()) - stream << ", '" << item->GetValue4() << "'"; - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxStaticText" || itemType == "wxStaticBitmap") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - if (item->GetValue4()) - stream << ", '" << item->GetValue4() << "'"; - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxCheckBox") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxCheckBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - stream << ", " << item->GetValue1(); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxRadioButton") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxRadioButton, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - stream << ", " << item->GetValue1(); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxStaticBox") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxStaticBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxText" || itemType == "wxMultiText" || itemType == "wxTextCtrl") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxTextCtrl, "; - stream << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - stream << ", " << SafeWord(item->GetValue4()); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxGauge") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxGauge, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - stream << ", " << item->GetValue1() << ", " << item->GetValue2(); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxSlider") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxSlider, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3(); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxScrollBar") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxScrollBar, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3() << ", "; - stream << item->GetValue5(); - } - else if (itemType == "wxListBox") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxListBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - - // Default list of values - - stream << ", ["; - if (item->GetStringValues().Number() > 0) - { - wxNode *node = item->GetStringValues().First(); + if (1) // item->GetStyle() & wxNO_3D) + { + if (item->GetBackgroundColour().Ok()) + { + char buf[7]; + wxDecToHex(item->GetBackgroundColour().Red(), buf); + wxDecToHex(item->GetBackgroundColour().Green(), buf+2); + wxDecToHex(item->GetBackgroundColour().Blue(), buf+4); + buf[6] = 0; + + stream << ",\\\n " << "background_colour = '" << buf << "'"; + } + } + + int dialogUnits = 0; + int useDefaults = 0; + if ((item->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) + dialogUnits = 1; + if ((item->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) + useDefaults = 1; + + stream << ",\\\n " << "use_dialog_units = " << dialogUnits; + stream << ",\\\n " << "use_system_defaults = " << useDefaults; + + if (item->GetFont().Ok()) + { + stream << ",\\\n font = "; + OutputFont(stream, item->GetFont()); + } + + if (item->GetChildren().Number() > 0) + stream << ",\\\n"; + else + stream << "\\\n"; + wxNode *node = item->GetChildren().First(); while (node) { - char *s = (char *)node->Data(); - stream << SafeWord(s); - if (node->Next()) - stream << ", "; - node = node->Next(); + wxItemResource *child = (wxItemResource *)node->Data(); + + stream << " control = ["; + + SaveResource(stream, child, item); + + stream << "]"; + + if (node->Next()) + stream << ",\\\n"; + node = node->Next(); } - } - stream << "]"; -/* Styles are now in the window style, not in a separate arg - stream << ", "; - switch (item->GetValue1()) - { + stream << ").\";\n\n"; + } + else if (itemType == "wxButton" || itemType == "wxBitmapButton") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + if (item->GetValue4()) + stream << ", '" << item->GetValue4() << "'"; + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxStaticText" || itemType == "wxStaticBitmap") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + if (item->GetValue4()) + stream << ", '" << item->GetValue4() << "'"; + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxCheckBox") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxCheckBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + stream << ", " << item->GetValue1(); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxRadioButton") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxRadioButton, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + stream << ", " << item->GetValue1(); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxStaticBox") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxStaticBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxText" || itemType == "wxMultiText" || itemType == "wxTextCtrl") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxTextCtrl, "; + stream << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + stream << ", " << SafeWord(item->GetValue4()); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxGauge") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxGauge, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + stream << ", " << item->GetValue1() << ", " << item->GetValue2(); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxSlider") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxSlider, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3(); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxScrollBar") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxScrollBar, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3() << ", "; + stream << item->GetValue5(); + } + else if (itemType == "wxListBox") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxListBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + + // Default list of values + + stream << ", ["; + if (item->GetStringValues().Number() > 0) + { + wxNode *node = item->GetStringValues().First(); + while (node) + { + char *s = (char *)node->Data(); + stream << SafeWord(s); + if (node->Next()) + stream << ", "; + node = node->Next(); + } + } + stream << "]"; + /* Styles are now in the window style, not in a separate arg + stream << ", "; + switch (item->GetValue1()) + { case wxLB_MULTIPLE: { - stream << "'wxLB_MULTIPLE'"; - break; + stream << "'wxLB_MULTIPLE'"; + break; } case wxLB_EXTENDED: { - stream << "'wxLB_EXTENDED'"; - break; + stream << "'wxLB_EXTENDED'"; + break; } case wxLB_SINGLE: default: { - stream << "'wxLB_SINGLE'"; - break; + stream << "'wxLB_SINGLE'"; + break; } - } - */ - - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxChoice" || itemType == "wxComboBox") - { - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - - stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - - if (itemType == "wxComboBox") - stream << ", " << SafeWord(item->GetValue4()); - - // Default list of values - - stream << ", ["; - if (item->GetStringValues().Number() > 0) - { - wxNode *node = item->GetStringValues().First(); - while (node) - { - char *s = (char *)node->Data(); - stream << SafeWord(s); - if (node->Next()) - stream << ", "; - node = node->Next(); } - } - stream << "]"; - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxRadioBox") - { - // Must write out the orientation and number of rows/cols!! - GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - stream << item->GetId() << ", " << "wxRadioBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; - stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; - stream << item->GetWidth() << ", " << item->GetHeight(); - - // Default list of values - - stream << ", ["; - if (item->GetStringValues().Number() > 0) - { - wxNode *node = item->GetStringValues().First(); - while (node) - { - char *s = (char *)node->Data(); - stream << SafeWord(s); - if (node->Next()) - stream << ", "; - node = node->Next(); - } - } - stream << "], " << item->GetValue1(); - if (item->GetFont().Ok()) - { - stream << ",\\\n "; - OutputFont(stream, item->GetFont()); - } - } - else if (itemType == "wxBitmap") - { - stream << "static char *" << item->GetName() << " = \"bitmap(name = '" << item->GetName() << "',\\\n"; - - wxNode *node = item->GetChildren().First(); - while (node) - { - wxItemResource *child = (wxItemResource *)node->Data(); - stream << " bitmap = ["; + */ - char buf[400]; - strcpy(buf, child->GetName()); -#ifdef __WXMSW__ - wxDos2UnixFilename(buf); -#endif - - stream << "'" << buf << "', "; + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxChoice" || itemType == "wxComboBox") + { + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); - int bitmapType = (int)child->GetValue1(); - switch (bitmapType) + stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); + + if (itemType == "wxComboBox") + stream << ", " << SafeWord(item->GetValue4()); + + // Default list of values + + stream << ", ["; + if (item->GetStringValues().Number() > 0) { - case wxBITMAP_TYPE_XBM_DATA: - { - stream << "wxBITMAP_TYPE_XBM_DATA"; - break; - } - case wxBITMAP_TYPE_XPM_DATA: - { - stream << "wxBITMAP_TYPE_XPM_DATA"; - break; - } - case wxBITMAP_TYPE_XBM: - { - stream << "wxBITMAP_TYPE_XBM"; - break; - } - case wxBITMAP_TYPE_XPM: - { - stream << "wxBITMAP_TYPE_XPM"; - break; - } - case wxBITMAP_TYPE_BMP: - { - stream << "wxBITMAP_TYPE_BMP"; - break; - } - case wxBITMAP_TYPE_BMP_RESOURCE: - { - stream << "wxBITMAP_TYPE_BMP_RESOURCE"; - break; - } - case wxBITMAP_TYPE_GIF: - { - stream << "wxBITMAP_TYPE_GIF"; - break; - } - case wxBITMAP_TYPE_TIF: - { - stream << "wxBITMAP_TYPE_TIF"; - break; - } - case wxBITMAP_TYPE_ICO: - { - stream << "wxBITMAP_TYPE_ICO"; - break; - } - case wxBITMAP_TYPE_ICO_RESOURCE: - { - stream << "wxBITMAP_TYPE_ICO_RESOURCE"; - break; - } - case wxBITMAP_TYPE_CUR: - { - stream << "wxBITMAP_TYPE_CUR"; - break; - } - case wxBITMAP_TYPE_CUR_RESOURCE: - { - stream << "wxBITMAP_TYPE_CUR_RESOURCE"; - break; - } - default: - case wxBITMAP_TYPE_ANY: - { - stream << "wxBITMAP_TYPE_ANY"; - break; - } + wxNode *node = item->GetStringValues().First(); + while (node) + { + char *s = (char *)node->Data(); + stream << SafeWord(s); + if (node->Next()) + stream << ", "; + node = node->Next(); + } } - stream << ", "; - int platform = child->GetValue2(); - switch (platform) - { - case RESOURCE_PLATFORM_WINDOWS: - { - stream << "'WINDOWS'"; - break; - } - case RESOURCE_PLATFORM_X: - { - stream << "'X'"; - break; - } - case RESOURCE_PLATFORM_MAC: - { - stream << "'MAC'"; - break; - } - case RESOURCE_PLATFORM_ANY: - { - stream << "'ANY'"; - break; - } - } - int noColours = (int)child->GetValue3(); - if (noColours > 0) - stream << ", " << noColours; - stream << "]"; - - if (node->Next()) - stream << ",\\\n"; + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxRadioBox") + { + // Must write out the orientation and number of rows/cols!! + GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); + stream << item->GetId() << ", " << "wxRadioBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; + stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; + stream << item->GetWidth() << ", " << item->GetHeight(); - node = node->Next(); + // Default list of values + + stream << ", ["; + if (item->GetStringValues().Number() > 0) + { + wxNode *node = item->GetStringValues().First(); + while (node) + { + char *s = (char *)node->Data(); + stream << SafeWord(s); + if (node->Next()) + stream << ", "; + node = node->Next(); + } + } + stream << "], " << item->GetValue1(); + if (item->GetFont().Ok()) + { + stream << ",\\\n "; + OutputFont(stream, item->GetFont()); + } + } + else if (itemType == "wxBitmap") + { + stream << "static char *" << item->GetName() << " = \"bitmap(name = '" << item->GetName() << "',\\\n"; + + wxNode *node = item->GetChildren().First(); + while (node) + { + wxItemResource *child = (wxItemResource *)node->Data(); + stream << " bitmap = ["; + + char buf[400]; + strcpy(buf, child->GetName()); +#ifdef __WXMSW__ + wxDos2UnixFilename(buf); +#endif + + stream << "'" << buf << "', "; + + int bitmapType = (int)child->GetValue1(); + switch (bitmapType) + { + case wxBITMAP_TYPE_XBM_DATA: + { + stream << "wxBITMAP_TYPE_XBM_DATA"; + break; + } + case wxBITMAP_TYPE_XPM_DATA: + { + stream << "wxBITMAP_TYPE_XPM_DATA"; + break; + } + case wxBITMAP_TYPE_XBM: + { + stream << "wxBITMAP_TYPE_XBM"; + break; + } + case wxBITMAP_TYPE_XPM: + { + stream << "wxBITMAP_TYPE_XPM"; + break; + } + case wxBITMAP_TYPE_BMP: + { + stream << "wxBITMAP_TYPE_BMP"; + break; + } + case wxBITMAP_TYPE_BMP_RESOURCE: + { + stream << "wxBITMAP_TYPE_BMP_RESOURCE"; + break; + } + case wxBITMAP_TYPE_GIF: + { + stream << "wxBITMAP_TYPE_GIF"; + break; + } + case wxBITMAP_TYPE_TIF: + { + stream << "wxBITMAP_TYPE_TIF"; + break; + } + case wxBITMAP_TYPE_ICO: + { + stream << "wxBITMAP_TYPE_ICO"; + break; + } + case wxBITMAP_TYPE_ICO_RESOURCE: + { + stream << "wxBITMAP_TYPE_ICO_RESOURCE"; + break; + } + case wxBITMAP_TYPE_CUR: + { + stream << "wxBITMAP_TYPE_CUR"; + break; + } + case wxBITMAP_TYPE_CUR_RESOURCE: + { + stream << "wxBITMAP_TYPE_CUR_RESOURCE"; + break; + } + default: + case wxBITMAP_TYPE_ANY: + { + stream << "wxBITMAP_TYPE_ANY"; + break; + } + } + stream << ", "; + int platform = child->GetValue2(); + switch (platform) + { + case RESOURCE_PLATFORM_WINDOWS: + { + stream << "'WINDOWS'"; + break; + } + case RESOURCE_PLATFORM_X: + { + stream << "'X'"; + break; + } + case RESOURCE_PLATFORM_MAC: + { + stream << "'MAC'"; + break; + } + case RESOURCE_PLATFORM_ANY: + { + stream << "'ANY'"; + break; + } + } + int noColours = (int)child->GetValue3(); + if (noColours > 0) + stream << ", " << noColours; + + stream << "]"; + + if (node->Next()) + stream << ",\\\n"; + + node = node->Next(); } stream << ").\";\n\n"; } @@ -526,85 +526,85 @@ bool wxResourceTableWithSaving::SaveResource(wxTextOutputStream& stream, wxItemR str += itemType; wxMessageBox(str); } - return TRUE; + return TRUE; } void wxResourceTableWithSaving::GenerateDialogStyleString(long windowStyle, char *buf) { - buf[0] = 0; - m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); - m_styleTable.GenerateStyleStrings("wxPanel", windowStyle, buf); - m_styleTable.GenerateStyleStrings("wxDialog", windowStyle, buf); - - if (strlen(buf) == 0) - strcat(buf, "0"); + buf[0] = 0; + m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); + m_styleTable.GenerateStyleStrings("wxPanel", windowStyle, buf); + m_styleTable.GenerateStyleStrings("wxDialog", windowStyle, buf); + + if (strlen(buf) == 0) + strcat(buf, "0"); } void wxResourceTableWithSaving::GeneratePanelStyleString(long windowStyle, char *buf) { - buf[0] = 0; - m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); - m_styleTable.GenerateStyleStrings("wxPanel", windowStyle, buf); - - if (strlen(buf) == 0) - strcat(buf, "0"); + buf[0] = 0; + m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); + m_styleTable.GenerateStyleStrings("wxPanel", windowStyle, buf); + + if (strlen(buf) == 0) + strcat(buf, "0"); } void wxResourceTableWithSaving::GenerateControlStyleString(const wxString& windowClass, long windowStyle, char *buf) { - buf[0] = 0; - m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); - m_styleTable.GenerateStyleStrings("wxControl", windowStyle, buf); - m_styleTable.GenerateStyleStrings(windowClass, windowStyle, buf); - - if (strlen(buf) == 0) - strcat(buf, "0"); + buf[0] = 0; + m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); + m_styleTable.GenerateStyleStrings("wxControl", windowStyle, buf); + m_styleTable.GenerateStyleStrings(windowClass, windowStyle, buf); + + if (strlen(buf) == 0) + strcat(buf, "0"); } // Returns quoted string or "NULL" char *SafeString(const wxString& s) { - if (s == "") - return "NULL"; - else - { - strcpy(wxBuffer, "\""); - strcat(wxBuffer, s); - strcat(wxBuffer, "\""); - return wxBuffer; - } + if (s == "") + return "NULL"; + else + { + strcpy(wxBuffer, "\""); + strcat(wxBuffer, s); + strcat(wxBuffer, "\""); + return wxBuffer; + } } // Returns quoted string or '' : convert " to \" char *SafeWord(const wxString& s) { - const char *cp; - char *dp; - - if (s == "") - return "''"; - else - { - dp = wxBuffer; - cp = s.c_str(); - *dp++ = '\''; - while(*cp != 0) { - if(*cp == '"') { - *dp++ = '\\'; - *dp++ = '"'; - } else if(*cp == '\'') { - *dp++ = '\\'; - *dp++ = '\''; - } else - *dp++ = *cp; - - cp++; - } - *dp++ = '\''; - *dp++ = 0; - - return wxBuffer; - } + const char *cp; + char *dp; + + if (s == "") + return "''"; + else + { + dp = wxBuffer; + cp = s.c_str(); + *dp++ = '\''; + while(*cp != 0) { + if(*cp == '"') { + *dp++ = '\\'; + *dp++ = '"'; + } else if(*cp == '\'') { + *dp++ = '\\'; + *dp++ = '\''; + } else + *dp++ = *cp; + + cp++; + } + *dp++ = '\''; + *dp++ = 0; + + return wxBuffer; + } } diff --git a/utils/dialoged/src/symbtabl.cpp b/utils/dialoged/src/symbtabl.cpp index 110764e782..bed48b411d 100644 --- a/utils/dialoged/src/symbtabl.cpp +++ b/utils/dialoged/src/symbtabl.cpp @@ -32,7 +32,7 @@ #include "symbtabl.h" wxResourceSymbolTable::wxResourceSymbolTable(): - m_hashTable(wxKEY_STRING) +m_hashTable(wxKEY_STRING) { } @@ -48,70 +48,70 @@ bool wxResourceSymbolTable::ReadIncludeFile(const wxString& filename) wxFile file; if (!wxFileExists(filename)) return FALSE; - + if (!file.Open(filename, wxFile::read)) return FALSE; - + off_t len = file.Length(); if (len == -1) return FALSE; - + Clear(); AddStandardSymbols(); - + wxString str; char* p = str.GetWriteBuf(len + 1); - + if (file.Read(p, len) == wxFile::fd_invalid) { str.UngetWriteBuf(); return FALSE; } str.UngetWriteBuf(); - + // Look for #define occurrences int pos = str.Find("#define"); while (pos != -1) { size_t len = str.Length(); - + size_t i = pos + 8; - + // Eat whitespace until symbol while ((str[i] == ' ' || str[i] == '\t') && (i < len)) i ++; - + size_t start = i; - + // Eat symbol while (str[i] != ' ' && str[i] != '\t' && (i < len)) i ++; size_t end = i-1; - + wxString symbol(str.Mid(start, (end - start + 1))); - + // Eat whitespace until number while ((str[i] == ' ' || str[i] == '\t') && (i < len)) i ++; - + size_t startNum = i; - + // Eat number while (str[i] != ' ' && str[i] != '\t' && str[i] != '\n' && (i < len)) i ++; - + size_t endNum = i-1; - + wxString numStr(str.Mid(startNum, (endNum - startNum + 1))); - + int id = atol(numStr); - + AddSymbol(symbol, id); - + str = str.Right(len - i); pos = str.Find("#define"); } - + return TRUE; } @@ -120,30 +120,30 @@ bool wxResourceSymbolTable::WriteIncludeFile(const wxString& filename) wxFile file; if (!file.Open(filename, wxFile::write)) return FALSE; - + wxString fileOnly(wxFileNameFromPath(filename)); wxString line; line.Printf("/*\n * %s\n * Window identifiers file written by Dialog Editor\n */\n\n", (const char*) fileOnly); - + file.Write(line, line.Length()); - + m_hashTable.BeginFind(); - + wxNode* node = m_hashTable.Next(); while (node) { const char* str = node->GetKeyString(); int id = (int) node->Data() ; - + if (!IsStandardSymbol(str)) { wxString line; line.Printf("#define %s %ld\n", str, id); - + file.Write(line, line.Length()); } - + node = m_hashTable.Next(); } return TRUE; @@ -177,14 +177,14 @@ bool wxResourceSymbolTable::RemoveSymbol(int id) wxString wxResourceSymbolTable::GetSymbolForId(int id) { m_hashTable.BeginFind(); - + wxNode* node = m_hashTable.Next(); while (node) { const char* str = node->GetKeyString(); if (str && ( ((int) node->Data()) == id) ) return wxString(str); - + node = m_hashTable.Next(); } return wxString(""); @@ -203,13 +203,13 @@ bool wxResourceSymbolTable::SymbolExists(const wxString& symbol) const bool wxResourceSymbolTable::IdExists(int id) { m_hashTable.BeginFind(); - + wxNode* node = m_hashTable.Next(); while (node) { if ( (((int) node->Data()) == id) ) return TRUE; - + node = m_hashTable.Next(); } return FALSE; @@ -218,19 +218,19 @@ bool wxResourceSymbolTable::IdExists(int id) int wxResourceSymbolTable::FindHighestId() { int highest = 0; - + m_hashTable.BeginFind(); - + wxNode* node = m_hashTable.Next(); while (node) { int id = ((int) node->Data()); if (id > highest) highest = id; - + node = m_hashTable.Next(); } - + // Make sure we don't clash with future standard wxWindows ids if (highest <= wxID_HIGHEST) highest = wxID_HIGHEST + 1; @@ -238,8 +238,8 @@ int wxResourceSymbolTable::FindHighestId() } /* - * A table of the standard identifiers - */ +* A table of the standard identifiers +*/ struct wxStandardSymbolStruct { @@ -256,7 +256,7 @@ static wxStandardSymbolStruct sg_StandardSymbols[] = { "wxID_STATIC", wxID_STATIC }, { "wxID_YES", wxID_YES }, { "wxID_NO", wxID_NO }, - + { "wxID_OPEN", wxID_OPEN }, { "wxID_CLOSE", wxID_CLOSE }, { "wxID_NEW", wxID_NEW }, @@ -274,14 +274,14 @@ static wxStandardSymbolStruct sg_StandardSymbols[] = { "wxID_HELP_COMMANDS", wxID_HELP_COMMANDS }, { "wxID_HELP_PROCEDURES", wxID_HELP_PROCEDURES }, { "wxID_HELP_CONTEXT", wxID_HELP_CONTEXT }, - + { "wxID_CUT", wxID_CUT }, { "wxID_COPY", wxID_COPY }, { "wxID_PASTE", wxID_PASTE }, { "wxID_CLEAR", wxID_CLEAR }, { "wxID_FIND", wxID_FIND }, { "wxID_DUPLICATE", wxID_DUPLICATE }, - + { "wxID_FILE1", wxID_FILE1 }, { "wxID_FILE2", wxID_FILE2 }, { "wxID_FILE3", wxID_FILE3 }, @@ -291,7 +291,7 @@ static wxStandardSymbolStruct sg_StandardSymbols[] = { "wxID_FILE7", wxID_FILE7 }, { "wxID_FILE8", wxID_FILE8 }, { "wxID_FILE9", wxID_FILE9 } - + }; static int sg_StandardSymbolSize = (sizeof(sg_StandardSymbols)/sizeof(wxStandardSymbolStruct)); @@ -319,12 +319,12 @@ bool wxResourceSymbolTable::IsStandardSymbol(const wxString& symbol) const bool wxResourceSymbolTable::FillComboBox(wxComboBox* comboBox) { m_hashTable.BeginFind(); - + wxNode* node = m_hashTable.Next(); while (node) { const char* str = node->GetKeyString(); - + comboBox->Append(str); node = m_hashTable.Next(); } diff --git a/utils/dialoged/src/symbtabl.h b/utils/dialoged/src/symbtabl.h index 440b14b222..b95bc9fa9e 100644 --- a/utils/dialoged/src/symbtabl.h +++ b/utils/dialoged/src/symbtabl.h @@ -21,8 +21,8 @@ class wxResourceSymbolTable: public wxObject public: wxResourceSymbolTable(); ~wxResourceSymbolTable(); - -// Operations + + // Operations bool ReadIncludeFile(const wxString& filename); bool WriteIncludeFile(const wxString& filename); void Clear(); @@ -31,22 +31,22 @@ public: bool RemoveSymbol(int id); void AddStandardSymbols(); bool FillComboBox(wxComboBox* comboBox); - -// Accessors + + // Accessors wxString GetSymbolForId(int id); int GetIdForSymbol(const wxString& symbol); bool SymbolExists(const wxString& symbol) const; bool IdExists(int id) ; bool IsStandardSymbol(const wxString& symbol) const; int FindHighestId() ; - -// Implementation - -// Member variables + + // Implementation + + // Member variables protected: wxHashTable m_hashTable; }; #endif - // _SYMBTABL_H_ +// _SYMBTABL_H_ diff --git a/utils/dialoged/src/winprop.cpp b/utils/dialoged/src/winprop.cpp index dde79ec61c..277776f655 100644 --- a/utils/dialoged/src/winprop.cpp +++ b/utils/dialoged/src/winprop.cpp @@ -39,61 +39,61 @@ // Causes immediate feedback. void wxResourcePropertyListView::OnPropertyChanged(wxProperty *property) { - // Sets the value of the property back into the actual object, - // IF the property value was modified. - if (property->GetValue().GetModified()) - { - m_propertyInfo->SetProperty(property->GetName(), property); - property->GetValue().SetModified(FALSE); - wxResourceManager::GetCurrentResourceManager()->Modify(TRUE); - } + // Sets the value of the property back into the actual object, + // IF the property value was modified. + if (property->GetValue().GetModified()) + { + m_propertyInfo->SetProperty(property->GetName(), property); + property->GetValue().SetModified(FALSE); + wxResourceManager::GetCurrentResourceManager()->Modify(TRUE); + } } bool wxResourcePropertyListView::OnClose(void) { - int w, h, x, y; - GetManagedWindow()->GetSize(& w, & h); - GetManagedWindow()->GetPosition(& x, & y); - - wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width = w; - wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height = h; - wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x = x; - wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y = y; - - return wxPropertyListView::OnClose(); + int w, h, x, y; + GetManagedWindow()->GetSize(& w, & h); + GetManagedWindow()->GetPosition(& x, & y); + + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width = w; + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height = h; + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x = x; + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y = y; + + return wxPropertyListView::OnClose(); } wxWindow *wxPropertyInfo::sm_propertyWindow; /* - * wxDialogEditorPropertyListDialog - */ +* wxDialogEditorPropertyListDialog +*/ - /* +/* wxDialogEditorPropertyListDialog::wxDialogEditorPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name): - wxPropertyListDialog(v, parent, title, pos, size, style, name) +const wxPoint& pos, const wxSize& size, +long style, const wxString& name): +wxPropertyListDialog(v, parent, title, pos, size, style, name) { - m_propSheet = NULL; - m_propInfo = NULL; +m_propSheet = NULL; +m_propInfo = NULL; } -wxDialogEditorPropertyListDialog::~wxDialogEditorPropertyListDialog() -{ - delete m_propSheet; - delete m_propInfo; - wxPropertyInfo::sm_propertyWindow = NULL; -} + wxDialogEditorPropertyListDialog::~wxDialogEditorPropertyListDialog() + { + delete m_propSheet; + delete m_propInfo; + wxPropertyInfo::sm_propertyWindow = NULL; + } */ wxDialogEditorPropertyListFrame::wxDialogEditorPropertyListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name): - wxPropertyListFrame(v, parent, title, pos, size, style, name) + const wxPoint& pos, const wxSize& size, + long style, const wxString& name): +wxPropertyListFrame(v, parent, title, pos, size, style, name) { - m_propSheet = NULL; - m_propInfo = NULL; + m_propSheet = NULL; + m_propInfo = NULL; } wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame() @@ -105,116 +105,116 @@ wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame() } /* - * wxPropertyInfo - */ +* wxPropertyInfo +*/ // Edit the information represented by this object, whatever that // might be. bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title) { - if (sm_propertyWindow) - { - wxWindowPropertyInfo* thisProp = (wxWindowPropertyInfo*) this; - wxWindowPropertyInfo* oldProp = (wxWindowPropertyInfo*) (((wxDialogEditorPropertyListFrame *) sm_propertyWindow)->GetInfo()); - if (oldProp->GetWindow() == thisProp->GetWindow()) - { - sm_propertyWindow->Raise(); - return TRUE; - } - else - { - CloseWindow(); // Close the window so we can open a new one - } - } - - int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width; - int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height; - int x = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x; - int y = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y; - - wxPropertySheet *propSheet = new wxPropertySheet; - - wxStringList propNames; - GetPropertyNames(propNames); - - wxNode *node = propNames.First(); - while (node) - { - wxString name((char *)node->Data()); - wxProperty *prop = GetProperty(name); - if (prop) + if (sm_propertyWindow) { - propSheet->AddProperty(prop); + wxWindowPropertyInfo* thisProp = (wxWindowPropertyInfo*) this; + wxWindowPropertyInfo* oldProp = (wxWindowPropertyInfo*) (((wxDialogEditorPropertyListFrame *) sm_propertyWindow)->GetInfo()); + if (oldProp->GetWindow() == thisProp->GetWindow()) + { + sm_propertyWindow->Raise(); + return TRUE; + } + else + { + CloseWindow(); // Close the window so we can open a new one + } } - node = node->Next(); - } - - // Reset 'modified' flags for all property values - propSheet->SetAllModified(FALSE); - - wxResourcePropertyListView *view = new wxResourcePropertyListView(this, NULL, - wxPROP_BUTTON_OK | // wxPROP_BUTTON_CANCEL | - wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES); - - wxDialogEditorPropertyListFrame *propWin = new wxDialogEditorPropertyListFrame(view, - wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title, wxPoint(x, y), - wxSize(width, height), wxDEFAULT_FRAME_STYLE); - sm_propertyWindow = propWin; - - propWin->m_registry.RegisterValidator(wxString("real"), new wxRealListValidator); - propWin->m_registry.RegisterValidator(wxString("string"), new wxStringListValidator); - propWin->m_registry.RegisterValidator(wxString("integer"), new wxIntegerListValidator); - propWin->m_registry.RegisterValidator(wxString("bool"), new wxBoolListValidator); - propWin->m_registry.RegisterValidator(wxString("filename"), new wxFilenameListValidator); - propWin->m_registry.RegisterValidator(wxString("stringlist"), new wxListOfStringsListValidator); - propWin->m_registry.RegisterValidator(wxString("window_id"), new wxResourceSymbolValidator); - - propWin->m_propInfo = this; - propWin->m_propSheet = propSheet; - -// view->m_propertyWindow = propWin; - view->AddRegistry(&(propWin->m_registry)); - - propWin->Initialize(); - view->ShowView(propSheet, propWin->GetPropertyPanel()); - - propWin->Show(TRUE); - - // Otherwise doesn't show itself + + int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width; + int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height; + int x = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x; + int y = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y; + + wxPropertySheet *propSheet = new wxPropertySheet; + + wxStringList propNames; + GetPropertyNames(propNames); + + wxNode *node = propNames.First(); + while (node) + { + wxString name((char *)node->Data()); + wxProperty *prop = GetProperty(name); + if (prop) + { + propSheet->AddProperty(prop); + } + node = node->Next(); + } + + // Reset 'modified' flags for all property values + propSheet->SetAllModified(FALSE); + + wxResourcePropertyListView *view = new wxResourcePropertyListView(this, NULL, + wxPROP_BUTTON_OK | // wxPROP_BUTTON_CANCEL | + wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES); + + wxDialogEditorPropertyListFrame *propWin = new wxDialogEditorPropertyListFrame(view, + wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title, wxPoint(x, y), + wxSize(width, height), wxDEFAULT_FRAME_STYLE); + sm_propertyWindow = propWin; + + propWin->m_registry.RegisterValidator(wxString("real"), new wxRealListValidator); + propWin->m_registry.RegisterValidator(wxString("string"), new wxStringListValidator); + propWin->m_registry.RegisterValidator(wxString("integer"), new wxIntegerListValidator); + propWin->m_registry.RegisterValidator(wxString("bool"), new wxBoolListValidator); + propWin->m_registry.RegisterValidator(wxString("filename"), new wxFilenameListValidator); + propWin->m_registry.RegisterValidator(wxString("stringlist"), new wxListOfStringsListValidator); + propWin->m_registry.RegisterValidator(wxString("window_id"), new wxResourceSymbolValidator); + + propWin->m_propInfo = this; + propWin->m_propSheet = propSheet; + + // view->m_propertyWindow = propWin; + view->AddRegistry(&(propWin->m_registry)); + + propWin->Initialize(); + view->ShowView(propSheet, propWin->GetPropertyPanel()); + + propWin->Show(TRUE); + + // Otherwise doesn't show itself #ifdef __WXMOTIF__ - wxNoOptimize noOptimize; - propWin->SetSize(-1, -1, width, height); + wxNoOptimize noOptimize; + propWin->SetSize(-1, -1, width, height); #endif - - return TRUE; + + return TRUE; } void wxPropertyInfo::CloseWindow() { - if (sm_propertyWindow) - { + if (sm_propertyWindow) + { int w, h, x, y; sm_propertyWindow->GetSize(& w, & h); sm_propertyWindow->GetPosition(& x, & y); - + wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width = w; wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height = h; wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x = x; wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y = y; - + sm_propertyWindow->Destroy(); sm_propertyWindow = (wxDialogEditorPropertyListFrame *) NULL; - } + } } /* - * wxWindowPropertyInfo - */ +* wxWindowPropertyInfo +*/ wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow *win, wxItemResource *res) { - m_propertyWindow = win; - m_propertyResource = res; + m_propertyWindow = win; + m_propertyResource = res; } wxWindowPropertyInfo::~wxWindowPropertyInfo(void) @@ -223,524 +223,526 @@ wxWindowPropertyInfo::~wxWindowPropertyInfo(void) wxProperty *wxWindowPropertyInfo::GetFontProperty(wxString& name, wxFont *font) { - if (!font) - return NULL; + if (!font) + return NULL; - if (name.Contains("Points")) - return new wxProperty(name, (long)font->GetPointSize(), "integer", new wxIntegerListValidator(1, 100)); - else if (name.Contains("Family")) - return new wxProperty(name, font->GetFamilyString(), "string", - new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN", - NULL))); - else if (name.Contains("Style")) - return new wxProperty(name, font->GetStyleString(), "string", - new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL))); - else if (name.Contains("Weight")) - return new wxProperty(name, font->GetWeightString(), "string", - new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL))); - else if (name.Contains("Underlined")) - return new wxProperty(name, (bool)font->GetUnderlined(), "bool"); - else - return NULL; + if (name.Contains("Points")) + return new wxProperty(name, (long)font->GetPointSize(), "integer", new wxIntegerListValidator(1, 100)); + else if (name.Contains("Family")) + return new wxProperty(name, font->GetFamilyString(), "string", + new wxStringListValidator(new wxStringList("wxDECORATIVE", "wxROMAN", "wxSCRIPT", "wxSWISS", "wxMODERN", + NULL))); + else if (name.Contains("Style")) + return new wxProperty(name, font->GetStyleString(), "string", + new wxStringListValidator(new wxStringList("wxNORMAL", "wxITALIC", "wxSLANT", NULL))); + else if (name.Contains("Weight")) + return new wxProperty(name, font->GetWeightString(), "string", + new wxStringListValidator(new wxStringList("wxNORMAL", "wxBOLD", "wxLIGHT", NULL))); + else if (name.Contains("Underlined")) + return new wxProperty(name, (bool)font->GetUnderlined(), "bool"); + else + return NULL; } wxFont *wxWindowPropertyInfo::SetFontProperty(wxString& name, wxProperty *property, wxFont *font) { - int pointSize = 12; - int fontFamily = wxMODERN; - int fontStyle = wxNORMAL; - int fontWeight = wxNORMAL; - bool fontUnderlined = FALSE; - - if (name.Contains("Points")) - { - pointSize = (int)property->GetValue().IntegerValue(); - if (font && (pointSize == font->GetPointSize())) - return NULL; // No change - } - else if (font) pointSize = font->GetPointSize(); - - if (name.Contains("Family")) - { - wxString val = property->GetValue().StringValue(); - fontFamily = wxStringToFontFamily(val); + int pointSize = 12; + int fontFamily = wxMODERN; + int fontStyle = wxNORMAL; + int fontWeight = wxNORMAL; + bool fontUnderlined = FALSE; - if (font && (fontFamily == font->GetFamily())) - return NULL; // No change - } - else if (font) fontFamily = font->GetFamily(); - - if (name.Contains("Style")) - { - wxString val = property->GetValue().StringValue(); - fontStyle = wxStringToFontStyle(val); + if (name.Contains("Points")) + { + pointSize = (int)property->GetValue().IntegerValue(); + if (font && (pointSize == font->GetPointSize())) + return NULL; // No change + } + else if (font) pointSize = font->GetPointSize(); - if (font && (fontStyle == font->GetStyle())) - return NULL; // No change - } - else if (font) fontStyle = font->GetStyle(); - if (name.Contains("Weight")) - { - wxString val = property->GetValue().StringValue(); - fontWeight = wxStringToFontWeight(val); - - if (font && (fontWeight == font->GetWeight())) - return NULL; // No change - } - else if (font) fontWeight = font->GetWeight(); - - if (name.Contains("Underlined")) - { - fontUnderlined = property->GetValue().BoolValue(); - - if (font && (fontUnderlined == font->GetUnderlined())) - return NULL; // No change - } - else if (font) fontUnderlined = font->GetUnderlined(); - - wxFont *newFont = wxTheFontList->FindOrCreateFont(pointSize, fontFamily, fontStyle, fontWeight, fontUnderlined); - if (newFont) - { - return newFont; - } - else - return NULL; + if (name.Contains("Family")) + { + wxString val = property->GetValue().StringValue(); + fontFamily = wxStringToFontFamily(val); + + if (font && (fontFamily == font->GetFamily())) + return NULL; // No change + } + else if (font) fontFamily = font->GetFamily(); + + if (name.Contains("Style")) + { + wxString val = property->GetValue().StringValue(); + fontStyle = wxStringToFontStyle(val); + + if (font && (fontStyle == font->GetStyle())) + return NULL; // No change + } + else if (font) fontStyle = font->GetStyle(); + if (name.Contains("Weight")) + { + wxString val = property->GetValue().StringValue(); + fontWeight = wxStringToFontWeight(val); + + if (font && (fontWeight == font->GetWeight())) + return NULL; // No change + } + else if (font) fontWeight = font->GetWeight(); + + if (name.Contains("Underlined")) + { + fontUnderlined = property->GetValue().BoolValue(); + + if (font && (fontUnderlined == font->GetUnderlined())) + return NULL; // No change + } + else if (font) fontUnderlined = font->GetUnderlined(); + + wxFont *newFont = wxTheFontList->FindOrCreateFont(pointSize, fontFamily, fontStyle, fontWeight, fontUnderlined); + if (newFont) + { + return newFont; + } + else + return NULL; } wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - - wxFont *font = & m_propertyWindow->GetFont(); - if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || - name == "fontUnderlined") - return GetFontProperty(name, font); - else if (name == "name") - return new wxProperty("name", m_propertyWindow->GetName(), "string"); - else if (name == "title") - return new wxProperty("title", m_propertyWindow->GetTitle(), "string"); - else if (name == "x") - { - return new wxProperty("x", (long)resource->GetX(), "integer"); - } - else if (name == "y") - { - return new wxProperty("y", (long)resource->GetY(), "integer"); - } - else if (name == "width") - { - return new wxProperty("width", (long)resource->GetWidth(), "integer"); - } - else if (name == "height") - { - return new wxProperty("height", (long)resource->GetHeight(), "integer"); - } - else if (name == "id") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource) + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + + wxFont *font = & m_propertyWindow->GetFont(); + if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || + name == "fontUnderlined") + return GetFontProperty(name, font); + else if (name == "name") + return new wxProperty("name", m_propertyWindow->GetName(), "string"); + else if (name == "title") + return new wxProperty("title", m_propertyWindow->GetTitle(), "string"); + else if (name == "x") { - int id = resource->GetId(); - wxString idStr; - idStr.Printf("%d", id); - wxString symbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id); - symbolName += "="; - symbolName += idStr; - // symbolName is now e.g. "ID_PANEL21=105" - return new wxProperty("id", symbolName, "window_id"); + return new wxProperty("x", (long)resource->GetX(), "integer"); + } + else if (name == "y") + { + return new wxProperty("y", (long)resource->GetY(), "integer"); + } + else if (name == "width") + { + return new wxProperty("width", (long)resource->GetWidth(), "integer"); + } + else if (name == "height") + { + return new wxProperty("height", (long)resource->GetHeight(), "integer"); + } + else if (name == "id") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource) + { + int id = resource->GetId(); + wxString idStr; + idStr.Printf("%d", id); + wxString symbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id); + symbolName += "="; + symbolName += idStr; + // symbolName is now e.g. "ID_PANEL21=105" + return new wxProperty("id", symbolName, "window_id"); + } + else + return NULL; + } + else if (name == "border") + { + wxString border(""); + if (m_propertyWindow->GetWindowStyleFlag() & wxSIMPLE_BORDER) + border = "wxSIMPLE_BORDER"; + else if (m_propertyWindow->GetWindowStyleFlag() & wxRAISED_BORDER) + border = "wxRAISED_BORDER"; + else if (m_propertyWindow->GetWindowStyleFlag() & wxSUNKEN_BORDER) + border = "wxSUNKEN_BORDER"; + else if (m_propertyWindow->GetWindowStyleFlag() & wxDOUBLE_BORDER) + border = "wxDOUBLE_BORDER"; + else if (m_propertyWindow->GetWindowStyleFlag() & wxSTATIC_BORDER) + border = "wxSTATIC_BORDER"; + else if (m_propertyWindow->GetWindowStyleFlag() & wxNO_BORDER) + border = "wxNO_BORDER"; + else + border = "default border"; + + return new wxProperty("border", border, "string", + new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER", + "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", "default border", NULL))); } else return NULL; - } - else if (name == "border") - { - wxString border(""); - if (m_propertyWindow->GetWindowStyleFlag() & wxSIMPLE_BORDER) - border = "wxSIMPLE_BORDER"; - else if (m_propertyWindow->GetWindowStyleFlag() & wxRAISED_BORDER) - border = "wxRAISED_BORDER"; - else if (m_propertyWindow->GetWindowStyleFlag() & wxSUNKEN_BORDER) - border = "wxSUNKEN_BORDER"; - else if (m_propertyWindow->GetWindowStyleFlag() & wxDOUBLE_BORDER) - border = "wxDOUBLE_BORDER"; - else if (m_propertyWindow->GetWindowStyleFlag() & wxSTATIC_BORDER) - border = "wxSTATIC_BORDER"; - else - border = "wxNO_BORDER"; - - return new wxProperty("border", border, "string", - new wxStringListValidator(new wxStringList("wxSIMPLE_BORDER", "wxRAISED_BORDER", - "wxSUNKEN_BORDER", "wxDOUBLE_BORDER", "wxSTATIC_BORDER", "wxNO_BORDER", NULL))); - } - else - return NULL; } bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxFont *font = & m_propertyWindow->GetFont(); - if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) - { - wxFont *newFont = SetFontProperty(name, property, font); - if (newFont) + wxFont *font = & m_propertyWindow->GetFont(); + if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) { - m_propertyWindow->SetFont(* newFont); - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource) - { - resource->SetFont(* newFont); - } - } - - return TRUE; - } - else if (name == "name") - { - // Remove old name from resource table, if it's there. - wxItemResource *oldResource = (wxItemResource *)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow->GetName()); - if (oldResource) - { - // It's a top-level resource - m_propertyWindow->SetName(property->GetValue().StringValue()); - oldResource->SetName(property->GetValue().StringValue()); - wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow->GetName(), oldResource); - } - else - { - // It's a child of something; just set the name of the resource and the window. - m_propertyWindow->SetName(property->GetValue().StringValue()); - m_propertyResource->SetName(property->GetValue().StringValue()); - } - // Refresh the resource manager list, because the name changed. - wxResourceManager::GetCurrentResourceManager()->UpdateResourceList(); - return TRUE; - } - else if (name == "title") - { - m_propertyWindow->SetTitle(property->GetValue().StringValue()); - return TRUE; - } - else if (name == "x") - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - int x, y; - m_propertyWindow->GetPosition(&x, &y); - int newX = (int)property->GetValue().IntegerValue(); - int pixelX = newX; - - // We need to convert to pixels if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) - { - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + wxFont *newFont = SetFontProperty(name, property, font); + if (newFont) { - wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(newX, y)); - pixelX = pt.x; - } - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(newX, y)); - pixelX = pt.x; - } - } - - if (x != pixelX) - { - m_propertyWindow->Move(pixelX, y); - resource->SetSize(newX, resource->GetY(), resource->GetWidth(), resource->GetHeight()); - } - return TRUE; - } - else if (name == "y") - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - int x, y; - m_propertyWindow->GetPosition(&x, &y); - int newY = (int)property->GetValue().IntegerValue(); - int pixelY = newY; - - // We need to convert to pixels if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) - { - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(x, newY)); - pixelY = pt.y; - } - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(x, newY)); - pixelY = pt.y; - } - } - - if (y != pixelY) - { - m_propertyWindow->Move(x, pixelY); - resource->SetSize(resource->GetX(), newY, resource->GetWidth(), resource->GetHeight()); - } - return TRUE; - } - else if (name == "width") - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - int width, height; - m_propertyWindow->GetSize(&width, &height); - int newWidth = (int)property->GetValue().IntegerValue(); - int pixelWidth = newWidth; - - // We need to convert to pixels if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) - { - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(newWidth, height)); - pixelWidth = sz.x; - } - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(newWidth, height)); - pixelWidth = sz.x; - } - } - - if (width != pixelWidth) - { - m_propertyWindow->SetSize(pixelWidth, height); - resource->SetSize(resource->GetX(), resource->GetY(), newWidth, resource->GetHeight()); - } - return TRUE; - } - else if (name == "height") - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - int width, height; - m_propertyWindow->GetSize(&width, &height); - int newHeight = (int)property->GetValue().IntegerValue(); - int pixelHeight = newHeight; - - // We need to convert to pixels if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) - { - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(width, newHeight)); - pixelHeight = sz.y; - } - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(width, newHeight)); - pixelHeight = sz.y; - } - } - - if (height != pixelHeight) - { - m_propertyWindow->SetSize(width, pixelHeight); - resource->SetSize(resource->GetX(), resource->GetY(), resource->GetWidth(), newHeight); - } - return TRUE; - } - else if (name == "id") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource) - { - wxString value = property->GetValue().StringValue(); - - wxString strName = value.Before('='); - wxString strId = value.After('='); - int id = atoi(strId); - - wxString oldSymbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource->GetId()); - int oldSymbolId = resource->GetId(); - - if (strName != "") - { - // If we change the id for an existing symbol, we need to: - // 1) Check if there are any other resources currently using the original id. - // If so, will need to change their id to the new id. - // 2) Remove the old symbol, add the new symbol. - // In this check, we don't have to do this, but we need to do it in SetProperty. - - if (strName == oldSymbolName && id != oldSymbolId) + m_propertyWindow->SetFont(* newFont); + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource) { - wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) ); - - // It's OK to change just the id. But we'll need to change all matching ids in all resources, - // because ids are unique and changing one resource's id must change all identical ones. - wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId, id); - - wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName); - wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id); + resource->SetFont(* newFont); } - - // If we change the name but not the id, we'll just need to remove and - // re-add the symbol/id pair. - if (strName != oldSymbolName && id == oldSymbolId) + } + + return TRUE; + } + else if (name == "name") + { + // Remove old name from resource table, if it's there. + wxItemResource *oldResource = (wxItemResource *)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow->GetName()); + if (oldResource) + { + // It's a top-level resource + m_propertyWindow->SetName(property->GetValue().StringValue()); + oldResource->SetName(property->GetValue().StringValue()); + wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow->GetName(), oldResource); + } + else + { + // It's a child of something; just set the name of the resource and the window. + m_propertyWindow->SetName(property->GetValue().StringValue()); + m_propertyResource->SetName(property->GetValue().StringValue()); + } + // Refresh the resource manager list, because the name changed. + wxResourceManager::GetCurrentResourceManager()->UpdateResourceList(); + return TRUE; + } + else if (name == "title") + { + m_propertyWindow->SetTitle(property->GetValue().StringValue()); + return TRUE; + } + else if (name == "x") + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + int x, y; + m_propertyWindow->GetPosition(&x, &y); + int newX = (int)property->GetValue().IntegerValue(); + int pixelX = newX; + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { - wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) ); - - wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName); - - if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName)) - { - wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id); - } + wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(newX, y)); + pixelX = pt.x; } - - // What if we're changing both the name and the id? - // - if there's no symbol of that name, just remove the old, add the new (in SetProperty) - // - if there is a symbol of that name, if id matches, do nothing. If not, veto. - - if (strName != oldSymbolName && id != oldSymbolId) + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) { - // Remove old symbol if it's not being used - if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource, oldSymbolId) && - !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) + wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(newX, y)); + pixelX = pt.x; + } + } + + if (x != pixelX) + { + m_propertyWindow->Move(pixelX, y); + resource->SetSize(newX, resource->GetY(), resource->GetWidth(), resource->GetHeight()); + } + return TRUE; + } + else if (name == "y") + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + int x, y; + m_propertyWindow->GetPosition(&x, &y); + int newY = (int)property->GetValue().IntegerValue(); + int pixelY = newY; + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(x, newY)); + pixelY = pt.y; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(x, newY)); + pixelY = pt.y; + } + } + + if (y != pixelY) + { + m_propertyWindow->Move(x, pixelY); + resource->SetSize(resource->GetX(), newY, resource->GetWidth(), resource->GetHeight()); + } + return TRUE; + } + else if (name == "width") + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + int width, height; + m_propertyWindow->GetSize(&width, &height); + int newWidth = (int)property->GetValue().IntegerValue(); + int pixelWidth = newWidth; + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(newWidth, height)); + pixelWidth = sz.x; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(newWidth, height)); + pixelWidth = sz.x; + } + } + + if (width != pixelWidth) + { + m_propertyWindow->SetSize(pixelWidth, height); + resource->SetSize(resource->GetX(), resource->GetY(), newWidth, resource->GetHeight()); + } + return TRUE; + } + else if (name == "height") + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + int width, height; + m_propertyWindow->GetSize(&width, &height); + int newHeight = (int)property->GetValue().IntegerValue(); + int pixelHeight = newHeight; + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(width, newHeight)); + pixelHeight = sz.y; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(width, newHeight)); + pixelHeight = sz.y; + } + } + + if (height != pixelHeight) + { + m_propertyWindow->SetSize(width, pixelHeight); + resource->SetSize(resource->GetX(), resource->GetY(), resource->GetWidth(), newHeight); + } + return TRUE; + } + else if (name == "id") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource) + { + wxString value = property->GetValue().StringValue(); + + wxString strName = value.Before('='); + wxString strId = value.After('='); + int id = atoi(strId); + + wxString oldSymbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource->GetId()); + int oldSymbolId = resource->GetId(); + + if (strName != "") + { + // If we change the id for an existing symbol, we need to: + // 1) Check if there are any other resources currently using the original id. + // If so, will need to change their id to the new id. + // 2) Remove the old symbol, add the new symbol. + // In this check, we don't have to do this, but we need to do it in SetProperty. + + if (strName == oldSymbolName && id != oldSymbolId) { + wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) ); + + // It's OK to change just the id. But we'll need to change all matching ids in all resources, + // because ids are unique and changing one resource's id must change all identical ones. + wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId, id); + wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName); - } - - if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName)) - { wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id); } + + // If we change the name but not the id, we'll just need to remove and + // re-add the symbol/id pair. + if (strName != oldSymbolName && id == oldSymbolId) + { + wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) ); + + wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName); + + if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName)) + { + wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id); + } + } + + // What if we're changing both the name and the id? + // - if there's no symbol of that name, just remove the old, add the new (in SetProperty) + // - if there is a symbol of that name, if id matches, do nothing. If not, veto. + + if (strName != oldSymbolName && id != oldSymbolId) + { + // Remove old symbol if it's not being used + if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource, oldSymbolId) && + !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) + { + wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName); + } + + if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName)) + { + wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id); + } + } + resource->SetId(id); } - resource->SetId(id); + + return TRUE; } - + else + return FALSE; + } + else if (name == "border") + { + long borderStyle = 0; + wxString val = property->GetValue().StringValue(); + + if (val == "wxSIMPLE_BORDER") + borderStyle = wxSIMPLE_BORDER; + else if (val == "wxRAISED_BORDER") + borderStyle = wxRAISED_BORDER; + else if (val == "wxSUNKEN_BORDER") + borderStyle = wxSUNKEN_BORDER; + else if (val == "wxDOUBLE_BORDER") + borderStyle = wxDOUBLE_BORDER; + else if (val == "wxSTATIC_BORDER") + borderStyle = wxSTATIC_BORDER; + else if (val == "wxNO_BORDER") + borderStyle = wxNO_BORDER; + + SetWindowStyle(m_propertyWindow, wxSIMPLE_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxRAISED_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxSUNKEN_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxDOUBLE_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxSTATIC_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxNO_BORDER, FALSE); + + SetWindowStyle(m_propertyWindow, borderStyle, TRUE); + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); return TRUE; } else return FALSE; - } - else if (name == "border") - { - long borderStyle = wxNO_BORDER; - wxString val = property->GetValue().StringValue(); - - if (val == "wxSIMPLE_BORDER") - borderStyle = wxSIMPLE_BORDER; - else if (val == "wxRAISED_BORDER") - borderStyle = wxRAISED_BORDER; - else if (val == "wxSUNKEN_BORDER") - borderStyle = wxSUNKEN_BORDER; - else if (val == "wxDOUBLE_BORDER") - borderStyle = wxDOUBLE_BORDER; - else if (val == "wxSTATIC_BORDER") - borderStyle = wxSTATIC_BORDER; - else - borderStyle = wxNO_BORDER; - - SetWindowStyle(m_propertyWindow, wxSIMPLE_BORDER, FALSE); - SetWindowStyle(m_propertyWindow, wxRAISED_BORDER, FALSE); - SetWindowStyle(m_propertyWindow, wxSUNKEN_BORDER, FALSE); - SetWindowStyle(m_propertyWindow, wxDOUBLE_BORDER, FALSE); - SetWindowStyle(m_propertyWindow, wxSTATIC_BORDER, FALSE); - SetWindowStyle(m_propertyWindow, wxNO_BORDER, FALSE); - - SetWindowStyle(m_propertyWindow, borderStyle, TRUE); - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - return TRUE; - } - else - return FALSE; } void wxWindowPropertyInfo::GetPropertyNames(wxStringList& names) { - names.Add("id"); - names.Add("name"); - names.Add("x"); - names.Add("y"); - names.Add("width"); - names.Add("height"); - names.Add("border"); - if (!m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) - { - names.Add("fontPoints"); - names.Add("fontFamily"); - names.Add("fontStyle"); - names.Add("fontWeight"); - names.Add("fontUnderlined"); - } + names.Add("id"); + names.Add("name"); + names.Add("x"); + names.Add("y"); + names.Add("width"); + names.Add("height"); + names.Add("border"); + if (!m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + names.Add("fontPoints"); + names.Add("fontFamily"); + names.Add("fontStyle"); + names.Add("fontWeight"); + names.Add("fontUnderlined"); + } } // Fill in the wxItemResource members to mirror the current window settings bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource) { -// resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName()); - -// resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - wxString str(m_propertyWindow->GetName()); - resource->SetName(str); - + // resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName()); + + // resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); + wxString str(m_propertyWindow->GetName()); + resource->SetName(str); + #if 0 // Why did we comment this out? Possibly because of rounding errors - // that will build up as the conversion is repeatedly done. - // so only do the conversion when a resize happens. - int x, y, w, h; - - if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) - m_propertyWindow->GetClientSize(&w, &h); - else - m_propertyWindow->GetSize(&w, &h); - - m_propertyWindow->GetPosition(&x, &y); - - // We need to convert to dialog units if this is not a dialog or panel, but - // the parent resource specifies dialog units. - if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) - { - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y)); - x = pt.x; y = pt.y; - wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); - w = sz.x; h = sz.y; - } - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) - { - if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) - { - wxPoint pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(x, y)); - x = pt.x; y = pt.y; - wxSize sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(w, h)); - w = sz.x; h = sz.y; - } - } - - resource->SetSize(x, y, w, h); + // that will build up as the conversion is repeatedly done. + // so only do the conversion when a resize happens. + int x, y, w, h; + + if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + m_propertyWindow->GetClientSize(&w, &h); + else + m_propertyWindow->GetSize(&w, &h); + + m_propertyWindow->GetPosition(&x, &y); + + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y)); + x = pt.x; y = pt.y; + wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(x, y)); + x = pt.x; y = pt.y; + wxSize sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + } + + resource->SetSize(x, y, w, h); #endif - - return TRUE; + + return TRUE; } // Set the window style @@ -748,7 +750,7 @@ void wxWindowPropertyInfo::SetWindowStyle(wxWindow* win, long style, bool set) { if (style == 0) return; - + if ((win->GetWindowStyleFlag() & style) == style) { if (!set) @@ -766,1482 +768,1482 @@ void wxWindowPropertyInfo::SetWindowStyle(wxWindow* win, long style, bool set) } /* - * Controls - */ +* Controls +*/ wxProperty *wxItemPropertyInfo::GetProperty(wxString& name) { - wxControl *itemWindow = (wxControl *)m_propertyWindow; - wxFont *font = & itemWindow->GetFont(); - - if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || - name == "fontUnderlined") - return GetFontProperty(name, font); - else if (name == "label" && itemWindow->GetLabel()) - return new wxProperty("label", m_propertyWindow->GetLabel(), "string"); - else - return wxWindowPropertyInfo::GetProperty(name); + wxControl *itemWindow = (wxControl *)m_propertyWindow; + wxFont *font = & itemWindow->GetFont(); + + if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || + name == "fontUnderlined") + return GetFontProperty(name, font); + else if (name == "label" && itemWindow->GetLabel()) + return new wxProperty("label", m_propertyWindow->GetLabel(), "string"); + else + return wxWindowPropertyInfo::GetProperty(name); } bool wxItemPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxControl *itemWindow = (wxControl *)m_propertyWindow; + wxControl *itemWindow = (wxControl *)m_propertyWindow; #if 0 - wxFont *font = & itemWindow->GetFont(); - - if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) - { - wxFont *newFont = SetFontProperty(name, property, font); - if (newFont) - itemWindow->SetFont(* newFont); - return TRUE; - } - else + wxFont *font = & itemWindow->GetFont(); + + if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) + { + wxFont *newFont = SetFontProperty(name, property, font); + if (newFont) + itemWindow->SetFont(* newFont); + return TRUE; + } + else #endif - if (name == "label") - { - itemWindow->SetLabel(property->GetValue().StringValue()); - return TRUE; - } - else - return wxWindowPropertyInfo::SetProperty(name, property); + if (name == "label") + { + itemWindow->SetLabel(property->GetValue().StringValue()); + return TRUE; + } + else + return wxWindowPropertyInfo::SetProperty(name, property); } void wxItemPropertyInfo::GetPropertyNames(wxStringList& names) { - wxWindowPropertyInfo::GetPropertyNames(names); - - names.Add("fontPoints"); - names.Add("fontFamily"); - names.Add("fontStyle"); - names.Add("fontWeight"); - names.Add("fontUnderlined"); + wxWindowPropertyInfo::GetPropertyNames(names); + + names.Add("fontPoints"); + names.Add("fontFamily"); + names.Add("fontStyle"); + names.Add("fontWeight"); + names.Add("fontUnderlined"); } bool wxItemPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxWindowPropertyInfo::InstantiateResource(resource); - - wxControl *item = (wxControl *)m_propertyWindow; - wxString str(item->GetLabel()); - resource->SetTitle(str); - - if (item->GetFont().Ok()) - resource->SetFont(* wxTheFontList->FindOrCreateFont(item->GetFont().GetPointSize(), - item->GetFont().GetFamily(), item->GetFont().GetStyle(), item->GetFont().GetWeight(), - item->GetFont().GetUnderlined(), item->GetFont().GetFaceName())); - return TRUE; + wxWindowPropertyInfo::InstantiateResource(resource); + + wxControl *item = (wxControl *)m_propertyWindow; + wxString str(item->GetLabel()); + resource->SetTitle(str); + + if (item->GetFont().Ok()) + resource->SetFont(* wxTheFontList->FindOrCreateFont(item->GetFont().GetPointSize(), + item->GetFont().GetFamily(), item->GetFont().GetStyle(), item->GetFont().GetWeight(), + item->GetFont().GetUnderlined(), item->GetFont().GetFaceName())); + return TRUE; } /* - * Button - */ +* Button +*/ wxProperty *wxButtonPropertyInfo::GetProperty(wxString& name) { - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxButtonPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("label"); } bool wxButtonPropertyInfo::InstantiateResource(wxItemResource *resource) { - return wxItemPropertyInfo::InstantiateResource(resource); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * wxBitmapButton - */ +* wxBitmapButton +*/ wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) { - wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; - if (name == "bitmapFilename") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button); - wxString str("none.bmp"); - - if (resource) + wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; + if (name == "bitmapFilename") { - str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button); + wxString str("none.bmp"); + + if (resource) + { + str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); + } + return new wxProperty("bitmapFilename", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); } - return new wxProperty("bitmapFilename", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); - } - else - return wxButtonPropertyInfo::GetProperty(name); + else + return wxButtonPropertyInfo::GetProperty(name); } bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; - if (name == "bitmapFilename") - { - char *s = property->GetValue().StringValue(); - if (s && wxFileExists(s)) + wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; + if (name == "bitmapFilename") { - wxString str(s); - wxBitmap *bitmap = new wxBitmap(str, wxBITMAP_TYPE_BMP); - if (!bitmap->Ok()) - { - delete bitmap; - return FALSE; - } - else - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button); - if (resource) + char *s = property->GetValue().StringValue(); + if (s && wxFileExists(s)) { - wxString oldResource(resource->GetValue4()); - wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str); - resource->SetValue4(resName); - - if (!oldResource.IsNull()) - wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); + wxString str(s); + wxBitmap *bitmap = new wxBitmap(str, wxBITMAP_TYPE_BMP); + if (!bitmap->Ok()) + { + delete bitmap; + return FALSE; + } + else + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button); + if (resource) + { + wxString oldResource(resource->GetValue4()); + wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str); + resource->SetValue4(resName); + + if (!oldResource.IsNull()) + wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); + } + + button->SetLabel(* bitmap); + return TRUE; + } } - - button->SetLabel(* bitmap); - return TRUE; - } + return FALSE; } - return FALSE; - } - else - return wxButtonPropertyInfo::SetProperty(name, property); + else + return wxButtonPropertyInfo::SetProperty(name, property); } void wxBitmapButtonPropertyInfo::GetPropertyNames(wxStringList& names) { - wxButtonPropertyInfo::GetPropertyNames(names); - names.Delete("label"); - names.Add("bitmapFilename"); + wxButtonPropertyInfo::GetPropertyNames(names); + names.Delete("label"); + names.Add("bitmapFilename"); } bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource *resource) { - return wxItemPropertyInfo::InstantiateResource(resource); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * wxStaticText - */ +* wxStaticText +*/ wxProperty *wxStaticTextPropertyInfo::GetProperty(wxString& name) { - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxStaticTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxStaticText* itemWindow = (wxStaticText*) m_propertyWindow; - if (name == "label") - { - // Because setting a wxStaticText control's label may change the - // size, we must get the size and instantiate the resource immediately. - itemWindow->SetLabel(property->GetValue().StringValue()); - int w, h; - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(itemWindow); - - m_propertyWindow->GetSize(&w, &h); - // m_propertyWindow->GetPosition(&x, &y); - - // We need to convert to dialog units if - // the parent resource specifies dialog units. - if (m_propertyWindow->GetParent()) + wxStaticText* itemWindow = (wxStaticText*) m_propertyWindow; + if (name == "label") { - wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); - if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + // Because setting a wxStaticText control's label may change the + // size, we must get the size and instantiate the resource immediately. + itemWindow->SetLabel(property->GetValue().StringValue()); + int w, h; + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(itemWindow); + + m_propertyWindow->GetSize(&w, &h); + // m_propertyWindow->GetPosition(&x, &y); + + // We need to convert to dialog units if + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent()) { - // wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y)); - // x = pt.x; y = pt.y; - wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); - w = sz.x; h = sz.y; + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + // wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y)); + // x = pt.x; y = pt.y; + wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } } + resource->SetSize(resource->GetX(), resource->GetY(), w, h); + return TRUE; } - resource->SetSize(resource->GetX(), resource->GetY(), w, h); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("label"); } bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource *resource) { - return wxItemPropertyInfo::InstantiateResource(resource); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * wxStaticBitmap - */ +* wxStaticBitmap +*/ wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) { - wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; - if (name == "bitmapFilename") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message); - wxString str("none.bmp"); - - if (resource) + wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; + if (name == "bitmapFilename") { - str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message); + wxString str("none.bmp"); + + if (resource) + { + str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); + } + return new wxProperty("bitmapFilename", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); } - return new wxProperty("bitmapFilename", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); - } - else - return wxItemPropertyInfo::GetProperty(name); + else + return wxItemPropertyInfo::GetProperty(name); } bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; - if (name == "bitmapFilename") - { - char *s = property->GetValue().StringValue(); - if (s && wxFileExists(s)) + wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; + if (name == "bitmapFilename") { - wxString str(s); - - wxBitmap *bitmap = new wxBitmap(str, wxBITMAP_TYPE_BMP); - if (!bitmap->Ok()) - { - delete bitmap; - return FALSE; - } - else - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message); - if (resource) + char *s = property->GetValue().StringValue(); + if (s && wxFileExists(s)) { - wxString oldResource(resource->GetValue4()); - wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str); - resource->SetValue4(resName); - - if (!oldResource.IsNull()) - wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); + wxString str(s); + + wxBitmap *bitmap = new wxBitmap(str, wxBITMAP_TYPE_BMP); + if (!bitmap->Ok()) + { + delete bitmap; + return FALSE; + } + else + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message); + if (resource) + { + wxString oldResource(resource->GetValue4()); + wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(str); + resource->SetValue4(resName); + + if (!oldResource.IsNull()) + wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); + } + + message->SetBitmap(* bitmap); + return TRUE; + } } - - message->SetBitmap(* bitmap); - return TRUE; - } + return FALSE; } - return FALSE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("bitmapFilename"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("bitmapFilename"); } bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource *resource) { - return wxItemPropertyInfo::InstantiateResource(resource); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Text item - */ +* Text item +*/ wxProperty *wxTextPropertyInfo::GetProperty(wxString& name) { - wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; - if (name == "value") - return new wxProperty("value", text->GetValue(), "string"); - else if (name == "password") - { - bool isPassword = ((text->GetWindowStyleFlag() & wxTE_PASSWORD) == wxTE_PASSWORD); - return new wxProperty("password", isPassword, "bool"); - } - else if (name == "readonly") - { - bool isReadOnly = ((text->GetWindowStyleFlag() & wxTE_READONLY) == wxTE_READONLY); - return new wxProperty("readonly", isReadOnly, "bool"); - } - else - return wxItemPropertyInfo::GetProperty(name); + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; + if (name == "value") + return new wxProperty("value", text->GetValue(), "string"); + else if (name == "password") + { + bool isPassword = ((text->GetWindowStyleFlag() & wxTE_PASSWORD) == wxTE_PASSWORD); + return new wxProperty("password", isPassword, "bool"); + } + else if (name == "readonly") + { + bool isReadOnly = ((text->GetWindowStyleFlag() & wxTE_READONLY) == wxTE_READONLY); + return new wxProperty("readonly", isReadOnly, "bool"); + } + else + return wxItemPropertyInfo::GetProperty(name); } bool wxTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; - if (name == "value") - { - text->SetValue(property->GetValue().StringValue()); - return TRUE; - } - else if (name == "password") - { - long flag = text->GetWindowStyleFlag(); - if (property->GetValue().BoolValue()) + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; + if (name == "value") { - if ((flag & wxTE_PASSWORD) != wxTE_PASSWORD) - flag |= wxTE_PASSWORD; + text->SetValue(property->GetValue().StringValue()); + return TRUE; + } + else if (name == "password") + { + long flag = text->GetWindowStyleFlag(); + if (property->GetValue().BoolValue()) + { + if ((flag & wxTE_PASSWORD) != wxTE_PASSWORD) + flag |= wxTE_PASSWORD; + } + else + { + if ((flag & wxTE_PASSWORD) == wxTE_PASSWORD) + flag -= wxTE_PASSWORD; + } + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text); + resource->SetStyle(flag); + + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); + return TRUE; + } + else if (name == "readonly") + { + long flag = text->GetWindowStyleFlag(); + if (property->GetValue().BoolValue()) + { + if ((flag & wxTE_READONLY) != wxTE_READONLY) + flag |= wxTE_READONLY; + } + else + { + if ((flag & wxTE_READONLY) == wxTE_READONLY) + flag -= wxTE_READONLY; + } + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text); + resource->SetStyle(flag); + + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); + return TRUE; } else - { - if ((flag & wxTE_PASSWORD) == wxTE_PASSWORD) - flag -= wxTE_PASSWORD; - } - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text); - resource->SetStyle(flag); - - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); - return TRUE; - } - else if (name == "readonly") - { - long flag = text->GetWindowStyleFlag(); - if (property->GetValue().BoolValue()) - { - if ((flag & wxTE_READONLY) != wxTE_READONLY) - flag |= wxTE_READONLY; - } - else - { - if ((flag & wxTE_READONLY) == wxTE_READONLY) - flag -= wxTE_READONLY; - } - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(text); - resource->SetStyle(flag); - - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(text, this); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxTextPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("value"); - names.Add("readonly"); - names.Add("password"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("value"); + names.Add("readonly"); + names.Add("password"); } bool wxTextPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; - wxString str(text->GetValue()); - resource->SetValue4(str); + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; + wxString str(text->GetValue()); + resource->SetValue4(str); - return wxItemPropertyInfo::InstantiateResource(resource); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Listbox item - */ +* Listbox item +*/ wxProperty *wxListBoxPropertyInfo::GetProperty(wxString& name) { - wxListBox *listBox = (wxListBox *)m_propertyWindow; - if (name == "values") - { - wxStringList *stringList = new wxStringList; - int i; - for (i = 0; i < listBox->Number(); i++) - stringList->Add(listBox->GetString(i)); - - return new wxProperty(name, stringList, "stringlist"); - } - else if (name == "multiple") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); - if (!resource) - return NULL; - - char *mult = "wxLB_SINGLE"; - - if ((listBox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) - mult = "wxLB_MULTIPLE"; - else if ((listBox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0) - mult = "wxLB_EXTENDED"; + wxListBox *listBox = (wxListBox *)m_propertyWindow; + if (name == "values") + { + wxStringList *stringList = new wxStringList; + int i; + for (i = 0; i < listBox->Number(); i++) + stringList->Add(listBox->GetString(i)); + + return new wxProperty(name, stringList, "stringlist"); + } + else if (name == "multiple") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); + if (!resource) + return NULL; + + char *mult = "wxLB_SINGLE"; + + if ((listBox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) + mult = "wxLB_MULTIPLE"; + else if ((listBox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0) + mult = "wxLB_EXTENDED"; + else + mult = "wxLB_SINGLE"; + + return new wxProperty("multiple", mult, "string", + new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED", + NULL))); + } else - mult = "wxLB_SINGLE"; - - return new wxProperty("multiple", mult, "string", - new wxStringListValidator(new wxStringList("wxLB_SINGLE", "wxLB_MULTIPLE", "wxLB_EXTENDED", - NULL))); - } - else - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxListBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxListBox *listBox = (wxListBox *)m_propertyWindow; - if (name == "values") - { - listBox->Clear(); - wxPropertyValue *expr = property->GetValue().GetFirst(); - while (expr) + wxListBox *listBox = (wxListBox *)m_propertyWindow; + if (name == "values") { - char *s = expr->StringValue(); - if (s) - listBox->Append(s); - expr = expr->GetNext(); + listBox->Clear(); + wxPropertyValue *expr = property->GetValue().GetFirst(); + while (expr) + { + char *s = expr->StringValue(); + if (s) + listBox->Append(s); + expr = expr->GetNext(); + } + return TRUE; + } + else if (name == "multiple") + { + SetWindowStyle(m_propertyWindow, wxLB_SINGLE, FALSE); + SetWindowStyle(m_propertyWindow, wxLB_MULTIPLE, FALSE); + SetWindowStyle(m_propertyWindow, wxLB_EXTENDED, FALSE); + + wxString str(property->GetValue().StringValue()); + if (str == "wxLB_MULTIPLE") + SetWindowStyle(m_propertyWindow, wxLB_MULTIPLE, TRUE); + else if (str == "wxLB_EXTENDED") + SetWindowStyle(m_propertyWindow, wxLB_EXTENDED, TRUE); + else + SetWindowStyle(m_propertyWindow, wxLB_SINGLE, TRUE); + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); + if (resource) + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this); + return TRUE; } - return TRUE; - } - else if (name == "multiple") - { - SetWindowStyle(m_propertyWindow, wxLB_SINGLE, FALSE); - SetWindowStyle(m_propertyWindow, wxLB_MULTIPLE, FALSE); - SetWindowStyle(m_propertyWindow, wxLB_EXTENDED, FALSE); - - wxString str(property->GetValue().StringValue()); - if (str == "wxLB_MULTIPLE") - SetWindowStyle(m_propertyWindow, wxLB_MULTIPLE, TRUE); - else if (str == "wxLB_EXTENDED") - SetWindowStyle(m_propertyWindow, wxLB_EXTENDED, TRUE); else - SetWindowStyle(m_propertyWindow, wxLB_SINGLE, TRUE); - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); - if (resource) - resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(listBox, this); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxListBoxPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("values"); - names.Add("multiple"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("values"); + names.Add("multiple"); } bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxListBox *lbox = (wxListBox *)m_propertyWindow; - // This will be set for the wxItemResource on reading or in SetProperty -// resource->SetValue1(lbox->GetSelectionMode()); - int i; - if (lbox->Number() == 0) - resource->SetStringValues(NULL); - else - { - wxStringList slist; - - for (i = 0; i < lbox->Number(); i++) - slist.Add(lbox->GetString(i)); - - resource->SetStringValues(slist); - } - return wxItemPropertyInfo::InstantiateResource(resource); + wxListBox *lbox = (wxListBox *)m_propertyWindow; + // This will be set for the wxItemResource on reading or in SetProperty + // resource->SetValue1(lbox->GetSelectionMode()); + int i; + if (lbox->Number() == 0) + resource->SetStringValues(NULL); + else + { + wxStringList slist; + + for (i = 0; i < lbox->Number(); i++) + slist.Add(lbox->GetString(i)); + + resource->SetStringValues(slist); + } + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Choice item - */ +* Choice item +*/ wxProperty *wxChoicePropertyInfo::GetProperty(wxString& name) { - wxChoice *choice = (wxChoice *)m_propertyWindow; - if (name == "values") - { - wxStringList* stringList = new wxStringList; - int i; - for (i = 0; i < choice->Number(); i++) - stringList->Add(choice->GetString(i)); - - return new wxProperty(name, stringList, "stringlist"); - } - else - return wxItemPropertyInfo::GetProperty(name); + wxChoice *choice = (wxChoice *)m_propertyWindow; + if (name == "values") + { + wxStringList* stringList = new wxStringList; + int i; + for (i = 0; i < choice->Number(); i++) + stringList->Add(choice->GetString(i)); + + return new wxProperty(name, stringList, "stringlist"); + } + else + return wxItemPropertyInfo::GetProperty(name); } bool wxChoicePropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxChoice *choice = (wxChoice *)m_propertyWindow; - if (name == "values") - { - choice->Clear(); - wxPropertyValue *expr = property->GetValue().GetFirst(); - while (expr) + wxChoice *choice = (wxChoice *)m_propertyWindow; + if (name == "values") { - char *s = expr->StringValue(); - if (s) - choice->Append(s); - expr = expr->GetNext(); + choice->Clear(); + wxPropertyValue *expr = property->GetValue().GetFirst(); + while (expr) + { + char *s = expr->StringValue(); + if (s) + choice->Append(s); + expr = expr->GetNext(); + } + if (choice->Number() > 0) + choice->SetSelection(0); + return TRUE; } - if (choice->Number() > 0) - choice->SetSelection(0); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxChoicePropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("values"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("values"); } bool wxChoicePropertyInfo::InstantiateResource(wxItemResource *resource) { - wxChoice *choice = (wxChoice *)m_propertyWindow; - int i; - if (choice->Number() == 0) - resource->SetStringValues(NULL); - else - { - wxStringList slist; - - for (i = 0; i < choice->Number(); i++) - slist.Add(choice->GetString(i)); - - resource->SetStringValues(slist); - } - return wxItemPropertyInfo::InstantiateResource(resource); + wxChoice *choice = (wxChoice *)m_propertyWindow; + int i; + if (choice->Number() == 0) + resource->SetStringValues(NULL); + else + { + wxStringList slist; + + for (i = 0; i < choice->Number(); i++) + slist.Add(choice->GetString(i)); + + resource->SetStringValues(slist); + } + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Choice item - */ +* Choice item +*/ wxProperty *wxComboBoxPropertyInfo::GetProperty(wxString& name) { - wxComboBox *choice = (wxComboBox *)m_propertyWindow; - if (name == "values") - { - wxStringList *stringList = new wxStringList; - int i; - for (i = 0; i < choice->Number(); i++) - stringList->Add(choice->GetString(i)); - - return new wxProperty(name, stringList, "stringlist"); - } - else if (name == "sort") - { - bool sort = ((m_propertyWindow->GetWindowStyleFlag() & wxCB_SORT) == wxCB_SORT); - return new wxProperty(name, sort, "bool"); - } - else if (name == "style") - { - wxString styleStr("dropdown"); - if (m_propertyWindow->GetWindowStyleFlag() & wxCB_SIMPLE) - styleStr = "simple"; - else if (m_propertyWindow->GetWindowStyleFlag() & wxCB_READONLY) - styleStr = "readonly"; + wxComboBox *choice = (wxComboBox *)m_propertyWindow; + if (name == "values") + { + wxStringList *stringList = new wxStringList; + int i; + for (i = 0; i < choice->Number(); i++) + stringList->Add(choice->GetString(i)); + + return new wxProperty(name, stringList, "stringlist"); + } + else if (name == "sort") + { + bool sort = ((m_propertyWindow->GetWindowStyleFlag() & wxCB_SORT) == wxCB_SORT); + return new wxProperty(name, sort, "bool"); + } + else if (name == "style") + { + wxString styleStr("dropdown"); + if (m_propertyWindow->GetWindowStyleFlag() & wxCB_SIMPLE) + styleStr = "simple"; + else if (m_propertyWindow->GetWindowStyleFlag() & wxCB_READONLY) + styleStr = "readonly"; + else + styleStr = "dropdown"; + + return new wxProperty(name, styleStr, "string", + new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly", + NULL))); + } else - styleStr = "dropdown"; - - return new wxProperty(name, styleStr, "string", - new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly", - NULL))); - } - else - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxComboBox *choice = (wxComboBox *)m_propertyWindow; - if (name == "values") - { - choice->Clear(); - wxPropertyValue *expr = property->GetValue().GetFirst(); - while (expr) + wxComboBox *choice = (wxComboBox *)m_propertyWindow; + if (name == "values") { - char *s = expr->StringValue(); - if (s) - choice->Append(s); - expr = expr->GetNext(); + choice->Clear(); + wxPropertyValue *expr = property->GetValue().GetFirst(); + while (expr) + { + char *s = expr->StringValue(); + if (s) + choice->Append(s); + expr = expr->GetNext(); + } + if (choice->Number() > 0) + choice->SetSelection(0); + return TRUE; } - if (choice->Number() > 0) - choice->SetSelection(0); - return TRUE; - } - else if (name == "sort") - { - SetWindowStyle(m_propertyWindow, wxCB_SORT, property->GetValue().BoolValue()); - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); - return TRUE; - } - else if (name == "style") - { - SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, FALSE); - SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, FALSE); - SetWindowStyle(m_propertyWindow, wxCB_READONLY, FALSE); - - wxString styleStr(property->GetValue().StringValue()); - if (styleStr == "simple") - SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, TRUE); - else if (styleStr == "dropdown") - SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, TRUE); - else if (styleStr == "readonly") - SetWindowStyle(m_propertyWindow, wxCB_READONLY, TRUE); - - // Necesary? - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); - - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + else if (name == "sort") + { + SetWindowStyle(m_propertyWindow, wxCB_SORT, property->GetValue().BoolValue()); + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); + + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); + return TRUE; + } + else if (name == "style") + { + SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, FALSE); + SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, FALSE); + SetWindowStyle(m_propertyWindow, wxCB_READONLY, FALSE); + + wxString styleStr(property->GetValue().StringValue()); + if (styleStr == "simple") + SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, TRUE); + else if (styleStr == "dropdown") + SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, TRUE); + else if (styleStr == "readonly") + SetWindowStyle(m_propertyWindow, wxCB_READONLY, TRUE); + + // Necesary? + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); + + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); + + return TRUE; + } + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("values"); - names.Add("style"); - names.Add("sort"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("values"); + names.Add("style"); + names.Add("sort"); } bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxComboBox *choice = (wxComboBox *)m_propertyWindow; - int i; - if (choice->Number() == 0) - resource->SetStringValues(NULL); - else - { - wxStringList slist; - - for (i = 0; i < choice->Number(); i++) - slist.Add(choice->GetString(i)); - - resource->SetStringValues(slist); - } - return wxItemPropertyInfo::InstantiateResource(resource); + wxComboBox *choice = (wxComboBox *)m_propertyWindow; + int i; + if (choice->Number() == 0) + resource->SetStringValues(NULL); + else + { + wxStringList slist; + + for (i = 0; i < choice->Number(); i++) + slist.Add(choice->GetString(i)); + + resource->SetStringValues(slist); + } + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Radiobox item - */ +* Radiobox item +*/ wxProperty *wxRadioBoxPropertyInfo::GetProperty(wxString& name) { - wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; - if (name == "numberRowsOrCols") - { - return new wxProperty("numberRowsOrCols", (long)radioBox->GetNumberOfRowsOrCols(), "integer"); - } - if (name == "orientation") - { - wxString orient; - if (m_propertyWindow->GetWindowStyleFlag() & wxRA_SPECIFY_COLS) - orient = "wxRA_SPECIFY_COLS"; - else - orient = "wxRA_SPECIFY_ROWS"; - - return new wxProperty("orientation", orient, "string", - new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS", - NULL))); - } - else if (name == "values") - { - wxStringList *stringList = new wxStringList; - int i; - for (i = 0; i < radioBox->Number(); i++) - stringList->Add(radioBox->GetString(i)); - - return new wxProperty(name, stringList, "stringlist"); - } - return wxItemPropertyInfo::GetProperty(name); + wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; + if (name == "numberRowsOrCols") + { + return new wxProperty("numberRowsOrCols", (long)radioBox->GetNumberOfRowsOrCols(), "integer"); + } + if (name == "orientation") + { + wxString orient; + if (m_propertyWindow->GetWindowStyleFlag() & wxRA_SPECIFY_COLS) + orient = "wxRA_SPECIFY_COLS"; + else + orient = "wxRA_SPECIFY_ROWS"; + + return new wxProperty("orientation", orient, "string", + new wxStringListValidator(new wxStringList("wxRA_SPECIFY_COLS", "wxRA_SPECIFY_ROWS", + NULL))); + } + else if (name == "values") + { + wxStringList *stringList = new wxStringList; + int i; + for (i = 0; i < radioBox->Number(); i++) + stringList->Add(radioBox->GetString(i)); + + return new wxProperty(name, stringList, "stringlist"); + } + return wxItemPropertyInfo::GetProperty(name); } bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; - if (name == "numberRowsOrCols") - { - wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); - - radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue()); - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); - return TRUE; - } - else if (name == "orientation") - { - long windowStyle = radioBox->GetWindowStyleFlag(); - wxString val(property->GetValue().StringValue()); - if (val == "wxRA_SPECIFY_COLS") + wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; + if (name == "numberRowsOrCols") { - if (windowStyle & wxRA_SPECIFY_ROWS) - windowStyle -= wxRA_SPECIFY_ROWS; - windowStyle |= wxRA_SPECIFY_COLS; + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); + + radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue()); + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); + return TRUE; } - else + else if (name == "orientation") { - if (windowStyle & wxRA_SPECIFY_COLS) - windowStyle -= wxRA_SPECIFY_COLS; - windowStyle |= wxRA_SPECIFY_ROWS; + long windowStyle = radioBox->GetWindowStyleFlag(); + wxString val(property->GetValue().StringValue()); + if (val == "wxRA_SPECIFY_COLS") + { + if (windowStyle & wxRA_SPECIFY_ROWS) + windowStyle -= wxRA_SPECIFY_ROWS; + windowStyle |= wxRA_SPECIFY_COLS; + } + else + { + if (windowStyle & wxRA_SPECIFY_COLS) + windowStyle -= wxRA_SPECIFY_COLS; + windowStyle |= wxRA_SPECIFY_ROWS; + } + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); + + radioBox->SetWindowStyleFlag(windowStyle); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox); + resource->SetStyle(windowStyle); + resource->SetSize(resource->GetX(), resource->GetY(), -1, -1); // Let it calculate it's own size + + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE); + return TRUE; + } + else if (name == "values") + { + // Set property into *resource*, not wxRadioBox, and then recreate + // the wxRadioBox. This is because we can't dynamically set the strings + // of a wxRadioBox. + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (!resource) + return FALSE; + + wxStringList stringList; + wxPropertyValue *expr = property->GetValue().GetFirst(); + while (expr) + { + char *s = expr->StringValue(); + if (s) + stringList.Add(s); + expr = expr->GetNext(); + } + resource->SetStringValues(stringList); + resource->SetSize(resource->GetX(), resource->GetY(), -1, -1); // Let it calculate it's own size + m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE); + return TRUE; + } + else if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" ) + { + wxFont *font = & m_propertyWindow->GetFont(); + if (!font) + return FALSE; + wxFont *newFont = SetFontProperty(name, property, font); + if (newFont) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource) + { + resource->SetFont(* newFont); + } + + wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); + + radioBox->SetFont(* newFont); + radioBox->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + return TRUE; + } } - wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); - - radioBox->SetWindowStyleFlag(windowStyle); - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(radioBox); - resource->SetStyle(windowStyle); - resource->SetSize(resource->GetX(), resource->GetY(), -1, -1); // Let it calculate it's own size - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE); - return TRUE; - } - else if (name == "values") - { - // Set property into *resource*, not wxRadioBox, and then recreate - // the wxRadioBox. This is because we can't dynamically set the strings - // of a wxRadioBox. - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (!resource) - return FALSE; - - wxStringList stringList; - wxPropertyValue *expr = property->GetValue().GetFirst(); - while (expr) - { - char *s = expr->StringValue(); - if (s) - stringList.Add(s); - expr = expr->GetNext(); - } - resource->SetStringValues(stringList); - resource->SetSize(resource->GetX(), resource->GetY(), -1, -1); // Let it calculate it's own size - m_propertyWindow = wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this, FALSE); - return TRUE; - } - else if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" ) - { - wxFont *font = & m_propertyWindow->GetFont(); - if (!font) - return FALSE; - wxFont *newFont = SetFontProperty(name, property, font); - if (newFont) - { - wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - if (resource) - { - resource->SetFont(* newFont); - } - - wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(radioBox); - - radioBox->SetFont(* newFont); - radioBox->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); - return TRUE; - } - } - - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); - names.Add("values"); - names.Add("orientation"); - names.Add("numberRowsOrCols"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("label"); + names.Add("values"); + names.Add("orientation"); + names.Add("numberRowsOrCols"); } bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; - // Take strings from resource instead -/* - int i; - if (rbox->Number() == 0) + wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; + // Take strings from resource instead + /* + int i; + if (rbox->Number() == 0) resource->SetStringValues(NULL); - else - { + else + { wxStringList *slist = new wxStringList; - for (i = 0; i < rbox->Number(); i++) + for (i = 0; i < rbox->Number(); i++) slist->Add(rbox->GetString(i)); - resource->SetStringValues(slist); - } -*/ - resource->SetValue1(rbox->GetNumberOfRowsOrCols()); - return wxItemPropertyInfo::InstantiateResource(resource); + resource->SetStringValues(slist); + } + */ + resource->SetValue1(rbox->GetNumberOfRowsOrCols()); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Groupbox item - */ +* Groupbox item +*/ wxProperty *wxGroupBoxPropertyInfo::GetProperty(wxString& name) { - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxGroupBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("label"); } bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - return wxItemPropertyInfo::InstantiateResource(resource); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Checkbox item - */ +* Checkbox item +*/ wxProperty *wxCheckBoxPropertyInfo::GetProperty(wxString& name) { - wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; - if (name == "value") - return new wxProperty("value", checkBox->GetValue(), "bool"); - else - return wxItemPropertyInfo::GetProperty(name); + wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; + if (name == "value") + return new wxProperty("value", checkBox->GetValue(), "bool"); + else + return wxItemPropertyInfo::GetProperty(name); } bool wxCheckBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; - if (name == "value") - { - checkBox->SetValue((bool)property->GetValue().BoolValue()); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; + if (name == "value") + { + checkBox->SetValue((bool)property->GetValue().BoolValue()); + return TRUE; + } + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); - names.Add("value"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("label"); + names.Add("value"); } bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxCheckBox *cbox = (wxCheckBox *)m_propertyWindow; - resource->SetValue1(cbox->GetValue()); - return wxItemPropertyInfo::InstantiateResource(resource); + wxCheckBox *cbox = (wxCheckBox *)m_propertyWindow; + resource->SetValue1(cbox->GetValue()); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Radiobutton item - */ +* Radiobutton item +*/ wxProperty *wxRadioButtonPropertyInfo::GetProperty(wxString& name) { - wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow; - if (name == "value") - return new wxProperty("value", checkBox->GetValue(), "bool"); - else - return wxItemPropertyInfo::GetProperty(name); + wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow; + if (name == "value") + return new wxProperty("value", checkBox->GetValue(), "bool"); + else + return wxItemPropertyInfo::GetProperty(name); } bool wxRadioButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow; - if (name == "value") - { - checkBox->SetValue((bool)property->GetValue().BoolValue()); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow; + if (name == "value") + { + checkBox->SetValue((bool)property->GetValue().BoolValue()); + return TRUE; + } + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("label"); - names.Add("value"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("label"); + names.Add("value"); } bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxRadioButton *cbox = (wxRadioButton *)m_propertyWindow; - resource->SetValue1(cbox->GetValue()); - return wxItemPropertyInfo::InstantiateResource(resource); + wxRadioButton *cbox = (wxRadioButton *)m_propertyWindow; + resource->SetValue1(cbox->GetValue()); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Slider item - */ +* Slider item +*/ wxProperty *wxSliderPropertyInfo::GetProperty(wxString& name) { - wxSlider *slider = (wxSlider *)m_propertyWindow; - if (name == "value") - return new wxProperty("value", (long)slider->GetValue(), "integer"); - else if (name == "orientation") - { - char *pos = NULL; - if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) - pos = "wxHORIZONTAL"; + wxSlider *slider = (wxSlider *)m_propertyWindow; + if (name == "value") + return new wxProperty("value", (long)slider->GetValue(), "integer"); + else if (name == "orientation") + { + char *pos = NULL; + if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) + pos = "wxHORIZONTAL"; + else + pos = "wxVERTICAL"; + + return new wxProperty("orientation", pos, "string", + new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL", + NULL))); + } + else if (name == "minValue") + return new wxProperty("minValue", (long)slider->GetMin(), "integer"); + else if (name == "maxValue") + return new wxProperty("maxValue", (long)slider->GetMax(), "integer"); else - pos = "wxVERTICAL"; - - return new wxProperty("orientation", pos, "string", - new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL", - NULL))); - } - else if (name == "minValue") - return new wxProperty("minValue", (long)slider->GetMin(), "integer"); - else if (name == "maxValue") - return new wxProperty("maxValue", (long)slider->GetMax(), "integer"); - else - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxSliderPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxSlider *slider = (wxSlider *)m_propertyWindow; - if (name == "value") - { - slider->SetValue((int)property->GetValue().IntegerValue()); - return TRUE; - } - else if (name == "orientation") - { - long windowStyle = slider->GetWindowStyleFlag(); - long oldWindowStyle = windowStyle; - wxString val(property->GetValue().StringValue()); - if (val == "wxHORIZONTAL") + wxSlider *slider = (wxSlider *)m_propertyWindow; + if (name == "value") { - if (windowStyle & wxVERTICAL) - windowStyle -= wxVERTICAL; - windowStyle |= wxHORIZONTAL; + slider->SetValue((int)property->GetValue().IntegerValue()); + return TRUE; + } + else if (name == "orientation") + { + long windowStyle = slider->GetWindowStyleFlag(); + long oldWindowStyle = windowStyle; + wxString val(property->GetValue().StringValue()); + if (val == "wxHORIZONTAL") + { + if (windowStyle & wxVERTICAL) + windowStyle -= wxVERTICAL; + windowStyle |= wxHORIZONTAL; + } + else + { + if (windowStyle & wxHORIZONTAL) + windowStyle -= wxHORIZONTAL; + windowStyle |= wxVERTICAL; + } + + if (oldWindowStyle == windowStyle) + return TRUE; + + slider->SetWindowStyleFlag(windowStyle); + + // If the window style has changed, we swap the width and height parameters. + int w, h; + slider->GetSize(&w, &h); + + slider = (wxSlider *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider, this); + slider->SetSize(-1, -1, h, w); + m_propertyWindow = slider; + + return TRUE; + } + else if (name == "minValue") + { + slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax()); + return TRUE; + } + else if (name == "maxValue") + { + slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue()); + return TRUE; } else - { - if (windowStyle & wxHORIZONTAL) - windowStyle -= wxHORIZONTAL; - windowStyle |= wxVERTICAL; - } - - if (oldWindowStyle == windowStyle) - return TRUE; - - slider->SetWindowStyleFlag(windowStyle); - - // If the window style has changed, we swap the width and height parameters. - int w, h; - slider->GetSize(&w, &h); - - slider = (wxSlider *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(slider, this); - slider->SetSize(-1, -1, h, w); - m_propertyWindow = slider; - - return TRUE; - } - else if (name == "minValue") - { - slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax()); - return TRUE; - } - else if (name == "maxValue") - { - slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue()); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxSliderPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("value"); - names.Add("orientation"); - names.Add("minValue"); - names.Add("maxValue"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("value"); + names.Add("orientation"); + names.Add("minValue"); + names.Add("maxValue"); } bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxSlider *slider = (wxSlider *)m_propertyWindow; - resource->SetValue1(slider->GetValue()); - resource->SetValue2(slider->GetMin()); - resource->SetValue3(slider->GetMax()); - return wxItemPropertyInfo::InstantiateResource(resource); + wxSlider *slider = (wxSlider *)m_propertyWindow; + resource->SetValue1(slider->GetValue()); + resource->SetValue2(slider->GetMin()); + resource->SetValue3(slider->GetMax()); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Gauge item - */ +* Gauge item +*/ wxProperty *wxGaugePropertyInfo::GetProperty(wxString& name) { - wxGauge *gauge = (wxGauge *)m_propertyWindow; - if (name == "value") - return new wxProperty("value", (long)gauge->GetValue(), "integer"); - else if (name == "maxValue") - return new wxProperty("maxValue", (long)gauge->GetRange(), "integer"); - else - return wxItemPropertyInfo::GetProperty(name); + wxGauge *gauge = (wxGauge *)m_propertyWindow; + if (name == "value") + return new wxProperty("value", (long)gauge->GetValue(), "integer"); + else if (name == "maxValue") + return new wxProperty("maxValue", (long)gauge->GetRange(), "integer"); + else + return wxItemPropertyInfo::GetProperty(name); } bool wxGaugePropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxGauge *gauge = (wxGauge *)m_propertyWindow; - if (name == "value") - { - gauge->SetValue((int)property->GetValue().IntegerValue()); - return TRUE; - } - else if (name == "maxValue") - { - gauge->SetRange((int)property->GetValue().IntegerValue()); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + wxGauge *gauge = (wxGauge *)m_propertyWindow; + if (name == "value") + { + gauge->SetValue((int)property->GetValue().IntegerValue()); + return TRUE; + } + else if (name == "maxValue") + { + gauge->SetRange((int)property->GetValue().IntegerValue()); + return TRUE; + } + else + return wxItemPropertyInfo::SetProperty(name, property); } void wxGaugePropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("value"); - names.Add("maxValue"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("value"); + names.Add("maxValue"); } bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource) { - wxGauge *gauge = (wxGauge *)m_propertyWindow; - resource->SetValue1(gauge->GetValue()); - resource->SetValue2(gauge->GetRange()); - return wxItemPropertyInfo::InstantiateResource(resource); + wxGauge *gauge = (wxGauge *)m_propertyWindow; + resource->SetValue1(gauge->GetValue()); + resource->SetValue2(gauge->GetRange()); + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Scrollbar item - */ +* Scrollbar item +*/ wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name) { - wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; - if (name == "thumbPosition") - return new wxProperty("value", (long)scrollBar->GetThumbPosition(), "integer"); - else if (name == "orientation") - { - char *pos = NULL; - if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) - pos = "wxHORIZONTAL"; + wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; + if (name == "thumbPosition") + return new wxProperty("value", (long)scrollBar->GetThumbPosition(), "integer"); + else if (name == "orientation") + { + char *pos = NULL; + if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) + pos = "wxHORIZONTAL"; + else + pos = "wxVERTICAL"; + + return new wxProperty("orientation", pos, "string", + new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL", + NULL))); + } + else if (name == "pageSize") + { + int pageLength = scrollBar->GetPageSize(); + + return new wxProperty("pageSize", (long)pageLength, "integer"); + } + else if (name == "thumbSize") + { + int thumbSize = scrollBar->GetThumbSize(); + + return new wxProperty("thumbSize", (long)thumbSize, "integer"); + } + else if (name == "range") + { + int range = scrollBar->GetRange(); + return new wxProperty("range", (long)range, "integer"); + } else - pos = "wxVERTICAL"; - - return new wxProperty("orientation", pos, "string", - new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL", - NULL))); - } - else if (name == "pageSize") - { - int pageLength = scrollBar->GetPageSize(); - - return new wxProperty("pageSize", (long)pageLength, "integer"); - } - else if (name == "thumbSize") - { - int thumbSize = scrollBar->GetThumbSize(); - - return new wxProperty("thumbSize", (long)thumbSize, "integer"); - } - else if (name == "range") - { - int range = scrollBar->GetRange(); - return new wxProperty("range", (long)range, "integer"); - } - else - return wxItemPropertyInfo::GetProperty(name); + return wxItemPropertyInfo::GetProperty(name); } bool wxScrollBarPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; - if (name == "thumbPosition") - { - scrollBar->SetThumbPosition((int)property->GetValue().IntegerValue()); - return TRUE; - } - else if (name == "orientation") - { - long windowStyle = scrollBar->GetWindowStyleFlag(); - long oldWindowStyle = windowStyle; - wxString val(property->GetValue().StringValue()); - if (val == "wxHORIZONTAL") + wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; + if (name == "thumbPosition") { - if (windowStyle & wxVERTICAL) - windowStyle -= wxVERTICAL; - windowStyle |= wxHORIZONTAL; + scrollBar->SetThumbPosition((int)property->GetValue().IntegerValue()); + return TRUE; + } + else if (name == "orientation") + { + long windowStyle = scrollBar->GetWindowStyleFlag(); + long oldWindowStyle = windowStyle; + wxString val(property->GetValue().StringValue()); + if (val == "wxHORIZONTAL") + { + if (windowStyle & wxVERTICAL) + windowStyle -= wxVERTICAL; + windowStyle |= wxHORIZONTAL; + } + else + { + if (windowStyle & wxHORIZONTAL) + windowStyle -= wxHORIZONTAL; + windowStyle |= wxVERTICAL; + } + + if (oldWindowStyle == windowStyle) + return TRUE; + + scrollBar->SetWindowStyleFlag(windowStyle); + + // If the window style has changed, we swap the width and height parameters. + // int w, h; + // scrollBar->GetSize(&w, &h); + wxItemResource *item = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar); + if ( item ) { + item->SetSize(item->GetX(), item->GetY(), item->GetHeight(), item->GetWidth()); + item->SetStyle(windowStyle); + } /* IF */ + + scrollBar = (wxScrollBar *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar, this); + m_propertyWindow = scrollBar; + + return TRUE; + } + else if (name == "pageSize") + { + int pos = scrollBar->GetThumbPosition(); + int range = scrollBar->GetRange(); + int thumbSize = scrollBar->GetThumbSize(); + scrollBar->SetScrollbar(pos, thumbSize, range, (int)property->GetValue().IntegerValue()); + return TRUE; + } + else if (name == "thumbSize") + { + int pos = scrollBar->GetThumbPosition(); + int range = scrollBar->GetRange(); + int pageSize = scrollBar->GetPageSize(); + scrollBar->SetScrollbar(pos, (int)property->GetValue().IntegerValue(), range, pageSize); + return TRUE; + } + else if (name == "range") + { + int pos = scrollBar->GetThumbPosition(); + int thumbSize = scrollBar->GetThumbSize(); + int pageSize = scrollBar->GetPageSize(); + scrollBar->SetScrollbar(pos, thumbSize, (int)property->GetValue().IntegerValue(), pageSize); + return TRUE; } else - { - if (windowStyle & wxHORIZONTAL) - windowStyle -= wxHORIZONTAL; - windowStyle |= wxVERTICAL; - } - - if (oldWindowStyle == windowStyle) - return TRUE; - - scrollBar->SetWindowStyleFlag(windowStyle); - - // If the window style has changed, we swap the width and height parameters. -// int w, h; -// scrollBar->GetSize(&w, &h); - wxItemResource *item = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(scrollBar); - if ( item ) { - item->SetSize(item->GetX(), item->GetY(), item->GetHeight(), item->GetWidth()); - item->SetStyle(windowStyle); - } /* IF */ - - scrollBar = (wxScrollBar *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(scrollBar, this); - m_propertyWindow = scrollBar; - - return TRUE; - } - else if (name == "pageSize") - { - int pos = scrollBar->GetThumbPosition(); - int range = scrollBar->GetRange(); - int thumbSize = scrollBar->GetThumbSize(); - scrollBar->SetScrollbar(pos, thumbSize, range, (int)property->GetValue().IntegerValue()); - return TRUE; - } - else if (name == "thumbSize") - { - int pos = scrollBar->GetThumbPosition(); - int range = scrollBar->GetRange(); - int pageSize = scrollBar->GetPageSize(); - scrollBar->SetScrollbar(pos, (int)property->GetValue().IntegerValue(), range, pageSize); - return TRUE; - } - else if (name == "range") - { - int pos = scrollBar->GetThumbPosition(); - int thumbSize = scrollBar->GetThumbSize(); - int pageSize = scrollBar->GetPageSize(); - scrollBar->SetScrollbar(pos, thumbSize, (int)property->GetValue().IntegerValue(), pageSize); - return TRUE; - } - else - return wxItemPropertyInfo::SetProperty(name, property); + return wxItemPropertyInfo::SetProperty(name, property); } void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList& names) { - wxItemPropertyInfo::GetPropertyNames(names); - names.Add("orientation"); - names.Add("thumbPosition"); - names.Add("thumbSize"); - names.Add("pageSize"); - names.Add("range"); - - // Remove some properties we don't inherit - names.Delete("fontPoints"); - names.Delete("fontFamily"); - names.Delete("fontStyle"); - names.Delete("fontWeight"); - names.Delete("fontUnderlined"); + wxItemPropertyInfo::GetPropertyNames(names); + names.Add("orientation"); + names.Add("thumbPosition"); + names.Add("thumbSize"); + names.Add("pageSize"); + names.Add("range"); + + // Remove some properties we don't inherit + names.Delete("fontPoints"); + names.Delete("fontFamily"); + names.Delete("fontStyle"); + names.Delete("fontWeight"); + names.Delete("fontUnderlined"); } bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxScrollBar *sbar = (wxScrollBar *)m_propertyWindow; - - int thumbPosition = sbar->GetThumbPosition(); - int thumbSize = sbar->GetThumbSize(); - int pageSize = sbar->GetPageSize(); - int range = sbar->GetRange(); - - resource->SetValue1(thumbPosition); - resource->SetValue2(thumbSize); - resource->SetValue3(range); - resource->SetValue5(pageSize); - - return wxItemPropertyInfo::InstantiateResource(resource); + wxScrollBar *sbar = (wxScrollBar *)m_propertyWindow; + + int thumbPosition = sbar->GetThumbPosition(); + int thumbSize = sbar->GetThumbSize(); + int pageSize = sbar->GetPageSize(); + int range = sbar->GetRange(); + + resource->SetValue1(thumbPosition); + resource->SetValue2(thumbSize); + resource->SetValue3(range); + resource->SetValue5(pageSize); + + return wxItemPropertyInfo::InstantiateResource(resource); } /* - * Panels - */ +* Panels +*/ wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name) { - wxPanel *panelWindow = (wxPanel *)m_propertyWindow; - -/* - wxFont *labelFont = panelWindow->GetLabelFont(); - wxFont *buttonFont = panelWindow->GetButtonFont(); - - if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || + wxPanel *panelWindow = (wxPanel *)m_propertyWindow; + + /* + wxFont *labelFont = panelWindow->GetLabelFont(); + wxFont *buttonFont = panelWindow->GetButtonFont(); + + if (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined") - return GetFontProperty(name, labelFont); - else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || + return GetFontProperty(name, labelFont); + else if (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined") - return GetFontProperty(name, buttonFont); -*/ - - if (name == "no3D") - { - bool userColours; - if (panelWindow->GetWindowStyleFlag() & wxNO_3D) - userColours = TRUE; + return GetFontProperty(name, buttonFont); + */ + + if (name == "no3D") + { + bool userColours; + if (panelWindow->GetWindowStyleFlag() & wxNO_3D) + userColours = TRUE; + else + userColours = FALSE; + + return new wxProperty(name, (bool)userColours, "bool"); + } + else if (name == "backgroundColour") + { + wxColour col(panelWindow->GetBackgroundColour()); + char buf[7]; + wxDecToHex(col.Red(), buf); + wxDecToHex(col.Green(), buf+2); + wxDecToHex(col.Blue(), buf+4); + + return new wxProperty(name, buf, "string", new wxColourListValidator); + } + else if (name == "title") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + if (resource) + return new wxProperty(name, resource->GetTitle(), "string"); + else + return new wxProperty(name, "Could not get title", "string"); + } + else if (name == "caption") + { + return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxCAPTION) == wxCAPTION), + "bool"); + } + else if (name == "systemMenu") + { + return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxSYSTEM_MENU) == wxSYSTEM_MENU), + "bool"); + } + else if (name == "thickFrame") + { + return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxTHICK_FRAME) == wxTHICK_FRAME), + "bool"); + } + else if (name == "useSystemDefaults") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) == wxRESOURCE_USE_DEFAULTS), + "bool"); + } + else if (name == "useDialogUnits") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == wxRESOURCE_DIALOG_UNITS), + "bool"); + } else - userColours = FALSE; - - return new wxProperty(name, (bool)userColours, "bool"); - } - else if (name == "backgroundColour") - { - wxColour col(panelWindow->GetBackgroundColour()); - char buf[7]; - wxDecToHex(col.Red(), buf); - wxDecToHex(col.Green(), buf+2); - wxDecToHex(col.Blue(), buf+4); - - return new wxProperty(name, buf, "string", new wxColourListValidator); - } - else if (name == "title") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - if (resource) - return new wxProperty(name, resource->GetTitle(), "string"); - else - return new wxProperty(name, "Could not get title", "string"); - } - else if (name == "caption") - { - return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxCAPTION) == wxCAPTION), - "bool"); - } - else if (name == "systemMenu") - { - return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxSYSTEM_MENU) == wxSYSTEM_MENU), - "bool"); - } - else if (name == "thickFrame") - { - return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxTHICK_FRAME) == wxTHICK_FRAME), - "bool"); - } - else if (name == "useSystemDefaults") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) == wxRESOURCE_USE_DEFAULTS), - "bool"); - } - else if (name == "useDialogUnits") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == wxRESOURCE_DIALOG_UNITS), - "bool"); - } - else - return wxWindowPropertyInfo::GetProperty(name); + return wxWindowPropertyInfo::GetProperty(name); } bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxPanel *panelWindow = (wxPanel *)m_propertyWindow; -/* - wxFont *labelFont = panelWindow->GetLabelFont(); - wxFont *buttonFont = panelWindow->GetButtonFont(); - - if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" )) - { - wxFont *newFont = SetFontProperty(name, property, labelFont); - if (newFont) + wxPanel *panelWindow = (wxPanel *)m_propertyWindow; + /* + wxFont *labelFont = panelWindow->GetLabelFont(); + wxFont *buttonFont = panelWindow->GetButtonFont(); + + if (labelFont && (name == "labelFontPoints" || name == "labelFontFamily" || name == "labelFontStyle" || name == "labelFontWeight" || name == "labelFontUnderlined" )) + { + wxFont *newFont = SetFontProperty(name, property, labelFont); + if (newFont) panelWindow->SetLabelFont(* newFont); - return TRUE; - } - else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" )) - { - wxFont *newFont = SetFontProperty(name, property, buttonFont); - if (newFont) + return TRUE; + } + else if (buttonFont && (name == "buttonFontPoints" || name == "buttonFontFamily" || name == "buttonFontStyle" || name == "buttonFontWeight" || name == "buttonFontUnderlined" )) + { + wxFont *newFont = SetFontProperty(name, property, buttonFont); + if (newFont) panelWindow->SetButtonFont(* newFont); - return TRUE; - } -*/ - - if (name == "no3D") - { - bool userColours = property->GetValue().BoolValue(); + return TRUE; + } + */ - if (userColours) + if (name == "no3D") { - if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) != wxNO_3D) - panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() | wxNO_3D); + bool userColours = property->GetValue().BoolValue(); + + if (userColours) + { + if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) != wxNO_3D) + panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() | wxNO_3D); + } + else + { + if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) == wxNO_3D) + panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() - wxNO_3D); + } + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + resource->SetStyle(panelWindow->GetWindowStyleFlag()); + + panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + return TRUE; } - else + else if (name == "backgroundColour") { - if ((panelWindow->GetWindowStyleFlag() & wxNO_3D) == wxNO_3D) - panelWindow->SetWindowStyleFlag(panelWindow->GetWindowStyleFlag() - wxNO_3D); + char *hex = property->GetValue().StringValue(); + int r = wxHexToDec(hex); + int g = wxHexToDec(hex+2); + int b = wxHexToDec(hex+4); + + wxColour col(r,g,b); + panelWindow->SetBackgroundColour(col); + panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + m_propertyWindow = panelWindow; + return TRUE; } - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - resource->SetStyle(panelWindow->GetWindowStyleFlag()); - - panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); - return TRUE; - } - else if (name == "backgroundColour") - { - char *hex = property->GetValue().StringValue(); - int r = wxHexToDec(hex); - int g = wxHexToDec(hex+2); - int b = wxHexToDec(hex+4); - - wxColour col(r,g,b); - panelWindow->SetBackgroundColour(col); - panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); - m_propertyWindow = panelWindow; - return TRUE; - } - else if (name == "title") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - if (resource) + else if (name == "title") { - resource->SetTitle(property->GetValue().StringValue()); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + if (resource) + { + resource->SetTitle(property->GetValue().StringValue()); + return TRUE; + } + else + return FALSE; + } + else if (name == "caption") + { + SetWindowStyle(panelWindow, wxCAPTION, property->GetValue().BoolValue()); + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + resource->SetStyle(panelWindow->GetWindowStyleFlag()); + return TRUE; + } + else if (name == "thickFrame") + { + SetWindowStyle(panelWindow, wxTHICK_FRAME, property->GetValue().BoolValue()); + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + resource->SetStyle(panelWindow->GetWindowStyleFlag()); + return TRUE; + } + else if (name == "systemMenu") + { + SetWindowStyle(panelWindow, wxSYSTEM_MENU, property->GetValue().BoolValue()); + + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + resource->SetStyle(panelWindow->GetWindowStyleFlag()); + return TRUE; + } + else if (name == "useSystemDefaults") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + bool useDefaults = property->GetValue().BoolValue(); + long style = resource->GetResourceStyle(); + if (useDefaults) + { + if ((style & wxRESOURCE_USE_DEFAULTS) == 0) + style |= wxRESOURCE_USE_DEFAULTS; + } + else + { + if ((style & wxRESOURCE_USE_DEFAULTS) != 0) + style -= wxRESOURCE_USE_DEFAULTS; + } + resource->SetResourceStyle(style); + panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + return TRUE; + } + else if (name == "useDialogUnits") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + bool useDialogUnits = property->GetValue().BoolValue(); + long style = resource->GetResourceStyle(); + if (useDialogUnits) + { + if ((style & wxRESOURCE_DIALOG_UNITS) == 0) + { + style |= wxRESOURCE_DIALOG_UNITS; + ConvertDialogUnits(TRUE); // Convert all resources + } + } + else + { + if ((style & wxRESOURCE_DIALOG_UNITS) != 0) + { + style -= wxRESOURCE_DIALOG_UNITS; + ConvertDialogUnits(FALSE); // Convert all resources + } + } + resource->SetResourceStyle(style); + panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + m_propertyWindow = panelWindow; + // TODO: need to regenerate the width and height properties else they'll be inconsistent. return TRUE; } else - return FALSE; - } - else if (name == "caption") - { - SetWindowStyle(panelWindow, wxCAPTION, property->GetValue().BoolValue()); - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - resource->SetStyle(panelWindow->GetWindowStyleFlag()); - return TRUE; - } - else if (name == "thickFrame") - { - SetWindowStyle(panelWindow, wxTHICK_FRAME, property->GetValue().BoolValue()); - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - resource->SetStyle(panelWindow->GetWindowStyleFlag()); - return TRUE; - } - else if (name == "systemMenu") - { - SetWindowStyle(panelWindow, wxSYSTEM_MENU, property->GetValue().BoolValue()); - - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - resource->SetStyle(panelWindow->GetWindowStyleFlag()); - return TRUE; - } - else if (name == "useSystemDefaults") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - bool useDefaults = property->GetValue().BoolValue(); - long style = resource->GetResourceStyle(); - if (useDefaults) - { - if ((style & wxRESOURCE_USE_DEFAULTS) == 0) - style |= wxRESOURCE_USE_DEFAULTS; - } - else - { - if ((style & wxRESOURCE_USE_DEFAULTS) != 0) - style -= wxRESOURCE_USE_DEFAULTS; - } - resource->SetResourceStyle(style); - panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); - return TRUE; - } - else if (name == "useDialogUnits") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); - bool useDialogUnits = property->GetValue().BoolValue(); - long style = resource->GetResourceStyle(); - if (useDialogUnits) - { - if ((style & wxRESOURCE_DIALOG_UNITS) == 0) - { - style |= wxRESOURCE_DIALOG_UNITS; - ConvertDialogUnits(TRUE); // Convert all resources - } - } - else - { - if ((style & wxRESOURCE_DIALOG_UNITS) != 0) - { - style -= wxRESOURCE_DIALOG_UNITS; - ConvertDialogUnits(FALSE); // Convert all resources - } - } - resource->SetResourceStyle(style); - panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); - m_propertyWindow = panelWindow; - // TODO: need to regenerate the width and height properties else they'll be inconsistent. - return TRUE; - } - else - return wxWindowPropertyInfo::SetProperty(name, property); + return wxWindowPropertyInfo::SetProperty(name, property); } void wxPanelPropertyInfo::GetPropertyNames(wxStringList& names) { - wxWindowPropertyInfo::GetPropertyNames(names); - - names.Add("title"); - names.Add("no3D"); - names.Add("backgroundColour"); - names.Add("caption"); - names.Add("systemMenu"); - names.Add("thickFrame"); - names.Add("useSystemDefaults"); - names.Add("useDialogUnits"); + wxWindowPropertyInfo::GetPropertyNames(names); + + names.Add("title"); + names.Add("no3D"); + names.Add("backgroundColour"); + names.Add("caption"); + names.Add("systemMenu"); + names.Add("thickFrame"); + names.Add("useSystemDefaults"); + names.Add("useDialogUnits"); } bool wxPanelPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxPanel *panel = (wxPanel *)m_propertyWindow; - if (panel->GetFont().Ok()) - resource->SetFont(* wxTheFontList->FindOrCreateFont(panel->GetFont().GetPointSize(), - panel->GetFont().GetFamily(), panel->GetFont().GetStyle(), panel->GetFont().GetWeight(), - panel->GetFont().GetUnderlined(), panel->GetFont().GetFaceName())); - - resource->SetBackgroundColour(wxColour(panel->GetBackgroundColour())); - - return wxWindowPropertyInfo::InstantiateResource(resource); + wxPanel *panel = (wxPanel *)m_propertyWindow; + if (panel->GetFont().Ok()) + resource->SetFont(* wxTheFontList->FindOrCreateFont(panel->GetFont().GetPointSize(), + panel->GetFont().GetFamily(), panel->GetFont().GetStyle(), panel->GetFont().GetWeight(), + panel->GetFont().GetUnderlined(), panel->GetFont().GetFaceName())); + + resource->SetBackgroundColour(wxColour(panel->GetBackgroundColour())); + + return wxWindowPropertyInfo::InstantiateResource(resource); } // Convert this dialog, and its children, to or from dialog units void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits) { wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); - + wxPoint pt; wxSize sz; if (toDialogUnits) @@ -2255,7 +2257,7 @@ void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits) pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(resource->GetX(), resource->GetY())); } resource->SetSize(pt.x, pt.y, sz.x, sz.y); - + wxNode* node = m_propertyWindow->GetChildren().First(); while (node) { @@ -2281,85 +2283,85 @@ void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits) #if 0 /* - * Dialog boxes - */ +* Dialog boxes +*/ wxProperty *wxDialogPropertyInfo::GetProperty(wxString& name) { - wxDialog *dialogWindow = (wxDialog *)m_propertyWindow; - if (name == "modal") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow); - if (!resource) - return NULL; - - bool modal = (resource->GetValue1() != 0); - return new wxProperty(name, modal, "bool"); - } - else - return wxPanelPropertyInfo::GetProperty(name); + wxDialog *dialogWindow = (wxDialog *)m_propertyWindow; + if (name == "modal") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow); + if (!resource) + return NULL; + + bool modal = (resource->GetValue1() != 0); + return new wxProperty(name, modal, "bool"); + } + else + return wxPanelPropertyInfo::GetProperty(name); } bool wxDialogPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxDialog *dialogWindow = (wxDialog *)m_propertyWindow; - - if (name == "modal") - { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow); - if (!resource) - return FALSE; - - resource->SetValue1(property->GetValue().BoolValue()); - return TRUE; - } - else - return wxPanelPropertyInfo::SetProperty(name, property); + wxDialog *dialogWindow = (wxDialog *)m_propertyWindow; + + if (name == "modal") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow); + if (!resource) + return FALSE; + + resource->SetValue1(property->GetValue().BoolValue()); + return TRUE; + } + else + return wxPanelPropertyInfo::SetProperty(name, property); } void wxDialogPropertyInfo::GetPropertyNames(wxStringList& names) { - wxPanelPropertyInfo::GetPropertyNames(names); - names.Add("title"); - names.Add("modal"); + wxPanelPropertyInfo::GetPropertyNames(names); + names.Add("title"); + names.Add("modal"); } bool wxDialogPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxDialog *dialog = (wxDialog *)m_propertyWindow; - wxString str(dialog->GetTitle()); - resource->SetTitle(str); + wxDialog *dialog = (wxDialog *)m_propertyWindow; + wxString str(dialog->GetTitle()); + resource->SetTitle(str); - return wxPanelPropertyInfo::InstantiateResource(resource); + return wxPanelPropertyInfo::InstantiateResource(resource); } #endif /* - * Utilities - */ - +* Utilities +*/ + int wxStringToFontWeight(wxString& val) { - if (val == "wxBOLD") return wxBOLD; - else if (val == "wxLIGHT") return wxLIGHT; - else return wxNORMAL; + if (val == "wxBOLD") return wxBOLD; + else if (val == "wxLIGHT") return wxLIGHT; + else return wxNORMAL; } int wxStringToFontStyle(wxString& val) { - if (val == "wxITALIC") return wxITALIC; - else if (val == "wxSLANT") return wxSLANT; - else return wxNORMAL; + if (val == "wxITALIC") return wxITALIC; + else if (val == "wxSLANT") return wxSLANT; + else return wxNORMAL; } int wxStringToFontFamily(wxString& val) { - if (val == "wxDECORATIVE") return wxDECORATIVE; - else if (val == "wxROMAN") return wxROMAN; - else if (val == "wxSCRIPT") return wxSCRIPT; - else if (val == "wxMODERN") return wxMODERN; - else if (val == "wxTELETYPE") return wxTELETYPE; - else return wxSWISS; + if (val == "wxDECORATIVE") return wxDECORATIVE; + else if (val == "wxROMAN") return wxROMAN; + else if (val == "wxSCRIPT") return wxSCRIPT; + else if (val == "wxMODERN") return wxMODERN; + else if (val == "wxTELETYPE") return wxTELETYPE; + else return wxSWISS; } /// @@ -2368,7 +2370,7 @@ int wxStringToFontFamily(wxString& val) IMPLEMENT_DYNAMIC_CLASS(wxResourceSymbolValidator, wxPropertyListValidator) wxResourceSymbolValidator::wxResourceSymbolValidator(long flags): - wxPropertyListValidator(flags) +wxPropertyListValidator(flags) { } @@ -2378,7 +2380,7 @@ wxResourceSymbolValidator::~wxResourceSymbolValidator(void) bool wxResourceSymbolValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) { - return TRUE; + return TRUE; } // Called when TICK is pressed or focus is lost or view wants to update @@ -2386,11 +2388,11 @@ bool wxResourceSymbolValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxP // Does the transferance from the property editing area to the property itself bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { - if (!view->GetValueText()) - return FALSE; - wxString value(view->GetValueText()->GetValue()); - property->GetValue() = value ; - return TRUE; + if (!view->GetValueText()) + return FALSE; + wxString value(view->GetValueText()->GetValue()); + property->GetValue() = value ; + return TRUE; } // Called when TICK is pressed or focus is lost or view wants to update @@ -2398,108 +2400,108 @@ bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty *property, wxProperty // Does the transferance from the property editing area to the property itself bool wxResourceSymbolValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { - if (!view->GetValueText()) - return FALSE; - wxString str(property->GetValue().GetStringRepresentation()); - view->GetValueText()->SetValue(str); - return TRUE; + if (!view->GetValueText()) + return FALSE; + wxString str(property->GetValue().GetStringRepresentation()); + view->GetValueText()->SetValue(str); + return TRUE; } // Called when the property is double clicked. Extra functionality can be provided, // cycling through possible values. bool wxResourceSymbolValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { - if (!view->GetValueText()) - return FALSE; - OnEdit(property, view, parentWindow); - return TRUE; + if (!view->GetValueText()) + return FALSE; + OnEdit(property, view, parentWindow); + return TRUE; } bool wxResourceSymbolValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(TRUE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(TRUE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(TRUE); - if (view->GetValueText()) - view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); - return TRUE; + if (view->GetConfirmButton()) + view->GetConfirmButton()->Enable(TRUE); + if (view->GetCancelButton()) + view->GetCancelButton()->Enable(TRUE); + if (view->GetEditButton()) + view->GetEditButton()->Enable(TRUE); + if (view->GetValueText()) + view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); + return TRUE; } void wxResourceSymbolValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { - if (!view->GetValueText()) - return; - - wxResourceSymbolDialog* dialog = new wxResourceSymbolDialog(parentWindow, -1, "Edit Symbol"); - - // Split name/id pair e.g. "IDC_TEXT=123" - wxString value(property->GetValue().StringValue()); - - wxString strName = value.Before('='); - wxString strId = value.After('='); - - dialog->SetSymbol(strName); - dialog->SetId(atoi(strId)); - - dialog->Init(); - - if (dialog->ShowModal() == wxID_OK) - { - wxString symbolName(dialog->GetSymbol()); - long id = dialog->GetId(); - - wxString str; - str.Printf("%d", id); - property->GetValue() = symbolName + wxString("=") + str; - - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - } - // Moved from the 'if' branch on suggestion of Roman Pavlov - dialog->Destroy(); + if (!view->GetValueText()) + return; + + wxResourceSymbolDialog* dialog = new wxResourceSymbolDialog(parentWindow, -1, "Edit Symbol"); + + // Split name/id pair e.g. "IDC_TEXT=123" + wxString value(property->GetValue().StringValue()); + + wxString strName = value.Before('='); + wxString strId = value.After('='); + + dialog->SetSymbol(strName); + dialog->SetId(atoi(strId)); + + dialog->Init(); + + if (dialog->ShowModal() == wxID_OK) + { + wxString symbolName(dialog->GetSymbol()); + long id = dialog->GetId(); + + wxString str; + str.Printf("%d", id); + property->GetValue() = symbolName + wxString("=") + str; + + view->DisplayProperty(property); + view->UpdatePropertyDisplayInList(property); + view->OnPropertyChanged(property); + } + // Moved from the 'if' branch on suggestion of Roman Pavlov + dialog->Destroy(); } BEGIN_EVENT_TABLE(wxResourceSymbolDialog, wxDialog) - EVT_BUTTON(wxID_OK, wxResourceSymbolDialog::OnOK) - EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnComboBoxSelect) - EVT_TEXT(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnSymbolNameUpdate) +EVT_BUTTON(wxID_OK, wxResourceSymbolDialog::OnOK) +EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnComboBoxSelect) +EVT_TEXT(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnSymbolNameUpdate) END_EVENT_TABLE() wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, - const wxSize& size, long style): - wxDialog(parent, id, title, pos, size, style) + const wxSize& size, long style): +wxDialog(parent, id, title, pos, size, style) { int x = 5; int y = 5; - + (void) new wxStaticText(this, -1, "Name: ", wxPoint(x, y)); - + x += 80; - + m_nameCtrl = new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX, "", wxPoint(x, y), wxSize(200, -1), 0, NULL, wxCB_DROPDOWN|wxCB_SORT); - + y += 30; x = 5; - + (void) new wxStaticText(this, -1, "Id: ", wxPoint(x, y)); - + x += 80; - + m_idCtrl = new wxTextCtrl(this, ID_SYMBOLID_TEXTCTRL, "", wxPoint(x, y), wxSize(200, -1)); - + y += 30; x = 5; (void) new wxButton(this, wxID_OK, "OK", wxPoint(x, y), wxSize(80, -1)); - + x += 100; (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(x, y), wxSize(80, -1)); - + Fit(); Centre(); } @@ -2508,10 +2510,10 @@ void wxResourceSymbolDialog::Init() { wxString defaultId; defaultId.Printf("%ld", m_symbolId); - + m_nameCtrl->SetValue(m_symbolName); m_idCtrl->SetValue(defaultId); - + wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl); } @@ -2528,7 +2530,7 @@ bool wxResourceSymbolDialog::CheckValues() wxString nameStr(m_nameCtrl->GetValue()); wxString idStr(m_idCtrl->GetValue()); int id = atoi(idStr); - + if (id <= 0 ) { wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this); @@ -2555,7 +2557,7 @@ bool wxResourceSymbolDialog::CheckValues() return FALSE; } // TODO: other checks on the name syntax. - + if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr)) { // If we change the id for an existing symbol, we need to: @@ -2563,23 +2565,23 @@ bool wxResourceSymbolDialog::CheckValues() // If so, will need to change their id to the new id, in SetProperty. // 2) Remove the old symbol, add the new symbol. // In this check, we don't have to do this, but we need to do it in SetProperty. - + if (nameStr == GetSymbol() && id != GetId()) { // It's OK to change the id. But we'll need to change all matching ids in all resources, // in SetProperty. } - + // If we change the name but not the id... we'll just need to remove and // re-add the symbol/id pair, in SetProperty. if (nameStr != GetSymbol() && id == GetId()) { } - + // What if we're changing both the name and the id? // - if there's no symbol of that name, just remove the old, add the new (in SetProperty) // - if there is a symbol of that name, if id matches, do nothing. If not, veto. - + if (nameStr != GetSymbol() && id != GetId()) { if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr, id)) @@ -2589,12 +2591,12 @@ bool wxResourceSymbolDialog::CheckValues() return FALSE; } } - + } - + SetSymbol(nameStr); SetId(id); - + return TRUE; } diff --git a/utils/dialoged/src/winprop.h b/utils/dialoged/src/winprop.h index 27d1ea5a61..c94458aa79 100644 --- a/utils/dialoged/src/winprop.h +++ b/utils/dialoged/src/winprop.h @@ -28,9 +28,9 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); ~wxDialogEditorPropertyListFrame(); - + wxPropertyInfo* GetInfo() const { return m_propInfo; } - + private: wxPropertySheet* m_propSheet; wxPropertyValidatorRegistry m_registry; @@ -41,17 +41,17 @@ private: // feedback. class wxResourcePropertyListView: public wxPropertyListView { - public: - wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT): - wxPropertyListView(propPanel, flags) - { - m_propertyInfo = info; - } - void OnPropertyChanged(wxProperty *property); - bool OnClose(void); - - wxPropertyInfo* m_propertyInfo; - +public: + wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT): + wxPropertyListView(propPanel, flags) + { + m_propertyInfo = info; + } + void OnPropertyChanged(wxProperty *property); + bool OnClose(void); + + wxPropertyInfo* m_propertyInfo; + }; // Generic class for relating an object to a collection of properties. @@ -61,294 +61,294 @@ class wxResourcePropertyListView: public wxPropertyListView class wxPropertyInfo: public wxObject { friend class wxDialogEditorPropertyListFrame; - protected: - static wxWindow *sm_propertyWindow; - wxPropertyInfo(void) - { - } - ~wxPropertyInfo(void) - { - } - public: - virtual wxProperty *GetProperty(wxString& propName) = 0; - virtual bool SetProperty(wxString& propName, wxProperty *property) = 0; - virtual void GetPropertyNames(wxStringList& names) = 0; - virtual bool Edit(wxWindow *parent, const wxString& title); - static void CloseWindow(); // Close the current window if open. +protected: + static wxWindow *sm_propertyWindow; + wxPropertyInfo(void) + { + } + ~wxPropertyInfo(void) + { + } +public: + virtual wxProperty *GetProperty(wxString& propName) = 0; + virtual bool SetProperty(wxString& propName, wxProperty *property) = 0; + virtual void GetPropertyNames(wxStringList& names) = 0; + virtual bool Edit(wxWindow *parent, const wxString& title); + static void CloseWindow(); // Close the current window if open. }; // For all windows class wxWindowPropertyInfo: public wxPropertyInfo { - public: - wxWindowPropertyInfo(wxWindow *win, wxItemResource *res = NULL); - ~wxWindowPropertyInfo(void); - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - - inline void SetPropertyWindow(wxWindow *win) { m_propertyWindow = win; } - - inline void SetResource(wxItemResource *res) { m_propertyResource = res; } - - // Helper functions for font properties - - wxProperty *GetFontProperty(wxString& name, wxFont *font); - wxFont *SetFontProperty(wxString& name, wxProperty *property, wxFont *oldFont); - - // Fill in the wxItemResource members to mirror the current window settings - virtual bool InstantiateResource(wxItemResource *resource); - - // Set the window style - void SetWindowStyle(wxWindow* win, long style, bool set); - - wxWindow* GetWindow() const { return m_propertyWindow; } - wxItemResource* GetResource() const { return m_propertyResource; } - - protected: - wxWindow* m_propertyWindow; - wxItemResource* m_propertyResource; +public: + wxWindowPropertyInfo(wxWindow *win, wxItemResource *res = NULL); + ~wxWindowPropertyInfo(void); + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + + inline void SetPropertyWindow(wxWindow *win) { m_propertyWindow = win; } + + inline void SetResource(wxItemResource *res) { m_propertyResource = res; } + + // Helper functions for font properties + + wxProperty *GetFontProperty(wxString& name, wxFont *font); + wxFont *SetFontProperty(wxString& name, wxProperty *property, wxFont *oldFont); + + // Fill in the wxItemResource members to mirror the current window settings + virtual bool InstantiateResource(wxItemResource *resource); + + // Set the window style + void SetWindowStyle(wxWindow* win, long style, bool set); + + wxWindow* GetWindow() const { return m_propertyWindow; } + wxItemResource* GetResource() const { return m_propertyResource; } + +protected: + wxWindow* m_propertyWindow; + wxItemResource* m_propertyResource; }; // For panel items class wxItemPropertyInfo: public wxWindowPropertyInfo { - protected: - public: - wxItemPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxWindowPropertyInfo(win, res) {} - ~wxItemPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxItemPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxWindowPropertyInfo(win, res) {} + ~wxItemPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For buttons class wxButtonPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) { } - ~wxButtonPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) { } + ~wxButtonPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For bitmap buttons class wxBitmapButtonPropertyInfo: public wxButtonPropertyInfo { - protected: - public: - wxBitmapButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxButtonPropertyInfo(win, res) { } - ~wxBitmapButtonPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxBitmapButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxButtonPropertyInfo(win, res) { } + ~wxBitmapButtonPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For static text controls class wxStaticTextPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) { } - ~wxStaticTextPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) { } + ~wxStaticTextPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For static bitmap controls class wxStaticBitmapPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxStaticBitmapPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) { } - ~wxStaticBitmapPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxStaticBitmapPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) { } + ~wxStaticBitmapPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For text/multitext items class wxTextPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxTextPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxTextPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For list boxes class wxListBoxPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxListBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxListBoxPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxListBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxListBoxPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For choice items class wxChoicePropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxChoicePropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxChoicePropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxChoicePropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxChoicePropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For choice items class wxComboBoxPropertyInfo: public wxChoicePropertyInfo { - protected: - public: - wxComboBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxChoicePropertyInfo(win, res) {} - ~wxComboBoxPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxComboBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxChoicePropertyInfo(win, res) {} + ~wxComboBoxPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For radiobox items class wxRadioBoxPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxRadioBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxRadioBoxPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxRadioBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxRadioBoxPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For groupbox items class wxGroupBoxPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxGroupBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxGroupBoxPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxGroupBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxGroupBoxPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For checkbox items class wxCheckBoxPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxCheckBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxCheckBoxPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxCheckBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxCheckBoxPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For radiobutton items class wxRadioButtonPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxRadioButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxRadioButtonPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxRadioButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxRadioButtonPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For gauge items class wxGaugePropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxGaugePropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxGaugePropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxGaugePropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxGaugePropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For scrollbar items class wxScrollBarPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxScrollBarPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxScrollBarPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxScrollBarPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxScrollBarPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For slider items class wxSliderPropertyInfo: public wxItemPropertyInfo { - protected: - public: - wxSliderPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxItemPropertyInfo(win, res) {} - ~wxSliderPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); +protected: +public: + wxSliderPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxItemPropertyInfo(win, res) {} + ~wxSliderPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); }; // For panels class wxPanelPropertyInfo: public wxWindowPropertyInfo { - protected: - public: - wxPanelPropertyInfo(wxWindow *win, wxItemResource *res = NULL): - wxWindowPropertyInfo(win, res) {} - ~wxPanelPropertyInfo(void) {} - wxProperty *GetProperty(wxString& name); - bool SetProperty(wxString& name, wxProperty *property); - void GetPropertyNames(wxStringList& names); - bool InstantiateResource(wxItemResource *resource); - - // Convert this dialog, and its children, to or from dialog units - void ConvertDialogUnits(bool toDialogUnits); +protected: +public: + wxPanelPropertyInfo(wxWindow *win, wxItemResource *res = NULL): + wxWindowPropertyInfo(win, res) {} + ~wxPanelPropertyInfo(void) {} + wxProperty *GetProperty(wxString& name); + bool SetProperty(wxString& name, wxProperty *property); + void GetPropertyNames(wxStringList& names); + bool InstantiateResource(wxItemResource *resource); + + // Convert this dialog, and its children, to or from dialog units + void ConvertDialogUnits(bool toDialogUnits); }; int wxStringToFontWeight(wxString& val); @@ -356,39 +356,39 @@ int wxStringToFontStyle(wxString& val); int wxStringToFontFamily(wxString& val); /* - * A validator to allow editing symbol/id pairs - */ +* A validator to allow editing symbol/id pairs +*/ class wxResourceSymbolValidator: public wxPropertyListValidator { - DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator) - protected: - public: - wxResourceSymbolValidator(long flags = 0); - - ~wxResourceSymbolValidator(void); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost or view wants to update - // the property list. - // Does the transferance from the property editing area to the property itself - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the edit (...) button is pressed. - void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator) +protected: +public: + wxResourceSymbolValidator(long flags = 0); + + ~wxResourceSymbolValidator(void); + + // Called when TICK is pressed or focus is lost. + // Return FALSE if value didn't check out; signal to restore old value. + bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + + // Called when TICK is pressed or focus is lost or view wants to update + // the property list. + // Does the transferance from the property editing area to the property itself + bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + + bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + + bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + + // Called when the edit (...) button is pressed. + void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); }; /* - * A dialog for editing symbol/id pairs - */ +* A dialog for editing symbol/id pairs +*/ class wxResourceSymbolDialog: public wxDialog { @@ -396,31 +396,31 @@ public: wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); - + void Init(); - + inline void SetSymbol(const wxString& symbol) { m_symbolName = symbol; } inline void SetId(long id) { m_symbolId = id; } - + inline wxString GetSymbol() const { return m_symbolName; } inline long GetId() const { return m_symbolId; } - + bool CheckValues(); void OnOK(wxCommandEvent& event); void OnComboBoxSelect(wxCommandEvent& event); void OnSymbolNameUpdate(wxCommandEvent& event); - + protected: wxString m_symbolName; long m_symbolId; wxComboBox* m_nameCtrl; wxTextCtrl* m_idCtrl; - -DECLARE_EVENT_TABLE() + + DECLARE_EVENT_TABLE() }; #define ID_SYMBOLNAME_COMBOBOX 100 #define ID_SYMBOLID_TEXTCTRL 101 #endif - // _WINPROP_H_ +// _WINPROP_H_ diff --git a/utils/dialoged/src/winstyle.cpp b/utils/dialoged/src/winstyle.cpp index 47b5e92f93..c4abe1509a 100644 --- a/utils/dialoged/src/winstyle.cpp +++ b/utils/dialoged/src/winstyle.cpp @@ -32,244 +32,244 @@ #include "winstyle.h" /* - * Styles - */ +* Styles +*/ - /* wxListBox */ +/* wxListBox */ static wxWindowStylePair g_WindowStylesListBox[] = { - { "wxLB_SINGLE", wxLB_SINGLE }, - { "wxLB_MULTIPLE", wxLB_MULTIPLE }, - { "wxLB_EXTENDED", wxLB_EXTENDED }, - { "wxLB_NEEDED_SB", wxLB_NEEDED_SB }, - { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB }, - { "wxLB_SORT", wxLB_SORT }, - { "wxLB_OWNERDRAW", wxLB_OWNERDRAW }, - { "wxLB_HSCROLL", wxLB_HSCROLL } + { "wxLB_SINGLE", wxLB_SINGLE }, + { "wxLB_MULTIPLE", wxLB_MULTIPLE }, + { "wxLB_EXTENDED", wxLB_EXTENDED }, + { "wxLB_NEEDED_SB", wxLB_NEEDED_SB }, + { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB }, + { "wxLB_SORT", wxLB_SORT }, + { "wxLB_OWNERDRAW", wxLB_OWNERDRAW }, + { "wxLB_HSCROLL", wxLB_HSCROLL } }; int g_WindowStylesListBoxCount = sizeof(g_WindowStylesListBox)/sizeof(wxWindowStylePair) ; - - /* wxComboxBox */ + +/* wxComboxBox */ static wxWindowStylePair g_WindowStylesComboBox[] = { - { "wxCB_SIMPLE", wxCB_SIMPLE }, - { "wxCB_DROPDOWN", wxCB_DROPDOWN }, - { "wxCB_READONLY", wxCB_READONLY }, - { "wxCB_SORT", wxCB_SORT } + { "wxCB_SIMPLE", wxCB_SIMPLE }, + { "wxCB_DROPDOWN", wxCB_DROPDOWN }, + { "wxCB_READONLY", wxCB_READONLY }, + { "wxCB_SORT", wxCB_SORT } }; int g_WindowStylesComboBoxCount = sizeof(g_WindowStylesComboBox)/sizeof(wxWindowStylePair) ; #if 0 - /* wxChoice */ +/* wxChoice */ static wxWindowStylePair g_WindowStylesChoice[] = { }; int g_WindowStylesChoiceCount = sizeof(g_WindowStylesChoice)/sizeof(wxWindowStylePair) ; #endif - - /* wxGauge */ + +/* wxGauge */ static wxWindowStylePair g_WindowStylesGauge[] = { - { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR }, - { "wxGA_HORIZONTAL", wxGA_HORIZONTAL }, - { "wxGA_VERTICAL", wxGA_VERTICAL } + { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR }, + { "wxGA_HORIZONTAL", wxGA_HORIZONTAL }, + { "wxGA_VERTICAL", wxGA_VERTICAL } }; int g_WindowStylesGaugeCount = sizeof(g_WindowStylesGauge)/sizeof(wxWindowStylePair) ; - /* wxTextCtrl */ +/* wxTextCtrl */ static wxWindowStylePair g_WindowStylesTextCtrl[] = { -// { "wxPASSWORD", wxPASSWORD}, -// { "wxPROCESS_ENTER", wxPROCESS_ENTER}, - { "wxTE_PASSWORD", wxTE_PASSWORD}, - { "wxTE_READONLY", wxTE_READONLY}, - { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER}, - { "wxTE_MULTILINE", wxTE_MULTILINE} + // { "wxPASSWORD", wxPASSWORD}, + // { "wxPROCESS_ENTER", wxPROCESS_ENTER}, + { "wxTE_PASSWORD", wxTE_PASSWORD}, + { "wxTE_READONLY", wxTE_READONLY}, + { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER}, + { "wxTE_MULTILINE", wxTE_MULTILINE} }; int g_WindowStylesTextCtrlCount = sizeof(g_WindowStylesTextCtrl)/sizeof(wxWindowStylePair) ; - /* wxRadioButton */ +/* wxRadioButton */ static wxWindowStylePair g_WindowStylesRadioButton[] = { - { "wxRB_GROUP", wxRB_GROUP } + { "wxRB_GROUP", wxRB_GROUP } }; int g_WindowStylesRadioButtonCount = sizeof(g_WindowStylesRadioButton)/sizeof(wxWindowStylePair) ; - /* wxRadioBox */ +/* wxRadioBox */ static wxWindowStylePair g_WindowStylesRadioBox[] = { - { "wxRA_SPECIFY_COLS", wxRA_SPECIFY_COLS }, - { "wxRA_SPECIFY_ROWS", wxRA_SPECIFY_ROWS } -/* - , - { "wxRA_HORIZONTAL", wxRA_HORIZONTAL }, - { "wxRA_VERTICAL", wxRA_VERTICAL } -*/ + { "wxRA_SPECIFY_COLS", wxRA_SPECIFY_COLS }, + { "wxRA_SPECIFY_ROWS", wxRA_SPECIFY_ROWS } + /* + , + { "wxRA_HORIZONTAL", wxRA_HORIZONTAL }, + { "wxRA_VERTICAL", wxRA_VERTICAL } + */ }; int g_WindowStylesRadioBoxCount = sizeof(g_WindowStylesRadioBox)/sizeof(wxWindowStylePair) ; - /* wxSlider */ +/* wxSlider */ static wxWindowStylePair g_WindowStylesSlider[] = { - { "wxSL_HORIZONTAL", wxSL_HORIZONTAL }, - { "wxSL_VERTICAL", wxSL_VERTICAL }, - { "wxSL_AUTOTICKS", wxSL_AUTOTICKS }, - { "wxSL_LABELS", wxSL_LABELS }, - { "wxSL_LEFT", wxSL_LEFT }, - { "wxSL_TOP", wxSL_TOP }, - { "wxSL_RIGHT", wxSL_RIGHT }, - { "wxSL_BOTTOM", wxSL_BOTTOM }, - { "wxSL_BOTH", wxSL_BOTH }, - { "wxSL_SELRANGE", wxSL_SELRANGE } + { "wxSL_HORIZONTAL", wxSL_HORIZONTAL }, + { "wxSL_VERTICAL", wxSL_VERTICAL }, + { "wxSL_AUTOTICKS", wxSL_AUTOTICKS }, + { "wxSL_LABELS", wxSL_LABELS }, + { "wxSL_LEFT", wxSL_LEFT }, + { "wxSL_TOP", wxSL_TOP }, + { "wxSL_RIGHT", wxSL_RIGHT }, + { "wxSL_BOTTOM", wxSL_BOTTOM }, + { "wxSL_BOTH", wxSL_BOTH }, + { "wxSL_SELRANGE", wxSL_SELRANGE } }; int g_WindowStylesSliderCount = sizeof(g_WindowStylesSlider)/sizeof(wxWindowStylePair) ; - /* wxScrollBar */ +/* wxScrollBar */ static wxWindowStylePair g_WindowStylesScrollBar[] = { - { "wxSB_HORIZONTAL", wxSB_HORIZONTAL }, - { "wxSB_VERTICAL", wxSB_VERTICAL } + { "wxSB_HORIZONTAL", wxSB_HORIZONTAL }, + { "wxSB_VERTICAL", wxSB_VERTICAL } }; int g_WindowStylesScrollBarCount = sizeof(g_WindowStylesScrollBar)/sizeof(wxWindowStylePair) ; - /* wxButton */ +/* wxButton */ static wxWindowStylePair g_WindowStylesButton[] = { - { "wxBU_AUTODRAW", wxBU_AUTODRAW }, - { "wxBU_NOAUTODRAW", wxBU_NOAUTODRAW } + { "wxBU_AUTODRAW", wxBU_AUTODRAW }, + { "wxBU_NOAUTODRAW", wxBU_NOAUTODRAW } }; int g_WindowStylesButtonCount = sizeof(g_WindowStylesButton)/sizeof(wxWindowStylePair) ; - /* wxTreeCtrl */ +/* wxTreeCtrl */ static wxWindowStylePair g_WindowStylesTreeCtrl[] = { - { "wxTR_HAS_BUTTONS", wxTR_HAS_BUTTONS }, - { "wxTR_EDIT_LABELS", wxTR_EDIT_LABELS }, - { "wxTR_LINES_AT_ROOT", wxTR_LINES_AT_ROOT } + { "wxTR_HAS_BUTTONS", wxTR_HAS_BUTTONS }, + { "wxTR_EDIT_LABELS", wxTR_EDIT_LABELS }, + { "wxTR_LINES_AT_ROOT", wxTR_LINES_AT_ROOT } }; int g_WindowStylesTreeCtrlCount = sizeof(g_WindowStylesTreeCtrl)/sizeof(wxWindowStylePair) ; - /* wxListCtrl */ +/* wxListCtrl */ static wxWindowStylePair g_WindowStylesListCtrl[] = { - { "wxLC_ICON", wxLC_ICON }, - { "wxLC_SMALL_ICON", wxLC_SMALL_ICON }, - { "wxLC_LIST", wxLC_LIST }, - { "wxLC_REPORT", wxLC_REPORT }, - { "wxLC_ALIGN_TOP", wxLC_ALIGN_TOP }, - { "wxLC_ALIGN_LEFT", wxLC_ALIGN_LEFT }, - { "wxLC_AUTOARRANGE", wxLC_AUTOARRANGE }, - { "wxLC_USER_TEXT", wxLC_USER_TEXT }, - { "wxLC_EDIT_LABELS", wxLC_EDIT_LABELS }, - { "wxLC_NO_HEADER", wxLC_NO_HEADER }, - { "wxLC_NO_SORT_HEADER", wxLC_NO_SORT_HEADER }, - { "wxLC_SINGLE_SEL", wxLC_SINGLE_SEL }, - { "wxLC_SORT_ASCENDING", wxLC_SORT_ASCENDING }, - { "wxLC_SORT_DESCENDING", wxLC_SORT_DESCENDING } + { "wxLC_ICON", wxLC_ICON }, + { "wxLC_SMALL_ICON", wxLC_SMALL_ICON }, + { "wxLC_LIST", wxLC_LIST }, + { "wxLC_REPORT", wxLC_REPORT }, + { "wxLC_ALIGN_TOP", wxLC_ALIGN_TOP }, + { "wxLC_ALIGN_LEFT", wxLC_ALIGN_LEFT }, + { "wxLC_AUTOARRANGE", wxLC_AUTOARRANGE }, + { "wxLC_USER_TEXT", wxLC_USER_TEXT }, + { "wxLC_EDIT_LABELS", wxLC_EDIT_LABELS }, + { "wxLC_NO_HEADER", wxLC_NO_HEADER }, + { "wxLC_NO_SORT_HEADER", wxLC_NO_SORT_HEADER }, + { "wxLC_SINGLE_SEL", wxLC_SINGLE_SEL }, + { "wxLC_SORT_ASCENDING", wxLC_SORT_ASCENDING }, + { "wxLC_SORT_DESCENDING", wxLC_SORT_DESCENDING } }; int g_WindowStylesListCtrlCount = sizeof(g_WindowStylesListCtrl)/sizeof(wxWindowStylePair) ; - /* wxSpinButton */ +/* wxSpinButton */ static wxWindowStylePair g_WindowStylesSpinButton[] = { - { "wxSP_VERTICAL", wxSP_VERTICAL}, - { "wxSP_HORIZONTAL", wxSP_HORIZONTAL}, - { "wxSP_ARROW_KEYS", wxSP_ARROW_KEYS}, - { "wxSP_WRAP", wxSP_WRAP} + { "wxSP_VERTICAL", wxSP_VERTICAL}, + { "wxSP_HORIZONTAL", wxSP_HORIZONTAL}, + { "wxSP_ARROW_KEYS", wxSP_ARROW_KEYS}, + { "wxSP_WRAP", wxSP_WRAP} }; int g_WindowStylesSpinButtonCount = sizeof(g_WindowStylesSpinButton)/sizeof(wxWindowStylePair) ; - /* wxSplitterWindow */ +/* wxSplitterWindow */ static wxWindowStylePair g_WindowStylesSplitterWindow[] = { - { "wxSP_NOBORDER", wxSP_NOBORDER}, - { "wxSP_3D", wxSP_3D}, - { "wxSP_BORDER", wxSP_BORDER} + { "wxSP_NOBORDER", wxSP_NOBORDER}, + { "wxSP_3D", wxSP_3D}, + { "wxSP_BORDER", wxSP_BORDER} }; int g_WindowStylesSplitterWindowCount = sizeof(g_WindowStylesSplitterWindow)/sizeof(wxWindowStylePair) ; - /* wxTabCtrl */ +/* wxTabCtrl */ static wxWindowStylePair g_WindowStylesTabCtrl[] = { - { "wxTC_MULTILINE", wxTC_MULTILINE}, - { "wxTC_RIGHTJUSTIFY", wxTC_RIGHTJUSTIFY}, - { "wxTC_FIXEDWIDTH", wxTC_FIXEDWIDTH}, - { "wxTC_OWNERDRAW", wxTC_OWNERDRAW} + { "wxTC_MULTILINE", wxTC_MULTILINE}, + { "wxTC_RIGHTJUSTIFY", wxTC_RIGHTJUSTIFY}, + { "wxTC_FIXEDWIDTH", wxTC_FIXEDWIDTH}, + { "wxTC_OWNERDRAW", wxTC_OWNERDRAW} }; int g_WindowStylesTabCtrlCount = sizeof(g_WindowStylesTabCtrl)/sizeof(wxWindowStylePair) ; - /* wxStatusBar95 */ +/* wxStatusBar95 */ static wxWindowStylePair g_WindowStylesStatusBar[] = { - { "wxST_SIZEGRIP", wxST_SIZEGRIP} + { "wxST_SIZEGRIP", wxST_SIZEGRIP} }; int g_WindowStylesStatusBarCount = sizeof(g_WindowStylesStatusBar)/sizeof(wxWindowStylePair) ; - /* wxControl */ +/* wxControl */ static wxWindowStylePair g_WindowStylesControl[] = { - { "wxFIXED_LENGTH", wxFIXED_LENGTH}, - { "wxALIGN_LEFT", wxALIGN_LEFT}, - { "wxALIGN_CENTRE", wxALIGN_CENTRE}, - { "wxALIGN_RIGHT", wxALIGN_RIGHT}, - { "wxCOLOURED", wxCOLOURED} + { "wxFIXED_LENGTH", wxFIXED_LENGTH}, + { "wxALIGN_LEFT", wxALIGN_LEFT}, + { "wxALIGN_CENTRE", wxALIGN_CENTRE}, + { "wxALIGN_RIGHT", wxALIGN_RIGHT}, + { "wxCOLOURED", wxCOLOURED} }; int g_WindowStylesControlCount = sizeof(g_WindowStylesControl)/sizeof(wxWindowStylePair) ; - - /* wxToolBar */ + +/* wxToolBar */ static wxWindowStylePair g_WindowStylesToolBar[] = { - { "wxTB_3DBUTTONS", wxTB_3DBUTTONS}, - { "wxTB_HORIZONTAL", wxTB_HORIZONTAL}, - { "wxTB_VERTICAL", wxTB_VERTICAL}, - { "wxTB_FLAT", wxTB_FLAT} + { "wxTB_3DBUTTONS", wxTB_3DBUTTONS}, + { "wxTB_HORIZONTAL", wxTB_HORIZONTAL}, + { "wxTB_VERTICAL", wxTB_VERTICAL}, + { "wxTB_FLAT", wxTB_FLAT} }; int g_WindowStylesToolBarCount = sizeof(g_WindowStylesToolBar)/sizeof(wxWindowStylePair) ; - /* Frame/dialog */ +/* Frame/dialog */ static wxWindowStylePair g_WindowStylesDialog[] = { - { "wxSTAY_ON_TOP", wxSTAY_ON_TOP}, - { "wxCAPTION", wxCAPTION}, - { "wxICONIZE", wxICONIZE}, - { "wxMINIMIZE", wxICONIZE}, - { "wxMAXIMIZE", wxMAXIMIZE}, - { "wxTHICK_FRAME", wxTHICK_FRAME}, - { "wxRESIZE_BORDER", wxRESIZE_BORDER}, - { "wxSYSTEM_MENU", wxSYSTEM_MENU}, - { "wxMINIMIZE_BOX", wxMINIMIZE_BOX}, - { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX}, - { "wxRESIZE_BOX", wxRESIZE_BOX} + { "wxSTAY_ON_TOP", wxSTAY_ON_TOP}, + { "wxCAPTION", wxCAPTION}, + { "wxICONIZE", wxICONIZE}, + { "wxMINIMIZE", wxICONIZE}, + { "wxMAXIMIZE", wxMAXIMIZE}, + { "wxTHICK_FRAME", wxTHICK_FRAME}, + { "wxRESIZE_BORDER", wxRESIZE_BORDER}, + { "wxSYSTEM_MENU", wxSYSTEM_MENU}, + { "wxMINIMIZE_BOX", wxMINIMIZE_BOX}, + { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX}, + { "wxRESIZE_BOX", wxRESIZE_BOX} }; int g_WindowStylesDialogCount = sizeof(g_WindowStylesDialog)/sizeof(wxWindowStylePair) ; - /* Generic */ +/* Generic */ static wxWindowStylePair g_WindowStylesWindow[] = { - { "wxBORDER", wxBORDER}, - { "wxDOUBLE_BORDER", wxDOUBLE_BORDER}, - { "wxSUNKEN_BORDER", wxSUNKEN_BORDER}, - { "wxRAISED_BORDER", wxRAISED_BORDER}, - { "wxSIMPLE_BORDER", wxSIMPLE_BORDER}, - { "wxSTATIC_BORDER", wxSTATIC_BORDER}, - { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW}, - { "wxNO_BORDER", wxNO_BORDER}, - { "wxCLIP_CHILDREN", wxCLIP_CHILDREN} - -/* Would be duplicated with e.g. wxLB_HSCROLL - { "wxVSCROLL", wxVSCROLL }, - { "wxHSCROLL", wxHSCROLL } -*/ + { "wxBORDER", wxBORDER}, + { "wxDOUBLE_BORDER", wxDOUBLE_BORDER}, + { "wxSUNKEN_BORDER", wxSUNKEN_BORDER}, + { "wxRAISED_BORDER", wxRAISED_BORDER}, + { "wxSIMPLE_BORDER", wxSIMPLE_BORDER}, + { "wxSTATIC_BORDER", wxSTATIC_BORDER}, + { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW}, + { "wxNO_BORDER", wxNO_BORDER}, + { "wxCLIP_CHILDREN", wxCLIP_CHILDREN} + + /* Would be duplicated with e.g. wxLB_HSCROLL + { "wxVSCROLL", wxVSCROLL }, + { "wxHSCROLL", wxHSCROLL } + */ }; int g_WindowStylesWindowCount = sizeof(g_WindowStylesWindow)/sizeof(wxWindowStylePair) ; /* - * A table holding all class style objects - */ +* A table holding all class style objects +*/ wxWindowStyleTable::wxWindowStyleTable(): - m_classes(wxKEY_STRING) +m_classes(wxKEY_STRING) { } @@ -294,7 +294,7 @@ void wxWindowStyleTable::Init() AddStyles("wxSlider", g_WindowStylesSliderCount, g_WindowStylesSlider); AddStyles("wxGauge", g_WindowStylesGaugeCount, g_WindowStylesGauge); AddStyles("wxComboBox", g_WindowStylesComboBoxCount, g_WindowStylesComboBox); -// AddStyles("wxChoice", g_WindowStylesChoice, g_WindowStylesChoice); + // AddStyles("wxChoice", g_WindowStylesChoice, g_WindowStylesChoice); AddStyles("wxScrollBar", g_WindowStylesScrollBarCount, g_WindowStylesScrollBar); } @@ -334,25 +334,25 @@ bool wxWindowStyleTable::GenerateStyleStrings(const wxString& className, long wi wxWindowStyleClass* styleClass = FindClass(className); if (!styleClass) return FALSE; - + styleClass->GenerateStyleStrings(windowStyle, buf); return TRUE; } /* - * Holds all the styles for a particular class - */ +* Holds all the styles for a particular class +*/ wxWindowStyleClass::wxWindowStyleClass(int n, wxWindowStylePair *styles) { m_styleCount = n; m_styles = styles; -/* + /* m_styles = new wxWindowStylePair[n]; int i; for (i = 0; i < n; i++) - m_styles[i] = styles[i]; -*/ + m_styles[i] = styles[i]; + */ } wxWindowStyleClass::~wxWindowStyleClass() @@ -371,15 +371,15 @@ bool wxWindowStyleClass::GenerateStyle(char *buf, long windowStyle, long flag, c // Ignore zero flags if (flag == 0) return TRUE; - - if ((windowStyle & flag) == flag) - { - if (strlen(buf) > 0) - strcat(buf, " | "); - strcat(buf, (const char*) strStyle); - return TRUE; - } - else - return FALSE; + + if ((windowStyle & flag) == flag) + { + if (strlen(buf) > 0) + strcat(buf, " | "); + strcat(buf, (const char*) strStyle); + return TRUE; + } + else + return FALSE; } diff --git a/utils/dialoged/src/winstyle.h b/utils/dialoged/src/winstyle.h index d7aaf063f4..1f59adf01f 100644 --- a/utils/dialoged/src/winstyle.h +++ b/utils/dialoged/src/winstyle.h @@ -19,8 +19,8 @@ #include "wx/wx.h" /* - * A class for storing/generating window styles. - */ +* A class for storing/generating window styles. +*/ class wxWindowStyleClass; @@ -37,41 +37,41 @@ class wxWindowStyleTable: public wxObject public: wxWindowStyleTable(); ~wxWindowStyleTable(); - -// Operations + + // Operations void ClearTable(); void AddStyles(const wxString& className, int n, wxWindowStylePair *styles); wxWindowStyleClass* FindClass(const wxString& className) ; bool GenerateStyleStrings(const wxString& className, long windowStyle, char *buf); - + // Initialise with all possible styles void Init(); - -// Members + + // Members protected: wxList m_classes; // A list of wxWindowStyleClass objects, indexed by class name - + }; /* - * Classes for storing all the window style identifiers associated with a particular class - */ +* Classes for storing all the window style identifiers associated with a particular class +*/ class wxWindowStyleClass: public wxObject { public: wxWindowStyleClass(int n, wxWindowStylePair *styles); ~wxWindowStyleClass(); - -// Operations + + // Operations void GenerateStyleStrings(long windowStyle, char *buf); bool GenerateStyle(char *buf, long windowStyle, long flag, const wxString& strStyle); - -// Members + + // Members protected: wxWindowStylePair* m_styles; // An array of wxWindowStylePair objects int m_styleCount; }; #endif - // _DE_WINSTYLE_H_ +// _DE_WINSTYLE_H_