Added dialog for selecting a new stylesheet if the one from a set is not found;

'availible' is not a word

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@657 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-09-01 21:11:56 +00:00
parent a08d4e5a1b
commit c38166c2bd
8 changed files with 169 additions and 9 deletions
+84 -3
View File
@@ -25,14 +25,14 @@ SetP new_set_window(Window* parent) {
}
NewSetWindow::NewSetWindow(Window* parent)
: wxDialog(parent, wxID_ANY, _("New set"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
{
wxBusyCursor wait;
// init controls
game_list = new PackageList (this, ID_GAME_LIST);
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST);
game_text = new wxStaticText(this, ID_GAME_LIST, _LABEL_("game type"));
stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
wxStaticText* game_text = new wxStaticText(this, ID_GAME_LIST, _LABEL_("game type"));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(game_text, 0, wxALL, 4);
@@ -126,3 +126,84 @@ BEGIN_EVENT_TABLE(NewSetWindow, wxDialog)
EVT_UPDATE_UI (wxID_ANY, NewSetWindow::onUpdateUI)
EVT_IDLE ( NewSetWindow::onIdle)
END_EVENT_TABLE ()
// ----------------------------------------------------------------------------- : SelectStyleSheetWindow
StyleSheetP select_stylesheet(const Game& game, const String& failed_name) {
SelectStyleSheetWindow wnd(nullptr, game, failed_name);
wnd.ShowModal();
return wnd.stylesheet;
}
SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game, const String& failed_name)
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
, game(game)
{
wxBusyCursor wait;
// init controls
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST);
wxStaticText* description = new wxStaticText(this, ID_GAME_LIST, _LABEL_1_("stylesheet not found", failed_name));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(description, 0, wxALL, 4);
s->Add(stylesheet_text, 0, wxALL, 4);
s->Add(stylesheet_list, 0, wxEXPAND | wxALL & ~wxTOP, 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this);
SetSizer(s);
// init list
stylesheet_list->showData<StyleSheet>(game.name() + _("-*"));
stylesheet_list->select(settings.gameSettingsFor(game).default_stylesheet);
// Resize
SetSize(630,-1);
Layout();
GetSizer()->SetSizeHints(this);
SetSize(630,-1);
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
void SelectStyleSheetWindow::onStyleSheetSelect(wxCommandEvent&) {
handle_pending_errors();
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
void SelectStyleSheetWindow::onStyleSheetActivate(wxCommandEvent&) {
done();
}
void SelectStyleSheetWindow::OnOK(wxCommandEvent&) {
done();
}
void SelectStyleSheetWindow::done() {
try {
stylesheet = stylesheet_list->getSelection<StyleSheet>();
EndModal(wxID_OK);
} catch (const Error& e) {
handle_error(e);
EndModal(wxID_CANCEL);
}
}
void SelectStyleSheetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
switch (ev.GetId()) {
case wxID_OK:
ev.Enable(stylesheet_list->hasSelection());
break;
}
}
void SelectStyleSheetWindow::onIdle(wxIdleEvent& ev) {
// Stuff that must be done in the main thread
handle_pending_errors();
}
BEGIN_EVENT_TABLE(SelectStyleSheetWindow, wxDialog)
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetSelect)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
EVT_BUTTON (wxID_OK, SelectStyleSheetWindow::OnOK)
EVT_UPDATE_UI (wxID_ANY, SelectStyleSheetWindow::onUpdateUI)
EVT_IDLE ( SelectStyleSheetWindow::onIdle)
END_EVENT_TABLE ()
+39 -2
View File
@@ -12,7 +12,9 @@
#include <util/prec.hpp>
class PackageList;
class Game;
DECLARE_POINTER_TYPE(Set);
DECLARE_POINTER_TYPE(StyleSheet);
// ----------------------------------------------------------------------------- : NewSetWindow
@@ -33,8 +35,6 @@ class NewSetWindow : public wxDialog {
// gui items
PackageList* game_list, *stylesheet_list;
wxStaticText* game_text, *stylesheet_text;
Window* ok_button;
// --------------------------------------------------- : events
@@ -52,5 +52,42 @@ class NewSetWindow : public wxDialog {
void done();
};
// ----------------------------------------------------------------------------- : SelectStyleSheetWindow
// very similair, so in the same file
/// Show the select stylesheet window, return the selected stylesheet, if any
StyleSheetP select_stylesheet(const Game& game, const String& failed_name);
/// "Create a new set" dialog. First select game, then matching style.
class SelectStyleSheetWindow : public wxDialog {
public:
/// The selected stylesheet, if any
StyleSheetP stylesheet;
SelectStyleSheetWindow(Window* parent, const Game& game, const String& failed_name);
// --------------------------------------------------- : data
private:
DECLARE_EVENT_TABLE();
const Game& game;
// gui items
PackageList* stylesheet_list;
// --------------------------------------------------- : events
void onStyleSheetSelect (wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
virtual void OnOK(wxCommandEvent&);
void onUpdateUI(wxUpdateUIEvent&);
void onIdle(wxIdleEvent&);
// we are done, close the window
void done();
};
// ----------------------------------------------------------------------------- : EOF
#endif