Added 'insert symbol' menu for SymbolFonts;

Added scriptable 'enabled' to symbols in symbol font, used instead of scripted filenames. This means changing the tap symbol style now works;
Added localisation for games, stylesheets and symbolfonts;
Warnings from Reader are now shown onIdle;

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@198 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-02-07 22:31:21 +00:00
parent b93e5b2ae3
commit 73a2f61e68
36 changed files with 606 additions and 101 deletions
+17 -1
View File
@@ -143,6 +143,20 @@ void DataEditor::doCopy() { if (current_editor) current_ed
void DataEditor::doPaste() { if (current_editor) current_editor->doPaste(); }
void DataEditor::doFormat(int type) { if (current_editor) current_editor->doFormat(type); }
wxMenu* DataEditor::getMenu(int type) const {
if (current_editor) {
return current_editor->getMenu(type);
} else {
return nullptr;
}
}
void DataEditor::onCommand(int id) {
if (current_editor) {
current_editor->onCommand(id);
}
}
// ----------------------------------------------------------------------------- : Mouse events
void DataEditor::onLeftDown(wxMouseEvent& ev) {
@@ -274,7 +288,9 @@ void DataEditor::onContextMenu(wxContextMenuEvent& ev) {
}
void DataEditor::onMenu(wxCommandEvent& ev) {
if (current_editor) {
current_editor->onMenu(ev);
if (!current_editor->onCommand(ev.GetId())) {
ev.Skip();
}
} else {
ev.Skip();
}
+4
View File
@@ -53,6 +53,10 @@ class DataEditor : public CardViewer {
bool canFormat(int type) const;
bool hasFormat(int type) const;
void doFormat (int type);
/// Get a special menu, events should be sent to onCommand
wxMenu* getMenu(int type) const;
/// A menu item from getMenu was selected
void onCommand(int id);
// --------------------------------------------------- : ValueViewers
+3 -1
View File
@@ -282,7 +282,9 @@ void CardListBase::rebuild() {
if (f.second->card_list_align & ALIGN_RIGHT) align = wxLIST_FORMAT_RIGHT;
else if (f.second->card_list_align & ALIGN_CENTER) align = wxLIST_FORMAT_CENTRE;
else align = wxLIST_FORMAT_LEFT;
InsertColumn((long)column_fields.size(), capitalize(f.second->card_list_name), align, cs.width);
InsertColumn((long)column_fields.size(),
tr(*set->game, f.second->card_list_name, capitalize(f.second->card_list_name)),
align, cs.width);
column_fields.push_back(f.second);
}
// find field that determines color
+2 -2
View File
@@ -75,7 +75,7 @@ void CardListColumnSelectDialog::initList() {
// Init items
Color window_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
FOR_EACH(c, columns) {
list->Append(capitalize(c.field->card_list_name));
list->Append(tr(*game, c.field->card_list_name, capitalize(c.field->card_list_name)));
// check
int i = list->GetCount() - 1;
list->Check(i, c.settings.visible);
@@ -88,7 +88,7 @@ void CardListColumnSelectDialog::initList() {
void CardListColumnSelectDialog::refreshItem(int i) {
list->Check (i, columns[i].settings.visible);
list->SetString(i, capitalize(columns[i].field->card_list_name));
list->SetString(i, tr(*game, columns[i].field->card_list_name, capitalize(columns[i].field->card_list_name)) );
}
// ----------------------------------------------------------------------------- : Events
+3 -1
View File
@@ -38,7 +38,9 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
dc.DrawRectangle(s.getRect().grow(1));
// draw label
dc.SetFont(*wxNORMAL_FONT);
dc.DrawText(capitalize_sentence(s.fieldP->name), RealPoint(margin_left, s.top + 1));
// TODO : tr using stylesheet or using game?
dc.DrawText(tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name)),
RealPoint(margin_left, s.top + 1));
// draw 3D border
draw_control_border(this, dc.getDC(), RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2));
// draw viewer
+5
View File
@@ -77,6 +77,11 @@ void IconMenu::Append(int id, const String& text, const String& help, wxMenu* su
wxMenu::Append(item);
}
void IconMenu::Append(wxMenuItem* item) {
item->SetBitmap(wxNullBitmap);
wxMenu::Append(item);
}
void IconMenu::Insert(size_t pos, int id, const String& text, const String& help) {
wxMenuItem* item = new wxMenuItem (this, id, text, help);
item->SetBitmap(wxNullBitmap);
+2
View File
@@ -27,6 +27,8 @@ class IconMenu : public wxMenu {
void Append(int id, const String& text, const String& help);
/// Append a menu item, without an image
void Append(int id, const String& text, const String& help, wxMenu* submenu);
/// Append a menu item, without an image
void Append(wxMenuItem* item);
/// Insert a menu item, without an image
void Insert(size_t pos, int id, const String& text, const String& help);
};
+57 -27
View File
@@ -47,10 +47,49 @@ CardsPanel::CardsPanel(Window* parent, int id)
s->Add(splitter, 1, wxEXPAND);
s->SetSizeHints(this);
SetSizer(s);
// init menus
menuCard = new IconMenu();
menuCard->Append(ID_CARD_PREV, _("Select &Previous Card\tPgUp"), _("Selects the previous card in the list"));
menuCard->Append(ID_CARD_NEXT, _("Select &Next Card\tPgDn"), _("Selects the next card in the list"));
menuCard->AppendSeparator();
menuCard->Append(ID_CARD_ADD, _("card_add"), _("&Add Card\tCtrl++"), _("Add a new, blank, card to this set"));
menuCard->Append(ID_CARD_ADD_MULT, _("card_add_multiple"), _("Add &Multiple Cards..."), _("Add multiple cards to the set"));
// NOTE: space after "Del" prevents wx from making del an accellerator
// otherwise we delete a card when delete is pressed inside the editor
menuCard->Append(ID_CARD_REMOVE, _("card_del"), _("&Remove Select Card\tDel "), _("Delete the selected card from this set"));
menuCard->AppendSeparator();
IconMenu* menuRotate = new IconMenu();
menuRotate->Append(ID_CARD_ROTATE_0, _("card_rotate_0"), _("&Normal"), _("Display the card with the right side up"), wxITEM_CHECK);
menuRotate->Append(ID_CARD_ROTATE_270, _("card_rotate_270"), _("Rotated 90 &Clockwise"), _("Display the card rotated clockwise"), wxITEM_CHECK);
menuRotate->Append(ID_CARD_ROTATE_90, _("card_rotate_90"), _("Rotated 90 C&ounter Clockwise"), _("Display the card rotated counter-clockwise (anti-clockwise for the British)"), wxITEM_CHECK);
menuRotate->Append(ID_CARD_ROTATE_180, _("card_rotate_180"), _("Rotated 180, &Up Side Down"), _("Display the card up side down"), wxITEM_CHECK);
menuCard->Append(wxID_ANY, _("card_rotate"), _("&Orientation"), _("Orientation of the card display"), 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, _("C&ard List Columns..."), _("Select what columns should be shown and in what order."));
menuFormat = new IconMenu();
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);
menuFormat->AppendSeparator();
insertSymbolMenu = new wxMenuItem(menuFormat, ID_INSERT_SYMBOL, _("Insert Symbol"));
menuFormat->Append(insertSymbolMenu);
}
CardsPanel::~CardsPanel() {
// settings.card_notes_height = splitter->GetSashPosition();
// we don't own the submenu
wxMenu* menu = insertSymbolMenu->GetSubMenu();
if (menu && menu->GetParent() == menuFormat) {
menu->SetParent(nullptr);
}
insertSymbolMenu->SetSubMenu(nullptr);
// delete menus
delete menuCard;
delete menuFormat;
}
void CardsPanel::onChangeSet() {
@@ -78,32 +117,7 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
tb->AddTool(ID_CARD_ROTATE, _(""), load_resource_tool_image(_("card_rotate")), wxNullBitmap,wxITEM_NORMAL,_TOOL_("rotate card"));
tb->Realize();
// Menus
IconMenu* menuCard = new IconMenu();
menuCard->Append(ID_CARD_PREV, _("Select &Previous Card\tPgUp"), _("Selects the previous card in the list"));
menuCard->Append(ID_CARD_NEXT, _("Select &Next Card\tPgDn"), _("Selects the next card in the list"));
menuCard->AppendSeparator();
menuCard->Append(ID_CARD_ADD, _("card_add"), _("&Add Card\tCtrl++"), _("Add a new, blank, card to this set"));
menuCard->Append(ID_CARD_ADD_MULT, _("card_add_multiple"), _("Add &Multiple Cards..."), _("Add multiple cards to the set"));
// NOTE: space after "Del" prevents wx from making del an accellerator
// otherwise we delete a card when delete is pressed inside the editor
menuCard->Append(ID_CARD_REMOVE, _("card_del"), _("&Remove Select Card\tDel "), _("Delete the selected card from this set"));
menuCard->AppendSeparator();
IconMenu* menuRotate = new IconMenu();
menuRotate->Append(ID_CARD_ROTATE_0, _("card_rotate_0"), _("&Normal"), _("Display the card with the right side up"), wxITEM_CHECK);
menuRotate->Append(ID_CARD_ROTATE_270, _("card_rotate_270"), _("Rotated 90 &Clockwise"), _("Display the card rotated clockwise"), wxITEM_CHECK);
menuRotate->Append(ID_CARD_ROTATE_90, _("card_rotate_90"), _("Rotated 90 C&ounter Clockwise"), _("Display the card rotated counter-clockwise (anti-clockwise for the British)"), wxITEM_CHECK);
menuRotate->Append(ID_CARD_ROTATE_180, _("card_rotate_180"), _("Rotated 180, &Up Side Down"), _("Display the card up side down"), wxITEM_CHECK);
menuCard->Append(wxID_ANY, _("card_rotate"), _("&Orientation"), _("Orientation of the card display"), 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, _("C&ard List Columns..."), _("Select what columns should be shown and in what order."));
mb->Insert(2, menuCard, _("&Cards"));
IconMenu* menuFormat = new IconMenu();
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"));
}
@@ -120,8 +134,8 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
tb->DeleteToolByPos(10); // delete separator
tb->DeleteToolByPos(10); // delete separator
// Menus
delete mb->Remove(3);
delete mb->Remove(2);
mb->Remove(3);
mb->Remove(2);
}
void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
@@ -148,6 +162,16 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
}
break;
}
case ID_INSERT_SYMBOL: {
wxMenu* menu = editor->getMenu(ID_INSERT_SYMBOL);
ev.Enable(menu);
if (insertSymbolMenu->GetSubMenu() != menu || menu->GetParent() != menuFormat) {
// re-add the menu
menuFormat->Remove(insertSymbolMenu);
insertSymbolMenu->SetSubMenu(menu);
menuFormat->Append(insertSymbolMenu);
}
}
}
}
@@ -187,6 +211,12 @@ void CardsPanel::onCommand(int id) {
break;
}
}
default: {
if (id >= ID_INSERT_SYMBOL_MENU_MIN && id <= ID_INSERT_SYMBOL_MENU_MAX) {
// pass on to editor
editor->onCommand(id);
}
}
}
}
+3 -1
View File
@@ -16,6 +16,7 @@ class wxSplitterWindow;
class ImageCardList;
class DataEditor;
class TextCtrl;
class IconMenu;
// ----------------------------------------------------------------------------- : CardsPanel
@@ -95,7 +96,8 @@ class CardsPanel : public SetWindowPanel {
TextCtrl* notes;
// --------------------------------------------------- : Menus & tools
wxMenu* cardMenu, formatMenu;
IconMenu* menuCard, *menuFormat;
wxMenuItem* insertSymbolMenu; // owned by menuFormat, but submenu owned by SymbolFont
};
// ----------------------------------------------------------------------------- : EOF
+4 -2
View File
@@ -53,8 +53,10 @@ class ValueEditor {
/// a context menu is requested, add extra items to the menu m
/** return false to suppress menu */
virtual bool onContextMenu(wxMenu& m, wxContextMenuEvent& ev) { return true; }
/// A menu item was selected
virtual void onMenu(wxCommandEvent& ev) { ev.Skip(); }
/// 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
virtual bool onCommand(int id) { return false; }
// --------------------------------------------------- : Clipboard
+27 -1
View File
@@ -192,7 +192,7 @@ void TextValueEditor::onChar(wxKeyEvent& ev) {
// TODO: Find a more correct way to determine normal characters,
// this might not work for internationalized input.
// It might also not be portable!
replaceSelection(String(ev.GetUnicodeKey(), 1), _("Typing"));
replaceSelection(escape(String(ev.GetUnicodeKey(), 1)), _("Typing"));
}
}
}
@@ -224,6 +224,31 @@ bool TextValueEditor::onContextMenu(wxMenu& m, wxContextMenuEvent& ev) {
// always show the menu
return true;
}
bool TextValueEditor::onCommand(int id) {
if (id >= ID_INSERT_SYMBOL_MENU_MIN && id <= ID_INSERT_SYMBOL_MENU_MAX) {
// Insert a symbol
if ((style().always_symbol || style().allow_formating) && style().symbol_font.valid()) {
String code = style().symbol_font.font->insertSymbolCode(id);
if (!style().always_symbol) {
code = _("<sym>") + code + _("</sym>");
}
replaceSelection(code, _("Insert Symbol"));
return true;
}
}
return false;
}
wxMenu* TextValueEditor::getMenu(int type) const {
if (type == ID_INSERT_SYMBOL && (style().always_symbol || style().allow_formating)
&& style().symbol_font.valid()) {
return style().symbol_font.font->insertSymbolMenu(viewer.getContext());
} else {
return nullptr;
}
}
/*
/// TODO : move to doFormat
void TextValueEditor::onMenu(wxCommandEvent& ev) {
if (ev.GetId() == ID_FORMAT_REMINDER) {
// toggle reminder text
@@ -235,6 +260,7 @@ void TextValueEditor::onMenu(wxCommandEvent& ev) {
ev.Skip();
}
}
*/
// ----------------------------------------------------------------------------- : Other overrides
+3 -1
View File
@@ -44,7 +44,8 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
virtual void onMouseWheel(const RealPoint& pos, wxMouseEvent& ev);
virtual bool onContextMenu(wxMenu& m, wxContextMenuEvent&);
virtual void onMenu(wxCommandEvent&);
virtual wxMenu* getMenu(int type) const;
virtual bool onCommand(int);
virtual void onChar(wxKeyEvent&);
@@ -98,6 +99,7 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
void moveSelectionNoRedraw(IndexType t, size_t new_end, bool also_move_start=true, Movement dir = MOVE_MID);
/// Replace the current selection with 'replacement', name the action
/** replacement should be a tagged string (i.e. already escaped) */
void replaceSelection(const String& replacement, const String& name);
/// Make sure the selection satisfies its constraints