mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
Implement unique IDs and card linking
This commit is contained in:
+252
-70
@@ -25,6 +25,7 @@
|
||||
#include <util/tagged_string.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <wx/splitter.h>
|
||||
#include <wx/gbsizer.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardsPanel
|
||||
|
||||
@@ -32,15 +33,36 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
: SetWindowPanel(parent, id)
|
||||
{
|
||||
// init controls
|
||||
editor = new CardEditor(this, ID_EDITOR);
|
||||
splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
card_list = new FilteredImageCardList(splitter, ID_CARD_LIST);
|
||||
nodes_panel = new wxPanel(splitter, wxID_ANY);
|
||||
notes = new TextCtrl(nodes_panel, ID_NOTES, true);
|
||||
collapse_notes = new HoverButton(nodes_panel, ID_COLLAPSE_NOTES, _("btn_collapse"), Color(), false);
|
||||
editor = new CardEditor(this, ID_EDITOR);
|
||||
link_editor = new CardEditor(this, ID_CARD_LINK_EDITOR);
|
||||
focused_editor = editor;
|
||||
link_viewer_1 = new CardViewer(this, ID_CARD_LINK_VIEWER);
|
||||
link_viewer_2 = new CardViewer(this, ID_CARD_LINK_VIEWER);
|
||||
link_viewer_3 = new CardViewer(this, ID_CARD_LINK_VIEWER);
|
||||
link_viewer_4 = new CardViewer(this, ID_CARD_LINK_VIEWER);
|
||||
link_relation_1 = new wxStaticText(this, ID_CARD_LINK_RELATION_1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
link_relation_2 = new wxStaticText(this, ID_CARD_LINK_RELATION_2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
link_relation_3 = new wxStaticText(this, ID_CARD_LINK_RELATION_3, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
link_relation_4 = new wxStaticText(this, ID_CARD_LINK_RELATION_4, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
link_select = new wxButton(this, ID_CARD_LINK_SELECT, _BUTTON_("link select"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
|
||||
link_unlink_1 = new wxButton(this, ID_CARD_LINK_UNLINK_1, _BUTTON_("unlink"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
|
||||
link_unlink_2 = new wxButton(this, ID_CARD_LINK_UNLINK_2, _BUTTON_("unlink"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
|
||||
link_unlink_3 = new wxButton(this, ID_CARD_LINK_UNLINK_3, _BUTTON_("unlink"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
|
||||
link_unlink_4 = new wxButton(this, ID_CARD_LINK_UNLINK_4, _BUTTON_("unlink"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
|
||||
splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
card_list = new FilteredImageCardList(splitter, ID_CARD_LIST);
|
||||
nodes_panel = new wxPanel(splitter, wxID_ANY);
|
||||
notes = new TextCtrl(nodes_panel, ID_NOTES, true);
|
||||
collapse_notes = new HoverButton(nodes_panel, ID_COLLAPSE_NOTES, _("btn_collapse"), Color(), false);
|
||||
collapse_notes->SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES);
|
||||
filter = nullptr;
|
||||
filter = nullptr;
|
||||
editor->next_in_tab_order = card_list;
|
||||
wxFont font = link_relation_1->GetFont();
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
link_relation_1->SetFont(font);
|
||||
link_relation_2->SetFont(font);
|
||||
link_relation_3->SetFont(font);
|
||||
link_relation_4->SetFont(font);
|
||||
// init sizer for notes panel
|
||||
wxSizer* sn = new wxBoxSizer(wxVERTICAL);
|
||||
wxSizer* sc = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -54,10 +76,46 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
splitter->SetSashGravity(1.0);
|
||||
splitter->SplitHorizontally(card_list, nodes_panel, -40);
|
||||
notes_below_editor = false;
|
||||
// init sizer
|
||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||
s_left = new wxBoxSizer(wxVERTICAL);
|
||||
s_left->Add(editor);
|
||||
// init sizer for editors and viewers
|
||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL); // Global Sizer
|
||||
s_left = new wxBoxSizer(wxVERTICAL); // Sizer for the selected card, and it's linked cards
|
||||
wxSizer* card_and_link = new wxBoxSizer(wxHORIZONTAL);
|
||||
s_left->Add(card_and_link);
|
||||
card_and_link->Add(editor);
|
||||
wxGridBagSizer* link_boxes = new wxGridBagSizer(); // Sizer for the linked cards
|
||||
card_and_link->Add(link_boxes, 0, wxLEFT, 2);
|
||||
link_box_1 = new wxStaticBoxSizer(wxVERTICAL, this); // Box around the first linked card, it's relation, and buttons to select and unlink
|
||||
link_boxes->Add(link_box_1, wxGBPosition(0, 0), wxGBSpan(1, 1));
|
||||
link_box_2 = new wxStaticBoxSizer(wxVERTICAL, this); // Box around the second linked card, it's relation, and a button to unlink
|
||||
link_boxes->Add(link_box_2, wxGBPosition(1, 0), wxGBSpan(1, 1));
|
||||
link_box_3 = new wxStaticBoxSizer(wxVERTICAL, this); // Box around the third linked card, it's relation, and a button to unlink
|
||||
link_boxes->Add(link_box_3, wxGBPosition(0, 1), wxGBSpan(1, 1));
|
||||
link_box_4 = new wxStaticBoxSizer(wxVERTICAL, this); // Box around the fourth linked card, it's relation, and a button to unlink
|
||||
link_boxes->Add(link_box_4, wxGBPosition(1, 1), wxGBSpan(1, 1));
|
||||
wxGridBagSizer* link_grid_1 = new wxGridBagSizer(); // Sizer for the first linked card, with it's relation, and a button to unlink
|
||||
link_box_1->Add(link_grid_1);
|
||||
wxGridBagSizer* link_grid_2 = new wxGridBagSizer();
|
||||
link_box_2->Add(link_grid_2);
|
||||
wxGridBagSizer* link_grid_3 = new wxGridBagSizer();
|
||||
link_box_3->Add(link_grid_3);
|
||||
wxGridBagSizer* link_grid_4 = new wxGridBagSizer();
|
||||
link_box_4->Add(link_grid_4);
|
||||
wxSizer* link_grid_1_buttons = new wxBoxSizer(wxHORIZONTAL);
|
||||
link_grid_1->Add(link_relation_1, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxLEFT, 4);
|
||||
link_grid_1->Add(link_viewer_1, wxGBPosition(1, 0), wxGBSpan(1, 2));
|
||||
link_grid_1->Add(link_editor, wxGBPosition(2, 0), wxGBSpan(1, 2));
|
||||
link_grid_1->Add(link_grid_1_buttons, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_RIGHT);
|
||||
link_grid_1_buttons->Add(link_select);
|
||||
link_grid_1_buttons->Add(link_unlink_1);
|
||||
link_grid_2->Add(link_relation_2, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxLEFT, 4);
|
||||
link_grid_2->Add(link_unlink_2, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_RIGHT);
|
||||
link_grid_2->Add(link_viewer_2, wxGBPosition(1, 0), wxGBSpan(1, 2));
|
||||
link_grid_3->Add(link_relation_3, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxLEFT, 4);
|
||||
link_grid_3->Add(link_unlink_3, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_RIGHT);
|
||||
link_grid_3->Add(link_viewer_3, wxGBPosition(1, 0), wxGBSpan(1, 2));
|
||||
link_grid_4->Add(link_relation_4, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxLEFT, 4);
|
||||
link_grid_4->Add(link_unlink_4, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_RIGHT);
|
||||
link_grid_4->Add(link_viewer_4, wxGBPosition(1, 0), wxGBSpan(1, 2));
|
||||
s->Add(s_left, 0, wxEXPAND | wxRIGHT, 2);
|
||||
s->Add(splitter, 1, wxEXPAND);
|
||||
s->SetSizeHints(this);
|
||||
@@ -77,6 +135,8 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
add_menu_item(menuCard, ID_CARD_ADD_JSON, "card_add_multiple", _MENU_("add card json") + _(" "), _HELP_("add card json"));
|
||||
add_menu_item_tr(menuCard, ID_CARD_ADD, "card_add", "add_card");
|
||||
add_menu_item(menuCard, ID_CARD_REMOVE, "card_del", _MENU_("remove card")+_(" "), _HELP_("remove card"));
|
||||
add_menu_item(menuCard, ID_CARD_LINK, "card_link", _MENU_("link card") + _(" "), _HELP_("link card"));
|
||||
add_menu_item(menuCard, ID_CARD_AND_LINK_COPY, "card_copy", _MENU_("copy card and links") + _(" "), _HELP_("copy card and links"));
|
||||
menuCard->AppendSeparator();
|
||||
auto menuRotate = new wxMenu();
|
||||
add_menu_item_tr(menuRotate, ID_CARD_ROTATE_0, "card_rotate_0", "rotate_0", wxITEM_CHECK);
|
||||
@@ -90,7 +150,7 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
|
||||
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_ITALIC, "italic", "italic", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", 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);
|
||||
@@ -99,38 +159,38 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
menuFormat->Append(insertSymbolMenu);
|
||||
|
||||
toolAddCard = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CardsPanel::updateCardCounts() {
|
||||
if (counts && card_list && set) {
|
||||
int selected = card_list->GetSelectedItemCount();
|
||||
int filtered = card_list->GetItemCount();
|
||||
int total = set->cards.size();
|
||||
|
||||
if (
|
||||
selected_cards_count == selected
|
||||
&& filtered_cards_count == filtered
|
||||
&& total_cards_count == total
|
||||
&& !counts->GetLabel().empty()
|
||||
) return;
|
||||
|
||||
selected_cards_count = selected;
|
||||
filtered_cards_count = filtered;
|
||||
total_cards_count = total;
|
||||
|
||||
if (filtered == total) {
|
||||
counts->SetLabel(_TOOL_2_("card counts 2",
|
||||
wxString::Format(wxT("%i"), selected),
|
||||
wxString::Format(wxT("%i"), total)));
|
||||
}
|
||||
else {
|
||||
counts->SetLabel(_TOOL_3_("card counts 3",
|
||||
wxString::Format(wxT("%i"), selected),
|
||||
wxString::Format(wxT("%i"), filtered),
|
||||
wxString::Format(wxT("%i"), total)));
|
||||
}
|
||||
void CardsPanel::updateCardCounts() {
|
||||
if (counts && card_list && set) {
|
||||
int selected = card_list->GetSelectedItemCount();
|
||||
int filtered = card_list->GetItemCount();
|
||||
int total = set->cards.size();
|
||||
|
||||
if (
|
||||
selected_cards_count == selected
|
||||
&& filtered_cards_count == filtered
|
||||
&& total_cards_count == total
|
||||
&& !counts->GetLabel().empty()
|
||||
) return;
|
||||
|
||||
selected_cards_count = selected;
|
||||
filtered_cards_count = filtered;
|
||||
total_cards_count = total;
|
||||
|
||||
if (filtered == total) {
|
||||
counts->SetLabel(_TOOL_2_("card counts 2",
|
||||
wxString::Format(wxT("%i"), selected),
|
||||
wxString::Format(wxT("%i"), total)));
|
||||
}
|
||||
else {
|
||||
counts->SetLabel(_TOOL_3_("card counts 3",
|
||||
wxString::Format(wxT("%i"), selected),
|
||||
wxString::Format(wxT("%i"), filtered),
|
||||
wxString::Format(wxT("%i"), total)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CardsPanel::updateNotesPosition() {
|
||||
wxSize editor_size = editor->GetBestSize();
|
||||
@@ -177,6 +237,11 @@ CardsPanel::~CardsPanel() {
|
||||
|
||||
void CardsPanel::onChangeSet() {
|
||||
editor->setSet(set);
|
||||
link_editor->setSet(set);
|
||||
link_viewer_1->setSet(set);
|
||||
link_viewer_2->setSet(set);
|
||||
link_viewer_3->setSet(set);
|
||||
link_viewer_4->setSet(set);
|
||||
notes->setSet(set);
|
||||
card_list->setSet(set);
|
||||
|
||||
@@ -187,9 +252,9 @@ 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 (toolAddCard) {
|
||||
// Originally this was using the menu directly, but there are compatibility issues apparently.
|
||||
// At this point it might be possible to just store a reference to the toolbar directly instead.
|
||||
if (toolAddCard) {
|
||||
// Originally this was using the menu directly, but there are compatibility issues apparently.
|
||||
// At this point it might be possible to just store a reference to the toolbar directly instead.
|
||||
toolAddCard->GetToolBar()->SetDropdownMenu(ID_CARD_ADD, makeAddCardsSubmenu(true));
|
||||
}
|
||||
}
|
||||
@@ -218,7 +283,7 @@ wxMenu* CardsPanel::makeAddCardsSubmenu(bool add_single_card_option) {
|
||||
void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
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_ITALIC, "italic", "italic", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", 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);
|
||||
@@ -226,6 +291,7 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
toolAddCard = add_tool_tr(tb, ID_CARD_ADD, "card_add", "add_card", false, wxITEM_DROPDOWN);
|
||||
tb->SetDropdownMenu(ID_CARD_ADD, makeAddCardsSubmenu(true));
|
||||
add_tool_tr(tb, ID_CARD_REMOVE, "card_del", "remove_card");
|
||||
add_tool_tr(tb, ID_CARD_LINK, "card_link", "link_card");
|
||||
tb->AddSeparator();
|
||||
add_tool_tr(tb, ID_CARD_ROTATE, "card_rotate", "rotate_card", false, wxITEM_DROPDOWN);
|
||||
auto menuRotate = new wxMenu();
|
||||
@@ -239,10 +305,10 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
assert(!filter);
|
||||
filter = new FilterCtrl(tb, ID_CARD_FILTER, _TOOL_("search cards"), _HELP_("search cards control"));
|
||||
filter->setFilter(filter_value);
|
||||
tb->AddControl(filter);
|
||||
tb->AddControl(filter);
|
||||
counts = new wxStaticText(tb, ID_CARD_COUNTER, _(""));
|
||||
updateCardCounts();
|
||||
tb->AddControl(counts);
|
||||
updateCardCounts();
|
||||
tb->AddControl(counts);
|
||||
tb->Realize();
|
||||
// Menus
|
||||
mb->Insert(2, menuCard, _MENU_("cards"));
|
||||
@@ -252,12 +318,13 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
tb->DeleteTool(ID_FORMAT_BOLD);
|
||||
tb->DeleteTool(ID_FORMAT_ITALIC);
|
||||
tb->DeleteTool(ID_FORMAT_ITALIC);
|
||||
tb->DeleteTool(ID_FORMAT_UNDERLINE);
|
||||
tb->DeleteTool(ID_FORMAT_SYMBOL);
|
||||
tb->DeleteTool(ID_FORMAT_REMINDER);
|
||||
tb->DeleteTool(ID_CARD_ADD);
|
||||
tb->DeleteTool(ID_CARD_REMOVE);
|
||||
tb->DeleteTool(ID_CARD_LINK);
|
||||
tb->DeleteTool(ID_CARD_ROTATE);
|
||||
tb->DeleteTool(ID_CARD_COUNTER);
|
||||
// remember the value in the filter control, because the card list remains filtered
|
||||
@@ -277,8 +344,8 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
|
||||
void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_CARD_PREV: ev.Enable(card_list->canSelectPrevious()); break;
|
||||
case ID_CARD_NEXT: ev.Enable(card_list->canSelectNext()); break;
|
||||
case ID_CARD_PREV: ev.Enable(card_list->canSelectPrevious()); break;
|
||||
case ID_CARD_NEXT: ev.Enable(card_list->canSelectNext()); break;
|
||||
case ID_CARD_ROTATE_0: case ID_CARD_ROTATE_90: case ID_CARD_ROTATE_180: case ID_CARD_ROTATE_270: {
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(set->stylesheetFor(card_list->getCard()));
|
||||
int a = ev.GetId() == ID_CARD_ROTATE_0 ? 0
|
||||
@@ -292,11 +359,16 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
ev.Enable(insertManyCardsMenu->GetSubMenu() != nullptr);
|
||||
break;
|
||||
}
|
||||
case ID_CARD_REMOVE: ev.Enable(card_list->canDelete()); break;
|
||||
case ID_CARD_REMOVE: ev.Enable(card_list->canDelete()); break;
|
||||
case ID_CARD_LINK: ev.Enable(card_list->canLink()); break;
|
||||
case ID_CARD_AND_LINK_COPY: ev.Enable(card_list->canCopy()); break;
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_UNDERLINE: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
|
||||
if (focused_control(this) == ID_EDITOR) {
|
||||
ev.Enable(editor->canFormat(ev.GetId()));
|
||||
ev.Check (editor->hasFormat(ev.GetId()));
|
||||
} else if (focused_control(this) == ID_CARD_LINK_EDITOR) {
|
||||
ev.Enable(link_editor->canFormat(ev.GetId()));
|
||||
ev.Check (link_editor->hasFormat(ev.GetId()));
|
||||
} else {
|
||||
ev.Enable(false);
|
||||
ev.Check(false);
|
||||
@@ -313,18 +385,18 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
case ID_INSERT_SYMBOL: ev.Enable(false); break;
|
||||
#else
|
||||
case ID_INSERT_SYMBOL: {
|
||||
wxMenu* menu = editor->getMenu(ID_INSERT_SYMBOL);
|
||||
wxMenu* menu = focused_editor->getMenu(ID_INSERT_SYMBOL);
|
||||
ev.Enable(menu);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
updateCardCounts();
|
||||
}
|
||||
|
||||
void CardsPanel::onMenuOpen(wxMenuEvent& ev) {
|
||||
if (ev.GetMenu() != menuFormat) return;
|
||||
wxMenu* menu = editor->getMenu(ID_INSERT_SYMBOL);
|
||||
wxMenu* menu = focused_editor->getMenu(ID_INSERT_SYMBOL);
|
||||
if (insertSymbolMenu->GetSubMenu() != menu || (menu && menu->GetParent() != menuFormat)) {
|
||||
// re-add the menu
|
||||
menuFormat->Remove(ID_INSERT_SYMBOL);
|
||||
@@ -358,6 +430,27 @@ void CardsPanel::onCommand(int id) {
|
||||
case ID_CARD_REMOVE:
|
||||
card_list->doDelete();
|
||||
break;
|
||||
case ID_CARD_LINK:
|
||||
card_list->doLink();
|
||||
setCard(card_list->getCard(), true);
|
||||
break;
|
||||
case ID_CARD_LINK_UNLINK_1: case ID_CARD_LINK_UNLINK_2: case ID_CARD_LINK_UNLINK_3: case ID_CARD_LINK_UNLINK_4: {
|
||||
card_list->doUnlink((
|
||||
id == ID_CARD_LINK_UNLINK_1 ? link_viewer_1
|
||||
: id == ID_CARD_LINK_UNLINK_2 ? link_viewer_2
|
||||
: id == ID_CARD_LINK_UNLINK_3 ? link_viewer_3
|
||||
: link_viewer_4
|
||||
)->getCard());
|
||||
setCard(card_list->getCard(), true);
|
||||
break;
|
||||
}
|
||||
case ID_CARD_LINK_SELECT: {
|
||||
setCard(link_viewer_1->getCard(), true);
|
||||
break;
|
||||
}
|
||||
case ID_CARD_AND_LINK_COPY:
|
||||
card_list->doCopyCardAndLinkedCards();
|
||||
break;
|
||||
case ID_CARD_ROTATE:
|
||||
case ID_CARD_ROTATE_0: case ID_CARD_ROTATE_90: case ID_CARD_ROTATE_180: case ID_CARD_ROTATE_270: {
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(set->stylesheetFor(card_list->getCard()));
|
||||
@@ -378,6 +471,9 @@ void CardsPanel::onCommand(int id) {
|
||||
if (focused_control(this) == ID_EDITOR) {
|
||||
editor->doFormat(id);
|
||||
}
|
||||
else if (focused_control(this) == ID_CARD_LINK_EDITOR) {
|
||||
link_editor->doFormat(id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_COLLAPSE_NOTES: {
|
||||
@@ -399,7 +495,7 @@ void CardsPanel::onCommand(int id) {
|
||||
default: {
|
||||
if (id >= ID_INSERT_SYMBOL_MENU_MIN && id <= ID_INSERT_SYMBOL_MENU_MAX) {
|
||||
// pass on to editor
|
||||
editor->onCommand(id);
|
||||
focused_editor->onCommand(id);
|
||||
} else if (id >= ID_ADD_CARDS_MENU_MIN && id <= ID_ADD_CARDS_MENU_MAX) {
|
||||
// add multiple cards
|
||||
AddCardsScriptP script = set->game->add_cards_scripts.at(id - ID_ADD_CARDS_MENU_MIN);
|
||||
@@ -420,10 +516,11 @@ bool CardsPanel::wantsToHandle(const Action&, bool undone) const {
|
||||
// determine what control to use for clipboard actions
|
||||
#define CUT_COPY_PASTE(op,return) \
|
||||
int id = focused_control(this); \
|
||||
if (id == ID_EDITOR) { return editor->op(); } \
|
||||
else if (id == ID_CARD_LIST) { return card_list->op(); } \
|
||||
else if (id == ID_NOTES) { return notes->op(); } \
|
||||
else { return false; }
|
||||
if (id == ID_EDITOR) { return editor->op(); } \
|
||||
else if (id == ID_CARD_LINK_EDITOR) { return link_editor->op(); } \
|
||||
else if (id == ID_CARD_LIST) { return card_list->op(); } \
|
||||
else if (id == ID_NOTES) { return notes->op(); } \
|
||||
else { return false; }
|
||||
|
||||
bool CardsPanel::canCut() const { CUT_COPY_PASTE(canCut, return) }
|
||||
bool CardsPanel::canCopy() const { CUT_COPY_PASTE(canCopy, return) }
|
||||
@@ -434,17 +531,19 @@ void CardsPanel::doCopy() { CUT_COPY_PASTE(doCopy, return (void)) }
|
||||
bool CardsPanel::canPaste() const {
|
||||
if (card_list->canPaste()) return true;
|
||||
int id = focused_control(this);
|
||||
if (id == ID_EDITOR) return editor->canPaste();
|
||||
else if (id == ID_NOTES) return notes->canPaste();
|
||||
else return false;
|
||||
if (id == ID_EDITOR) return editor->canPaste();
|
||||
else if (id == ID_CARD_LINK_EDITOR) return link_editor->canPaste();
|
||||
else if (id == ID_NOTES) return notes->canPaste();
|
||||
else return false;
|
||||
}
|
||||
void CardsPanel::doPaste() {
|
||||
if (card_list->canPaste()) {
|
||||
card_list->doPaste();
|
||||
} else {
|
||||
int id = focused_control(this);
|
||||
if (id == ID_EDITOR) editor->doPaste();
|
||||
else if (id == ID_NOTES) notes->doPaste();
|
||||
if (id == ID_EDITOR) editor->doPaste();
|
||||
else if (id == ID_CARD_LINK_EDITOR) link_editor->doPaste();
|
||||
else if (id == ID_NOTES) notes->doPaste();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +564,7 @@ public:
|
||||
SearchFindInfo(CardsPanel& panel, wxFindReplaceData& what) : FindInfo(what), panel(panel) {}
|
||||
bool handle(const CardP& card, const TextValueP& value, size_t pos, bool was_selection) override {
|
||||
// Select the card
|
||||
panel.card_list->setCard(card);
|
||||
panel.setCard(card, true);
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
@@ -477,7 +576,7 @@ public:
|
||||
ReplaceFindInfo(CardsPanel& panel, wxFindReplaceData& what) : FindInfo(what), panel(panel) {}
|
||||
bool handle(const CardP& card, const TextValueP& value, size_t pos, bool was_selection) override {
|
||||
// Select the card
|
||||
panel.card_list->setCard(card);
|
||||
panel.setCard(card, true);
|
||||
// Replace
|
||||
if (was_selection) {
|
||||
panel.editor->insert(escape(what.GetReplaceString()), _("Replace"));
|
||||
@@ -512,10 +611,12 @@ bool CardsPanel::search(FindInfo& find, bool from_start) {
|
||||
if (include) {
|
||||
editor->setCard(card);
|
||||
if (editor->search(find, from_start || card != current)) {
|
||||
return true; // done
|
||||
// found a card, call handle
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// didn't find anything, put editor back in its previous state
|
||||
editor->setCard(current);
|
||||
return false;
|
||||
}
|
||||
@@ -527,9 +628,76 @@ CardP CardsPanel::selectedCard() const {
|
||||
}
|
||||
void CardsPanel::selectCard(const CardP& card) {
|
||||
if (!set) return; // we want onChangeSet first
|
||||
|
||||
card_list->setCard(card);
|
||||
|
||||
editor->setCard(card);
|
||||
vector<pair<CardP, String>> linked_cards = card->getLinkedCards(*set);
|
||||
int count = linked_cards.size();
|
||||
if (count >= 1) {
|
||||
link_box_1->Show(true);
|
||||
link_editor->setCard(linked_cards[0].first);
|
||||
link_viewer_1->setCard(linked_cards[0].first);
|
||||
link_relation_1->SetLabel(linked_cards[0].second);
|
||||
if (count == 1) {
|
||||
link_editor->Show(true);
|
||||
link_viewer_1->Show(false);
|
||||
link_select->Show(true);
|
||||
link_editor->InvalidateBestSize();
|
||||
link_relation_1->SetMaxSize(wxSize(link_editor->GetSize().x - link_unlink_1->GetSize().x, -1));
|
||||
} else {
|
||||
link_editor->Show(false);
|
||||
link_viewer_1->Show(true);
|
||||
link_select->Show(false);
|
||||
link_viewer_1->InvalidateBestSize();
|
||||
link_relation_1->SetMaxSize(wxSize(link_viewer_1->GetSize().x - link_unlink_1->GetSize().x, -1));
|
||||
}
|
||||
link_relation_1->InvalidateBestSize();
|
||||
} else {
|
||||
link_box_1->Show(false);
|
||||
link_editor->setCard(card);
|
||||
link_viewer_1->setCard(card);
|
||||
//link_relation_1->SetLabel(wxEmptyString);
|
||||
}
|
||||
if (count >= 2) {
|
||||
link_box_2->Show(true);
|
||||
link_viewer_2->setCard(linked_cards[1].first);
|
||||
link_relation_2->SetLabel(linked_cards[1].second);
|
||||
link_relation_2->SetMaxSize(wxSize(link_viewer_2->GetSize().x - link_unlink_2->GetSize().x, -1));
|
||||
link_relation_2->InvalidateBestSize();
|
||||
} else {
|
||||
link_box_2->Show(false);
|
||||
link_viewer_2->setCard(card);
|
||||
//link_relation_2->SetLabel(wxEmptyString);
|
||||
}
|
||||
if (count >= 3) {
|
||||
link_box_3->Show(true);
|
||||
link_viewer_3->setCard(linked_cards[2].first);
|
||||
link_relation_3->SetLabel(linked_cards[2].second);
|
||||
link_relation_3->SetMaxSize(wxSize(link_viewer_3->GetSize().x - link_unlink_3->GetSize().x, -1));
|
||||
link_relation_3->InvalidateBestSize();
|
||||
} else {
|
||||
link_box_3->Show(false);
|
||||
link_viewer_3->setCard(card);
|
||||
//link_relation_3->SetLabel(wxEmptyString);
|
||||
}
|
||||
if (count >= 4) {
|
||||
link_box_4->Show(true);
|
||||
link_viewer_4->setCard(linked_cards[3].first);
|
||||
link_relation_4->SetLabel(linked_cards[3].second);
|
||||
link_relation_4->SetMaxSize(wxSize(link_viewer_4->GetSize().x - link_unlink_4->GetSize().x, -1));
|
||||
link_relation_4->InvalidateBestSize();
|
||||
} else {
|
||||
link_box_4->Show(false);
|
||||
link_viewer_4->setCard(card);
|
||||
//link_relation_4->SetLabel(wxEmptyString);
|
||||
}
|
||||
if (count >= 5) {
|
||||
queue_message(MESSAGE_WARNING, "DEBUG More than 4 linked cards found for card: " + card->identification());
|
||||
}
|
||||
|
||||
notes->setValue(card ? &card->notes : nullptr);
|
||||
|
||||
Layout();
|
||||
updateNotesPosition();
|
||||
}
|
||||
@@ -539,6 +707,20 @@ void CardsPanel::selectFirstCard() {
|
||||
card_list->selectFirst();
|
||||
}
|
||||
|
||||
void CardsPanel::setCard(const CardP& card, bool event) {
|
||||
if (!set) return; // we want onChangeSet first
|
||||
card_list->setCard(card, event);
|
||||
}
|
||||
|
||||
void CardsPanel::refreshCard(const CardP& card) {
|
||||
if (!set) return; // we want onChangeSet first
|
||||
card_list->RefreshItem(card_list->findGivenItemPos(card));
|
||||
}
|
||||
|
||||
void CardsPanel::getCardLists(vector<CardListBase*>& out) {
|
||||
out.push_back(card_list);
|
||||
}
|
||||
}
|
||||
|
||||
void CardsPanel::setFocusedEditor(DataEditor* editor) {
|
||||
focused_editor = editor;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ class wxSplitterWindow;
|
||||
class FilteredImageCardList;
|
||||
class DataEditor;
|
||||
class TextCtrl;
|
||||
class CardViewer;
|
||||
class wxSizer;
|
||||
class wxButton;
|
||||
class HoverButton;
|
||||
class FindInfo;
|
||||
class FilterCtrl;
|
||||
@@ -74,17 +77,25 @@ public:
|
||||
CardP selectedCard() const override;
|
||||
void selectCard(const CardP& card) override;
|
||||
void selectFirstCard() override;
|
||||
void setCard(const CardP& card, bool event = false);
|
||||
void refreshCard(const CardP& card);
|
||||
|
||||
void getCardLists(vector<CardListBase*>& out) override;
|
||||
|
||||
void setFocusedEditor(DataEditor* editor);
|
||||
|
||||
private:
|
||||
// --------------------------------------------------- : Controls
|
||||
wxSizer* s_left;
|
||||
wxSplitterWindow* splitter;
|
||||
DataEditor* editor;
|
||||
DataEditor* editor, *link_editor, *focused_editor;
|
||||
FilteredImageCardList* card_list;
|
||||
wxPanel* nodes_panel;
|
||||
TextCtrl* notes;
|
||||
wxSizer* link_box_1, *link_box_2, *link_box_3, *link_box_4;
|
||||
wxStaticText* link_relation_1, *link_relation_2, *link_relation_3, *link_relation_4;
|
||||
CardViewer* link_viewer_1, *link_viewer_2, *link_viewer_3, *link_viewer_4;
|
||||
wxButton* link_unlink_1, *link_unlink_2, *link_unlink_3, *link_unlink_4, *link_select;
|
||||
HoverButton* collapse_notes;
|
||||
FilterCtrl* filter;
|
||||
String filter_value; // value of filter, need separate variable because the control is destroyed
|
||||
|
||||
@@ -25,7 +25,7 @@ DECLARE_POINTER_TYPE(ConsoleMessage);
|
||||
class ConsoleMessage : public IntrusivePtrBase<ConsoleMessage> {
|
||||
public:
|
||||
MessageType type;
|
||||
String text; // string message
|
||||
String text; // string message
|
||||
wxDateTime timestamp;
|
||||
Bitmap bitmap; // image message instead of string
|
||||
ScriptValueP value; // other valued message (images? cards?)
|
||||
@@ -80,13 +80,13 @@ public:
|
||||
}
|
||||
void add_message(MessageType type, String const& text, bool joined_to_previous = false) {
|
||||
add_message(make_intrusive<ConsoleMessage>(type,text,joined_to_previous));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void clear_console() {
|
||||
messages.clear();
|
||||
layout_all();
|
||||
selection = messages.size();
|
||||
update_scrollbar();
|
||||
messages.clear();
|
||||
layout_all();
|
||||
selection = messages.size();
|
||||
update_scrollbar();
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
@@ -245,11 +245,11 @@ private:
|
||||
wxAutoBufferedPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
draw(dc);
|
||||
}
|
||||
}
|
||||
|
||||
void draw(wxDC& dc) const {
|
||||
clearDC(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
|
||||
FOR_EACH_CONST(msg, messages) {
|
||||
draw(dc, *msg);
|
||||
@@ -283,23 +283,23 @@ private:
|
||||
// draw background
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(lerp(bg,color, 0.05));
|
||||
dc.DrawRectangle(left,top,width,msg.height);
|
||||
|
||||
// draw foreground
|
||||
dc.SetTextForeground(fg);
|
||||
|
||||
// draw timestamp
|
||||
dc.DrawText(msg.timestamp.FormatISOTime(), left + TIMESTAMP_PADDING, top + TEXT_PADDING_TOP);
|
||||
|
||||
int timestamp_resolved_width;
|
||||
dc.GetTextExtent(_("55:55:55"), ×tamp_resolved_width, nullptr);
|
||||
|
||||
left += timestamp_resolved_width;
|
||||
left += TIMESTAMP_PADDING * 2;
|
||||
|
||||
dc.DrawRectangle(left,top,width,msg.height);
|
||||
|
||||
// draw foreground
|
||||
dc.SetTextForeground(fg);
|
||||
|
||||
// draw timestamp
|
||||
dc.DrawText(msg.timestamp.FormatISOTime(), left + TIMESTAMP_PADDING, top + TEXT_PADDING_TOP);
|
||||
|
||||
int timestamp_resolved_width;
|
||||
dc.GetTextExtent(_("55:55:55"), ×tamp_resolved_width, nullptr);
|
||||
|
||||
left += timestamp_resolved_width;
|
||||
left += TIMESTAMP_PADDING * 2;
|
||||
|
||||
// draw line right of timestamp
|
||||
dc.SetPen(lerp(bg, fg, 0.3));
|
||||
dc.DrawLine(left, top, left, top + msg.height);
|
||||
dc.DrawLine(left, top, left, top + msg.height);
|
||||
|
||||
// draw icon
|
||||
if (icons[msg.type].Ok()) {
|
||||
@@ -331,7 +331,7 @@ private:
|
||||
if (msg.bitmap.Ok()) {
|
||||
dc.DrawBitmap(msg.bitmap, text_left, text_top);
|
||||
text_top += msg.bitmap.GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
// draw line below item
|
||||
dc.SetPen(lerp(bg,fg, 0.3));
|
||||
@@ -356,9 +356,9 @@ private:
|
||||
}
|
||||
if (begin != msg.text.end()) {
|
||||
text_height += dc.GetCharHeight() + TEXT_LINE_SPACING;
|
||||
}
|
||||
|
||||
// account for the height of a timestamp even if there is no other text content.
|
||||
}
|
||||
|
||||
// account for the height of a timestamp even if there is no other text content.
|
||||
if (text_height == 0) {
|
||||
text_height = dc.GetCharHeight() + TEXT_LINE_SPACING;
|
||||
}
|
||||
@@ -371,9 +371,9 @@ private:
|
||||
|
||||
// --------------------------------------------------- : Layout
|
||||
|
||||
static constexpr int LIST_SPACING = 1;
|
||||
static constexpr int LIST_SPACING = 1;
|
||||
static constexpr int TIMESTAMP_PADDING = 3;
|
||||
static constexpr int ICON_PADDING = 3;
|
||||
static constexpr int ICON_PADDING = 3;
|
||||
static constexpr int ICON_PADDING_LEFT = TIMESTAMP_PADDING + 3;
|
||||
static constexpr int TEXT_PADDING_LEFT = ICON_PADDING_LEFT + 16 + 4;
|
||||
static constexpr int TEXT_PADDING_RIGHT = 4;
|
||||
@@ -488,7 +488,7 @@ END_EVENT_TABLE()
|
||||
|
||||
ConsolePanel::ConsolePanel(Window* parent, int id)
|
||||
: SetWindowPanel(parent, id)
|
||||
, menuConsole(nullptr)
|
||||
, menuConsole(nullptr)
|
||||
, messages(nullptr)
|
||||
, entry(nullptr)
|
||||
, is_active_window(false)
|
||||
@@ -514,13 +514,13 @@ ConsolePanel::ConsolePanel(Window* parent, int id)
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(splitter, 1, wxEXPAND);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
|
||||
// init menus
|
||||
menuConsole = new wxMenu();
|
||||
SetSizer(s);
|
||||
|
||||
// init menus
|
||||
menuConsole = new wxMenu();
|
||||
add_menu_item_tr(menuConsole, ID_CLEAR_CONSOLE, "clear_console", "clear console");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ConsolePanel::~ConsolePanel() {
|
||||
delete menuConsole;
|
||||
}
|
||||
@@ -542,19 +542,19 @@ void ConsolePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
|
||||
// stop blinker
|
||||
is_active_window = true;
|
||||
stop_blinker();
|
||||
|
||||
add_tool_tr(tb, ID_CLEAR_CONSOLE, "clear_console", "clear console");
|
||||
tb->Realize();
|
||||
|
||||
stop_blinker();
|
||||
|
||||
add_tool_tr(tb, ID_CLEAR_CONSOLE, "clear_console", "clear console");
|
||||
tb->Realize();
|
||||
|
||||
mb->Insert(2, menuConsole, _MENU_("console"));
|
||||
}
|
||||
|
||||
void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
// Toolbar
|
||||
tb->DeleteTool(ID_CLEAR_CONSOLE);
|
||||
// Menus
|
||||
mb->Remove(2);
|
||||
// Menus
|
||||
mb->Remove(2);
|
||||
|
||||
// we are no longer active, allow blinker
|
||||
is_active_window = false;
|
||||
|
||||
@@ -19,7 +19,7 @@ class HistoryTextCtrl;
|
||||
|
||||
class ConsolePanel : public SetWindowPanel {
|
||||
public:
|
||||
ConsolePanel(Window* parent, int id);
|
||||
ConsolePanel(Window* parent, int id);
|
||||
~ConsolePanel();
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
@@ -49,8 +49,8 @@ private:
|
||||
wxSplitterWindow* splitter;
|
||||
MessageCtrl* messages;
|
||||
wxPanel* entry_panel;
|
||||
HistoryTextCtrl* entry;
|
||||
|
||||
HistoryTextCtrl* entry;
|
||||
|
||||
wxMenu* menuConsole;
|
||||
|
||||
void get_pending_errors();
|
||||
|
||||
@@ -35,7 +35,7 @@ void SetInfoPanel::onChangeSet() {
|
||||
void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
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_ITALIC, "italic", "italic", false, wxITEM_CHECK);
|
||||
add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", 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);
|
||||
@@ -43,7 +43,7 @@ void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Menus
|
||||
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_ITALIC, "italic", "italic", wxITEM_CHECK);
|
||||
add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", 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);
|
||||
@@ -55,7 +55,7 @@ void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
tb->DeleteTool(ID_FORMAT_BOLD);
|
||||
tb->DeleteTool(ID_FORMAT_ITALIC);
|
||||
tb->DeleteTool(ID_FORMAT_ITALIC);
|
||||
tb->DeleteTool(ID_FORMAT_UNDERLINE);
|
||||
tb->DeleteTool(ID_FORMAT_SYMBOL);
|
||||
tb->DeleteTool(ID_FORMAT_REMINDER);
|
||||
|
||||
+14
-14
@@ -35,20 +35,20 @@ void StylePanel::initControls() {
|
||||
list = new PackageList (this, wxID_ANY);
|
||||
use_for_all = new wxButton (this, ID_STYLE_USE_FOR_ALL, _BUTTON_("use for all cards"));
|
||||
use_custom_options = new wxCheckBox(this, ID_STYLE_USE_CUSTOM, _BUTTON_("use custom styling options"));
|
||||
editor = new StylingEditor(this, ID_EDITOR, wxNO_BORDER);
|
||||
|
||||
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
|
||||
stylesheet_filter->setFilter(stylesheet_filter_value);
|
||||
editor = new StylingEditor(this, ID_EDITOR, wxNO_BORDER);
|
||||
|
||||
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
|
||||
stylesheet_filter->setFilter(stylesheet_filter_value);
|
||||
|
||||
// init sizer
|
||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||
s->Add(preview, 0, wxRIGHT, 2);
|
||||
wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
|
||||
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
|
||||
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
|
||||
s3->Add(stylesheet_filter, 0, wxBOTTOM | wxLEFT, 4);
|
||||
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
|
||||
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
|
||||
s3->Add(stylesheet_filter, 0, wxBOTTOM | wxLEFT, 4);
|
||||
s3->AddStretchSpacer();
|
||||
s3->Add(use_for_all, 0, wxBOTTOM | wxRIGHT, 4);
|
||||
s3->Add(use_for_all, 0, wxBOTTOM | wxRIGHT, 4);
|
||||
s2->Add(s3, wxSizerFlags().Expand().Border(wxALL, 6));
|
||||
wxSizer* s4 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
|
||||
s4->Add(use_custom_options, 0, wxEXPAND | wxALL, 4);
|
||||
@@ -81,10 +81,10 @@ void StylePanel::updateListSize() {
|
||||
if (column_count != list->column_count) {
|
||||
list->column_count = column_count;
|
||||
static_cast<SetWindow*>(GetParent())->fixMinWindowSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
list_size_already_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool StylePanel::Layout() {
|
||||
updateListSize();
|
||||
@@ -136,8 +136,8 @@ void StylePanel::onAction(const Action& action, bool undone) {
|
||||
use_for_all->Enable(card && card->stylesheet);
|
||||
use_custom_options->Enable((bool)card);
|
||||
use_custom_options->SetValue(card ? card->has_styling : false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StylePanel::onStylesheetFilterUpdate(wxCommandEvent&) {
|
||||
if (list->hasSelection()) {
|
||||
StyleSheetP existingStylesheetSelection = list->getSelection<StyleSheet>(false);
|
||||
@@ -208,7 +208,7 @@ void StylePanel::onUseCustom(wxCommandEvent&) {
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
|
||||
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
|
||||
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
|
||||
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, StylePanel::onStylesheetFilterUpdate)
|
||||
EVT_BUTTON (ID_STYLE_USE_FOR_ALL, StylePanel::onUseForAll)
|
||||
EVT_CHECKBOX (ID_STYLE_USE_CUSTOM, StylePanel::onUseCustom)
|
||||
|
||||
Reference in New Issue
Block a user