mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Compatibility updates step 1.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@815 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -18,10 +18,6 @@ DEFINE_EVENT_TYPE(EVENT_GALLERY_ACTIVATE);
|
||||
|
||||
// ----------------------------------------------------------------------------- : GalleryList
|
||||
|
||||
const int MARGIN = 1; // margin between items (excluding border)
|
||||
const int BORDER = 1; // border aroung items
|
||||
const int SPACING = MARGIN + 2*BORDER; // distance between items
|
||||
|
||||
GalleryList::GalleryList(Window* parent, int id, int direction, bool always_focused)
|
||||
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxWANTS_CHARS | (direction == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL) )
|
||||
, selection(NO_SELECTION)
|
||||
@@ -72,19 +68,6 @@ wxPoint GalleryList::itemPos(size_t item) const {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Scrolling & sizing
|
||||
|
||||
int GalleryList::visibleEnd() const {
|
||||
return visible_start + mainSize(GetClientSize());
|
||||
}
|
||||
int GalleryList::itemStart(size_t item) const {
|
||||
return (int)item * (mainSize(item_size) + SPACING);
|
||||
}
|
||||
int GalleryList::itemEnd(size_t item) const {
|
||||
return (int)(item + 1) * (mainSize(item_size) + SPACING) + MARGIN;
|
||||
}
|
||||
int GalleryList::mainSize(wxSize s) const {
|
||||
return direction == wxHORIZONTAL ? s.x : s.y;
|
||||
}
|
||||
|
||||
void GalleryList::scrollTo(int top, bool update_scrollbar) {
|
||||
wxSize cs = GetClientSize();
|
||||
int total_height = itemEnd(itemCount() - 1);
|
||||
@@ -101,12 +84,12 @@ void GalleryList::scrollTo(int top, bool update_scrollbar) {
|
||||
}
|
||||
}
|
||||
|
||||
void GalleryList::updateScrollbar() {
|
||||
scrollTo(visible_start, false);
|
||||
// how many lines fit on the screen?
|
||||
void GalleryList::updateScrollbar() {
|
||||
scrollTo(visible_start, false);
|
||||
// how many lines fit on the screen?
|
||||
int screen_height = mainSize(GetClientSize());
|
||||
int total_height = itemEnd(itemCount() - 1);
|
||||
// set the scrollbar parameters to reflect this
|
||||
int total_height = itemEnd(itemCount() - 1);
|
||||
// set the scrollbar parameters to reflect this
|
||||
SetScrollbar(direction, visible_start, screen_height, total_height);
|
||||
}
|
||||
|
||||
@@ -114,26 +97,26 @@ void GalleryList::RefreshItem(size_t item) {
|
||||
if (item >= itemCount()) return;
|
||||
RefreshRect(wxRect(itemPos(item),item_size).Inflate(BORDER,BORDER), false);
|
||||
}
|
||||
|
||||
void GalleryList::onScroll(wxScrollWinEvent& ev) {
|
||||
wxEventType type = ev.GetEventType();
|
||||
if (type == wxEVT_SCROLLWIN_TOP) {
|
||||
scrollTo(0);
|
||||
} else if (type == wxEVT_SCROLLWIN_BOTTOM) {
|
||||
scrollTo(INT_MAX);
|
||||
} else if (type == wxEVT_SCROLLWIN_LINEUP) {
|
||||
scrollTo(visible_start - (mainSize(item_size) + SPACING));
|
||||
} else if (type == wxEVT_SCROLLWIN_LINEDOWN) {
|
||||
scrollTo(visible_start + (mainSize(item_size) + SPACING));
|
||||
} else if (type == wxEVT_SCROLLWIN_PAGEUP) {
|
||||
scrollTo(visible_start - visibleEnd() + mainSize(item_size));
|
||||
} else if (type == wxEVT_SCROLLWIN_PAGEDOWN) {
|
||||
scrollTo(visibleEnd() - mainSize(item_size));
|
||||
} else {
|
||||
scrollTo(ev.GetPosition());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GalleryList::onScroll(wxScrollWinEvent& ev) {
|
||||
wxEventType type = ev.GetEventType();
|
||||
if (type == wxEVT_SCROLLWIN_TOP) {
|
||||
scrollTo(0);
|
||||
} else if (type == wxEVT_SCROLLWIN_BOTTOM) {
|
||||
scrollTo(INT_MAX);
|
||||
} else if (type == wxEVT_SCROLLWIN_LINEUP) {
|
||||
scrollTo(visible_start - (mainSize(item_size) + SPACING));
|
||||
} else if (type == wxEVT_SCROLLWIN_LINEDOWN) {
|
||||
scrollTo(visible_start + (mainSize(item_size) + SPACING));
|
||||
} else if (type == wxEVT_SCROLLWIN_PAGEUP) {
|
||||
scrollTo(visible_start - visibleEnd() + mainSize(item_size));
|
||||
} else if (type == wxEVT_SCROLLWIN_PAGEDOWN) {
|
||||
scrollTo(visibleEnd() - mainSize(item_size));
|
||||
} else {
|
||||
scrollTo(ev.GetPosition());
|
||||
}
|
||||
}
|
||||
|
||||
void GalleryList::onSize(wxSizeEvent& ev) {
|
||||
update();
|
||||
ev.Skip();
|
||||
|
||||
Reference in New Issue
Block a user