1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#ifndef gui_scrollbar_h
#define gui_scrollbar_h
#include "../../ifc/gui_action_creator.h"
#include "../../simevent.h"
#include "gui_button.h"
/**
* Scrollbar class
* scrollbar can be horizontal or vertical
*
* @author Niels Roest, additions by Hj. Malthaner
*/
class scrollbar_t : public gui_komponente_action_creator_t
{
public:
enum type { vertical, horizontal };
private:
enum type type;
// the following three values are from host (e.g. list), NOT actual size.
sint32 knob_offset; // offset from top-left
sint32 knob_size; // size of scrollbar knob
sint32 knob_area; // size of area where knob moves in
/**
* number of pixels to scroll with arrow button press. default: 11 pixels
*/
sint32 knob_scroll_amount;
button_t button_def[3];
void reposition_buttons();
void button_press(sint32 number); // arrow button
void space_press(sint32 updown); // space in slidebar hit
sint32 slider_drag(sint32 amount); // drags slider. returns dragged amount.
/**
* real position of knob in pixels, counting from zero
*/
int real_knob_position() {
if (type == vertical) {
return button_def[2].pos.y-12;
} else /* horizontal */ {
return button_def[2].pos.x-12;
}
}
public:
// type is either scrollbar_t::horizontal or scrollbar_t::vertical
scrollbar_t(enum type type);
/**
* Vorzugsweise sollte diese Methode zum Setzen der Gre benutzt werden,
* obwohl groesse public ist.
* @author Hj. Malthaner
*/
void setze_groesse(koord groesse);
void setze_scroll_amount(sint32 sa) { knob_scroll_amount = sa; }
/**
* size is visible size, area is total size in pixels of _parent_.
*/
void setze_knob(sint32 knob_size, sint32 knob_area);
sint32 gib_knob_offset() const {return knob_offset;}
void setze_knob_offset(sint32 v) { knob_offset = v; reposition_buttons(); }
void infowin_event(const event_t *ev);
void zeichnen(koord pos);
};
#endif
|