From b46db1f9c9d74c2ef9d8980602d9c37223bad1cd Mon Sep 17 00:00:00 2001 From: twanvl Date: Sun, 13 May 2007 22:21:15 +0000 Subject: [PATCH] Added export toolbar button git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@360 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/set/window.cpp | 39 +++++++++++++++++++++++++++++++++++++-- src/gui/set/window.hpp | 2 ++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index b87a6d2a..c1000edc 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -55,13 +55,13 @@ SetWindow::SetWindow(Window* parent, const SetP& set) menuFile->Append(ID_FILE_OPEN, _("open"), _MENU_("open set"), _HELP_("open set")); menuFile->Append(ID_FILE_SAVE, _("save"), _MENU_("save set"), _HELP_("save set")); menuFile->Append(ID_FILE_SAVE_AS, _MENU_("save set as"), _HELP_("save set as")); - IconMenu* menuExport = new IconMenu(); + menuExport = new IconMenu(); menuExport->Append(ID_FILE_EXPORT_HTML, _("export_html"), _MENU_("export html"), _HELP_("export html")); menuExport->Append(ID_FILE_EXPORT_IMAGE, _("export_image"), _MENU_("export image"), _HELP_("export image")); menuExport->Append(ID_FILE_EXPORT_IMAGES, _("export_images"), _MENU_("export images"), _HELP_("export images")); menuExport->Append(ID_FILE_EXPORT_APPR, _("export_apprentice"), _MENU_("export apprentice"),_HELP_("export apprentice")); menuExport->Append(ID_FILE_EXPORT_MWS, _("export_mws"), _MENU_("export mws"), _HELP_("export mws")); - menuFile->Append(ID_FILE_EXPORT, _("export"), _MENU_("export"), _("Export the set..."), wxITEM_NORMAL, menuExport); + menuFile->Append(wxID_ANY, _("export"), _MENU_("export"), _HELP_("export"), wxITEM_NORMAL, menuExport); menuFile->AppendSeparator(); // menuFile->Append(ID_FILE_INSPECT, _("Inspect Internal Data..."), _("Shows a the data in the set using a tree structure")); // menuFile->AppendSeparator(); @@ -115,6 +115,8 @@ SetWindow::SetWindow(Window* parent, const SetP& set) tb->AddTool(ID_FILE_OPEN, _(""), load_resource_tool_image(_("open")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("open set"), _HELP_("open set")); tb->AddTool(ID_FILE_SAVE, _(""), load_resource_tool_image(_("save")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("save set"), _HELP_("save set")); tb->AddSeparator(); + tb->AddTool(ID_FILE_EXPORT, _(""), load_resource_tool_image(_("export")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("export"), _HELP_("export")); + tb->AddSeparator(); tb->AddTool(ID_EDIT_CUT, _(""), load_resource_tool_image(_("cut")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("cut"), _HELP_("cut")); tb->AddTool(ID_EDIT_COPY, _(""), load_resource_tool_image(_("copy")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("copy"), _HELP_("copy")); tb->AddTool(ID_EDIT_PASTE, _(""), load_resource_tool_image(_("paste")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("paste"), _HELP_("paste")); @@ -432,6 +434,38 @@ void SetWindow::onFileInspect(wxCommandEvent&) { wnd.show(); }*/ +#if defined(__WXMSW__) +#include "wx/msw/wrapcctl.h" +#endif + +void SetWindow::onFileExportMenu(wxCommandEvent& ev) { + // find position of export tool bar button + wxToolBar* tb = GetToolBar(); + int pos = tb->GetToolPos(ev.GetId()); + wxRect tool_rect; + #if defined(__WXMSW__) + RECT r = {0,0,0,0}; + ::SendMessage((HWND)tb->GetHWND(), TB_GETITEMRECT, pos, (LPARAM)&r); + tool_rect.x = r.left; + tool_rect.y = r.top; + tool_rect.width = r.right - r.left; + tool_rect.height = r.bottom - r.top; + #else + // TODO: This is probably not correct! + wxSize tool_size = tb->GetToolSize(); + wxSize tool_margin = tb->GetToolMargins(); + tool_rect.SetSize(tool_size); + tool_rect.y = 0; + tool_rect.x = tool_size.x * pos; + #endif + // tool down + tb->ToggleTool(ev.GetId(), true); + // pop up a menu of export options + tb->PopupMenu(menuExport, tool_rect.x, tool_rect.GetBottom()); + // tool up + tb->ToggleTool(ev.GetId(), false); +} + void SetWindow::onFileExportImage(wxCommandEvent&) { CardP card = current_panel->selectedCard(); if (!card) return; // no card selected @@ -601,6 +635,7 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame) EVT_MENU (ID_FILE_OPEN, SetWindow::onFileOpen) EVT_MENU (ID_FILE_SAVE, SetWindow::onFileSave) EVT_MENU (ID_FILE_SAVE_AS, SetWindow::onFileSaveAs) + EVT_MENU (ID_FILE_EXPORT, SetWindow::onFileExportMenu) EVT_MENU (ID_FILE_EXPORT_IMAGE, SetWindow::onFileExportImage) EVT_MENU (ID_FILE_EXPORT_IMAGES, SetWindow::onFileExportImages) EVT_MENU (ID_FILE_EXPORT_HTML, SetWindow::onFileExportHTML) diff --git a/src/gui/set/window.hpp b/src/gui/set/window.hpp index 13a9655f..71ec6e0b 100644 --- a/src/gui/set/window.hpp +++ b/src/gui/set/window.hpp @@ -39,6 +39,7 @@ class SetWindow : public wxFrame, public SetView { // gui items vector panels; ///< All panels on this window SetWindowPanel* current_panel; + IconMenu* menuExport; /// Number of items in the recent sets list size_t number_of_recentSets; @@ -104,6 +105,7 @@ class SetWindow : public wxFrame, public SetView { void onFileSave (wxCommandEvent&); void onFileSaveAs (wxCommandEvent&); // void onFileInspect (wxCommandEvent&); + void onFileExportMenu (wxCommandEvent&); void onFileExportImage (wxCommandEvent&); void onFileExportImages (wxCommandEvent&); void onFileExportHTML (wxCommandEvent&);