2 #include "bcresources.h"
9 #define TUMBLEBOTTOM_DN 2
10 #define TUMBLETOP_DN 3
11 #define TOTAL_STATES 4
13 BC_Tumbler::BC_Tumbler(int x, int y)
14 : BC_SubWindow(x, y, 0, 0, -1)
16 for(int i = 0; i < TOTAL_STATES; i++)
23 BC_Tumbler::~BC_Tumbler()
25 for(int i = 0; i < TOTAL_STATES; i ++)
31 int BC_Tumbler::initialize()
34 set_images(get_resources()->tumble_data);
35 w = images[TUMBLE_UP]->get_w();
36 h = images[TUMBLE_UP]->get_h();
38 // Create the subwindow
39 BC_SubWindow::initialize();
46 int BC_Tumbler::reposition_window(int x, int y)
48 BC_WindowBase::reposition_window(x, y);
54 int BC_Tumbler::update_bitmaps(VFrame **data)
57 draw_top_background(parent_window, 0, 0, w, h);
62 int BC_Tumbler::set_images(VFrame **data)
64 for(int i = 0; i < TOTAL_STATES; i++)
66 if(images[i]) delete images[i];
67 images[i] = new BC_Pixmap(parent_window, data[i], PIXMAP_ALPHA);
73 int BC_Tumbler::draw_face()
75 draw_top_background(parent_window, 0, 0, w, h);
76 images[status]->write_drawable(pixmap,
87 int BC_Tumbler::repeat_event(int64_t duration)
89 //printf("BC_Tumbler::repeat_event 1 %d\n", duration);
90 if(duration == top_level->get_resources()->tooltip_delay)
92 if(tooltip_text[0] != 0 &&
93 status == TUMBLE_UPHI &&
102 if(duration == top_level->get_resources()->tumble_duration)
104 //printf("BC_Tumbler::repeat_event 2\n");
106 if(repeat_count == 2) return 0;
107 if(status == TUMBLETOP_DN)
113 if(status == TUMBLEBOTTOM_DN)
122 int BC_Tumbler::cursor_enter_event()
124 if(top_level->event_win == win)
127 if(! top_level->button_down && status == TUMBLE_UP)
129 status = TUMBLE_UPHI;
136 int BC_Tumbler::cursor_leave_event()
139 if(status == TUMBLE_UPHI)
147 int BC_Tumbler::button_press_event()
150 if(top_level->event_win == win)
152 //printf("BC_Tumbler::button_press_event 1 %d\n", get_buttonpress());
153 if(get_buttonpress() == 4)
155 status = TUMBLETOP_DN;
160 // repeat_event(top_level->get_resources()->tumble_duration);
163 if(get_buttonpress() == 5)
165 status = TUMBLEBOTTOM_DN;
170 // repeat_event(top_level->get_resources()->tumble_duration);
174 if(top_level->cursor_y < get_h() / 2)
176 status = TUMBLETOP_DN;
180 status = TUMBLEBOTTOM_DN;
186 top_level->set_repeat(top_level->get_resources()->tumble_duration);
188 repeat_event(top_level->get_resources()->tumble_duration);
189 //printf("BC_Tumbler::button_press_event 2 %d\n", get_buttonpress());
196 int BC_Tumbler::button_release_event()
199 if(top_level->event_win == win)
201 if(status == TUMBLEBOTTOM_DN || status == TUMBLETOP_DN)
203 top_level->unset_repeat(top_level->get_resources()->tumble_duration);
205 status = TUMBLE_UPHI;
214 int BC_Tumbler::cursor_motion_event()
216 if(top_level->button_down && top_level->event_win == win &&
218 !(status == TUMBLETOP_DN || status == TUMBLEBOTTOM_DN))
229 BC_ITumbler::BC_ITumbler(BC_TextBox *textbox, int64_t min, int64_t max, int x, int y)
232 this->textbox = textbox;
237 BC_ITumbler::~BC_ITumbler()
241 int BC_ITumbler::handle_up_event()
243 int64_t value = atol(textbox->get_text());
245 if(value > max) value = max;
246 textbox->update(value);
247 textbox->handle_event();
251 int BC_ITumbler::handle_down_event()
253 int64_t value = atol(textbox->get_text());
255 if(value < min) value = min;
256 textbox->update(value);
257 textbox->handle_event();
261 void BC_ITumbler::set_boundaries(int64_t min, int64_t max)
276 BC_FTumbler::BC_FTumbler(BC_TextBox *textbox,
283 this->textbox = textbox;
286 this->increment = 1.0;
289 BC_FTumbler::~BC_FTumbler()
293 int BC_FTumbler::handle_up_event()
295 float value = atof(textbox->get_text());
297 if(value > max) value = max;
298 textbox->update(value);
299 textbox->handle_event();
303 int BC_FTumbler::handle_down_event()
305 float value = atof(textbox->get_text());
307 if(value < min) value = min;
308 textbox->update(value);
309 textbox->handle_event();
313 void BC_FTumbler::set_boundaries(float min, float max)
319 void BC_FTumbler::set_increment(float value)
321 this->increment = increment;