Implement scrollbars

- They work almost as you'd expect, though holding the mouse down on an arrow only scrolls once, and it's a little jerky
- Add an additional refresh option to redraw_screen, currently only partially implemented
- Scrollbars now have a page size in addition to pos and max
- cControl::handleClick() now takes the location clicked as a parameter, though the default implementation doesn't use it
- cControl::handleClick() is no longer responsible for redrawing the control when there is no parent dialog
- Fix cTextMsg not allowing retrieval of frame style
This commit is contained in:
2014-04-17 11:32:43 -04:00
parent b960139d6b
commit 369c7f9f93
13 changed files with 194 additions and 146 deletions

View File

@@ -12,14 +12,24 @@
#include "control.h"
class cScrollbar : public cControl {
int pos, max;
int pos, max, pgsz;
enum {
PART_UP,
PART_PGUP,
PART_THUMB,
PART_PGDN,
PART_DOWN,
} pressedPart;
click_callback_t onClick;
static sf::Texture scroll_gw;
public:
static void init();
explicit cScrollbar(sf::RenderWindow& parent);
explicit cScrollbar(cDialog& parent);
void attachClickHandler(click_callback_t f) throw(xHandlerNotSupported);
void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported);
bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, location where);
bool handleClick(location where);
void setFormat(eFormat prop, short val) throw(xUnsupportedProp);
short getFormat(eFormat prop) throw(xUnsupportedProp);
void setColour(sf::Color clr) throw(xUnsupportedProp);
@@ -27,8 +37,10 @@ public:
bool isClickable();
long getPosition();
long getMaximum();
long getPageSize();
void setPosition(long to);
void setMaximum(long to);
void setPageSize(long to);
void draw();
};