diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index 275328e7..5070d932 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -37,6 +37,8 @@ menu: cards tab: &Cards help: &Help + index: &Index... F1 + website: &Website... about: &About Not Quite Magic Set Editor... # symbol editor @@ -84,6 +86,9 @@ help: new window: Creates another window to edit the same set help: + index: + website: + about: # symbol editor diff --git a/src/data/settings.cpp b/src/data/settings.cpp index a9b80275..ea7d0063 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -90,6 +90,7 @@ Settings::Settings() , card_notes_height (40) , updates_url (_("http://magicseteditor.sourceforge.net/updates")) , check_updates (CHECK_IF_CONNECTED) + , website_url (_("http://magicseteditor.sourceforge.net/")) {} void Settings::addRecentFile(const String& filename) { @@ -158,6 +159,7 @@ IMPLEMENT_REFLECTION(Settings) { REFLECT(apprentice_location); REFLECT(updates_url); REFLECT(check_updates); + REFLECT(website_url); REFLECT(game_settings); REFLECT(stylesheet_settings); REFLECT(default_stylesheet_settings); diff --git a/src/data/settings.hpp b/src/data/settings.hpp index 58e1e102..9aa79b83 100644 --- a/src/data/settings.hpp +++ b/src/data/settings.hpp @@ -125,6 +125,7 @@ class Settings { // --------------------------------------------------- : Update checking String updates_url; CheckUpdates check_updates; + String website_url; // --------------------------------------------------- : The io diff --git a/src/gui/about_window.cpp b/src/gui/about_window.cpp index 265a7e3b..390b61d4 100644 --- a/src/gui/about_window.cpp +++ b/src/gui/about_window.cpp @@ -14,12 +14,12 @@ // ----------------------------------------------------------------------------- : About window AboutWindow::AboutWindow(Window* parent) - : wxDialog(parent, wxID_ANY, _TITLE_("about"), wxDefaultPosition, wxSize(510,340), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE) + : wxDialog(parent, wxID_ANY, _TITLE_("about"), wxDefaultPosition, wxSize(510,340), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL) , logo (load_resource_image(_("about"))) , logo2(load_resource_image(_("two"))) { // init controls - wxButton* ok_button = new HoverButton(this, wxID_OK, _("btn_ok")); + wxControl* ok_button = new HoverButton(this, wxID_OK, _("btn_ok")); wxSize bs = ok_button->GetSize(), ws = GetClientSize(); ok_button->Move(ws.GetWidth() - bs.GetWidth(), ws.GetHeight() - bs.GetHeight()); // align bottom right } @@ -65,22 +65,81 @@ END_EVENT_TABLE () HoverButton::HoverButton(Window* parent, int id, const String& name) - : normal(load_resource_image(name + _("_NORMAL"))) - , hover (load_resource_image(name + _("_HOVER"))) + : wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxNO_BORDER) + , bg_normal(load_resource_image(name + _("_normal"))) + , bg_hover (load_resource_image(name + _("_hover"))) + , bg_focus (load_resource_image(name + _("_focus"))) + , bg_down (load_resource_image(name + _("_down"))) + , hover(false), focus(false), mouse_down(false), key_down(false) + , last_drawn(nullptr) { - Create(parent, id, normal, wxDefaultPosition, wxSize(normal.GetWidth(), normal.GetHeight()), 0); + SetSize(DoGetBestSize()); } void HoverButton::onMouseEnter(wxMouseEvent&) { - SetBitmapLabel(hover); - Refresh(false); + hover = true; + refreshIfNeeded(); } void HoverButton::onMouseLeave(wxMouseEvent&) { - SetBitmapLabel(normal); - Refresh(false); + hover = false; + refreshIfNeeded(); +} +void HoverButton::onFocus(wxFocusEvent&) { + focus = true; + refreshIfNeeded(); +} +void HoverButton::onKillFocus(wxFocusEvent&) { + focus = false; + refreshIfNeeded(); +} +void HoverButton::onLeftDown(wxMouseEvent&) { + mouse_down = true; + SetFocus(); + CaptureMouse(); + refreshIfNeeded(); +} +void HoverButton::onLeftUp(wxMouseEvent&) { + if (HasCapture()) ReleaseMouse(); + if (mouse_down && hover) { + mouse_down = false; + refreshIfNeeded(); + wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); + ProcessEvent(evt); + } + mouse_down = false; +} +void HoverButton::onKeyDown(wxKeyEvent& ev) { + int code = ev.GetKeyCode(); + if (code == WXK_RETURN || code == WXK_SPACE) { + key_down = true; + refreshIfNeeded(); + } else { + ev.Skip(); + } +} +void HoverButton::onKeyUp(wxKeyEvent& ev) { + int code = ev.GetKeyCode(); + if (code == WXK_RETURN || code == WXK_SPACE) { + key_down = false; + refreshIfNeeded(); + wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); + ProcessEvent(evt); + } +} + +wxSize HoverButton::DoGetBestSize() const { + return wxSize(bg_normal.GetWidth(), bg_normal.GetHeight()); +} + +const Bitmap* HoverButton::toDraw() const { + return (mouse_down && hover) || key_down ? &bg_down + : hover ? &bg_hover + : focus ? &bg_focus + : &bg_normal; +} +void HoverButton::refreshIfNeeded() { + if (last_drawn != toDraw()) Refresh(false); } -void HoverButton::onFocus(wxFocusEvent&) {} -void HoverButton::onKillFocus(wxFocusEvent&) {} void HoverButton::onPaint(wxPaintEvent&) { wxPaintDC dc(this); @@ -95,13 +154,21 @@ void HoverButton::draw(DC& dc) { dc.SetBrush(Color(240,247,255)); dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); // draw button - dc.DrawBitmap(GetBitmapLabel(), 0, 0); + dc.DrawBitmap(*toDraw(), 0, 0); + last_drawn = toDraw(); +} +int HoverButton::drawDelta() const { + return (mouse_down && hover) || key_down ? 2 : 0; } -BEGIN_EVENT_TABLE(HoverButton, wxBitmapButton) +BEGIN_EVENT_TABLE(HoverButton, wxControl) EVT_ENTER_WINDOW (HoverButton::onMouseEnter) EVT_LEAVE_WINDOW (HoverButton::onMouseLeave) EVT_PAINT (HoverButton::onPaint) EVT_SET_FOCUS (HoverButton::onFocus) EVT_KILL_FOCUS (HoverButton::onKillFocus) + EVT_LEFT_DOWN (HoverButton::onLeftDown) + EVT_LEFT_UP (HoverButton::onLeftUp) + EVT_KEY_DOWN (HoverButton::onKeyDown) + EVT_KEY_UP (HoverButton::onKeyUp) END_EVENT_TABLE () diff --git a/src/gui/about_window.hpp b/src/gui/about_window.hpp index b83dc43c..1e789887 100644 --- a/src/gui/about_window.hpp +++ b/src/gui/about_window.hpp @@ -31,23 +31,34 @@ class AboutWindow : public wxDialog { // ----------------------------------------------------------------------------- : Button with image and hover effect // A button that changes images on mouseenter/leave -class HoverButton : public wxBitmapButton { +class HoverButton : public wxControl { public: HoverButton(Window* parent, int id, const String& name); private: DECLARE_EVENT_TABLE(); - Bitmap normal, hover; /// Bitmaps for the states of the button + Bitmap bg_normal, bg_hover, bg_focus, bg_down; /// Bitmaps for the states of the button + bool hover, focus, mouse_down, key_down; void onMouseEnter(wxMouseEvent&); void onMouseLeave(wxMouseEvent&); void onFocus (wxFocusEvent& ev); void onKillFocus (wxFocusEvent& ev); void onPaint (wxPaintEvent&); + void onLeftUp (wxMouseEvent&); + void onLeftDown (wxMouseEvent&); + void onKeyDown (wxKeyEvent&); + void onKeyUp (wxKeyEvent&); + virtual wxSize DoGetBestSize() const; + + const Bitmap* last_drawn; + const Bitmap* toDraw() const; + void refreshIfNeeded(); protected: virtual void draw(DC& dc); + int drawDelta() const; }; diff --git a/src/gui/new_window.cpp b/src/gui/new_window.cpp index 3a45251e..d22aa541 100644 --- a/src/gui/new_window.cpp +++ b/src/gui/new_window.cpp @@ -27,6 +27,7 @@ SetP new_set_window(Window* parent) { NewSetWindow::NewSetWindow(Window* parent) : wxDialog(parent, wxID_ANY, _("New set"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE) { + wxBusyCursor wait; // init controls game_list = new PackageList (this, ID_GAME_LIST); stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST); @@ -53,6 +54,7 @@ NewSetWindow::NewSetWindow(Window* parent) } void NewSetWindow::onGameSelect(wxCommandEvent&) { + wxBusyCursor wait; GameP game = game_list->getSelection(); settings.default_game = game->name(); GameSettings& gs = settings.gameSettingsFor(*game); diff --git a/src/gui/set/cards_panel.cpp b/src/gui/set/cards_panel.cpp index 3ace0c43..aea41d07 100644 --- a/src/gui/set/cards_panel.cpp +++ b/src/gui/set/cards_panel.cpp @@ -67,10 +67,10 @@ void CardsPanel::onChangeSet() { void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { // Toolbar - tb->AddTool(ID_FORMAT_BOLD, _(""), load_resource_tool_image(_("format_bold")), wxNullBitmap, wxITEM_CHECK, _TOOL_("bold")); - tb->AddTool(ID_FORMAT_ITALIC, _(""), load_resource_tool_image(_("format_italic")), wxNullBitmap, wxITEM_CHECK, _TOOL_("italic")); - tb->AddTool(ID_FORMAT_SYMBOL, _(""), load_resource_tool_image(_("format_symbol")), wxNullBitmap, wxITEM_CHECK, _TOOL_("symbols")); - tb->AddTool(ID_FORMAT_REMINDER, _(""), load_resource_tool_image(_("format_reminder")), wxNullBitmap, wxITEM_CHECK, _TOOL_("reminder text")); + tb->AddTool(ID_FORMAT_BOLD, _(""), load_resource_tool_image(_("bold")), wxNullBitmap, wxITEM_CHECK, _TOOL_("bold")); + tb->AddTool(ID_FORMAT_ITALIC, _(""), load_resource_tool_image(_("italic")), wxNullBitmap, wxITEM_CHECK, _TOOL_("italic")); + tb->AddTool(ID_FORMAT_SYMBOL, _(""), load_resource_tool_image(_("symbol")), wxNullBitmap, wxITEM_CHECK, _TOOL_("symbols")); + tb->AddTool(ID_FORMAT_REMINDER, _(""), load_resource_tool_image(_("reminder")), wxNullBitmap, wxITEM_CHECK, _TOOL_("reminder text")); tb->AddSeparator(); tb->AddTool(ID_CARD_ADD, _(""), load_resource_tool_image(_("card_add")), wxNullBitmap, wxITEM_NORMAL,_TOOL_("add card")); tb->AddTool(ID_CARD_REMOVE, _(""), load_resource_tool_image(_("card_del")), wxNullBitmap, wxITEM_NORMAL,_TOOL_("remove card")); @@ -100,10 +100,10 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { mb->Insert(2, menuCard, _("&Cards")); IconMenu* menuFormat = new IconMenu(); - menuFormat->Append(ID_FORMAT_BOLD, _("format_bold"), _("Bold\tCtrl+B"), _("Makes the selected text bold"), wxITEM_CHECK); - menuFormat->Append(ID_FORMAT_ITALIC, _("format_italic"), _("Italic\tCtrl+I"), _("Makes the selected text italic"), wxITEM_CHECK); - menuFormat->Append(ID_FORMAT_SYMBOL, _("format_symbol"), _("Symbols\tCtrl+M"), _("Draws the selected text with symbols"), wxITEM_CHECK); - menuFormat->Append(ID_FORMAT_REMINDER, _("format_reminder"), _("Reminder Text\tCtrl+R"), _("Show reminder text for the selected keyword"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_BOLD, _("bold"), _("Bold\tCtrl+B"), _("Makes the selected text bold"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_ITALIC, _("italic"), _("Italic\tCtrl+I"), _("Makes the selected text italic"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_SYMBOL, _("symbol"), _("Symbols\tCtrl+M"), _("Draws the selected text with symbols"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_REMINDER, _("reminder"), _("Reminder Text\tCtrl+R"), _("Show reminder text for the selected keyword"), wxITEM_CHECK); mb->Insert(3, menuFormat, _("&Format")); } diff --git a/src/gui/set/set_info_panel.cpp b/src/gui/set/set_info_panel.cpp index 42725101..5a4096c3 100644 --- a/src/gui/set/set_info_panel.cpp +++ b/src/gui/set/set_info_panel.cpp @@ -34,16 +34,16 @@ void SetInfoPanel::onChangeSet() { void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { // Toolbar - tb->AddTool(ID_FORMAT_BOLD, _(""), load_resource_tool_image(_("format_bold")), wxNullBitmap, wxITEM_CHECK, _("Bold")); - tb->AddTool(ID_FORMAT_ITALIC, _(""), load_resource_tool_image(_("format_italic")), wxNullBitmap, wxITEM_CHECK, _("Italic")); - tb->AddTool(ID_FORMAT_SYMBOL, _(""), load_resource_tool_image(_("format_symbol")), wxNullBitmap, wxITEM_CHECK, _("Symbols")); + tb->AddTool(ID_FORMAT_BOLD, _(""), load_resource_tool_image(_("bold")), wxNullBitmap, wxITEM_CHECK, _("Bold")); + tb->AddTool(ID_FORMAT_ITALIC, _(""), load_resource_tool_image(_("italic")), wxNullBitmap, wxITEM_CHECK, _("Italic")); + tb->AddTool(ID_FORMAT_SYMBOL, _(""), load_resource_tool_image(_("symbol")), wxNullBitmap, wxITEM_CHECK, _("Symbols")); tb->Realize(); // Menus IconMenu* menuFormat = new IconMenu(); - menuFormat->Append(ID_FORMAT_BOLD, _("format_bold"), _("Bold\tCtrl+B"), _("Makes the selected text bold"), wxITEM_CHECK); - menuFormat->Append(ID_FORMAT_ITALIC, _("format_italic"), _("Italic\tCtrl+I"), _("Makes the selected text italic"), wxITEM_CHECK); - menuFormat->Append(ID_FORMAT_SYMBOL, _("format_symbol"), _("Symbols\tCtrl+M"), _("Draws the selected text with symbols"), wxITEM_CHECK); - menuFormat->Append(ID_FORMAT_REMINDER, _("format_reminder"), _("Reminder Text\tCtrl+R"), _("Show reminder text for the selected keyword"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_BOLD, _("bold"), _("Bold\tCtrl+B"), _("Makes the selected text bold"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_ITALIC, _("italic"), _("Italic\tCtrl+I"), _("Makes the selected text italic"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_SYMBOL, _("symbol"), _("Symbols\tCtrl+M"), _("Draws the selected text with symbols"), wxITEM_CHECK); + menuFormat->Append(ID_FORMAT_REMINDER, _("reminder"), _("Reminder Text\tCtrl+R"), _("Show reminder text for the selected keyword"), wxITEM_CHECK); mb->Insert(2, menuFormat, _("&Format")); } diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 1843f593..b6a72d0c 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -48,9 +48,9 @@ SetWindow::SetWindow(Window* parent, const SetP& set) // initialize menu bar wxMenuBar* menuBar = new wxMenuBar(); IconMenu* menuFile = new IconMenu(); - menuFile->Append(ID_FILE_NEW, _("file_new"), _MENU_("new set"), _HELP_("new set")); - menuFile->Append(ID_FILE_OPEN, _("file_open"), _MENU_("open set"), _HELP_("open set")); - menuFile->Append(ID_FILE_SAVE, _("file_save"), _MENU_("save set"), _HELP_("save set")); + menuFile->Append(ID_FILE_NEW, _("new"), _MENU_("new set"), _HELP_("new 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->Append(ID_FILE_EXPORT_HTML, _("&HTML..."), _("Export the set to a HTML file")); @@ -71,14 +71,14 @@ SetWindow::SetWindow(Window* parent, const SetP& set) menuBar->Append(menuFile, _MENU_("file")); IconMenu* menuEdit = new IconMenu(); - menuEdit->Append(ID_EDIT_UNDO, _("edit_undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo")); - menuEdit->Append(ID_EDIT_REDO, _("edit_redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo")); + menuEdit->Append(ID_EDIT_UNDO, _("undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo")); + menuEdit->Append(ID_EDIT_REDO, _("redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo")); menuEdit->AppendSeparator(); - menuEdit->Append(ID_EDIT_CUT, _("edit_cut"), _MENU_("cut"), _HELP_("cut")); - menuEdit->Append(ID_EDIT_COPY, _("edit_copy"), _MENU_("copy"), _HELP_("copy")); - menuEdit->Append(ID_EDIT_PASTE, _("edit_paste"), _MENU_("paste"), _HELP_("paste")); + menuEdit->Append(ID_EDIT_CUT, _("cut"), _MENU_("cut"), _HELP_("cut")); + menuEdit->Append(ID_EDIT_COPY, _("copy"), _MENU_("copy"), _HELP_("copy")); + menuEdit->Append(ID_EDIT_PASTE, _("paste"), _MENU_("paste"), _HELP_("paste")); menuEdit->AppendSeparator(); - menuEdit->Append(ID_EDIT_FIND, _("edit_find"), _MENU_("find"), _("")); + menuEdit->Append(ID_EDIT_FIND, _("find"), _MENU_("find"), _("")); menuEdit->Append(ID_EDIT_FIND_NEXT, _MENU_("find next"), _("")); menuEdit->Append(ID_EDIT_REPLACE, _MENU_("replace"), _("")); menuEdit->AppendSeparator(); @@ -91,9 +91,10 @@ SetWindow::SetWindow(Window* parent, const SetP& set) menuBar->Append(menuWindow, _MENU_("window")); IconMenu* menuHelp = new IconMenu(); - menuHelp->Append(ID_HELP_INDEX, _("help"), _("&Index..\tF1"), _("")); + menuHelp->Append(ID_HELP_INDEX, _("help"), _MENU_("index"), _HELP_("index")); + menuHelp->Append(ID_HELP_WEBSITE, _MENU_("website"), _HELP_("website")); menuHelp->AppendSeparator(); - menuHelp->Append(ID_HELP_ABOUT, _MENU_("about"), _("")); + menuHelp->Append(ID_HELP_ABOUT, _MENU_("about"), _HELP_("about")); menuBar->Append(menuHelp, _MENU_("help")); SetMenuBar(menuBar); @@ -105,16 +106,16 @@ SetWindow::SetWindow(Window* parent, const SetP& set) // tool bar wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL); tb->SetToolBitmapSize(wxSize(18,18)); - tb->AddTool(ID_FILE_NEW, _(""), load_resource_tool_image(_("file_new")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("new set"), _HELP_("new set")); - tb->AddTool(ID_FILE_OPEN, _(""), load_resource_tool_image(_("file_open")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("open set"), _HELP_("open set")); - tb->AddTool(ID_FILE_SAVE, _(""), load_resource_tool_image(_("file_save")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("save set"), _HELP_("save set")); + tb->AddTool(ID_FILE_NEW, _(""), load_resource_tool_image(_("new")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("new set"), _HELP_("new set")); + tb->AddTool(ID_FILE_OPEN, _(""), load_resource_tool_image(_("open")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("open set"), _HELP_("open set")); + tb->AddTool(ID_FILE_SAVE, _(""), load_resource_tool_image(_("save")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("save set"), _HELP_("save set")); tb->AddSeparator(); - tb->AddTool(ID_EDIT_CUT, _(""), load_resource_tool_image(_("edit_cut")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("cut")); - tb->AddTool(ID_EDIT_COPY, _(""), load_resource_tool_image(_("edit_copy")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("copy")); - tb->AddTool(ID_EDIT_PASTE, _(""), load_resource_tool_image(_("edit_paste")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("paste")); + tb->AddTool(ID_EDIT_CUT, _(""), load_resource_tool_image(_("cut")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("cut")); + tb->AddTool(ID_EDIT_COPY, _(""), load_resource_tool_image(_("copy")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("copy")); + tb->AddTool(ID_EDIT_PASTE, _(""), load_resource_tool_image(_("paste")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("paste")); tb->AddSeparator(); - tb->AddTool(ID_EDIT_UNDO, _(""), load_resource_tool_image(_("edit_undo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("undo",wxEmptyString)); - tb->AddTool(ID_EDIT_REDO, _(""), load_resource_tool_image(_("edit_redo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("redo",wxEmptyString)); + tb->AddTool(ID_EDIT_UNDO, _(""), load_resource_tool_image(_("undo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("undo",wxEmptyString)); + tb->AddTool(ID_EDIT_REDO, _(""), load_resource_tool_image(_("redo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("redo",wxEmptyString)); tb->AddSeparator(); tb->Realize(); @@ -546,6 +547,10 @@ void SetWindow::onHelpIndex(wxCommandEvent&) { // wnd->Show(); } +void SetWindow::onHelpWebsite(wxCommandEvent&) { + wxLaunchDefaultBrowser(settings.website_url); +} + void SetWindow::onHelpAbout(wxCommandEvent&) { AboutWindow wnd(this); wnd.ShowModal(); @@ -592,6 +597,7 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame) EVT_MENU (ID_WINDOW_NEW, SetWindow::onWindowNewWindow) EVT_TOOL_RANGE (ID_WINDOW_MIN, ID_WINDOW_MAX, SetWindow::onWindowSelect) EVT_MENU (ID_HELP_INDEX, SetWindow::onHelpIndex) + EVT_MENU (ID_HELP_WEBSITE, SetWindow::onHelpWebsite) EVT_MENU (ID_HELP_ABOUT, SetWindow::onHelpAbout) EVT_TOOL_RANGE (ID_CHILD_MIN, ID_CHILD_MAX, SetWindow::onChildMenu) EVT_GALLERY_SELECT (ID_FIELD_LIST, SetWindow::onChildMenu) // for StatsPanel, because it is not a EVT_TOOL diff --git a/src/gui/set/window.hpp b/src/gui/set/window.hpp index d23c32ba..816154b5 100644 --- a/src/gui/set/window.hpp +++ b/src/gui/set/window.hpp @@ -139,6 +139,7 @@ class SetWindow : public wxFrame, public SetView { // --------------------------------------------------- : Window events - menu - help void onHelpIndex (wxCommandEvent&); + void onHelpWebsite (wxCommandEvent&); void onHelpAbout (wxCommandEvent&); // --------------------------------------------------- : Window events - other diff --git a/src/gui/symbol/window.cpp b/src/gui/symbol/window.cpp index 75962cdc..dc7d86d2 100644 --- a/src/gui/symbol/window.cpp +++ b/src/gui/symbol/window.cpp @@ -58,9 +58,9 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { // Menu bar wxMenuBar* menuBar = new wxMenuBar(); IconMenu* menuFile = new IconMenu(); - menuFile->Append(ID_FILE_NEW, _("file_new"), _MENU_("new symbol"), _HELP_("new symbol")); - menuFile->Append(ID_FILE_OPEN, _("file_open"), _MENU_("open symbol"), _HELP_("open symbol")); - menuFile->Append(ID_FILE_SAVE, _("file_save"), _MENU_("save symbol"), _HELP_("save symbol")); + menuFile->Append(ID_FILE_NEW, _("new"), _MENU_("new symbol"), _HELP_("new symbol")); + menuFile->Append(ID_FILE_OPEN, _("open"), _MENU_("open symbol"), _HELP_("open symbol")); + menuFile->Append(ID_FILE_SAVE, _("save"), _MENU_("save symbol"), _HELP_("save symbol")); menuFile->Append(ID_FILE_SAVE_AS, _MENU_("save symbol as"), _HELP_("save symbol as")); menuFile->AppendSeparator(); menuFile->Append(ID_FILE_STORE, _("apply"), _MENU_("store symbol"), _HELP_("store symbol")); @@ -69,8 +69,8 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { menuBar->Append(menuFile, _MENU_("file")); IconMenu* menuEdit = new IconMenu(); - menuEdit->Append(ID_EDIT_UNDO, _("edit_undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo")); - menuEdit->Append(ID_EDIT_REDO, _("edit_redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo")); + menuEdit->Append(ID_EDIT_UNDO, _("undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo")); + menuEdit->Append(ID_EDIT_REDO, _("redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo")); menuEdit->AppendSeparator(); menuEdit->Append(ID_EDIT_DUPLICATE, _("duplicate"), _MENU_("duplicate"), _HELP_("duplicate")); menuBar->Append(menuEdit, _MENU_("edit")); @@ -93,8 +93,8 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_TEXT); tb->AddTool(ID_FILE_STORE, _("Store"), load_resource_tool_image(_("apply")), wxNullBitmap, wxITEM_NORMAL, _TOOL_("store symbol"), _HELP_("store symbol")); tb->AddSeparator(); - tb->AddTool(ID_EDIT_UNDO, _("Undo"), load_resource_tool_image(_("edit_undo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("undo",wxEmptyString)); - tb->AddTool(ID_EDIT_REDO, _("Redo"), load_resource_tool_image(_("edit_redo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("redo",wxEmptyString)); + tb->AddTool(ID_EDIT_UNDO, _("Undo"), load_resource_tool_image(_("undo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("undo",wxEmptyString)); + tb->AddTool(ID_EDIT_REDO, _("Redo"), load_resource_tool_image(_("redo")), wxNullBitmap, wxITEM_NORMAL, _TOOL_1_("redo",wxEmptyString)); tb->Realize(); // Edit mode toolbar diff --git a/src/gui/util.cpp b/src/gui/util.cpp index ebfd4cdf..2d83bb29 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -90,7 +90,7 @@ Image load_resource_image(const String& name) { return wxImage(stream); #elif defined(__linux__) static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/"); - String file = path + name.Lower(); + String file = path + name; // if the name is in upper case, fix the call wxImage resource; if (wxFileExists(file + _(".png"))) resource.LoadFile(file + _(".png")); else if (wxFileExists(file + _(".bmp"))) resource.LoadFile(file + _(".bmp")); diff --git a/src/gui/welcome_window.cpp b/src/gui/welcome_window.cpp index 83170b43..b00c3750 100644 --- a/src/gui/welcome_window.cpp +++ b/src/gui/welcome_window.cpp @@ -16,28 +16,34 @@ #include #include +// 2007-02-06: New HoverButton, hopefully this on works on GTK +#define USE_HOVERBUTTON + // ----------------------------------------------------------------------------- : WelcomeWindow WelcomeWindow::WelcomeWindow() - : Frame(nullptr, wxID_ANY, _TITLE_("magic set editor"), wxDefaultPosition, wxSize(480,340), wxDEFAULT_DIALOG_STYLE) + : Frame(nullptr, wxID_ANY, _TITLE_("magic set editor"), wxDefaultPosition, wxSize(480,340), wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL | wxCLIP_CHILDREN ) , logo (load_resource_image(_("about"))) , logo2(load_resource_image(_("two"))) { SetIcon(load_resource_icon(_("app"))); // init controls - #ifdef __WXMSW__ - wxButton* new_set = new HoverButtonExt(this, ID_FILE_NEW, load_resource_image(_("welcome_new")), _BUTTON_("new set"), _HELP_("new set")); - wxButton* open_set = new HoverButtonExt(this, ID_FILE_OPEN, load_resource_image(_("welcome_open")), _BUTTON_("open set"), _HELP_("open set")); + #ifdef USE_HOVERBUTTON + wxControl* new_set = new HoverButtonExt(this, ID_FILE_NEW, load_resource_image(_("welcome_new")), _BUTTON_("new set"), _HELP_("new set")); + wxControl* open_set = new HoverButtonExt(this, ID_FILE_OPEN, load_resource_image(_("welcome_open")), _BUTTON_("open set"), _HELP_("open set")); #else - // For now, hover buttons don't work on GTK - wxButton* new_set = new wxButton(this, ID_FILE_NEW, _BUTTON_("new set")); - wxButton* open_set = new wxButton(this, ID_FILE_OPEN, _BUTTON_("open set")); + wxControl* new_set = new wxButton(this, ID_FILE_NEW, _BUTTON_("new set")); + wxControl* open_set = new wxButton(this, ID_FILE_OPEN, _BUTTON_("open set")); #endif - wxButton* open_last = 0; + wxControl* open_last = nullptr; if (!settings.recent_sets.empty()) { wxFileName n(settings.recent_sets.front()); - open_last = new HoverButtonExt(this, ID_FILE_RECENT, load_resource_image(_("welcome_last")), _BUTTON_("last opened set"), _("Open '") + n.GetName() + _("'")); + #ifdef USE_HOVERBUTTON + open_last = new HoverButtonExt(this, ID_FILE_RECENT, load_resource_image(_("welcome_last")), _BUTTON_("last opened set"), _("Open '") + n.GetName() + _("'")); + #else + open_last = new wxButton(this, ID_FILE_RECENT, _BUTTON_("last opened set")); + #endif } wxSizer* s1 = new wxBoxSizer(wxHORIZONTAL); @@ -121,13 +127,14 @@ HoverButtonExt::HoverButtonExt(Window* parent, int id, const wxImage& icon, cons void HoverButtonExt::draw(DC& dc) { // draw button -// HoverButton::draw(dc); + HoverButton::draw(dc); + int d = drawDelta(); // icon - if (icon.Ok()) dc.DrawBitmap(icon, 7, 7); + if (icon.Ok()) dc.DrawBitmap(icon, d+7, d+7); // text dc.SetTextForeground(*wxBLACK); dc.SetFont(font_large); - dc.DrawText(label, 44, 7); + dc.DrawText(label, d+44, d+7); dc.SetFont(font_small); - dc.DrawText(sub_label, 45, 28); + dc.DrawText(sub_label, d+45, d+28); } diff --git a/src/render/symbol/filter.cpp b/src/render/symbol/filter.cpp index 870b4315..a381898f 100644 --- a/src/render/symbol/filter.cpp +++ b/src/render/symbol/filter.cpp @@ -24,7 +24,7 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) { alpha = (Byte*) malloc (sizeof(Byte) * width * height); memset(alpha, 255, width * height); symbol.SetAlpha(alpha); - } + } for (UInt y = 0 ; y < width ; ++y) { for (UInt x = 0 ; x < height ; ++x) { // Determine set diff --git a/src/resource/common/btn_down.png b/src/resource/common/btn_down.png new file mode 100644 index 00000000..6ff44f05 Binary files /dev/null and b/src/resource/common/btn_down.png differ diff --git a/src/resource/common/btn_focus.png b/src/resource/common/btn_focus.png new file mode 100644 index 00000000..a1cbdf8d Binary files /dev/null and b/src/resource/common/btn_focus.png differ diff --git a/src/resource/common/btn_ok_down.png b/src/resource/common/btn_ok_down.png new file mode 100644 index 00000000..40b8a27f Binary files /dev/null and b/src/resource/common/btn_ok_down.png differ diff --git a/src/resource/common/btn_ok_focus.png b/src/resource/common/btn_ok_focus.png new file mode 100644 index 00000000..d2936ba9 Binary files /dev/null and b/src/resource/common/btn_ok_focus.png differ diff --git a/src/resource/msw/mse.rc b/src/resource/msw/mse.rc index 4eb2da6b..ab2831cd 100644 --- a/src/resource/msw/mse.rc +++ b/src/resource/msw/mse.rc @@ -19,22 +19,22 @@ icon/symbol ICON "icon/symbol.ico" cursor/rot_text CURSOR "cursor/rot_text.cur" -tool/new BITMAP "tool/file_new.bmp" -tool/open BITMAP "tool/file_open.bmp" -tool/save BITMAP "tool/file_save.bmp" +tool/new BITMAP "tool/new.bmp" +tool/open BITMAP "tool/open.bmp" +tool/save BITMAP "tool/save.bmp" -tool/undo BITMAP "tool/edit_undo.bmp" -tool/redo BITMAP "tool/edit_redo.bmp" -tool/cut BITMAP "tool/edit_cut.bmp" -tool/copy BITMAP "tool/edit_copy.bmp" -tool/paste BITMAP "tool/edit_paste.bmp" -tool/find BITMAP "tool/edit_find.bmp" +tool/undo BITMAP "tool/undo.bmp" +tool/redo BITMAP "tool/redo.bmp" +tool/cut BITMAP "tool/cut.bmp" +tool/copy BITMAP "tool/copy.bmp" +tool/paste BITMAP "tool/paste.bmp" +tool/find BITMAP "tool/find.bmp" -tool/bold BITMAP "tool/format_bold.bmp" -tool/italic BITMAP "tool/format_italic.bmp" -tool/symbol BITMAP "tool/format_symbol.bmp" -tool/reminder BITMAP "tool/format_reminder.bmp" -tool/no_auto BITMAP "tool/format_no_auto.bmp" +tool/bold BITMAP "tool/bold.bmp" +tool/italic BITMAP "tool/italic.bmp" +tool/symbol BITMAP "tool/symbol.bmp" +tool/reminder BITMAP "tool/reminder.bmp" +tool/no_auto BITMAP "tool/no_auto.bmp" tool/card_add BITMAP "tool/card_add.bmp" tool/card_add_multiple BITMAP "tool/card_add_multiple.bmp" @@ -111,8 +111,12 @@ about IMAGE "../common/about.png" two IMAGE "../common/two_beta.png" btn_normal IMAGE "../common/btn_normal.png" btn_hover IMAGE "../common/btn_hover.png" +btn_focus IMAGE "../common/btn_focus.png" +btn_down IMAGE "../common/btn_down.png" btn_ok_normal IMAGE "../common/btn_ok_normal.png" btn_ok_hover IMAGE "../common/btn_ok_hover.png" +btn_ok_focus IMAGE "../common/btn_ok_focus.png" +btn_ok_down IMAGE "../common/btn_ok_down.png" //about_xmas IMAGE "about-xmas.png" //two_xmas IMAGE "two_beta-xmas.png" diff --git a/src/resource/msw/tool/format_bold.bmp b/src/resource/msw/tool/bold.bmp similarity index 100% rename from src/resource/msw/tool/format_bold.bmp rename to src/resource/msw/tool/bold.bmp diff --git a/src/resource/msw/tool/edit_copy.bmp b/src/resource/msw/tool/copy.bmp similarity index 100% rename from src/resource/msw/tool/edit_copy.bmp rename to src/resource/msw/tool/copy.bmp diff --git a/src/resource/msw/tool/edit_cut.bmp b/src/resource/msw/tool/cut.bmp similarity index 100% rename from src/resource/msw/tool/edit_cut.bmp rename to src/resource/msw/tool/cut.bmp diff --git a/src/resource/msw/tool/edit_find.bmp b/src/resource/msw/tool/find.bmp similarity index 100% rename from src/resource/msw/tool/edit_find.bmp rename to src/resource/msw/tool/find.bmp diff --git a/src/resource/msw/tool/format_italic.bmp b/src/resource/msw/tool/italic.bmp similarity index 100% rename from src/resource/msw/tool/format_italic.bmp rename to src/resource/msw/tool/italic.bmp diff --git a/src/resource/msw/tool/file_new.bmp b/src/resource/msw/tool/new.bmp similarity index 100% rename from src/resource/msw/tool/file_new.bmp rename to src/resource/msw/tool/new.bmp diff --git a/src/resource/msw/tool/format_no_auto.bmp b/src/resource/msw/tool/no_auto.bmp similarity index 100% rename from src/resource/msw/tool/format_no_auto.bmp rename to src/resource/msw/tool/no_auto.bmp diff --git a/src/resource/msw/tool/file_open.bmp b/src/resource/msw/tool/open.bmp similarity index 100% rename from src/resource/msw/tool/file_open.bmp rename to src/resource/msw/tool/open.bmp diff --git a/src/resource/msw/tool/edit_paste.bmp b/src/resource/msw/tool/paste.bmp similarity index 100% rename from src/resource/msw/tool/edit_paste.bmp rename to src/resource/msw/tool/paste.bmp diff --git a/src/resource/msw/tool/edit_redo.bmp b/src/resource/msw/tool/redo.bmp similarity index 100% rename from src/resource/msw/tool/edit_redo.bmp rename to src/resource/msw/tool/redo.bmp diff --git a/src/resource/msw/tool/format_reminder.bmp b/src/resource/msw/tool/reminder.bmp similarity index 100% rename from src/resource/msw/tool/format_reminder.bmp rename to src/resource/msw/tool/reminder.bmp diff --git a/src/resource/msw/tool/file_save.bmp b/src/resource/msw/tool/save.bmp similarity index 100% rename from src/resource/msw/tool/file_save.bmp rename to src/resource/msw/tool/save.bmp diff --git a/src/resource/msw/tool/format_symbol.bmp b/src/resource/msw/tool/symbol.bmp similarity index 100% rename from src/resource/msw/tool/format_symbol.bmp rename to src/resource/msw/tool/symbol.bmp diff --git a/src/resource/msw/tool/edit_undo.bmp b/src/resource/msw/tool/undo.bmp similarity index 100% rename from src/resource/msw/tool/edit_undo.bmp rename to src/resource/msw/tool/undo.bmp diff --git a/src/script/functions.cpp b/src/script/functions.cpp index 11d12c9d..1a592a6b 100644 --- a/src/script/functions.cpp +++ b/src/script/functions.cpp @@ -339,6 +339,12 @@ SCRIPT_FUNCTION(contains) { SCRIPT_RETURN(input.find(match) != String::npos); } +SCRIPT_FUNCTION(format) { + SCRIPT_PARAM(String, format); + SCRIPT_PARAM(String, input); + SCRIPT_RETURN(format_string(_("%") + replace_all(format, _("%"), _("")), input)); +} + // ----------------------------------------------------------------------------- : Tagged stuff String replace_tag_contents(String input, const String& tag, const ScriptValueP& contents, Context& ctx) { @@ -582,6 +588,7 @@ void init_script_functions(Context& ctx) { ctx.setVariable(_("to title"), script_to_title); ctx.setVariable(_("substring"), script_substring); ctx.setVariable(_("contains"), script_contains); + ctx.setVariable(_("format"), script_format); ctx.setVariable(_("tag contents"), script_tag_contents); ctx.setVariable(_("remove tag"), script_tag_remove); ctx.setVariable(_("tag contents rule"), script_tag_contents_rule); diff --git a/src/script/parser.cpp b/src/script/parser.cpp index 2dad2210..6207cf2c 100644 --- a/src/script/parser.cpp +++ b/src/script/parser.cpp @@ -292,7 +292,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec); /// Parse an expression, possibly with operators applied. Optionally adds an instruction at the end. /** @param input Read tokens from the input - * @param script Add resulting instructions to the script + * @param script Add resulting instructions to the script * @param minPrec Minimum precedence level for operators * @param closeWith Add this instruction at the end * @param closeWithData Data for the instruction at the end diff --git a/src/util/window_id.hpp b/src/util/window_id.hpp index 6018e28a..8d435c3d 100644 --- a/src/util/window_id.hpp +++ b/src/util/window_id.hpp @@ -60,8 +60,10 @@ enum MenuID { , ID_WINDOW_MAX = 220 // Help menu (MainWindow) -, ID_HELP_INDEX = 301 -, ID_HELP_ABOUT +, ID_HELP_INDEX = wxID_HELP_CONTENTS +, ID_HELP_WEBSITE = 301 +, ID_HELP_DOCUMENTATION +, ID_HELP_ABOUT = wxID_ABOUT // Mode menu (SymbolWindow) , ID_MODE_MIN = 401