X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8c631bb299230a18a9d2bbb26d28a426c161a8f..8516328f1bf774bbd96ce400945b0f06be93c397:/utils/dialoged/src/reseditr.cpp diff --git a/utils/dialoged/src/reseditr.cpp b/utils/dialoged/src/reseditr.cpp index 9c98a3553f..755e83b153 100644 --- a/utils/dialoged/src/reseditr.cpp +++ b/utils/dialoged/src/reseditr.cpp @@ -44,11 +44,15 @@ #include #include +#if wxUSE_IOSTREAMH #if defined(__WXMSW__) && !defined(__GNUWIN32__) #include #else #include #endif +#else +#include +#endif #ifdef __WXMSW__ #include @@ -82,6 +86,11 @@ wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL; #include "bitmaps/toback.xpm" #include "bitmaps/help.xpm" #include "bitmaps/wxwin.xpm" + +#include "bitmaps/dialog.xpm" +#include "bitmaps/folder1.xpm" +#include "bitmaps/folder2.xpm" +#include "bitmaps/buttonsm.xpm" #endif /* @@ -150,13 +159,8 @@ bool wxResourceManager::Initialize() strcat(buf, "\\dialoged.ini"); m_optionsResourceFilename = buf; #elif defined(__WXGTK__) - /* - wxString buf; - wxGetHomeDir(&buf); - buf += "/.dialogedrc"; - m_optionsResourceFilename = buf; - */ - m_optionsResourceFilename = ".dialoged.rc"; + wxGetHomeDir( &m_optionsResourceFilename ); + m_optionsResourceFilename += "/.dialogedrc"; #else #error "Unsupported platform." #endif @@ -188,11 +192,16 @@ bool wxResourceManager::Initialize() 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 ); +#endif m_imageList.Add(icon1); m_imageList.Add(icon2); m_imageList.Add(icon3); m_imageList.Add(icon4); -#endif m_symbolTable.AddStandardSymbols(); @@ -314,7 +323,7 @@ bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent) c->bottom.SameAs (m_editorFrame, wxBottom, 0); c->width.Unconstrained(); #ifdef __WXGTK__ - c->height.Absolute(140); + c->height.Absolute(105); #else c->height.Absolute(60); #endif @@ -520,7 +529,7 @@ bool wxResourceManager::DisassociateWindows() { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); DisassociateResource(res); @@ -546,7 +555,7 @@ void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *wi else { char buf[200]; - sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? child->GetName() : "(unnamed)"); + sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)"); wxMessageBox(buf, "Dialog Editor problem", wxOK); } @@ -561,18 +570,15 @@ bool wxResourceManager::DisassociateResource(wxItemResource *resource) return FALSE; // Disassociate children of window - if (win->GetChildren()) + wxNode *node = win->GetChildren().First(); + while (node) { - wxNode *node = win->GetChildren()->First(); - while (node) - { - wxWindow *child = (wxWindow *)node->Data(); - if (child->IsKindOf(CLASSINFO(wxControl))) - DisassociateResource(child); - node = node->Next(); - } + wxWindow *child = (wxWindow *)node->Data(); + if (child->IsKindOf(CLASSINFO(wxControl))) + DisassociateResource(child); + node = node->Next(); } - + RemoveSelection(win); m_resourceAssociations.Delete((long)resource); return TRUE; @@ -600,7 +606,7 @@ bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow* win) win->PopEventHandler(); // Now reset all child event handlers - wxNode *node = win->GetChildren()->First(); + wxNode *node = win->GetChildren().First(); while ( node ) { wxWindow *child = (wxWindow *)node->Data(); @@ -649,12 +655,12 @@ wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win) { m_resourceAssociations.BeginFind(); wxNode *node; - while (node = m_resourceAssociations.Next()) + while ((node = m_resourceAssociations.Next())) { wxWindow *w = (wxWindow *)node->Data(); if (w == win) { - return (wxItemResource *)node->key.integer; + return (wxItemResource *)node->GetKeyInteger(); } } return NULL; @@ -680,8 +686,10 @@ void wxResourceManager::MakeUniqueName(char *prefix, char *buf) 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), @@ -692,8 +700,7 @@ wxFrame *wxResourceManager::OnCreateEditorFrame(const char *title) frame->SetAutoLayout(TRUE); #ifdef __WXMSW__ - wxIcon *icon = new wxIcon("DIALOGEDICON"); - frame->SetIcon(icon); + frame->SetIcon(wxIcon("DIALOGEDICON")); #endif return frame; } @@ -790,47 +797,47 @@ wxToolBar *wxResourceManager::OnCreateToolBar(wxFrame *parent) #endif int currentX = gap; toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_NEW, ToolbarNewBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_NEW, ToolbarNewBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "New dialog"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_LOAD_FILE, ToolbarLoadBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_LOAD_FILE, ToolbarLoadBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Load"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_SAVE_FILE, ToolbarSaveBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_SAVE_FILE, ToolbarSaveBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Save"); currentX += width + dx + gap; toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_FORMAT_HORIZ, ToolbarVertBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_FORMAT_HORIZ, ToolbarVertBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Horizontal align"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN, ToolbarAlignTBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN, ToolbarAlignTBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Top align"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN, ToolbarAlignBBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN, ToolbarAlignBBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Bottom align"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_VERT, ToolbarHorizBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_FORMAT_VERT, ToolbarHorizBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Vertical align"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN, ToolbarAlignLBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN, ToolbarAlignLBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Left align"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN, ToolbarAlignRBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN, ToolbarAlignRBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Right align"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_COPY_SIZE, ToolbarCopySizeBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_COPY_SIZE, ToolbarCopySizeBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Copy size"); currentX += width + dx + gap; toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_TO_FRONT, ToolbarToFrontBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_TO_FRONT, ToolbarToFrontBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "To front"); currentX += width + dx; - toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "To back"); currentX += width + dx + gap; toolbar->AddSeparator(); - toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, (wxBitmap *)NULL, + toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Help"); currentX += width + dx; @@ -847,15 +854,11 @@ void wxResourceManager::UpdateResourceList() m_editorResourceTree->SetInvalid(TRUE); m_editorResourceTree->DeleteAllItems(); - long id = m_editorResourceTree->InsertItem(0, "Dialogs" -#ifdef __WXMSW__ - , 1, 2 -#endif - ); + long id = m_editorResourceTree->AddRoot("Dialogs", 1, 2); m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -864,7 +867,7 @@ void wxResourceManager::UpdateResourceList() AddItemsRecursively(id, res); } } - m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND); + m_editorResourceTree->Expand(id); m_editorResourceTree->SetInvalid(FALSE); } @@ -880,13 +883,9 @@ void wxResourceManager::AddItemsRecursively(long parent, wxItemResource *resourc else imageId = 3; - long id = m_editorResourceTree->InsertItem(parent, theString -#ifdef __WXMSW__ - , imageId -#endif - ); + long id = m_editorResourceTree->AppendItem(parent, theString, imageId ); - m_editorResourceTree->SetItemData(id, (long) resource); + m_editorResourceTree->SetItemData(id, new wxResourceTreeData(resource)); if (strcmp(resource->GetType(), "wxBitmap") != 0) { @@ -898,7 +897,7 @@ void wxResourceManager::AddItemsRecursively(long parent, wxItemResource *resourc node = node->Next(); } } - m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND); +// m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND); } bool wxResourceManager::EditSelectedResource() @@ -906,7 +905,8 @@ bool wxResourceManager::EditSelectedResource() int sel = m_editorResourceTree->GetSelection(); if (sel != 0) { - wxItemResource *res = (wxItemResource *)m_editorResourceTree->GetItemData(sel); + wxResourceTreeData *data = (wxResourceTreeData *)m_editorResourceTree->GetItemData(sel); + wxItemResource *res = data->GetResource(); return Edit(res); } return FALSE; @@ -926,8 +926,8 @@ bool wxResourceManager::Edit(wxItemResource *res) } else { - long style = res->GetStyle(); - res->SetStyle(style|wxRAISED_BORDER); +// long style = res->GetStyle(); +// res->SetStyle(style|wxRAISED_BORDER); panel = new wxPanel; wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(panel, res, panel->GetEventHandler(), this); @@ -936,7 +936,7 @@ bool wxResourceManager::Edit(wxItemResource *res) panel->PushEventHandler(handler); - res->SetStyle(style); +// res->SetStyle(style); handler->AddChildHandlers(); // Add event handlers for all controls AssociateResource(res, panel); @@ -962,6 +962,8 @@ bool wxResourceManager::CreateNewPanel() 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); @@ -972,13 +974,19 @@ bool wxResourceManager::CreateNewPanel() m_resourceTable.AddResource(resource); + wxSize size(400, 300); + wxPanel *panel = new wxPanel(m_editorPanel, -1, wxPoint(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()), - wxSize(400, 300), wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf); + size, wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf); m_editorPanel->m_childWindow = panel; resource->SetStyle(panel->GetWindowStyleFlag()); - resource->SetSize(10, 10, 400, 300); + + // 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. @@ -1012,7 +1020,14 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * wxItemResource *res = new wxItemResource; wxControl *newItem = NULL; - res->SetSize(x, y, -1, -1); + + 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; @@ -1025,7 +1040,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * MakeUniqueName("button", buf); res->SetName(buf); if (isBitmap) - newItem = new wxBitmapButton(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); + newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); else newItem = new wxButton(panel, -1, "Button", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); } @@ -1034,7 +1049,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * prefix = "ID_BITMAPBUTTON"; MakeUniqueName("button", buf); res->SetName(buf); - newItem = new wxBitmapButton(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); + newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf); } else if (itemType == "wxMessage" || itemType == "wxStaticText") { @@ -1042,7 +1057,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * MakeUniqueName("statictext", buf); res->SetName(buf); if (isBitmap) - newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf); + 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); } @@ -1051,7 +1066,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * prefix = "ID_STATICBITMAP"; MakeUniqueName("static", buf); res->SetName(buf); - newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf); + newItem = new wxStaticBitmap(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf); } else if (itemType == "wxCheckBox") { @@ -1075,7 +1090,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * wxString names[] = { "One", "Two" }; newItem = new wxRadioBox(panel, -1, "Radiobox", wxPoint(x, y), wxSize(-1, -1), 2, names, 2, wxHORIZONTAL, wxDefaultValidator, buf); - res->SetStringValues(new wxStringList("One", "Two", NULL)); + res->SetStringValues(wxStringList("One", "Two", NULL)); } else if (itemType == "wxRadioButton") { @@ -1147,6 +1162,16 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * 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); @@ -1189,16 +1214,13 @@ bool wxResourceManager::TestCurrentDialog(wxWindow* parent) InstantiateResourceFromWindow(item, m_editorPanel->m_childWindow, TRUE); wxDialog* dialog = new wxDialog; - long oldStyle = item->GetStyle(); bool success = FALSE; -// item->SetStyle(wxDEFAULT_DIALOG_STYLE); if (dialog->LoadFromResource(parent, item->GetName(), & m_resourceTable)) { dialog->Centre(); dialog->ShowModal(); success = TRUE; } -// item->SetStyle(oldStyle); return success; } return FALSE; @@ -1210,13 +1232,13 @@ wxWindow *wxResourceManager::FindParentOfSelection() { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxWindow *win = FindWindowForResource(res); if (win) { - wxNode *node1 = win->GetChildren()->First(); + wxNode *node1 = win->GetChildren().First(); while (node1) { wxControl *item = (wxControl *)node1->Data(); @@ -1252,7 +1274,7 @@ void wxResourceManager::AlignItems(int flag) int centreX = (int)(firstX + (firstW / 2)); int centreY = (int)(firstY + (firstH / 2)); - while (node = node->Next()) + while ((node = node->Next())) { wxControl *item = (wxControl *)node->Data(); if (item->GetParent() == win) @@ -1306,7 +1328,22 @@ void wxResourceManager::AlignItems(int flag) 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(); @@ -1331,14 +1368,28 @@ void wxResourceManager::CopySize() 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()) + while ((node = node->Next())) { wxControl *item = (wxControl *)node->Data(); if (item->GetParent() == win) + { item->SetSize(-1, -1, firstW, 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)); + firstW = sz.x; firstH = sz.y; + } + resource->SetSize(resource->GetX(), resource->GetY(), firstW, firstH); + + } } win->Refresh(); } @@ -1357,18 +1408,18 @@ void wxResourceManager::ToBackOrFront(bool toBack) wxItemResource *itemResource = FindResourceForWindow(item); if (item->GetParent() == win) { - win->GetChildren()->DeleteObject(item); + win->GetChildren().DeleteObject(item); if (winResource) winResource->GetChildren().DeleteObject(itemResource); if (toBack) { - win->GetChildren()->Insert(item); + win->GetChildren().Insert(item); if (winResource) winResource->GetChildren().Insert(itemResource); } else { - win->GetChildren()->Append(item); + win->GetChildren().Append(item); if (winResource) winResource->GetChildren().Append(itemResource); } @@ -1395,7 +1446,7 @@ bool wxResourceManager::RemoveResourceFromParent(wxItemResource *res) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *thisRes = (wxItemResource *)node->Data(); if (thisRes->GetChildren().Member(res)) @@ -1426,11 +1477,13 @@ bool wxResourceManager::DeleteResource(wxItemResource *res) // 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())) @@ -1456,7 +1509,9 @@ bool wxResourceManager::DeleteResource(wxWindow *win) { RemoveSelection(item); childHandler->SelectItem(FALSE); +#ifndef __WXGTK__ item->GetParent()->Refresh(); +#endif } } @@ -1471,7 +1526,7 @@ bool wxResourceManager::DeleteResource(wxWindow *win) // Will eventually have bitmap type information, for different // kinds of bitmap. -char *wxResourceManager::AddBitmapResource(char *filename) +wxString wxResourceManager::AddBitmapResource(const wxString& filename) { wxItemResource *resource = FindBitmapResourceByFilename(filename); if (!resource) @@ -1500,11 +1555,11 @@ char *wxResourceManager::AddBitmapResource(char *filename) if (resource) return resource->GetName(); else - return NULL; + return wxEmptyString; } // Delete the bitmap resource if it isn't being used by another resource. -void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName) +void wxResourceManager::PossiblyDeleteBitmapResource(const wxString& resourceName) { if (!IsBitmapResourceUsed(resourceName)) { @@ -1514,11 +1569,11 @@ void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName) } } -bool wxResourceManager::IsBitmapResourceUsed(char *resourceName) +bool wxResourceManager::IsBitmapResourceUsed(const wxString& resourceName) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1542,13 +1597,13 @@ bool wxResourceManager::IsBitmapResourceUsed(char *resourceName) } // Given a wxButton or wxMessage, find the corresponding bitmap filename. -char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) +wxString wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) { - if (!resource || !resource->GetValue4()) - return NULL; + if (!resource || (resource->GetValue4() == "")) + return wxEmptyString; wxItemResource *bitmapResource = m_resourceTable.FindResource(resource->GetValue4()); if (!bitmapResource) - return NULL; + return wxEmptyString; wxNode *node = bitmapResource->GetChildren().First(); while (node) @@ -1561,14 +1616,14 @@ char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) node = node->Next(); } - return NULL; + return wxEmptyString; } -wxItemResource *wxResourceManager::FindBitmapResourceByFilename(char *filename) +wxItemResource *wxResourceManager::FindBitmapResourceByFilename(const wxString& filename) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1595,7 +1650,7 @@ bool wxResourceManager::IsSymbolUsed(wxItemResource* thisResource, wxWindowID id { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); @@ -1638,7 +1693,7 @@ void wxResourceManager::ChangeIds(int oldId, int newId) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); @@ -1670,7 +1725,7 @@ bool wxResourceManager::RepairResourceIds() m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1746,6 +1801,9 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP wxWindow *newWin = NULL; wxWindow *parent = win->GetParent(); + wxItemResource* parentResource = NULL; + if (parent) + parentResource = FindResourceForWindow(parent); if (win->IsKindOf(CLASSINFO(wxPanel))) { @@ -1759,7 +1817,7 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP win->PopEventHandler(TRUE); DeleteWindow(win); - newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource); + newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource, parentResource); newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin)); AssociateResource(resource, newWin); UpdateResourceList(); @@ -1780,7 +1838,8 @@ bool wxResourceManager::DeleteSelection() int sel = m_editorResourceTree->GetSelection(); if (sel != 0) { - wxItemResource *res = (wxItemResource *)m_editorResourceTree->GetItemData(sel); + wxResourceTreeData *data = (wxResourceTreeData *)m_editorResourceTree->GetItemData(sel); + wxItemResource *res = data->GetResource(); wxWindow *win = FindWindowForResource(res); if (win) { @@ -1815,7 +1874,7 @@ bool wxResourceManager::RecreateSelection() return TRUE; } -bool wxResourceManager::EditDialog(wxDialog *dialog, wxWindow *parent) +bool wxResourceManager::EditDialog(wxDialog *WXUNUSED(dialog), wxWindow *WXUNUSED(parent)) { return FALSE; } @@ -1826,7 +1885,7 @@ bool wxResourceManager::InstantiateAllResourcesFromWindows() { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1865,7 +1924,7 @@ bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource *resource, if (!childWindow) { char buf[200]; - sprintf(buf, "Could not find window %s", child->GetName()); + sprintf(buf, "Could not find window %s", (const char*) child->GetName()); wxMessageBox(buf, "Dialog Editor problem", wxOK); } else @@ -1913,30 +1972,30 @@ wxWindowPropertyInfo *wxResourceManager::CreatePropertyInfoForWindow(wxWindow *w { info = new wxRadioButtonPropertyInfo(win); } - else if (win->IsKindOf(CLASSINFO(wxChoice))) - { - info = new wxChoicePropertyInfo(win); - } else if (win->IsKindOf(CLASSINFO(wxComboBox))) { info = new wxComboBoxPropertyInfo(win); } - else if (win->IsKindOf(CLASSINFO(wxButton))) + else if (win->IsKindOf(CLASSINFO(wxChoice))) { - info = new wxButtonPropertyInfo(win); + info = new wxChoicePropertyInfo(win); } else if (win->IsKindOf(CLASSINFO(wxBitmapButton))) { info = new wxBitmapButtonPropertyInfo(win); } - else if (win->IsKindOf(CLASSINFO(wxStaticText))) + else if (win->IsKindOf(CLASSINFO(wxButton))) { - info = new wxStaticTextPropertyInfo(win); + 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); @@ -2058,8 +2117,8 @@ void wxResourceEditorFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event)) void wxResourceEditorFrame::OnExit(wxCommandEvent& WXUNUSED(event)) { - manager->Clear(TRUE, FALSE) ; - this->Close(); + manager->Clear(TRUE, FALSE) ; + this->Destroy(); } void wxResourceEditorFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) @@ -2235,7 +2294,7 @@ EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& s { } -bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled) +bool EditorToolBar::OnLeftClick(int toolIndex, bool WXUNUSED(toggled)) { wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager();