diff --git a/src/gui/about_window.cpp b/src/gui/about_window.cpp new file mode 100644 index 00000000..840409fe --- /dev/null +++ b/src/gui/about_window.cpp @@ -0,0 +1,107 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +// ----------------------------------------------------------------------------- : Includes + +#include +#include +#include +#include + +// ----------------------------------------------------------------------------- : About window + +AboutWindow::AboutWindow(Window* parent) + : wxDialog(parent, wxID_ANY, _("About Magic Set Editor"), wxDefaultPosition, wxSize(510,340), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE) + , logo (load_resource_image(_("ABOUT"))) + , logo2(load_resource_image(_("TWO"))) +{ + // init controls + wxButton* ok_button = new HoverButton(this, wxID_OK, _("BTN_OK")); + wxSize bs = ok_button->GetSize(), ws = GetClientSize(); + ok_button->Move(ws.GetWidth() - bs.GetWidth(), ws.GetHeight() - bs.GetHeight()); // align bottom right +} + +void AboutWindow::onPaint(wxPaintEvent& ev) { + wxBufferedPaintDC dc(this); + dc.BeginDrawing(); + draw(dc); + dc.EndDrawing(); +} + +void AboutWindow::draw(DC& dc) { + wxSize ws = GetClientSize(); + // draw background + dc.SetPen (*wxTRANSPARENT_PEN); + dc.SetBrush(Color(240,247,255)); + dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); + // draw logo + dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5); + dc.DrawBitmap(logo2, ws.GetWidth() - logo2.GetWidth(), ws.GetHeight() - logo2.GetHeight()); + // draw version box + dc.SetPen (wxPen(Color(184,29,19), 2)); + dc.SetBrush(Color(114,197,224)); + dc.DrawRectangle(28, 104, 245, 133); + dc.SetTextBackground(Color(114,197,224)); + dc.SetTextForeground(Color(0,0,0)); + // draw version info + dc.SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial"))); + dc.DrawText(_("Version: ") + app_version.toString() + version_suffix, 34, 110); + dc.DrawText(_("This is a development version!"), 34, 130); + dc.DrawText(_(" it probably contains lots bugs,"), 34, 147); + dc.DrawText(_(" it misses some very important features,"), 34, 164); + dc.DrawText(_(" don't use it for anything important"), 34, 181); + dc.DrawText(_("Copyright \xA9 2006 Twan van Laarhoven"), 34, 214); +} + +BEGIN_EVENT_TABLE(AboutWindow, wxDialog) + EVT_PAINT (AboutWindow::onPaint) +END_EVENT_TABLE () + + +// ----------------------------------------------------------------------------- : Button with image and hover effect + + +HoverButton::HoverButton(Window* parent, int id, const String& name) + : normal(load_resource_image(name + _("_NORMAL"))) + , hover (load_resource_image(name + _("_HOVER"))) +{ + Create(parent, id, normal, wxDefaultPosition, wxSize(normal.GetWidth(), normal.GetHeight()), 0); +} + +void HoverButton::onMouseEnter(wxMouseEvent&) { + SetBitmapLabel(hover); + Refresh(false); +} +void HoverButton::onMouseLeave(wxMouseEvent&) { + SetBitmapLabel(normal); + Refresh(false); +} +void HoverButton::onFocus(wxFocusEvent&) {} +void HoverButton::onKillFocus(wxFocusEvent&) {} + +void HoverButton::onPaint(wxPaintEvent&) { + wxPaintDC dc(this); + dc.BeginDrawing(); + draw(dc); + dc.EndDrawing(); +} +void HoverButton::draw(DC& dc) { + // clear background (for transparent button images) + wxSize ws = GetClientSize(); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(Color(240,247,255)); + dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); + // draw button + dc.DrawBitmap(GetBitmapLabel(), 0, 0); +} + +BEGIN_EVENT_TABLE(HoverButton, wxBitmapButton) + EVT_ENTER_WINDOW (HoverButton::onMouseEnter) + EVT_LEAVE_WINDOW (HoverButton::onMouseLeave) + EVT_PAINT (HoverButton::onPaint) + EVT_SET_FOCUS (HoverButton::onFocus) + EVT_KILL_FOCUS (HoverButton::onKillFocus) +END_EVENT_TABLE () diff --git a/src/gui/about_window.hpp b/src/gui/about_window.hpp new file mode 100644 index 00000000..128c9f4e --- /dev/null +++ b/src/gui/about_window.hpp @@ -0,0 +1,55 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +#ifndef HEADER_GUI_ABOUT_WINDOW +#define HEADER_GUI_ABOUT_WINDOW + +// ----------------------------------------------------------------------------- : Includes + +#include + +// ----------------------------------------------------------------------------- : About window + +/// Nice about dialog +class AboutWindow : public wxDialog { + public: + AboutWindow(Window* parent); + + private: + DECLARE_EVENT_TABLE(); + + // graphics + Bitmap logo, logo2; + + void onPaint(wxPaintEvent& e); + void draw(DC& dc); +}; + +// ----------------------------------------------------------------------------- : Button with image and hover effect + +// A button that changes images on mouseenter/leave +class HoverButton : public wxBitmapButton { + public: + HoverButton(Window* parent, int id, const String& name); + + private: + DECLARE_EVENT_TABLE(); + + Bitmap normal, hover; /// Bitmaps for the states of the button + + void onMouseEnter(wxMouseEvent&); + void onMouseLeave(wxMouseEvent&); + void onFocus (wxFocusEvent& ev); + void onKillFocus (wxFocusEvent& ev); + void onPaint (wxPaintEvent&); + + protected: + virtual void draw(DC& dc); +}; + + +// ----------------------------------------------------------------------------- : EOF +#endif diff --git a/src/gui/control/card_list.cpp b/src/gui/control/card_list.cpp index 45e028b1..bd0d9944 100644 --- a/src/gui/control/card_list.cpp +++ b/src/gui/control/card_list.cpp @@ -51,9 +51,14 @@ void CardListBase::onChangeSet() { void CardListBase::onAction(const Action& action, bool undone) { TYPE_CASE(action, AddCardAction) { - // select the new card - selectCard(action.card, false /*list will be refreshed anyway*/); - refreshList(); + if (undone) { + refreshList(); + selectCardPos((long)sorted_card_list.size() - 1, true); + } else { + // select the new card + selectCard(action.card, false /*list will be refreshed anyway*/); + refreshList(); + } } TYPE_CASE(action, RemoveCardAction) { if (undone) { diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 84108ef0..3cb8d90a 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -535,8 +537,8 @@ void SetWindow::onHelpIndex(wxCommandEvent&) { } void SetWindow::onHelpAbout(wxCommandEvent&) { -// AboutWindow wnd(this); -// wnd.ShowModal(); + AboutWindow wnd(this); + wnd.ShowModal(); } // ----------------------------------------------------------------------------- : Window events - menu - for child panel diff --git a/src/mse.vcproj b/src/mse.vcproj index 4e316991..f08a1896 100644 --- a/src/mse.vcproj +++ b/src/mse.vcproj @@ -545,6 +545,28 @@ RelativePath=".\gui\symbol\window.hpp"> + + + + + + + + + + + + + +