Changed scroll size of PackageList;

Added 'collapse' option for card notes;
Made variant of  DECLARE_TYPEOF for maps (two template arguments).

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@202 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-02-08 22:15:11 +00:00
parent 73a2f61e68
commit e83c00c05a
35 changed files with 292 additions and 81 deletions
+25 -4
View File
@@ -10,6 +10,7 @@
#include <gui/control/image_card_list.hpp>
#include <gui/control/card_editor.hpp>
#include <gui/control/text_ctrl.hpp>
#include <gui/about_window.hpp>
#include <gui/icon_menu.hpp>
#include <gui/util.hpp>
#include <data/set.hpp>
@@ -26,19 +27,23 @@ CardsPanel::CardsPanel(Window* parent, int id)
{
// init controls
wxPanel* notesP;
wxSplitterWindow* splitter;
editor = new CardEditor(this, ID_EDITOR);
splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
card_list = new ImageCardList(splitter, ID_CARD_LIST);
notesP = new Panel(splitter, wxID_ANY);
notes = new TextCtrl(notesP, ID_NOTES);
collapse_notes = new HoverButton(notesP, ID_COLLAPSE_NOTES, _("btn_collapse"), wxNullColour);
collapse_notes->SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES);
// init sizer for notes panel
wxSizer* sn = new wxBoxSizer(wxVERTICAL);
sn->Add(new wxStaticText(notesP, wxID_ANY, _LABEL_("card notes")), 0, wxEXPAND, 2);
wxSizer* sc = new wxBoxSizer(wxHORIZONTAL);
sc->Add(new wxStaticText(notesP, wxID_ANY, _LABEL_("card notes")), 1, wxEXPAND);
sc->Add(collapse_notes, 0, wxALIGN_CENTER | wxRIGHT, 2);
sn->Add(sc, 0, wxEXPAND, 2);
sn->Add(notes, 1, wxEXPAND | wxTOP, 2);
notesP->SetSizer(sn);
// init splitter
splitter->SetMinimumPaneSize(14);
splitter->SetMinimumPaneSize(15);
splitter->SetSashGravity(1.0);
splitter->SplitHorizontally(card_list, notesP, -40);
// init sizer
@@ -162,10 +167,15 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
}
break;
}
case ID_COLLAPSE_NOTES: {
bool collapse = notes->GetSize().y > 0;
collapse_notes->loadBitmaps(collapse ? _("btn_collapse") : _("btn_expand"));
break;
}
case ID_INSERT_SYMBOL: {
wxMenu* menu = editor->getMenu(ID_INSERT_SYMBOL);
ev.Enable(menu);
if (insertSymbolMenu->GetSubMenu() != menu || menu->GetParent() != menuFormat) {
if (insertSymbolMenu->GetSubMenu() != menu || (menu && menu->GetParent() != menuFormat)) {
// re-add the menu
menuFormat->Remove(insertSymbolMenu);
insertSymbolMenu->SetSubMenu(menu);
@@ -211,6 +221,17 @@ void CardsPanel::onCommand(int id) {
break;
}
}
case ID_COLLAPSE_NOTES: {
bool collapse = notes->GetSize().y > 0;
if (collapse) {
splitter->SetSashPosition(-1);
notes->SetFocus();
} else {
splitter->SetSashPosition(-150);
card_list->SetFocus();
}
break;
}
default: {
if (id >= ID_INSERT_SYMBOL_MENU_MIN && id <= ID_INSERT_SYMBOL_MENU_MAX) {
// pass on to editor
+2
View File
@@ -17,6 +17,7 @@ class ImageCardList;
class DataEditor;
class TextCtrl;
class IconMenu;
class HoverButton;
// ----------------------------------------------------------------------------- : CardsPanel
@@ -94,6 +95,7 @@ class CardsPanel : public SetWindowPanel {
DataEditor* editor;
ImageCardList* card_list;
TextCtrl* notes;
HoverButton* collapse_notes;
// --------------------------------------------------- : Menus & tools
IconMenu* menuCard, *menuFormat;
+13
View File
@@ -20,10 +20,23 @@ class KeywordList : public wxListView {
/// Set the list of keywords to show
void setData(vector<KeywordP>& dat);
// --------------------------------------------------- : Selection
inline KeywordP getKeyword() const { return selected_keyword; }
inline void setKeyword(const KeywordP& kw) { /* TODO */ }
bool canSelectPrevious() const;
bool canSelectNext() const;
void selectPrevious();
void selectNext();
protected:
/// Get the text of an item in a specific column
/** Overrides a function from wxListCtrl */
virtual String OnGetItemText (long pos, long col) const;
private:
KeywordP selected_keyword;
long selected_keyword_pos;
};
// ----------------------------------------------------------------------------- : KeywordsPanel
+4
View File
@@ -12,12 +12,16 @@
#include <util/prec.hpp>
#include <gui/set/panel.hpp>
class KeywordList;
// ----------------------------------------------------------------------------- : KeywordsPanel
/// A panel for listing and editing the keywords in a set
class KeywordsPanel : public SetWindowPanel {
public:
KeywordsPanel(Window* parent, int id);
private:
KeywordList* list;
};
// ----------------------------------------------------------------------------- : EOF
+1 -1
View File
@@ -72,7 +72,7 @@ void StatCategoryList::drawItem(DC& dc, int x, int y, size_t item, bool selected
dc.DrawBitmap(cat.icon, x+1, y+1);
}
// draw name
RealRect rect(RealPoint(x + 24, y), RealSize(item_size.width - 30, item_size.height));
RealRect rect(RealPoint(x + 24, y), RealSize(item_size.x - 30, item_size.y));
String str = capitalize(cat.name);
// dc.SetFont(wxFont(9.5 * text_scaling, wxSWISS, wxNORMAL, wxNORMAL, false,_("Arial")));
dc.SetFont(*wxNORMAL_FONT);
+6 -1
View File
@@ -135,7 +135,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
addPanel(menuWindow, tabBar, new KeywordsPanel(this, wxID_ANY), 2, _("F8"), _("Keywords"), _("Keywords"), _("Define extra keywords for this set"));
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
// addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
selectPanel(ID_WINDOW_MIN + 4); // select cards panel
selectPanel(ID_WINDOW_CARDS); // select cards panel
// loose ends
tabBar->Realize();
@@ -253,6 +253,7 @@ void SetWindow::onCardSelect(CardSelectEvent& ev) {
void SetWindow::fixMinWindowSize() {
current_panel->SetMinSize(current_panel->GetSizer()->GetMinSize());
Layout();
current_panel->Layout();
wxSize s = GetSizer()->GetMinSize();
wxSize ws = GetSize();
wxSize cs = GetClientSize();
@@ -348,6 +349,9 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
case ID_EDIT_FIND : ev.Enable(current_panel->canFind()); break;
case ID_EDIT_FIND_NEXT : ev.Enable(current_panel->canFind()); break;
case ID_EDIT_REPLACE : ev.Enable(current_panel->canReplace());break;
// windows
case ID_WINDOW_KEYWORDS: ev.Enable(set->game->has_keywords); break;
// other
default:
// items created by the panel, and cut/copy/paste and find/replace
if(current_panel) current_panel->onUpdateUI(ev);
@@ -600,6 +604,7 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
EVT_MENU (ID_HELP_WEBSITE, SetWindow::onHelpWebsite)
EVT_MENU (ID_HELP_ABOUT, SetWindow::onHelpAbout)
EVT_TOOL_RANGE (ID_CHILD_MIN, ID_CHILD_MAX, SetWindow::onChildMenu)
EVT_COMMAND_RANGE (ID_CHILD_MIN, ID_CHILD_MAX, wxEVT_COMMAND_BUTTON_CLICKED, SetWindow::onChildMenu)
EVT_GALLERY_SELECT (ID_FIELD_LIST, SetWindow::onChildMenu) // for StatsPanel, because it is not a EVT_TOOL
EVT_UPDATE_UI (wxID_ANY, SetWindow::onUpdateUI)