3 * Copyright (C) 2007, Harbour, All rights reserved.
6 #include <F_Scrollbar.H>
11 void F_Scrollbar::draw()
15 bgch(f_text_display->recode('�'));
19 smb.color(parent()->fg(), parent()->bg());
21 if (type_ == F_VERTICAL) {
35 smb.ch_ = f_text_display->recode('�');
36 unsigned int position;
37 if (type_ == F_VERTICAL)
38 position = (int)((((float)value_)/((float)bounds_)) * ((h() - 1) - size_));
40 position = (int)((((float)value_)/((float)bounds_)) * ((w() - 1) - size_));
43 if (type_ == F_VERTICAL) {
44 if (int(position + size_) > (h() - 1))
45 position = (h() - 1) - size_;
47 if (int(position + size_) > (w() - 1))
48 position = (w() - 1) - size_;
52 for (unsigned int i = 0; i < size_; i++) {
53 if (type_ == F_VERTICAL)
54 p.move(0, position + i);
56 p.move(position + i, 0);
61 static coord_t cur_mouse_x, cur_mouse_y;
63 bool F_Scrollbar::handle(F_Event_t &ev)
68 // debug("F_ENTER: sbrid - %d", id());
73 // debug("F_LEAVE: sbrid - %d", id());
79 if (type_ == F_VERTICAL)
80 value(value() + (h() - 1));
82 value(value() + (w() - 1));
85 if (type_ == F_VERTICAL)
86 value(value() - (h() - 1));
88 value(value() - (w() - 1));
91 if (type_ == F_VERTICAL)
95 if (type_ == F_VERTICAL)
99 if (type_ == F_HORIZONTAL)
103 if (type_ == F_HORIZONTAL)
107 if (ev.kbd.modifiers & F_CTRL) {
112 if (ev.kbd.modifiers & F_CTRL) {
125 // debug("F_POINTER_DRAG: sbrid - %d", id());
126 if (type_ == F_HORIZONTAL) { // sense x movement
127 int x = ev.mouse.x - cur_mouse_x;
135 int y = ev.mouse.y - cur_mouse_y;
145 case F_POINTER_PRESS:
146 // check if bar or space pressed
148 cur_mouse_x = ev.mouse.x;
149 cur_mouse_y = ev.mouse.y;
152 // debug("sbrid - %d, evtype - %d", id(), ev.type);