Generate image for disabled toolbar buttons and menu items.
Fixes #13. Removed IconMenu class, use add_menu_item/add_menu_item_tr instead. Added _tr variants that automatically do locale translation
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 166 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 226 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 252 B |
@@ -107,17 +107,17 @@ tool/ungroup IMAGE "tool/ungroup.png"
|
||||
tool/symmetry_add IMAGE "tool/symmetry_add.png"
|
||||
tool/symmetry_remove IMAGE "tool/symmetry_remove.png"
|
||||
|
||||
combine_or IMAGE "combine_or.png"
|
||||
combine_sub IMAGE "combine_sub.png"
|
||||
combine_sub_dark IMAGE "combine_sub_dark.png"
|
||||
combine_and IMAGE "combine_and.png"
|
||||
combine_and_dark IMAGE "combine_and_dark.png"
|
||||
combine_xor IMAGE "combine_xor.png"
|
||||
combine_over IMAGE "combine_over.png"
|
||||
combine_border IMAGE "combine_border.png"
|
||||
symmetry_rotation IMAGE "symmetry_rotation.png"
|
||||
symmetry_reflection IMAGE "symmetry_reflection.png"
|
||||
symbol_group IMAGE "symbol_group.png"
|
||||
tool/combine_or IMAGE "tool/combine_or.png"
|
||||
tool/combine_sub IMAGE "tool/combine_sub.png"
|
||||
tool/combine_sub_dark IMAGE "tool/combine_sub_dark.png"
|
||||
tool/combine_and IMAGE "tool/combine_and.png"
|
||||
tool/combine_and_dark IMAGE "tool/combine_and_dark.png"
|
||||
tool/combine_xor IMAGE "tool/combine_xor.png"
|
||||
tool/combine_over IMAGE "tool/combine_over.png"
|
||||
tool/combine_border IMAGE "tool/combine_border.png"
|
||||
tool/symmetry_rotation IMAGE "tool/symmetry_rotation.png"
|
||||
tool/symmetry_reflection IMAGE "tool/symmetry_reflection.png"
|
||||
tool/symbol_group IMAGE "tool/symbol_group.png"
|
||||
|
||||
icon_combine_merge IMAGE "icon_combine_merge.png"
|
||||
icon_combine_subtract IMAGE "icon_combine_subtract.png"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <gui/value/editor.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/settings.hpp>
|
||||
@@ -424,10 +424,10 @@ void DataEditor::onChar(wxKeyEvent& ev) {
|
||||
|
||||
void DataEditor::onContextMenu(wxContextMenuEvent& ev) {
|
||||
if (current_editor) {
|
||||
IconMenu m;
|
||||
m.Append(ID_EDIT_CUT, _("cut"), _MENU_("cut"), _HELP_("cut"));
|
||||
m.Append(ID_EDIT_COPY, _("copy"), _MENU_("copy"), _HELP_("copy"));
|
||||
m.Append(ID_EDIT_PASTE, _("paste"), _MENU_("paste"), _HELP_("paste"));
|
||||
wxMenu m;
|
||||
add_menu_item_tr(&m, ID_EDIT_CUT, "cut", "cut");
|
||||
add_menu_item_tr(&m, ID_EDIT_COPY, "copy", "copy");
|
||||
add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste");
|
||||
m.Enable(ID_EDIT_CUT, canCut());
|
||||
m.Enable(ID_EDIT_COPY, canCopy());
|
||||
m.Enable(ID_EDIT_PASTE, canPaste());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_list.hpp>
|
||||
#include <gui/control/card_list_column_select.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <data/field/choice.hpp>
|
||||
@@ -382,13 +382,13 @@ void CardListBase::onDrag(wxMouseEvent& ev) {
|
||||
|
||||
void CardListBase::onContextMenu(wxContextMenuEvent&) {
|
||||
if (allowModify()) {
|
||||
IconMenu m;
|
||||
m.Append(wxID_CUT, _("cut"), _CONTEXT_MENU_("cut"), _HELP_("cut card"));
|
||||
m.Append(wxID_COPY, _("copy"), _CONTEXT_MENU_("copy"), _HELP_("copy card"));
|
||||
m.Append(wxID_PASTE, _("paste"), _CONTEXT_MENU_("paste"), _HELP_("paste card"));
|
||||
wxMenu m;
|
||||
add_menu_item_tr(&m, wxID_CUT, "cut", "cut_card");
|
||||
add_menu_item_tr(&m, wxID_COPY, "copy", "copy_card");
|
||||
add_menu_item_tr(&m, wxID_PASTE, "paste", "paste_card");
|
||||
m.AppendSeparator();
|
||||
m.Append(ID_CARD_ADD, _("card_add"), _CONTEXT_MENU_("add card"), _HELP_("add card"));
|
||||
m.Append(ID_CARD_REMOVE,_("card_del"), _CONTEXT_MENU_("remove card"), _HELP_("remove card"));
|
||||
add_menu_item_tr(&m, ID_CARD_ADD, "card_add", "add card");
|
||||
add_menu_item_tr(&m, ID_CARD_REMOVE, "card_del", "remove card");
|
||||
PopupMenu(&m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/keyword_list.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/card.hpp>
|
||||
@@ -237,13 +237,13 @@ wxListItemAttr* KeywordList::OnGetItemAttr(long pos) const {
|
||||
// ----------------------------------------------------------------------------- : KeywordList : Context menu
|
||||
|
||||
void KeywordList::onContextMenu(wxContextMenuEvent&) {
|
||||
IconMenu m;
|
||||
m.Append(ID_EDIT_CUT, _("cut"), _CONTEXT_MENU_("cut"), _HELP_("cut keyword"));
|
||||
m.Append(ID_EDIT_COPY, _("copy"), _CONTEXT_MENU_("copy"), _HELP_("copy keyword"));
|
||||
m.Append(ID_EDIT_PASTE, _("paste"), _CONTEXT_MENU_("paste"), _HELP_("paste keyword"));
|
||||
wxMenu m;
|
||||
add_menu_item_tr(&m, ID_EDIT_CUT, "cut", "cut_keyword");
|
||||
add_menu_item_tr(&m, ID_EDIT_COPY, "copy", "copy_keyword");
|
||||
add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste_keyword");
|
||||
m.AppendSeparator();
|
||||
m.Append(ID_KEYWORD_ADD, _("keyword_add"), _CONTEXT_MENU_("add keyword"), _HELP_("add keyword"));
|
||||
m.Append(ID_KEYWORD_REMOVE, _("keyword_del"), _CONTEXT_MENU_("remove keyword"), _HELP_("remove keyword"));
|
||||
add_menu_item_tr(&m, ID_KEYWORD_ADD, "keyword_add", "add_keyword");
|
||||
add_menu_item_tr(&m, ID_KEYWORD_REMOVE, "keyword_del", "remove_keyword");
|
||||
PopupMenu(&m);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : generateDisabledImage
|
||||
|
||||
// Generate an image to use for the disabled state of menu items
|
||||
Image generateDisabledImage(const Image& imgIn) {
|
||||
// Some system colors
|
||||
Color trans(1,2,3); // mask color used by bitmaps as 'transparent'
|
||||
Color light = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
|
||||
Color shadow = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
|
||||
// generate disabled bitmap
|
||||
Image imgOut(16, 16);
|
||||
imgOut.SetMaskColour(1,2,3);
|
||||
Byte *in = imgIn.GetData(), *out = imgOut.GetData();
|
||||
// For each pixel...
|
||||
for (int y = 0 ; y < 16 ; ++y) {
|
||||
for (int x = 0 ; x < 16 ; ++x) {
|
||||
// is the pixel mask color or white?
|
||||
Color in1 = trans, in2 = trans;
|
||||
if (x<15 && y<15) in1 = Color(in[0], in[1], in[2]);
|
||||
// and the pixel to the left+up?
|
||||
if (x>0 && y>0 ) in2 = Color(in[0 - 3*17], in[1 - 3*17], in[2 - 3*17]);
|
||||
// determine output color
|
||||
Color col;
|
||||
if (in1 != trans && in1 != light) col = shadow;
|
||||
else if (in2 != trans && in2 != light) col = light;
|
||||
else col = trans;
|
||||
out[0] = col.Red();
|
||||
out[1] = col.Green();
|
||||
out[2] = col.Blue();
|
||||
in += 3;
|
||||
out += 3;
|
||||
}
|
||||
}
|
||||
return imgOut;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : set_menu_item_image
|
||||
|
||||
void set_menu_item_image(wxMenuItem* item, const String& resource) {
|
||||
// load bitmap
|
||||
Bitmap bitmap = load_resource_tool_image(resource);
|
||||
#if defined(__WXMSW__)
|
||||
// make greyed bitmap
|
||||
bitmap = bitmap.GetSubBitmap(wxRect(0,0,16,16));
|
||||
Image disabledImage = generateDisabledImage(bitmap.ConvertToImage());
|
||||
item->SetBitmaps(bitmap, bitmap);
|
||||
item->SetDisabledBitmap(disabledImage);
|
||||
#else
|
||||
// Check items can't have bitmaps :(
|
||||
if (item->GetKind() == wxITEM_NORMAL) {
|
||||
item->SetBitmap(bitmap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : IconMenu
|
||||
|
||||
void IconMenu::Append(int id, const String& resource, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) {
|
||||
// create menu, load icon
|
||||
wxMenuItem* item = new wxMenuItem(this, id, text, help, kind, submenu);
|
||||
set_menu_item_image(item, resource);
|
||||
// add to menu
|
||||
wxMenu::Append(item);
|
||||
}
|
||||
|
||||
void IconMenu::Append(int id, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) {
|
||||
wxMenuItem* item = new wxMenuItem (this, id, text, help, kind, submenu);
|
||||
item->SetBitmap(wxNullBitmap);
|
||||
wxMenu::Append(item);
|
||||
}
|
||||
|
||||
void IconMenu::Append(wxMenuItem* item) {
|
||||
item->SetBitmap(wxNullBitmap);
|
||||
wxMenu::Append(item);
|
||||
}
|
||||
|
||||
void IconMenu::Insert(size_t pos, int id, const String& resource, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) {
|
||||
// create menu, load icon
|
||||
wxMenuItem* item = new wxMenuItem(this, id, text, help, kind, submenu);
|
||||
set_menu_item_image(item, resource);
|
||||
// add to menu
|
||||
wxMenu::Insert(pos,item);
|
||||
}
|
||||
|
||||
void IconMenu::Insert(size_t pos, int id, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) {
|
||||
wxMenuItem* item = new wxMenuItem (this, id, text, help, kind, submenu);
|
||||
item->SetBitmap(wxNullBitmap);
|
||||
wxMenu::Insert(pos, item);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#pragma once
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include "../util/prec.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------------- : IconMenu
|
||||
|
||||
/// Helper class for menus with icons
|
||||
/** This class functions just like a normal wxMenu.
|
||||
* The difference is that Append takes an extra parameter:
|
||||
* the resource name of the bitmap to use.
|
||||
* Bitmaps are resized (cut) to 16x16 pixels.
|
||||
*/
|
||||
class IconMenu : public wxMenu {
|
||||
public:
|
||||
/// Append a menu item, with an image (loaded from a resource)
|
||||
void Append(int id, const String& resource, const String& text, const String& help, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
/// Append a menu item, without an image
|
||||
void Append(int id, const String& text, const String& help, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
/// Append a menu item, without an image
|
||||
void Append(wxMenuItem* item);
|
||||
/// Insert a menu item, with an image (loaded from a resource)
|
||||
void Insert(size_t pos, int id, const String& resource, const String& text, const String& help, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
/// Insert a menu item, without an image
|
||||
void Insert(size_t pos, int id, const String& text, const String& help, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
};
|
||||
|
||||
void set_menu_item_image(wxMenuItem* menuitem, const String& resource);
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <gui/control/filter_ctrl.hpp>
|
||||
#include <gui/about_window.hpp> // for HoverButton
|
||||
#include <gui/update_checker.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/game.hpp>
|
||||
@@ -27,12 +26,6 @@
|
||||
#include <util/window_id.hpp>
|
||||
#include <wx/splitter.h>
|
||||
|
||||
#ifdef EVT_TOOL_DROPDOWN
|
||||
// This is only available after patching wx or in version 2.10
|
||||
// see http://trac.wxwidgets.org/ticket/8556
|
||||
#define HAVE_TOOLBAR_DROPDOWN_MENU 1
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardsPanel
|
||||
|
||||
CardsPanel::CardsPanel(Window* parent, int id)
|
||||
@@ -71,34 +64,32 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
SetSizer(s);
|
||||
|
||||
// init menus
|
||||
menuCard = new IconMenu();
|
||||
menuCard->Append(ID_CARD_PREV, _MENU_("previous card"), _HELP_("previous card"));
|
||||
menuCard->Append(ID_CARD_NEXT, _MENU_("next card"), _HELP_("next card"));
|
||||
menuCard = new wxMenu();
|
||||
add_menu_item_tr(menuCard, ID_CARD_PREV, nullptr, "previous card");
|
||||
add_menu_item_tr(menuCard, ID_CARD_NEXT, nullptr, "next card");
|
||||
menuCard->AppendSeparator();
|
||||
menuCard->Append(ID_CARD_ADD, _("card_add"), _MENU_("add card"), _HELP_("add card"));
|
||||
insertManyCardsMenu = new wxMenuItem(menuCard, ID_CARD_ADD_MULT, _MENU_("add cards"), _HELP_("add cards"));
|
||||
set_menu_item_image(insertManyCardsMenu, _("card_add_multiple"));
|
||||
((wxMenu*)menuCard)->Append(insertManyCardsMenu);
|
||||
add_menu_item_tr(menuCard, ID_CARD_ADD, "card_add", "add_card");
|
||||
insertManyCardsMenu = add_menu_item_tr(menuCard, ID_CARD_ADD_MULT, "card_add_multiple", "add cards");
|
||||
// NOTE: space after "Del" prevents wx from making del an accellerator
|
||||
// otherwise we delete a card when delete is pressed inside the editor
|
||||
// Adding a space never hurts, please keep it just to be safe.
|
||||
menuCard->Append(ID_CARD_REMOVE, _("card_del"), _MENU_("remove card")+_(" "),_HELP_("remove card"));
|
||||
add_menu_item(menuCard, ID_CARD_REMOVE, "card_del", _MENU_("remove card")+_(" "), _HELP_("remove card"));
|
||||
menuCard->AppendSeparator();
|
||||
IconMenu* menuRotate = new IconMenu();
|
||||
menuRotate->Append(ID_CARD_ROTATE_0, _("card_rotate_0"), _MENU_("rotate 0"), _HELP_("rotate 0"), wxITEM_CHECK);
|
||||
menuRotate->Append(ID_CARD_ROTATE_270, _("card_rotate_270"), _MENU_("rotate 270"), _HELP_("rotate 270"), wxITEM_CHECK);
|
||||
menuRotate->Append(ID_CARD_ROTATE_90, _("card_rotate_90"), _MENU_("rotate 90"), _HELP_("rotate 90"), wxITEM_CHECK);
|
||||
menuRotate->Append(ID_CARD_ROTATE_180, _("card_rotate_180"), _MENU_("rotate 180"), _HELP_("rotate 180"), wxITEM_CHECK);
|
||||
menuCard->Append(wxID_ANY, _("card_rotate"), _MENU_("orientation"), _HELP_("orientation"), wxITEM_NORMAL, menuRotate);
|
||||
auto menuRotate = new wxMenu();
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_0, "card_rotate_0", "rotate_0", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_270, "card_rotate_270", "rotate_270", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_180, "card_rotate_180", "rotate_180", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_90, "card_rotate_90", "rotate_90", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuCard, wxID_ANY, "card_rotate", "orientation", wxITEM_NORMAL, menuRotate);
|
||||
menuCard->AppendSeparator();
|
||||
// This probably belongs in the window menu, but there we can't remove the separator once it is added
|
||||
menuCard->Append(ID_SELECT_COLUMNS, _MENU_("card list columns"),_HELP_("card list columns"));
|
||||
add_menu_item_tr(menuCard, ID_SELECT_COLUMNS, nullptr, "card_list_columns");
|
||||
|
||||
menuFormat = new IconMenu();
|
||||
menuFormat->Append(ID_FORMAT_BOLD, _("bold"), _MENU_("bold"), _HELP_("bold"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_ITALIC, _("italic"), _MENU_("italic"), _HELP_("italic"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_SYMBOL, _("symbol"), _MENU_("symbols"), _HELP_("symbols"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_REMINDER, _("reminder"), _MENU_("reminder text"), _HELP_("reminder text"), wxITEM_CHECK);
|
||||
menuFormat = new wxMenu();
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK);
|
||||
menuFormat->AppendSeparator();
|
||||
insertSymbolMenu = new wxMenuItem(menuFormat, ID_INSERT_SYMBOL, _MENU_("insert symbol"));
|
||||
menuFormat->Append(insertSymbolMenu);
|
||||
@@ -161,25 +152,23 @@ void CardsPanel::onChangeSet() {
|
||||
menuCard->Remove(ID_CARD_ADD_MULT);
|
||||
((wxMenu*)menuCard)->Insert(4,insertManyCardsMenu); // HACK: the position is hardcoded
|
||||
// also for the toolbar dropdown menu
|
||||
#if HAVE_TOOLBAR_DROPDOWN_MENU
|
||||
if (toolAddCard) {
|
||||
toolAddCard->SetDropdownMenu(makeAddCardsSubmenu(true));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
wxMenu* CardsPanel::makeAddCardsSubmenu(bool add_single_card_option) {
|
||||
IconMenu* cards_scripts_menu = nullptr;
|
||||
wxMenu* cards_scripts_menu = nullptr;
|
||||
// default item?
|
||||
if (add_single_card_option) {
|
||||
cards_scripts_menu = new IconMenu;
|
||||
cards_scripts_menu->Append(ID_CARD_ADD, _("card_add"), _MENU_("add card"), _HELP_("add card"));
|
||||
cards_scripts_menu = new wxMenu();
|
||||
add_menu_item_tr(cards_scripts_menu, ID_CARD_ADD, "card_add", "add_card");
|
||||
cards_scripts_menu->AppendSeparator();
|
||||
}
|
||||
// create menu for add_cards_scripts
|
||||
if (set && set->game && !set->game->add_cards_scripts.empty()) {
|
||||
int id = ID_ADD_CARDS_MENU_MIN;
|
||||
if (!cards_scripts_menu) cards_scripts_menu = new IconMenu;
|
||||
if (!cards_scripts_menu) cards_scripts_menu = new wxMenu();
|
||||
FOR_EACH(cs, set->game->add_cards_scripts) {
|
||||
cards_scripts_menu->Append(id++, cs->name, cs->description);
|
||||
}
|
||||
@@ -191,30 +180,22 @@ wxMenu* CardsPanel::makeAddCardsSubmenu(bool add_single_card_option) {
|
||||
|
||||
void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
tb->AddTool(ID_FORMAT_BOLD, _(""), load_resource_tool_image(_("bold")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("bold"), _HELP_("bold"));
|
||||
tb->AddTool(ID_FORMAT_ITALIC, _(""), load_resource_tool_image(_("italic")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("italic"), _HELP_("italic"));
|
||||
tb->AddTool(ID_FORMAT_SYMBOL, _(""), load_resource_tool_image(_("symbol")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("symbols"), _HELP_("symbols"));
|
||||
tb->AddTool(ID_FORMAT_REMINDER, _(""), load_resource_tool_image(_("reminder")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("reminder text"), _HELP_("reminder text"));
|
||||
add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK);
|
||||
tb->AddSeparator();
|
||||
#if HAVE_TOOLBAR_DROPDOWN_MENU
|
||||
toolAddCard = tb->AddTool(ID_CARD_ADD, _(""), load_resource_tool_image(_("card_add")), wxNullBitmap, wxITEM_DROPDOWN,_TOOLTIP_("add card"), _HELP_("add card"));
|
||||
toolAddCard = add_tool_tr(tb, ID_CARD_ADD, "card_add", "add_card", false, wxITEM_DROPDOWN);
|
||||
toolAddCard->SetDropdownMenu(makeAddCardsSubmenu(true));
|
||||
#else
|
||||
tb->AddTool(ID_CARD_ADD, _(""), load_resource_tool_image(_("card_add")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("add card"), _HELP_("add card"));
|
||||
#endif
|
||||
tb->AddTool(ID_CARD_REMOVE, _(""), load_resource_tool_image(_("card_del")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("remove card"), _HELP_("remove card"));
|
||||
add_tool_tr(tb, ID_CARD_REMOVE, "card_del", "remove_card");
|
||||
tb->AddSeparator();
|
||||
#if HAVE_TOOLBAR_DROPDOWN_MENU
|
||||
wxToolBarToolBase* rot = tb->AddTool(ID_CARD_ROTATE, _(""), load_resource_tool_image(_("card_rotate")), wxNullBitmap, wxITEM_DROPDOWN, _TOOLTIP_("rotate card"), _HELP_("rotate card"));
|
||||
IconMenu* menuRotate = new IconMenu();
|
||||
menuRotate->Append(ID_CARD_ROTATE_0, _("card_rotate_0"), _MENU_("rotate 0"), _HELP_("rotate 0"), wxITEM_CHECK);
|
||||
menuRotate->Append(ID_CARD_ROTATE_270, _("card_rotate_270"), _MENU_("rotate 270"), _HELP_("rotate 270"), wxITEM_CHECK);
|
||||
menuRotate->Append(ID_CARD_ROTATE_90, _("card_rotate_90"), _MENU_("rotate 90"), _HELP_("rotate 90"), wxITEM_CHECK);
|
||||
menuRotate->Append(ID_CARD_ROTATE_180, _("card_rotate_180"), _MENU_("rotate 180"), _HELP_("rotate 180"), wxITEM_CHECK);
|
||||
wxToolBarToolBase* rot = add_tool_tr(tb, ID_CARD_ROTATE, "card_rotate", "rotate_card", false, wxITEM_DROPDOWN);
|
||||
auto menuRotate = new wxMenu();
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_0, "card_rotate_0", "rotate_0", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_270, "card_rotate_270", "rotate_270", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_180, "card_rotate_180", "rotate_180", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_90, "card_rotate_90", "rotate_90", wxITEM_CHECK);
|
||||
rot->SetDropdownMenu(menuRotate);
|
||||
#else
|
||||
tb->AddTool(ID_CARD_ROTATE, _(""), load_resource_tool_image(_("card_rotate")), wxNullBitmap,wxITEM_NORMAL, _TOOLTIP_("rotate card"), _HELP_("rotate card"));
|
||||
#endif
|
||||
// Filter/search textbox
|
||||
tb->AddSeparator();
|
||||
assert(!filter);
|
||||
|
||||
@@ -15,7 +15,6 @@ class wxSplitterWindow;
|
||||
class FilteredImageCardList;
|
||||
class DataEditor;
|
||||
class TextCtrl;
|
||||
class IconMenu;
|
||||
class HoverButton;
|
||||
class FindInfo;
|
||||
class FilterCtrl;
|
||||
@@ -91,7 +90,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
virtual bool Layout();
|
||||
|
||||
// --------------------------------------------------- : Menus & tools
|
||||
IconMenu* menuCard, *menuFormat;
|
||||
wxMenu* menuCard, *menuFormat;
|
||||
wxToolBarToolBase* toolAddCard;
|
||||
wxMenuItem* insertSymbolMenu; // owned by menuFormat, but submenu owned by SymbolFont
|
||||
wxMenuItem* insertManyCardsMenu; // owned my menuCard, but submenu can be changed
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <gui/set/keywords_panel.hpp>
|
||||
#include <gui/control/keyword_list.hpp>
|
||||
#include <gui/control/text_ctrl.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/keyword.hpp>
|
||||
#include <data/game.hpp>
|
||||
@@ -102,14 +101,14 @@ void KeywordsPanel::initControls() {
|
||||
s2->Add(list_inactive, 1, wxEXPAND);*/
|
||||
|
||||
// init menus
|
||||
menuKeyword = new IconMenu();
|
||||
menuKeyword->Append(ID_KEYWORD_PREV, _MENU_("previous keyword"), _HELP_("previous keyword"));
|
||||
menuKeyword->Append(ID_KEYWORD_NEXT, _MENU_("next keyword"), _HELP_("next keyword"));
|
||||
menuKeyword = new wxMenu();
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_PREV, nullptr, "previous_keyword");
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_NEXT, nullptr, "next_keyword");
|
||||
menuKeyword->AppendSeparator();
|
||||
menuKeyword->Append(ID_KEYWORD_ADD, _("keyword_add"), _MENU_("add keyword"), _HELP_("add keyword"));
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_ADD, "keyword_add", "add_keyword");
|
||||
// NOTE: space after "Del" prevents wx from making del an accellerator
|
||||
// otherwise we delete a card when delete is pressed inside the editor
|
||||
menuKeyword->Append(ID_KEYWORD_REMOVE, _("keyword_del"), _MENU_("remove keyword")+_(" "),_HELP_("remove keyword"));
|
||||
add_menu_item(menuKeyword, ID_KEYWORD_REMOVE, "keyword_del", _MENU_("remove_keyword")+_(" "), _HELP_("remove_keyword"));
|
||||
}
|
||||
|
||||
KeywordsPanel::~KeywordsPanel() {
|
||||
@@ -127,8 +126,8 @@ void KeywordsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
onChangeSet();
|
||||
}
|
||||
// Toolbar
|
||||
tb->AddTool(ID_KEYWORD_ADD, _(""), load_resource_tool_image(_("keyword_add")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("add keyword"), _HELP_("add keyword"));
|
||||
tb->AddTool(ID_KEYWORD_REMOVE, _(""), load_resource_tool_image(_("keyword_del")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("remove keyword"),_HELP_("remove keyword"));
|
||||
add_tool_tr(tb, ID_KEYWORD_ADD, "keyword_add", "add_keyword");
|
||||
add_tool_tr(tb, ID_KEYWORD_REMOVE, "keyword_del", "remove_keyword");
|
||||
// Filter/search textbox
|
||||
tb->AddSeparator();
|
||||
assert(!filter);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
class wxSplitterWindow;
|
||||
class KeywordList;
|
||||
class TextCtrl;
|
||||
class IconMenu;
|
||||
struct KeywordSelectEvent;
|
||||
class FilterCtrl;
|
||||
|
||||
@@ -63,7 +62,7 @@ class KeywordsPanel : public SetWindowPanel {
|
||||
TextCtrl* match;
|
||||
TextCtrl* reminder;
|
||||
TextCtrl* rules;
|
||||
IconMenu* menuKeyword;
|
||||
wxMenu* menuKeyword;
|
||||
wxStaticText* fixedL;
|
||||
wxSizer* fixed;
|
||||
wxStaticText* errors;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/set_info_panel.hpp>
|
||||
#include <gui/control/native_look_editor.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
|
||||
@@ -35,16 +34,17 @@ void SetInfoPanel::onChangeSet() {
|
||||
|
||||
void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
tb->AddTool(ID_FORMAT_BOLD, _(""), load_resource_tool_image(_("bold")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("bold"), _HELP_("bold"));
|
||||
tb->AddTool(ID_FORMAT_ITALIC, _(""), load_resource_tool_image(_("italic")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("italic"), _HELP_("italic"));
|
||||
tb->AddTool(ID_FORMAT_SYMBOL, _(""), load_resource_tool_image(_("symbol")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("symbols"), _HELP_("symbols"));
|
||||
add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK);
|
||||
tb->Realize();
|
||||
// Menus
|
||||
IconMenu* menuFormat = new IconMenu();
|
||||
menuFormat->Append(ID_FORMAT_BOLD, _("bold"), _MENU_("bold"), _HELP_("bold"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_ITALIC, _("italic"), _MENU_("italic"), _HELP_("italic"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_SYMBOL, _("symbol"), _MENU_("symbols"), _HELP_("symbols"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_REMINDER, _("reminder"), _MENU_("reminder text"), _HELP_("reminder text"), wxITEM_CHECK);
|
||||
auto menuFormat = new wxMenu();
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK);
|
||||
mb->Insert(2, menuFormat, _MENU_("format"));
|
||||
// focus on editor
|
||||
editor->SetFocus();
|
||||
@@ -55,13 +55,14 @@ void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
tb->DeleteTool(ID_FORMAT_BOLD);
|
||||
tb->DeleteTool(ID_FORMAT_ITALIC);
|
||||
tb->DeleteTool(ID_FORMAT_SYMBOL);
|
||||
tb->DeleteTool(ID_FORMAT_REMINDER);
|
||||
// Menus
|
||||
delete mb->Remove(2);
|
||||
}
|
||||
|
||||
void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
|
||||
ev.Enable(editor->canFormat(ev.GetId()));
|
||||
ev.Check (editor->hasFormat(ev.GetId()));
|
||||
break;
|
||||
@@ -71,7 +72,7 @@ void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
|
||||
void SetInfoPanel::onCommand(int id) {
|
||||
switch (id) {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
|
||||
editor->doFormat(id);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <gui/control/graph.hpp>
|
||||
#include <gui/control/gallery_list.hpp>
|
||||
#include <gui/control/filtered_card_list.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/statistics.hpp>
|
||||
@@ -315,12 +314,12 @@ void StatsPanel::initControls() {
|
||||
SetSizer(s);
|
||||
|
||||
// init menu
|
||||
menuGraph = new IconMenu();
|
||||
menuGraph->Append(ID_GRAPH_PIE, _("graph_pie"), _MENU_("pie"), _HELP_("pie"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_BAR, _("graph_bar"), _MENU_("bar"), _HELP_("bar"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_STACK, _("graph_stack"), _MENU_("stack"), _HELP_("stack"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_SCATTER, _("graph_scatter"), _MENU_("scatter"), _HELP_("scatter"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_SCATTER_PIE, _("graph_scatter_pie"), _MENU_("scatter pie"), _HELP_("scatter pie"), wxITEM_CHECK);
|
||||
menuGraph = new wxMenu();
|
||||
add_menu_item_tr(menuGraph, ID_GRAPH_PIE, "graph_pie", "pie", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuGraph, ID_GRAPH_BAR, "graph_bar", "bar", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuGraph, ID_GRAPH_STACK, "graph_stack", "stack", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuGraph, ID_GRAPH_SCATTER, "graph_scatter", "scatter", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuGraph, ID_GRAPH_SCATTER_PIE, "graph_scatter_pie", "scatter pie", wxITEM_CHECK);
|
||||
}
|
||||
|
||||
StatsPanel::~StatsPanel() {
|
||||
@@ -364,11 +363,11 @@ void StatsPanel::initUI (wxToolBar* tb, wxMenuBar* mb) {
|
||||
if (!up_to_date) showCategory();
|
||||
// Toolbar
|
||||
#if USE_DIMENSION_LISTS || USE_SEPARATE_DIMENSION_LISTS
|
||||
tb->AddTool(ID_GRAPH_PIE, _(""), load_resource_tool_image(_("graph_pie")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("pie"), _HELP_("pie"));
|
||||
tb->AddTool(ID_GRAPH_BAR, _(""), load_resource_tool_image(_("graph_bar")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("bar"), _HELP_("bar"));
|
||||
tb->AddTool(ID_GRAPH_STACK, _(""), load_resource_tool_image(_("graph_stack")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("stack"), _HELP_("stack"));
|
||||
tb->AddTool(ID_GRAPH_SCATTER, _(""), load_resource_tool_image(_("graph_scatter")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("scatter"), _HELP_("scatter"));
|
||||
tb->AddTool(ID_GRAPH_SCATTER_PIE, _(""), load_resource_tool_image(_("graph_scatter_pie")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("scatter pie"), _HELP_("scatter pie"));
|
||||
add_tool_tr(tb, ID_GRAPH_PIE, "graph_pie", "pie");
|
||||
add_tool_tr(tb, ID_GRAPH_BAR, "graph_bar", "bar");
|
||||
add_tool_tr(tb, ID_GRAPH_STACK, "graph_stack", "stack");
|
||||
add_tool_tr(tb, ID_GRAPH_SCATTER, "graph_scatter", "scatter");
|
||||
add_tool_tr(tb, ID_GRAPH_SCATTER_PIE, "graph_scatter_pie", "scatter_pie");
|
||||
tb->Realize();
|
||||
// Menu
|
||||
mb->Insert(2, menuGraph, _MENU_("graph"));
|
||||
|
||||
@@ -16,7 +16,6 @@ class StatCategoryList;
|
||||
class StatDimensionList;
|
||||
class GraphControl;
|
||||
class FilteredCardList;
|
||||
class IconMenu;
|
||||
|
||||
// Pick the style here:
|
||||
#define USE_DIMENSION_LISTS 1
|
||||
@@ -57,7 +56,7 @@ class StatsPanel : public SetWindowPanel {
|
||||
#endif
|
||||
GraphControl* graph;
|
||||
FilteredCardList* card_list;
|
||||
IconMenu* menuGraph;
|
||||
wxMenu* menuGraph;
|
||||
|
||||
CardP card; ///< Selected card
|
||||
bool up_to_date; ///< Are the graph and card list up to date?
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <gui/images_export_window.hpp>
|
||||
#include <gui/html_export_window.hpp>
|
||||
#include <gui/auto_replace_window.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <util/io/package_manager.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
@@ -52,57 +51,55 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
SetIcon(load_resource_icon(_("app")));
|
||||
|
||||
// initialize menu bar
|
||||
wxMenuBar* menuBar = new wxMenuBar();
|
||||
IconMenu* menuFile = new IconMenu();
|
||||
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 = makeExportMenu();
|
||||
menuFile->Append(wxID_ANY, _("export"), _MENU_("export"), _HELP_("export"), wxITEM_NORMAL, menuExport);
|
||||
auto menuBar = new wxMenuBar();
|
||||
auto menuFile = new wxMenu();
|
||||
add_menu_item_tr(menuFile, ID_FILE_NEW, "new", "new_set");
|
||||
add_menu_item_tr(menuFile, ID_FILE_OPEN, "open", "open_set");
|
||||
add_menu_item_tr(menuFile, ID_FILE_SAVE, "save", "save_set");
|
||||
add_menu_item_tr(menuFile, ID_FILE_SAVE_AS, nullptr, "save_set_as");
|
||||
add_menu_item_tr(menuFile, wxID_ANY, "export", "export", wxITEM_NORMAL, makeExportMenu());
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_CHECK_UPDATES, _MENU_("check updates"), _HELP_("check updates"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_CHECK_UPDATES, nullptr, "check_updates");
|
||||
#if USE_SCRIPT_PROFILING
|
||||
menuFile->Append(ID_FILE_PROFILER, _MENU_("show profiler"), _HELP_("show profiler"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_PROFILER, nullptr, "show_profiler");
|
||||
#endif
|
||||
// menuFile->Append(ID_FILE_INSPECT, _("Inspect Internal Data..."), _("Shows a the data in the set using a tree structure"));
|
||||
// menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_RELOAD, _MENU_("reload data"), _HELP_("reload data"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_RELOAD, nullptr, "reload_data");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_PRINT_PREVIEW, _("print_preview"), _MENU_("print preview"), _HELP_("print preview"));
|
||||
menuFile->Append(ID_FILE_PRINT, _("print"), _MENU_("print"), _HELP_("print"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_PRINT_PREVIEW, "print_preview", "print_preview");
|
||||
add_menu_item_tr(menuFile, ID_FILE_PRINT, "print", "print");
|
||||
menuFile->AppendSeparator();
|
||||
// recent files go here
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_EXIT, _MENU_("exit"), _HELP_("exit"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_EXIT, nullptr, "exit");
|
||||
menuBar->Append(menuFile, _MENU_("file"));
|
||||
|
||||
IconMenu* menuEdit = new IconMenu();
|
||||
menuEdit->Append(ID_EDIT_UNDO, _("undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo"));
|
||||
menuEdit->Append(ID_EDIT_REDO, _("redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
|
||||
auto menuEdit = new wxMenu();
|
||||
add_menu_item(menuEdit, ID_EDIT_UNDO, "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo"));
|
||||
add_menu_item(menuEdit, ID_EDIT_REDO, "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
|
||||
menuEdit->AppendSeparator();
|
||||
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"));
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_CUT, "cut", "cut");
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_COPY, "copy", "copy");
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_PASTE, "paste", "paste");
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_FIND, _("find"), _MENU_("find"), _HELP_("find"));
|
||||
menuEdit->Append(ID_EDIT_FIND_NEXT, _MENU_("find next"), _HELP_("find next"));
|
||||
menuEdit->Append(ID_EDIT_REPLACE, _MENU_("replace"), _HELP_("replace"));
|
||||
menuEdit->Append(ID_EDIT_AUTO_REPLACE, _MENU_("auto replace"), _HELP_("auto replace"));
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_FIND, "find", "find");
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_FIND_NEXT, nullptr, "find_next");
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_REPLACE, nullptr, "replace");
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_AUTO_REPLACE, nullptr, "auto_replace");
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_PREFERENCES, _MENU_("preferences"), _HELP_("preferences"));
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_PREFERENCES, nullptr, "preferences");
|
||||
menuBar->Append(menuEdit, _MENU_("edit"));
|
||||
|
||||
IconMenu* menuWindow = new IconMenu();
|
||||
menuWindow->Append(ID_WINDOW_NEW, _MENU_("new window"), _HELP_("new window"));
|
||||
auto menuWindow = new wxMenu();
|
||||
add_menu_item_tr(menuWindow, ID_WINDOW_NEW, nullptr, "new_window");
|
||||
menuWindow->AppendSeparator();
|
||||
menuBar->Append(menuWindow, _MENU_("window"));
|
||||
|
||||
IconMenu* menuHelp = new IconMenu();
|
||||
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"), _HELP_("about"));
|
||||
auto menuHelp = new wxMenu();
|
||||
add_menu_item_tr(menuHelp, ID_HELP_INDEX, "help", "index");
|
||||
add_menu_item_tr(menuHelp, ID_HELP_WEBSITE, nullptr, "website");
|
||||
add_menu_item_tr(menuHelp, ID_HELP_ABOUT, nullptr, "about");
|
||||
menuBar->Append(menuHelp, _MENU_("help"));
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
@@ -113,24 +110,25 @@ 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(_("new")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("new set"), _HELP_("new 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->SetToolBitmapSize(wxSize(20,20));
|
||||
add_tool_tr(tb, ID_FILE_NEW, "new", "new_set");
|
||||
add_tool_tr(tb, ID_FILE_OPEN, "open", "open_set");
|
||||
add_tool_tr(tb, ID_FILE_SAVE, "save", "save_set");
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_FILE_EXPORT, _(""), load_resource_tool_image(_("export")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("export"), _HELP_("export"));
|
||||
add_tool_tr(tb, ID_FILE_EXPORT, "export", "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"));
|
||||
add_tool_tr(tb, ID_EDIT_CUT, "cut", "cut");
|
||||
add_tool_tr(tb, ID_EDIT_COPY, "copy", "copy");
|
||||
add_tool_tr(tb, ID_EDIT_PASTE, "paste", "paste");
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_EDIT_UNDO, _(""), load_resource_tool_image(_("undo")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_1_("undo",wxEmptyString));
|
||||
tb->AddTool(ID_EDIT_REDO, _(""), load_resource_tool_image(_("redo")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_1_("redo",wxEmptyString));
|
||||
add_tool(tb, ID_EDIT_UNDO, "undo", {}, _TOOLTIP_1_("undo", {}), _HELP_("undo"));
|
||||
add_tool(tb, ID_EDIT_REDO, "redo", {}, _TOOLTIP_1_("redo", {}), _HELP_("redo"));
|
||||
tb->AddSeparator();
|
||||
tb->Realize();
|
||||
|
||||
// tab bar, sizer
|
||||
wxToolBar* tabBar = new wxToolBar(this, ID_TAB_BAR, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_HORZ_TEXT | wxTB_NOALIGN);
|
||||
tabBar->SetToolBitmapSize(wxSize(18,18));
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(tabBar, 0, wxEXPAND | wxBOTTOM, 0);
|
||||
SetSizer(s);
|
||||
@@ -178,13 +176,13 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
current_panel->Layout();
|
||||
}
|
||||
|
||||
IconMenu* SetWindow::makeExportMenu() {
|
||||
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"));
|
||||
wxMenu* SetWindow::makeExportMenu() {
|
||||
auto menuExport = new wxMenu();
|
||||
add_menu_item_tr(menuExport, ID_FILE_EXPORT_HTML, "export_html", "export_html");
|
||||
add_menu_item_tr(menuExport, ID_FILE_EXPORT_IMAGE, "export_image", "export_image");
|
||||
add_menu_item_tr(menuExport, ID_FILE_EXPORT_IMAGES, "export_images", "export_images");
|
||||
add_menu_item_tr(menuExport, ID_FILE_EXPORT_APPR, "export_apprentice", "export_apprentice");
|
||||
add_menu_item_tr(menuExport, ID_FILE_EXPORT_MWS, "export_mws", "export_mws");
|
||||
return menuExport;
|
||||
}
|
||||
|
||||
@@ -207,7 +205,7 @@ SetWindow::~SetWindow() {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Panel managment
|
||||
|
||||
void SetWindow::addPanel(IconMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* panel, UInt pos, const String& image_name, const String& name) {
|
||||
void SetWindow::addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* panel, UInt pos, const String& image_name, const String& name) {
|
||||
// insert in list
|
||||
if (panels.size() <= pos) panels.resize(pos + 1);
|
||||
panels[pos] = panel;
|
||||
@@ -221,7 +219,8 @@ void SetWindow::addPanel(IconMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel
|
||||
tabBar->AddTool(id, tab_name + _(" "), load_resource_tool_image(image_name), wxNullBitmap, wxITEM_CHECK, tab_help, description);
|
||||
tabBar->AddSeparator();
|
||||
// add to menu bar
|
||||
windowMenu->Append(id, image_name, menu_name, description, wxITEM_CHECK);
|
||||
auto menu_item = windowMenu->Append(id, menu_name, description, wxITEM_CHECK);
|
||||
set_menu_item_image(menu_item, image_name);
|
||||
// add to sizer
|
||||
GetSizer()->Add(panel, 1, wxEXPAND);
|
||||
}
|
||||
@@ -541,8 +540,8 @@ void SetWindow::updateRecentSets() {
|
||||
mb->SetLabel(ID_FILE_RECENT + i, String(_("&")) << (i+1) << _(" ") << file);
|
||||
} else {
|
||||
// add new item
|
||||
int pos = i + FILE_MENU_SIZE_BEFORE_RECENT_SETS; // HUGE HACK, we should calculate the position to insert!
|
||||
IconMenu* file_menu = static_cast<IconMenu*>(mb->GetMenu(0));
|
||||
wxMenu* file_menu = mb->GetMenu(0);
|
||||
size_t pos = file_menu->GetMenuItemCount() - 2; // last two items are separator and exit
|
||||
file_menu->Insert(pos, ID_FILE_RECENT + i, String(_("&")) << (i+1) << _(" ") << file, wxEmptyString);
|
||||
}
|
||||
i++;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <wx/fdrepdlg.h>
|
||||
#include <gui/card_select_window.hpp>
|
||||
|
||||
class IconMenu;
|
||||
class SetWindowPanel;
|
||||
class wxFindDialogEvent;
|
||||
struct CardSelectEvent;
|
||||
@@ -42,7 +41,7 @@ private:
|
||||
// gui items
|
||||
vector<SetWindowPanel*> panels; ///< All panels on this window
|
||||
SetWindowPanel* current_panel;
|
||||
IconMenu* export_menu = nullptr;
|
||||
wxMenu* export_menu = nullptr;
|
||||
|
||||
/// Number of items in the recent sets list
|
||||
size_t number_of_recentSets;
|
||||
@@ -56,7 +55,7 @@ private:
|
||||
/// Add a panel to the window, as well as to the menu and tab bar
|
||||
/** The position only determines the order in which events will be send.
|
||||
*/
|
||||
void addPanel(IconMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* panel, UInt pos, const String& image_name, const String& name);
|
||||
void addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* panel, UInt pos, const String& image_name, const String& name);
|
||||
|
||||
/// Select a panel, based on a tab id
|
||||
void selectPanel(int id);
|
||||
@@ -113,7 +112,7 @@ private:
|
||||
UInt number_of_recent_sets;
|
||||
void updateRecentSets();
|
||||
|
||||
IconMenu* makeExportMenu();
|
||||
wxMenu* makeExportMenu();
|
||||
|
||||
// --------------------------------------------------- : Window events - menu - file
|
||||
void onFileNew (wxCommandEvent&);
|
||||
|
||||
@@ -42,10 +42,10 @@ void SymbolBasicShapeEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
sides->SetHelpText(_HELP_("sides"));
|
||||
sides->SetSize(50, -1);
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_SHAPE_CIRCLE, _TOOL_("ellipse"), load_resource_tool_image(_("circle")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("ellipse"), _HELP_("ellipse"));
|
||||
tb->AddTool(ID_SHAPE_RECTANGLE, _TOOL_("rectangle"), load_resource_tool_image(_("rectangle")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("rectangle"), _HELP_("rectangle"));
|
||||
tb->AddTool(ID_SHAPE_POLYGON, _TOOL_("polygon"), load_resource_tool_image(_("triangle")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("polygon"), _HELP_("polygon"));
|
||||
tb->AddTool(ID_SHAPE_STAR, _TOOL_("star"), load_resource_tool_image(_("star")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("star"), _HELP_("star"));
|
||||
add_tool_tr(tb, ID_SHAPE_CIRCLE, "circle", "ellipse", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SHAPE_RECTANGLE, "rectangle", "rectangle",true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SHAPE_POLYGON, "triangle", "polygon", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SHAPE_STAR, "star", "star", true, wxITEM_CHECK);
|
||||
// tb->AddControl(sidesL);
|
||||
tb->AddControl(sides);
|
||||
tb->Realize();
|
||||
|
||||
@@ -154,12 +154,12 @@ wxPen SymbolPointEditor::handlePen(WhichPen p, LockMode lock) {
|
||||
void SymbolPointEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Initialize toolbar
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_SEGMENT_LINE, _TOOL_("line segment"), load_resource_tool_image(_("line")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("line segment"), _HELP_("line segment"));
|
||||
tb->AddTool(ID_SEGMENT_CURVE, _TOOL_("curve segment"), load_resource_tool_image(_("curve")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("curve segment"), _HELP_("curve segment"));
|
||||
add_tool_tr(tb, ID_SEGMENT_LINE, "line", "line_segment", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SEGMENT_CURVE, "curve", "curve_segment", true, wxITEM_CHECK);
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_LOCK_FREE, _TOOL_("free point"), load_resource_tool_image(_("lock_free")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("free point"), _HELP_("free point"));
|
||||
tb->AddTool(ID_LOCK_DIR, _TOOL_("smooth point"), load_resource_tool_image(_("lock_dir")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("smooth point"), _HELP_("smooth point"));
|
||||
tb->AddTool(ID_LOCK_SIZE, _TOOL_("symmetric point"), load_resource_tool_image(_("lock_size")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("symmetric point"), _HELP_("symmetric point"));
|
||||
add_tool_tr(tb, ID_LOCK_FREE, "lock_free", "free_point", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_LOCK_DIR, "lock_dir", "smooth_point", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_LOCK_SIZE, "lock_size", "symmetric point", true, wxITEM_CHECK);
|
||||
tb->Realize();
|
||||
// TODO : menu bar
|
||||
//mb->Insert(2, curveMenu, _("&Curve"))
|
||||
|
||||
@@ -116,12 +116,12 @@ void SymbolSelectEditor::drawRotationCenter(DC& dc, const Vector2D& pos) {
|
||||
|
||||
void SymbolSelectEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_SYMBOL_COMBINE_MERGE, _TOOL_("merge"), load_resource_image(_("combine_or")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("merge"), _HELP_("merge"));
|
||||
tb->AddTool(ID_SYMBOL_COMBINE_SUBTRACT, _TOOL_("subtract"), load_resource_image(_("combine_sub_dark")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("subtract"), _HELP_("subtract"));
|
||||
tb->AddTool(ID_SYMBOL_COMBINE_INTERSECTION, _TOOL_("intersect"), load_resource_image(_("combine_and_dark")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("intersect"), _HELP_("intersect"));
|
||||
tb->AddTool(ID_SYMBOL_COMBINE_DIFFERENCE, _TOOL_("difference"), load_resource_image(_("combine_xor")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("difference"), _HELP_("difference"));
|
||||
tb->AddTool(ID_SYMBOL_COMBINE_OVERLAP, _TOOL_("overlap"), load_resource_image(_("combine_over")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("overlap"), _HELP_("overlap"));
|
||||
tb->AddTool(ID_SYMBOL_COMBINE_BORDER, _TOOL_("border"), load_resource_image(_("combine_border")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("border"), _HELP_("border"));
|
||||
add_tool_tr(tb, ID_SYMBOL_COMBINE_MERGE, "combine_or", "merge", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SYMBOL_COMBINE_SUBTRACT, "combine_sub_dark", "subtract", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SYMBOL_COMBINE_INTERSECTION, "combine_and_dark", "intersect", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SYMBOL_COMBINE_DIFFERENCE, "combine_xor", "difference", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SYMBOL_COMBINE_OVERLAP, "combine_over", "overlap", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SYMBOL_COMBINE_BORDER, "combine_border", "border", true, wxITEM_CHECK);
|
||||
tb->Realize();
|
||||
}
|
||||
void SymbolSelectEditor::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
|
||||
@@ -58,11 +58,11 @@ void SymbolSymmetryEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
copies->SetHelpText(_HELP_("copies"));
|
||||
copies->SetSize(50, -1);
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_ADD_SYMMETRY, _TOOL_("add symmetry"), load_resource_tool_image(_("symmetry_add")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("add symmetry"), _HELP_("add symmetry"));
|
||||
tb->AddTool(ID_REMOVE_SYMMETRY, _TOOL_("remove symmetry"), load_resource_tool_image(_("symmetry_remove")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("remove symmetry"), _HELP_("remove symmetry"));
|
||||
add_tool_tr(tb, ID_ADD_SYMMETRY, "symmetry_add", "add_symmetry", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_REMOVE_SYMMETRY, "symmetry_remove", "remove_symmetry", true, wxITEM_CHECK);
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_SYMMETRY_ROTATION, _TOOL_("rotation"), load_resource_image(_("symmetry_rotation")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("rotation"), _HELP_("rotation"));
|
||||
tb->AddTool(ID_SYMMETRY_REFLECTION, _TOOL_("reflection"), load_resource_image(_("symmetry_reflection")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("reflection"), _HELP_("reflection"));
|
||||
add_tool_tr(tb, ID_SYMMETRY_ROTATION, "symmetry_rotation", "rotation", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_SYMMETRY_REFLECTION, "symmetry_reflection", "reflection", true, wxITEM_CHECK);
|
||||
tb->AddSeparator();
|
||||
tb->AddControl(copies);
|
||||
tb->Realize();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <gui/symbol/window.hpp>
|
||||
#include <gui/symbol/control.hpp>
|
||||
#include <gui/symbol/part_list.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/field/symbol.hpp>
|
||||
#include <data/format/image_to_symbol.hpp>
|
||||
@@ -71,35 +70,35 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
inSelectionEvent = false;
|
||||
|
||||
// Menu bar
|
||||
wxMenuBar* menuBar = new wxMenuBar();
|
||||
IconMenu* menuFile = new IconMenu();
|
||||
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"));
|
||||
auto menuBar = new wxMenuBar();
|
||||
auto menuFile = new wxMenu();
|
||||
add_menu_item_tr(menuFile, ID_FILE_NEW, "new", "new_symbol");
|
||||
add_menu_item_tr(menuFile, ID_FILE_OPEN, "open", "open_symbol");
|
||||
add_menu_item_tr(menuFile, ID_FILE_SAVE, "save", "save_symbol");
|
||||
add_menu_item_tr(menuFile, ID_FILE_SAVE_AS, nullptr, "save_symbol_as");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_STORE, _("apply"), _MENU_("store symbol"), _HELP_("store symbol"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_STORE, "apply", "store_symbol");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_EXIT, _MENU_("close symbol editor"), _HELP_("close symbol editor"));
|
||||
add_menu_item_tr(menuFile, ID_FILE_EXIT, nullptr, "close_symbol_editor");
|
||||
menuBar->Append(menuFile, _MENU_("file"));
|
||||
|
||||
IconMenu* menuEdit = new IconMenu();
|
||||
menuEdit->Append(ID_EDIT_UNDO, _("undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo"));
|
||||
menuEdit->Append(ID_EDIT_REDO, _("redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
|
||||
auto menuEdit = new wxMenu();
|
||||
add_menu_item(menuEdit, ID_EDIT_UNDO, "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo"));
|
||||
add_menu_item(menuEdit, ID_EDIT_REDO, "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_GROUP, _("group"), _MENU_("group"), _HELP_("group"));
|
||||
menuEdit->Append(ID_EDIT_UNGROUP, _("ungroup"), _MENU_("ungroup"), _HELP_("ungroup"));
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_GROUP, "group", "group");
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_UNGROUP, "ungroup", "ungroup");
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_DUPLICATE, _("duplicate"), _MENU_("duplicate"), _HELP_("duplicate"));
|
||||
add_menu_item_tr(menuEdit, ID_EDIT_DUPLICATE, "duplicate", "duplicate");
|
||||
menuBar->Append(menuEdit, _MENU_("edit"));
|
||||
|
||||
IconMenu* menuTool = new IconMenu();
|
||||
menuTool->Append(ID_MODE_SELECT, _("mode_select"), _MENU_("select"), _HELP_("select"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_ROTATE, _("mode_rotate"), _MENU_("rotate"), _HELP_("rotate"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_POINTS, _("mode_curve"), _MENU_("points"), _HELP_("points"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_SHAPES, _("circle"), _MENU_("basic shapes"), _HELP_("basic shapes"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_SYMMETRY, _("mode_symmetry"), _MENU_("symmetry"), _HELP_("symmetry"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_PAINT, _("mode_paint"), _MENU_("paint"), _HELP_("paint"), wxITEM_CHECK);
|
||||
auto menuTool = new wxMenu();
|
||||
add_menu_item_tr(menuTool, ID_MODE_SELECT, "mode_select", "select", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuTool, ID_MODE_ROTATE, "mode_rotate", "rotate", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuTool, ID_MODE_POINTS, "mode_curve", "points", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuTool, ID_MODE_SHAPES, "circle", "basic_shapes", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuTool, ID_MODE_SYMMETRY, "mode_symmetry", "symmetry", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuTool, ID_MODE_PAINT, "mode_paint", "paint", wxITEM_CHECK);
|
||||
menuBar->Append(menuTool, _MENU_("tool"));
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
@@ -110,27 +109,27 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
|
||||
// Toolbar
|
||||
wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_TEXT);
|
||||
tb->AddTool(ID_FILE_STORE, _TOOL_("store symbol"), load_resource_tool_image(_("apply")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_("store symbol"), _HELP_("store symbol"));
|
||||
add_tool_tr(tb, ID_FILE_STORE, "apply", "store_symbol", true);
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_EDIT_UNDO, _TOOL_("undo"), load_resource_tool_image(_("undo")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_1_("undo",wxEmptyString));
|
||||
tb->AddTool(ID_EDIT_REDO, _TOOL_("redo"), load_resource_tool_image(_("redo")), wxNullBitmap, wxITEM_NORMAL, _TOOLTIP_1_("redo",wxEmptyString));
|
||||
add_tool(tb, ID_EDIT_UNDO, "undo", _TOOL_("undo"), _TOOLTIP_1_("undo",wxEmptyString), _HELP_("undo"));
|
||||
add_tool(tb, ID_EDIT_REDO, "redo", _TOOL_("redo"), _TOOLTIP_1_("redo",wxEmptyString), _HELP_("redo"));
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_VIEW_GRID, _TOOL_("grid"), load_resource_tool_image(_("grid")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("grid"), _HELP_("grid"));
|
||||
tb->AddTool(ID_VIEW_GRID_SNAP, _TOOL_("snap"), load_resource_tool_image(_("grid_snap")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("snap"), _HELP_("snap"));
|
||||
add_tool_tr(tb, ID_VIEW_GRID, "grid", "grid", true, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_VIEW_GRID_SNAP, "grid_snap", "snap", true, wxITEM_CHECK);
|
||||
tb->Realize();
|
||||
|
||||
// Edit mode toolbar
|
||||
wxPanel* emp = new wxPanel(this, wxID_ANY);
|
||||
wxToolBar* em = new wxToolBar(emp, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_VERTICAL | wxTB_HORZ_TEXT);
|
||||
em->SetToolBitmapSize(wxSize(17,17));
|
||||
em->AddTool(ID_MODE_SELECT, _TOOL_("select"), load_resource_tool_image(_("mode_select")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("select"), _HELP_("select"));
|
||||
em->AddTool(ID_MODE_ROTATE, _TOOL_("rotate"), load_resource_tool_image(_("mode_rotate")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("rotate"), _HELP_("rotate"));
|
||||
add_tool_tr(em, ID_MODE_SELECT, "mode_select", "select", true, wxITEM_CHECK);
|
||||
add_tool_tr(em, ID_MODE_ROTATE, "mode_rotate", "rotate", true, wxITEM_CHECK);
|
||||
em->AddSeparator();
|
||||
em->AddTool(ID_MODE_POINTS, _TOOL_("points"), load_resource_tool_image(_("mode_curve")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("points"), _HELP_("points"));
|
||||
add_tool_tr(em, ID_MODE_POINTS, "mode_curve", "points", true, wxITEM_CHECK);
|
||||
em->AddSeparator();
|
||||
em->AddTool(ID_MODE_SHAPES, _TOOL_("basic shapes"), load_resource_tool_image(_("circle")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("basic shapes"), _HELP_("basic shapes"));
|
||||
em->AddTool(ID_MODE_SYMMETRY, _TOOL_("symmetry"), load_resource_tool_image(_("mode_symmetry")),wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("symmetry"), _HELP_("symmetry"));
|
||||
//em->AddTool(ID_MODE_PAINT, _TOOL_("paint"), load_resource_tool_image(_("mode_paint")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("paint"), _HELP_("paint"));
|
||||
add_tool_tr(em, ID_MODE_SHAPES, "circle", "basic shapes", true, wxITEM_CHECK);
|
||||
add_tool_tr(em, ID_MODE_SYMMETRY, "mode_symmetry", "symmetry", true, wxITEM_CHECK);
|
||||
//add_tool_tr(em, ID_MODE_PAINT, "mode_paint", "paint", true, wxITEM_CHECK);
|
||||
em->Realize();
|
||||
|
||||
// Lay out
|
||||
@@ -177,14 +176,13 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
em = new wxToolBar(emp, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_VERTICAL | wxTB_HORZ_TEXT);
|
||||
em->SetToolBitmapSize(wxSize(17,17));
|
||||
String spaces(max(0,n-1), _(' '));
|
||||
em->AddTool(ID_MODE_SELECT, _TOOL_("select") + spaces, load_resource_tool_image(_("mode_select")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("select"), _HELP_("select"));
|
||||
em->AddTool(ID_MODE_ROTATE, _TOOL_("rotate") + spaces, load_resource_tool_image(_("mode_rotate")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("rotate"), _HELP_("rotate"));
|
||||
add_tool(em, ID_MODE_SELECT, "mode_select", _TOOL_("select") + spaces, _TOOLTIP_("select"), _HELP_("select"), wxITEM_CHECK);
|
||||
add_tool(em, ID_MODE_ROTATE, "mode_rotate", _TOOL_("rotate") + spaces, _TOOLTIP_("rotate"), _HELP_("rotate"), wxITEM_CHECK);
|
||||
em->AddSeparator();
|
||||
em->AddTool(ID_MODE_POINTS, _TOOL_("points") + spaces, load_resource_tool_image(_("mode_curve")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("points"), _HELP_("points"));
|
||||
add_tool(em, ID_MODE_POINTS, "mode_curve", _TOOL_("points") + spaces, _TOOLTIP_("points"), _HELP_("points"), wxITEM_CHECK);
|
||||
em->AddSeparator();
|
||||
em->AddTool(ID_MODE_SHAPES, _TOOL_("basic shapes") + spaces, load_resource_tool_image(_("circle")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("basic shapes"),_HELP_("basic shapes"));
|
||||
em->AddTool(ID_MODE_SYMMETRY, _TOOL_("symmetry") + spaces, load_resource_tool_image(_("mode_symmetry")),wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("symmetry"), _HELP_("symmetry"));
|
||||
//em->AddTool(ID_MODE_PAINT, _TOOL_("paint") + spaces, load_resource_tool_image(_("mode_paint")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("paint"), _HELP_("paint"));
|
||||
add_tool(em, ID_MODE_SHAPES, "circle", _TOOL_("basic shapes") + spaces, _TOOLTIP_("basic shapes"),_HELP_("basic shapes"), wxITEM_CHECK);
|
||||
add_tool(em, ID_MODE_SYMMETRY, "mode_symmetry", _TOOL_("symmetry") + spaces, _TOOLTIP_("symmetry"), _HELP_("symmetry"), wxITEM_CHECK);
|
||||
em->Realize();
|
||||
|
||||
es = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/rotation.hpp>
|
||||
#include <wx/renderer.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <gfx/gfx.hpp>
|
||||
|
||||
#if wxUSE_UXTHEME && defined(__WXMSW__)
|
||||
#include <wx/msw/uxtheme.h>
|
||||
@@ -131,7 +132,7 @@ void draw_checker(RotatedDC& dc, const RealRect& rect) {
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image related
|
||||
// ----------------------------------------------------------------------------- : Seekable stream
|
||||
|
||||
/// A wxInputStream in which we can seek, even if the underlying stream can't
|
||||
/** Seeking is used by the wxImage format detection code, to peek at the header.
|
||||
@@ -214,6 +215,8 @@ private:
|
||||
size_t last_read = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image related
|
||||
|
||||
bool image_load_file(Image& image, wxInputStream &stream) {
|
||||
wxLogNull noLog; // prevent wx from showing popups about sRGB profiles and other notices
|
||||
if (!stream.IsSeekable()) {
|
||||
@@ -229,6 +232,67 @@ bool image_load_file(Image& image, const wxString &name) {
|
||||
return image.LoadFile(name);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Tool/menu bar
|
||||
|
||||
Image generate_disabled_image(Image const& image) {
|
||||
Image imgOut = image.ConvertToGreyscale();
|
||||
set_alpha(imgOut, 0.33);
|
||||
return imgOut;
|
||||
}
|
||||
|
||||
void set_menu_item_image(wxMenuItem* item, const String& resource) {
|
||||
Image bitmap = load_resource_tool_image(resource);
|
||||
Image disabled_bitmap = generate_disabled_image(bitmap);
|
||||
item->SetBitmaps(bitmap, bitmap);
|
||||
item->SetDisabledBitmap(disabled_bitmap);
|
||||
}
|
||||
|
||||
wxMenuItem* make_menu_item(wxMenu* menu, int id, const char* resource, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) {
|
||||
wxMenuItem* item = new wxMenuItem(menu, id, text, help, kind, submenu);
|
||||
if (resource) set_menu_item_image(item, resource);
|
||||
return item;
|
||||
}
|
||||
wxMenuItem* make_menu_item_tr(wxMenu* menu, int id, const char* resource, const String& locale_key, wxItemKind kind, wxMenu* submenu) {
|
||||
wxMenuItem* item = new wxMenuItem(menu, id, tr(LOCALE_CAT_MENU, locale_key), tr(LOCALE_CAT_HELP, locale_key), kind, submenu);
|
||||
if (resource) set_menu_item_image(item, resource);
|
||||
return item;
|
||||
}
|
||||
wxMenuItem* add_menu_item(wxMenu* menu, int id, const char* resource, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) {
|
||||
wxMenuItem* item = make_menu_item(menu, id, resource, text, help, kind, submenu);
|
||||
menu->Append(item);
|
||||
return item;
|
||||
}
|
||||
wxMenuItem* add_menu_item_tr(wxMenu* menu, int id, const char* resource, const String& locale_key, wxItemKind kind, wxMenu* submenu) {
|
||||
wxMenuItem* item = make_menu_item_tr(menu, id, resource, locale_key, kind, submenu);
|
||||
menu->Append(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
wxToolBarToolBase* add_tool(wxToolBar* toolbar, int id, const char* resource, const String& label, const String& tooltip, const String& help, wxItemKind kind) {
|
||||
if (resource) {
|
||||
// Note: the bitmap must match the toolbar bitmap size, otherwise disabled and normal bitmap look different
|
||||
// if the size doesn't match, we center the image
|
||||
auto size = toolbar->GetToolBitmapSize();
|
||||
Image bitmap = load_resource_tool_image(resource);
|
||||
if (bitmap.GetSize() != size) {
|
||||
wxPoint pos((size.GetWidth() - bitmap.GetWidth()) / 2, (size.GetHeight() - bitmap.GetHeight()) / 2);
|
||||
bitmap.Resize(size, pos);
|
||||
}
|
||||
Image disabled_bitmap = generate_disabled_image(bitmap);
|
||||
auto tool = new wxToolBarToolBase(toolbar, id, label, bitmap, disabled_bitmap, kind, nullptr, tooltip, help);
|
||||
toolbar->AddTool(tool);
|
||||
return tool;
|
||||
} else {
|
||||
auto tool = new wxToolBarToolBase(toolbar, id, label, wxNullBitmap, wxNullBitmap, kind, nullptr, tooltip, help);
|
||||
toolbar->AddTool(tool);
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
|
||||
wxToolBarToolBase* add_tool_tr(wxToolBar* toolbar, int id, const char* resource, const String& locale_key, bool label, wxItemKind kind) {
|
||||
return add_tool(toolbar, id, resource, label ? tr(LOCALE_CAT_TOOL,locale_key) : String(), tr(LOCALE_CAT_TOOLTIP, locale_key), tr(LOCALE_CAT_HELP, locale_key), kind);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Resource related
|
||||
|
||||
Image load_resource_image(const String& name) {
|
||||
@@ -293,12 +357,8 @@ wxIcon load_resource_icon(const String& name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
wxBitmap load_resource_tool_image(const String& name) {
|
||||
#if defined(__WXMSW__) && !defined(__GNUC__)
|
||||
wxImage load_resource_tool_image(const String& name) {
|
||||
return load_resource_image(_("tool/") + name);
|
||||
#else
|
||||
return load_resource_image(_("tool/") + name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,26 @@ bool image_load_file(Image& image, wxInputStream &stream);
|
||||
/// Proxy around Image.LoadFile that suppresses errors.
|
||||
bool image_load_file(Image& image, const wxString &name);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Tool/menu bar
|
||||
|
||||
/// Generate an image to use for the disabled state of menu and toolbar items
|
||||
Image generate_disabled_image(Image const& image);
|
||||
|
||||
void set_menu_item_image(wxMenuItem* item, const String& resource);
|
||||
|
||||
// menu items with images.
|
||||
// resource may be nullptr
|
||||
wxMenuItem* make_menu_item(wxMenu*, int id, const char* resource, const String& text, const String& help, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
wxMenuItem* make_menu_item_tr(wxMenu*, int id, const char* resource, const String& locale_key, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
wxMenuItem* add_menu_item(wxMenu*, int id, const char* resource, const String& text, const String& help, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
wxMenuItem* add_menu_item_tr(wxMenu*, int id, const char* resource, const String& locale_key, wxItemKind kind = wxITEM_NORMAL, wxMenu* submenu = nullptr);
|
||||
|
||||
// toolbars with images loaded from resource
|
||||
// resource may be nullptr
|
||||
wxToolBarToolBase* add_tool(wxToolBar*, int id, const char* resource, const String& label, const String& tooltip, const String& help, wxItemKind kind = wxITEM_NORMAL);
|
||||
// add a tool to a toolbar, translate tooltip and help using locale
|
||||
wxToolBarToolBase* add_tool_tr(wxToolBar*, int id, const char* resource, const String& locale_key, bool label = false, wxItemKind kind = wxITEM_NORMAL);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Resource related
|
||||
|
||||
/// Load an image from a resource
|
||||
@@ -59,7 +79,7 @@ wxCursor load_resource_cursor(const String& name);
|
||||
wxIcon load_resource_icon(const String& name);
|
||||
|
||||
/// Load an image for use in a toolbar (filename: tool/...) from a resource
|
||||
wxBitmap load_resource_tool_image(const String& name);
|
||||
wxImage load_resource_tool_image(const String& name);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Platform look
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <render/value/viewer.hpp>
|
||||
|
||||
class IconMenu;
|
||||
class ValueAction;
|
||||
DECLARE_POINTER_TYPE(ValueActionPerformer);
|
||||
|
||||
@@ -56,7 +55,7 @@ class ValueEditor {
|
||||
|
||||
/// a context menu is requested, add extra items to the menu m
|
||||
/** return false to suppress menu */
|
||||
virtual bool onContextMenu(IconMenu& m, wxContextMenuEvent& ev) { return true; }
|
||||
virtual bool onContextMenu(wxMenu& m, wxContextMenuEvent& ev) { return true; }
|
||||
/// Get a special menu, events will be sent to onMenu
|
||||
virtual wxMenu* getMenu(int type) const { return nullptr; }
|
||||
/// A menu item was selected, return true if the command was processed
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/value/text.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <gui/drop_down_list.hpp>
|
||||
#include <data/word_list.hpp>
|
||||
@@ -552,12 +551,12 @@ void TextValueEditor::onLoseFocus() {
|
||||
//selection_start_i = selection_end_i = 0;
|
||||
}
|
||||
|
||||
bool TextValueEditor::onContextMenu(IconMenu& m, wxContextMenuEvent& ev) {
|
||||
bool TextValueEditor::onContextMenu(wxMenu& m, wxContextMenuEvent& ev) {
|
||||
// in a keword? => "reminder text" option
|
||||
size_t kwpos = in_tag(value().value(), _("<kw-"), selection_start_i, selection_start_i);
|
||||
if (kwpos != String::npos) {
|
||||
m.InsertSeparator(0);
|
||||
m.Insert(0,ID_FORMAT_REMINDER, _("reminder"), _MENU_("reminder text"), _HELP_("reminder text"), wxITEM_CHECK);
|
||||
m.Insert(0, make_menu_item_tr(&m, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK));
|
||||
}
|
||||
// in a spelling error? => show suggestions and "add to dictionary"
|
||||
size_t error_pos = in_tag(value().value(), _("<error-spelling"), selection_start_i, selection_start_i);
|
||||
|
||||
@@ -45,7 +45,7 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
|
||||
virtual void onMouseLeave(const RealPoint& pos, wxMouseEvent&);
|
||||
virtual bool onMouseWheel(const RealPoint& pos, wxMouseEvent&);
|
||||
|
||||
virtual bool onContextMenu(IconMenu& m, wxContextMenuEvent&);
|
||||
virtual bool onContextMenu(wxMenu& m, wxContextMenuEvent&);
|
||||
virtual wxMenu* getMenu(int type) const;
|
||||
virtual bool onCommand(int);
|
||||
|
||||
|
||||
@@ -37,6 +37,12 @@ sub make_comment {
|
||||
return $input;
|
||||
}
|
||||
|
||||
sub normalize {
|
||||
my $key = shift;
|
||||
$key =~ s/_/ /g;
|
||||
return $key;
|
||||
}
|
||||
|
||||
# for each .cpp/.hpp file, collect locale calls
|
||||
sub gather_locale_keys {
|
||||
my $filename = $_;
|
||||
@@ -74,26 +80,46 @@ sub find_locale_calls {
|
||||
while ($body =~ /_(COMMENT_)?(MENU|HELP|TOOL|TOOLTIP|LABEL|BUTTON|TITLE|TYPE|ACTION|ERROR)_(?:([1-9])_)?\(\s*\"([^\"]+)\"/g) {
|
||||
my $type = $2;
|
||||
my $argc = $3 ? $3 : 0;
|
||||
my $key = $4;
|
||||
my $key = normalize($4);
|
||||
if (defined($locale_keys{$type}{$key}{'argc'}) && $locale_keys{$type}{$key}{'argc'} != $argc) {
|
||||
die "ERROR: locale key _${type}_($key) used with different arities";
|
||||
}
|
||||
$locale_keys{$type}{$key}{'opt'} = defined($locale_keys{$type}{$key}{'opt'}) ? ($locale_keys{$type}{$key}{'opt'} && $in_comment) : $in_comment;
|
||||
$locale_keys{$type}{$key}{'argc'} = $argc;
|
||||
}
|
||||
# addPanel uses multiple types
|
||||
while ($body =~ m{
|
||||
( addPanel \((?:[^,]+,){6} # gui/set/window.cpp
|
||||
)
|
||||
\s* _ \(\" ([^\"]+) \"\)
|
||||
}xg) {
|
||||
my $key = $2;
|
||||
$key =~ s/_/ /g;
|
||||
foreach my $type ("MENU","HELP","TOOL","TOOLTIP") {
|
||||
# addPanel/add_menu_tr/add_tool_tr use multiple locale types
|
||||
my $ARG = qr{[^,]+};
|
||||
my $STRARG = qr{\s*(?:_\()?\"([^\"]+)\"\)?};
|
||||
find_multi_locale_calls($body, $in_comment, qr{addPanel\s*\((?:$ARG,){6} $STRARG \)}x, ["MENU","HELP","TOOL","TOOLTIP"]);
|
||||
find_multi_locale_calls($body, $in_comment, qr{menu_item_tr\s*\((?:$ARG,){3} $STRARG }x, ["MENU","HELP"]);
|
||||
while ($body =~ m{add_tool_tr\s*\((?:$ARG,){3} $STRARG \s*,?\s*(true|false)?}gx) {
|
||||
if ($2 eq 'true') {
|
||||
add_locale_keys(["TOOL","TOOLTIP","HELP"], normalize($1), $in_comment);
|
||||
} else {
|
||||
add_locale_keys(["TOOLTIP","HELP"], normalize($1), $in_comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub add_locale_keys {
|
||||
my $types = shift;
|
||||
my $key = shift;
|
||||
my $in_comment = shift;
|
||||
foreach my $type (@{$types}) {
|
||||
$locale_keys{$type}{$key}{'opt'} = $in_comment;
|
||||
$locale_keys{$type}{$key}{'argc'} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
sub find_multi_locale_calls {
|
||||
my $body = shift;
|
||||
my $in_comment = shift;
|
||||
my $re = shift;
|
||||
my $types = shift;
|
||||
while ($body =~ m{$re}g) {
|
||||
my $key = normalize($1);
|
||||
add_locale_keys($types, $key, $in_comment);
|
||||
}
|
||||
}
|
||||
|
||||
#my $filename = 'src/code_template.cpp';
|
||||
@@ -126,7 +152,7 @@ sub parse_locale {
|
||||
$type = uc $1;
|
||||
$key = undef;
|
||||
} elsif ($line =~ /^\t([^:\t]+):(.*)/) {
|
||||
$key = $1;
|
||||
$key = normalize($1);
|
||||
if (defined($locale{$type}{$key})) {
|
||||
die "Locale key already defined: $type: $key";
|
||||
}
|
||||
@@ -149,14 +175,14 @@ sub validate_locale {
|
||||
my $ok = 1;
|
||||
foreach my $type (sort keys %locale_keys) {
|
||||
if (!defined($locale{$type})) {
|
||||
print STDERR "Missing key in locale: $type\n have keys " . "[" . join(', ', keys %locale) . "]\n";
|
||||
print "Missing key in locale: $type\n have keys " . "[" . join(', ', keys %locale) . "]\n";
|
||||
$ok = 0;
|
||||
next;
|
||||
}
|
||||
foreach my $key (sort keys %{$locale_keys{$type}}) {
|
||||
if (!defined($locale{$type}{$key})) {
|
||||
if (!$locale_keys{$type}{$key}{'opt'}) {
|
||||
print STDERR "Missing key in locale: $type: $key\n";
|
||||
print "Missing key in locale: $type: $key\n";
|
||||
$ok = 0;
|
||||
}
|
||||
next;
|
||||
@@ -165,7 +191,7 @@ sub validate_locale {
|
||||
my @args = $locale{$type}{$key} =~ /%[sd]/g;
|
||||
my $argc = scalar(@args);
|
||||
if ($argc != $locale_keys{$type}{$key}{'argc'}) {
|
||||
print STDERR "Incorrect number of arguments for $type: $key. Expected $locale_keys{$type}{$key}{'argc'}, got $argc\n";
|
||||
print "Incorrect number of arguments for $type: $key. Expected $locale_keys{$type}{$key}{'argc'}, got $argc\n";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
@@ -173,13 +199,13 @@ sub validate_locale {
|
||||
foreach my $type (sort keys %locale) {
|
||||
next if $type eq 'PACKAGE'; # Ignore package specific locale keys
|
||||
if (!defined($locale_keys{$type})) {
|
||||
print STDERR "Unknown key in locale: $type\n expected keys " . "[" . join(', ', keys %locale_keys) . "]\n";
|
||||
print "Unknown key in locale: $type\n expected keys " . "[" . join(', ', keys %locale_keys) . "]\n";
|
||||
$ok = 0;
|
||||
next;
|
||||
}
|
||||
foreach my $key (sort keys %{$locale{$type}}) {
|
||||
if (!defined($locale_keys{$type}{$key})) {
|
||||
print STDERR "Unknown key in locale: $type: $key\n";
|
||||
print "Unknown key in locale: $type: $key\n";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||