zenilib: zenilib/jni/external/zenilib/zeni_rest/Zeni/Widget.hxx Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Widget.hxx
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef ZENI_WIDGET_HXX
19 #define ZENI_WIDGET_HXX
20
21 // HXXed below
22 #include <Zeni/Font.h>
23 #include <Zeni/Material.h>
24 #include <Zeni/Projector.h>
25 #include <Zeni/Timer.h>
26 #include <Zeni/Video.h>
27
28 #include <Zeni/Widget.h>
29
30 // Not HXXed
31 #include <Zeni/Colors.h>
32 #include <Zeni/Fonts.h>
33
34 #include <cassert>
35 #include <algorithm>
36
37 namespace Zeni {
38
39 Widget::Widget()
40 : m_layer(0.0f),
41 m_busy(false),
42 m_editable(true),
43 m_renderer(0),
44 delete_m_renderer(false)
45 {
46 }
47
48 const bool & Widget::is_busy() const {
49 return m_busy;
50 }
51
52 const bool & Widget::is_editable() const {
53 return m_editable;
54 }
55
56 const float & Widget::get_layer() const {
57 return m_layer;
58 }
59
60 void Widget::set_busy(const bool &busy_) {
61 m_busy = busy_;
62 }
63
64 void Widget::set_layer(const float &layer_) {
65 m_layer = layer_;
66 }
67
68 #ifndef ANDROID
69 void Widget::on_event(const SDL_KeyboardEvent &event) {
70 on_key(event.keysym, event.type == SDL_KEYDOWN);
71 }
72
73 void Widget::on_event(const SDL_MouseButtonEvent &event) {
74 on_mouse_button(Point2i(event.x, event.y),
75 event.type == SDL_MOUSEBUTTONDOWN,
76 event.button);
77 }
78
79 void Widget::on_event(const SDL_MouseButtonEvent &event, const Projector2D &projector) {
80 const Point2f projected = projector.unproject(Point2f(float(event.x), float(event.y)));
81 on_mouse_button(Point2i(int(projected.x), int(projected.y)),
82 event.type == SDL_MOUSEBUTTONDOWN,
83 event.button);
84 }
85
86 void Widget::on_event(const SDL_MouseMotionEvent &event) {
87 on_mouse_motion(Point2i(event.x, event.y));
88 }
89
90 void Widget::on_event(const SDL_MouseMotionEvent &event, const Projector2D &projector) {
91 const Point2f projected = projector.unproject(Point2f(float(event.x), float(event.y)));
92 on_mouse_motion(Point2i(int(projected.x), int(projected.y)));
93 }
94
95 #if SDL_VERSION_ATLEAST(2,0,0)
96 void Widget::on_event(const SDL_MouseWheelEvent &event) {
97 Point2i pos;
98 SDL_GetMouseState(&pos.x, &pos.y);
99 on_mouse_wheel(pos, event.y);
100 }
101
102 void Widget::on_event(const SDL_MouseWheelEvent &event, const Projector2D &projector) {
103 Point2i pos;
104 SDL_GetMouseState(&pos.x, &pos.y);
105 const Point2f projected = projector.unproject(Point2f(float(pos.x), float(pos.y)));
106 on_mouse_wheel(Point2i(int(projected.x), int(projected.y)), event.y);
107 }
108 #endif
109 #endif
110
111 void Widget::render() const {
112 Video &vr = get_Video();
113
114 vr.push_world_stack();
115 vr.translate_scene(Vector3f(0.0f, 0.0f, m_layer));
116
117 render_impl();
118
119 vr.pop_world_stack();
120 }
121
122 const Widget_Render_Function * Widget::get_Renderer() const {
123 return m_renderer;
124 }
125
126 void Widget::give_Renderer(Widget_Render_Function * const &renderer) {
127 if(delete_m_renderer)
128 delete m_renderer;
129 m_renderer = renderer;
130 delete_m_renderer = true;
131 }
132
133 void Widget::lend_Renderer(const Widget_Render_Function * const &renderer) {
134 give_Renderer(const_cast<Widget_Render_Function * const &>(renderer));
135 delete_m_renderer = false;
136 }
137
138 void Widget::fax_Renderer(const Widget_Render_Function * const &renderer) {
139 give_Renderer(renderer->get_duplicate());
140 }
141
142 Widget_Rectangle::Widget_Rectangle(const Point2f &upper_left_, const Point2f &lower_right_)
143 : m_upper_left(upper_left_),
144 m_lower_right(lower_right_)
145 {
146 }
147
148 const Point2f & Widget_Rectangle::get_upper_left() const {
149 return m_upper_left;
150 }
151
152 Point2f Widget_Rectangle::get_lower_left() const {
153 return Point2f(m_upper_left.x, m_lower_right.y);
154 }
155
156 const Point2f & Widget_Rectangle::get_lower_right() const {
157 return m_lower_right;
158 }
159
160 Point2f Widget_Rectangle::get_upper_right() const {
161 return Point2f(m_lower_right.x, m_upper_left.y);
162 }
163
164 float Widget_Rectangle::get_height() const {
165 return m_lower_right.y - m_upper_left.y;
166 }
167
168 float Widget_Rectangle::get_width() const {
169 return m_lower_right.x - m_upper_left.x;
170 }
171
172 Point2f Widget_Rectangle::get_center() const {
173 return Point2f(0.5f * (m_upper_left.x + m_lower_right.x),
174 0.5f * (m_upper_left.y + m_lower_right.y));
175 }
176
177 bool Widget_Rectangle::is_inside(const Point2i &pos) const {
178 return m_upper_left.x < pos.x && pos.x < m_lower_right.x &&
179 m_upper_left.y < pos.y && pos.y < m_lower_right.y;
180 }
181
182 template <typename T1, typename T2>
183 Widget_Renderer_Pair<T1, T2>::Widget_Renderer_Pair(const T1 * const &first_, const bool &delete_first_,
184 const T2 * const &second_, const bool &delete_second_)
185 : m_first(const_cast<T1 * const &>(first_)),
186 delete_m_first(delete_first_),
187 m_second(const_cast<T2 * const &>(second_)),
188 delete_m_second(delete_second_)
189 {
190 }
191
192 template <typename T1, typename T2>
193 Widget_Renderer_Pair<T1, T2>::~Widget_Renderer_Pair() {
194 if(delete_m_first)
195 delete m_first;
196 if(delete_m_second)
197 delete m_second;
198 }
199
200 template <typename T1, typename T2>
201 const T1 * const & Widget_Renderer_Pair<T1, T2>::first() const {
202 return m_first;
203 }
204
205 template <typename T1, typename T2>
206 const T2 * const & Widget_Renderer_Pair<T1, T2>::second() const {
207 return m_second;
208 }
209
210 template <typename T1, typename T2>
211 T1 * const & Widget_Renderer_Pair<T1, T2>::first() {
212 return m_first;
213 }
214
215 template <typename T1, typename T2>
216 T2 * const & Widget_Renderer_Pair<T1, T2>::second() {
217 return m_second;
218 }
219
220 template <typename T1, typename T2>
221 void Widget_Renderer_Pair<T1, T2>::render_to(const Widget &rect) {
222 if(m_first)
223 m_first->render_to(rect);
224 if(m_second)
225 m_second->render_to(rect);
226 }
227
228 template <typename T1, typename T2>
229 Widget_Renderer_Pair<T1, T2> * Widget_Renderer_Pair<T1, T2>::get_duplicate() const {
230 return new Widget_Renderer_Pair<T1, T2>(new T1(*m_first), true, new T2(*m_second), true);
231 }
232
233 template <typename T1, typename T2>
234 Widget_Renderer_Pair<T1, T2> * make_Widget_Renderer_Pair(const T1 * const &first_, const bool &delete_first_,
235 const T2 * const &second_, const bool &delete_second_)
236 {
237 return new Widget_Renderer_Pair<T1, T2>(first_, delete_first_, second_, delete_second_);
238 }
239
240 Widget_Renderer_Text::Widget_Renderer_Text(const String &font_name_, const String &text_, const Color &color_)
241 : font_name(font_name_),
242 text(text_),
243 color(color_)
244 {
245 }
246
247 Widget_Renderer_Color::Widget_Renderer_Color(const Color &color_)
248 : color(color_)
249 {
250 }
251
252 Widget_Renderer_Texture::Widget_Renderer_Texture(const String &texture_)
253 : texture(texture_),
254 tex_coord_ul(0.0f, 0.0f),
255 tex_coord_ll(0.0f, 1.0f),
256 tex_coord_lr(1.0f, 1.0f),
257 tex_coord_ur(1.0f, 0.0f)
258 {
259 }
260
261 Widget_Renderer_Texture::Widget_Renderer_Texture(const String &texture_,
262 const Point2f &tex_coord_ul_,
263 const Point2f &tex_coord_ll_,
264 const Point2f &tex_coord_lr_,
265 const Point2f &tex_coord_ur_)
266 : texture(texture_),
267 tex_coord_ul(tex_coord_ul_),
268 tex_coord_ll(tex_coord_ll_),
269 tex_coord_lr(tex_coord_lr_),
270 tex_coord_ur(tex_coord_ur_)
271 {
272 }
273
274 Widget_Renderer_Tricolor::Widget_Renderer_Tricolor()
275 : Widget_Renderer_Color(Color()),
276 bg_normal(get_Colors()["default_button_bg_normal"]),
277 bg_clicked(get_Colors()["default_button_bg_clicked"]),
278 bg_hovered_strayed(get_Colors()["default_button_bg_hovered_strayed"]),
279 text_normal(get_Colors()["default_button_text_normal"]),
280 text_clicked(get_Colors()["default_button_text_clicked"]),
281 text_hovered_strayed(get_Colors()["default_button_text_hovered_strayed"])
282 {
283 }
284
285 Widget_Renderer_Tricolor::Widget_Renderer_Tricolor(const Color &bg_normal_, const Color &bg_clicked_, const Color &bg_hovered_strayed_,
286 const Color &text_normal_, const Color &text_clicked_, const Color &text_hovered_strayed_)
287 : Widget_Renderer_Color(Color()),
288 bg_normal(bg_normal_),
289 bg_clicked(bg_clicked_),
290 bg_hovered_strayed(bg_hovered_strayed_),
291 text_normal(text_normal_),
292 text_clicked(text_clicked_),
293 text_hovered_strayed(text_hovered_strayed_)
294 {
295 }
296
297 Widget_Renderer_Check_Box::Widget_Renderer_Check_Box()
298 : border_color(get_Colors()["default_button_bg_normal"]),
299 check_color(get_Colors()["default_button_bg_normal"])
300 {
301 }
302
303 Widget_Renderer_Check_Box::Widget_Renderer_Check_Box(const Color &border_color_, const Color &check_color_)
304 : border_color(border_color_),
305 check_color(check_color_)
306 {
307 }
308
309 Widget_Renderer_Slider::Widget_Renderer_Slider()
310 : line_color(get_Colors()["default_button_bg_normal"]),
311 slider_color(get_Colors()["default_button_bg_normal"])
312 {
313 }
314
315 Widget_Renderer_Slider::Widget_Renderer_Slider(const Color &line_color_, const Color &slider_color_)
316 : line_color(line_color_),
317 slider_color(slider_color_)
318 {
319 }
320
321 Widget_Button::Widget_Button(const Point2f &upper_left_, const Point2f &lower_right_)
322 : Widget_Rectangle(upper_left_, lower_right_),
323 m_state(NORMAL)
324 {
325 }
326
327 const Widget_Button::State & Widget_Button::get_State() const {
328 return m_state;
329 }
330
331 Text_Button::Text_Button(const Point2f &upper_left_, const Point2f &lower_right_,
332 const String &font_name_, const String &text_)
333 : Widget_Button(upper_left_, lower_right_),
334 Widget_Renderer_Text(font_name_, text_, Color())
335 {
336 give_Renderer(new Widget_Renderer_Tricolor);
337 }
338
339 Check_Box::Check_Box(const Point2f &upper_left_, const Point2f &lower_right_,
340 const bool &checked_, const bool &toggleable_)
341 : Widget_Button(upper_left_, lower_right_),
342 m_checked(checked_),
343 m_toggling(false)
344 {
345 set_editable(toggleable_);
346
347 give_Renderer(new Widget_Renderer_Check_Box());
348 }
349
350 const bool & Check_Box::is_checked() const {return m_checked;}
351 void Check_Box::set_checked(const bool &checked_) {m_checked = checked_;}
352 const bool & Check_Box::is_toggling() const {return m_toggling;}
353
354 Radio_Button::Radio_Button(Radio_Button_Set &radio_button_set_,
355 const Point2f &upper_left_, const Point2f &lower_right_,
356 const bool &checked_, const bool &toggleable_)
357 : Check_Box(upper_left_, lower_right_, checked_, toggleable_),
358 m_radio_button_set(&radio_button_set_)
359 {
360 radio_button_set_.lend_Radio_Button(*this);
361 }
362
363 Radio_Button::~Radio_Button() {
364 if(m_radio_button_set)
365 m_radio_button_set->unlend_Radio_Button(*this);
366 }
367
368 void Radio_Button_Set::accept(Radio_Button &radio_button) {
369 for(std::set<Radio_Button *>::iterator it = m_radio_buttons.begin(); it != m_radio_buttons.end(); ++it)
370 (*it)->set_checked((*it) == &radio_button);
371 }
372
373 void Radio_Button_Set::clear() {
374 for(std::set<Radio_Button *>::iterator it = m_radio_buttons.begin(); it != m_radio_buttons.end(); ++it)
375 (*it)->set_checked(false);
376 }
377
378 void Radio_Button_Set::lend_Radio_Button(Radio_Button &radio_button) {
379 m_radio_buttons.insert(&radio_button);
380 }
381
382 void Radio_Button_Set::unlend_Radio_Button(Radio_Button &radio_button) {
383 m_radio_buttons.erase(&radio_button);
384 radio_button.m_radio_button_set = 0;
385 }
386
387 Point2f Slider::get_end_point_a() const {
388 return Point2f(m_line_segment.get_end_point_a());
389 }
390
391 Point2f Slider::get_end_point_b() const {
392 return Point2f(m_line_segment.get_end_point_b());
393 }
394
395 const float & Slider::get_slider_radius() const {
396 return m_slider_radius;
397 }
398
399 const float & Slider::get_slider_position() const {
400 return m_slider_position;
401 }
402
403 void Slider::set_end_points(const Point2f &end_point_a_, const Point2f &end_point_b_) {
404 m_line_segment = Collision::Line_Segment(Point3f(end_point_a_), Point3f(end_point_b_));
405 }
406
407 void Slider::set_slider_radius(const float &radius_) {
408 m_slider_radius = radius_;
409 }
410
411 void Slider::set_slider_position(const float &slider_position_) {
412 if(slider_position_ < 0.0f)
413 m_slider_position = 0.0f;
414 else if(slider_position_ > 1.0f)
415 m_slider_position = 1.0f;
416 else
417 m_slider_position = slider_position_;
418 }
419
420 const bool & Slider::is_mouse_wheel_inverted() const {
421 return m_mouse_wheel_inverted;
422 }
423
424 void Slider::invert_mouse_wheel(const bool &invert) {
425 m_mouse_wheel_inverted = invert;
426 }
427
428 const float & Slider::get_mouse_wheel_continuous_rate() const {
429 return m_mouse_wheel_continuous_rate;
430 }
431
432 void Slider::set_mouse_wheel_continuous_rate(const float &mouse_wheel_continuous_rate) {
433 m_mouse_wheel_continuous_rate = mouse_wheel_continuous_rate;
434 }
435
436 const Collision::Line_Segment & Slider::get_line_segment() const {
437 return m_line_segment;
438 }
439
440 const Slider_Int::Range & Slider_Int::get_range() const {
441 return m_range;
442 }
443
444 void Slider_Int::set_range(const Range &range_) {
445 assert(range_.first <= range_.second);
446 m_range = range_;
447 }
448
449 int Slider_Int::get_value() const {
450 return int(get_slider_position() * (m_range.second - m_range.first) + 0.5f) + m_range.first;
451 }
452
453 void Slider_Int::set_value(const int &value) {
454 const int clamped = value < m_range.first ? m_range.first : value > m_range.second ? m_range.second : value;
455 set_slider_position(float(clamped - m_range.first) / (m_range.second - m_range.first));
456 }
457
458 const Widget_Render_Function * Selector::get_Text_Button_Renderer() const {
459 return m_button_renderer;
460 }
461
462 void Selector::give_Text_Button_Renderer(Widget_Render_Function * const &renderer) {
463 if(delete_m_button_renderer)
464 delete m_button_renderer;
465 m_button_renderer = renderer;
466 delete_m_button_renderer = true;
467
468 m_normal_button.lend_Renderer(m_button_renderer);
469 for(std::vector<Selector_Button *>::iterator it = m_selector_buttons.begin(); it != m_selector_buttons.end(); ++it)
470 (*it)->lend_Renderer(m_button_renderer);
471 }
472
473 void Selector::lend_Text_Button_Renderer(const Widget_Render_Function * const &renderer) {
474 give_Text_Button_Renderer(const_cast<Widget_Render_Function * const &>(renderer));
475 delete_m_button_renderer = false;
476 }
477
478 void Selector::fax_Text_Button_Renderer(const Widget_Render_Function * const &renderer) {
479 give_Text_Button_Renderer(renderer->get_duplicate());
480 }
481
482 const Widget_Render_Function * Selector::get_Slider_Renderer() const {
483 return m_slider_renderer;
484 }
485
486 void Selector::give_Slider_Renderer(Widget_Render_Function * const &renderer) {
487 if(delete_m_slider_renderer)
488 delete m_slider_renderer;
489 m_slider_renderer = renderer;
490 delete_m_slider_renderer = true;
491
492 m_selector_slider.lend_Renderer(m_slider_renderer);
493 }
494
495 void Selector::lend_Slider_Renderer(const Widget_Render_Function * const &renderer) {
496 give_Slider_Renderer(const_cast<Widget_Render_Function * const &>(renderer));
497 delete_m_button_renderer = false;
498 }
499
500 void Selector::fax_Slider_Renderer(const Widget_Render_Function * const &renderer) {
501 give_Slider_Renderer(renderer->get_duplicate());
502 }
503
504 const Widget_Render_Function * Selector::get_Slider_BG_Renderer() const {
505 return m_slider_bg_renderer;
506 }
507
508 void Selector::give_Slider_BG_Renderer(Widget_Render_Function * const &renderer) {
509 if(delete_m_slider_bg_renderer)
510 delete m_slider_bg_renderer;
511 m_slider_bg_renderer = renderer;
512 delete_m_slider_bg_renderer = true;
513 }
514
515 void Selector::lend_Slider_BG_Renderer(const Widget_Render_Function * const &renderer) {
516 give_Slider_BG_Renderer(const_cast<Widget_Render_Function * const &>(renderer));
517 delete_m_slider_bg_renderer = false;
518 }
519
520 void Selector::fax_Slider_BG_Renderer(const Widget_Render_Function * const &renderer) {
521 give_Slider_BG_Renderer(renderer->get_duplicate());
522 }
523
524 const String & Selector::get_Font() const {
525 return m_font;
526 }
527
528 void Selector::set_font(const String &font_) {
529 m_font = font_;
530
531 m_normal_button.font_name = m_font;
532 for(std::vector<Selector_Button *>::iterator it = m_selector_buttons.begin(); it != m_selector_buttons.end(); ++it)
533 (*it)->font_name = m_font;
534 }
535
536 const String & Text_Box::get_font_name() const {
537 return m_text.font_name;
538 }
539
540 const Font & Text_Box::get_Font() const {
541 return get_Fonts()[m_text.font_name];
542 }
543
544 const String & Text_Box::get_text() const {
545 return m_text.text;
546 }
547
548 const Color & Text_Box::get_text_color() const {
549 return m_text.color;
550 }
551
552 const JUSTIFY & Text_Box::get_justify() const {
553 return m_justify;
554 }
555
556 size_t Text_Box::get_num_lines() const {
557 return size_t(m_lines.size());
558 }
559
560 size_t Text_Box::get_max_lines() const {
561 return size_t(get_height() / get_Font().get_text_height());
562 }
563
564 void Text_Box::set_font_name(const String &font_name_) {
565 m_text.font_name = font_name_;
566 format();
567 seek(m_edit_pos);
568 }
569
570 void Text_Box::set_text(const String &text_) {
571 m_text.text = text_;
572 format();
573 seek(std::min(m_edit_pos, this->get_max_seek()));
574 }
575
576 void Text_Box::set_text_color(const Color &text_color_) {
577 m_text.color = text_color_;
578 }
579
580 void Text_Box::set_justify(const JUSTIFY &justify_) {
581 m_justify = justify_;
582 }
583
584 void Text_Box::erase_lines(const unsigned int &begin, const unsigned int &end) {
585 String new_text;
586
587 assert(begin <= end);
588 assert(end <= get_num_lines());
589
590 for(unsigned int i = 0; i != begin; ++i)
591 new_text += m_lines[i].unformatted;
592 if(end != get_num_lines()) {
593 if(m_lines[end].endled)
594 new_text += m_lines[end].unformatted.substr(1u);
595 else
596 new_text += m_lines[end].unformatted;
597
598 for(unsigned int i = end + 1; i != get_num_lines(); ++i)
599 new_text += m_lines[i].unformatted;
600 }
601
602 m_text.text = new_text;
603
604 format();
605 invalidate_edit_pos();
606 }
607
608 const Widget_Render_Function * Text_Box::get_BG_Renderer() const {
609 return m_bg_renderer;
610 }
611
612 void Text_Box::give_BG_Renderer(Widget_Render_Function * const &renderer) {
613 if(delete_m_bg_renderer)
614 delete m_bg_renderer;
615 m_bg_renderer = renderer;
616 delete_m_bg_renderer = true;
617 }
618
619 void Text_Box::lend_BG_Renderer(const Widget_Render_Function * const &renderer) {
620 give_BG_Renderer(const_cast<Widget_Render_Function * const &>(renderer));
621 delete_m_bg_renderer = false;
622 }
623
624 void Text_Box::fax_BG_Renderer(const Widget_Render_Function * const &renderer) {
625 give_BG_Renderer(renderer->get_duplicate());
626 }
627
628 void Text_Box::invalidate_edit_pos() {
629 m_edit_pos = -1;
630 m_cursor_index.x = -1;
631 m_cursor_index.y = -1;
632 }
633
634 Widget_Input_Repeater::Widget_Input_Repeater(Widget &widget_,
635 const int &repeat_delay_,
636 const int &repeat_interval_)
637 : m_widget(&widget_),
638 m_repeat_delay(repeat_delay_),
639 m_repeat_interval(repeat_interval_),
640 m_last_repeated(0),
641 m_active(false)
642 {
643 }
644
645 Widget * const & Widget_Input_Repeater::get_widget() const {return m_widget;}
646 const int & Widget_Input_Repeater::get_repeat_delay() const {return m_repeat_delay;}
647 const int & Widget_Input_Repeater::get_repeat_interval() const {return m_repeat_interval;}
648
649 void Widget_Input_Repeater::set_widget(Widget &widget_) {m_widget = &widget_; set_busy(widget_.is_busy());}
650 void Widget_Input_Repeater::set_repeat_delay(const int &repeat_delay_) {m_repeat_delay = repeat_delay_;}
651 void Widget_Input_Repeater::set_repeat_interval(const int &repeat_interval_) {m_repeat_interval = repeat_interval_;}
652
653 Widgets::Widgets()
654 : m_busy_one(0)
655 {
656 }
657
658 void Widgets::lend_Widget(Widget &widget) {
659 m_widgets.push_back(&widget);
660
661 if(widget.is_busy()) {
662 assert(!m_busy_one);
663 m_busy_one = &widget;
664 set_busy(true);
665 }
666 }
667
668 void Widgets::unlend_Widget(Widget &widget) {
669 std::vector<Widget *>::iterator it = std::find(m_widgets.begin(), m_widgets.end(), &widget);
670 if(it != m_widgets.end())
671 m_widgets.erase(it);
672
673 if(m_busy_one == &widget) {
674 m_busy_one = 0;
675 set_busy(false);
676 }
677 }
678
679 }
680
681 #include <Zeni/Font.hxx>
682 #include <Zeni/Material.hxx>
683 #include <Zeni/Projector.hxx>
684 #include <Zeni/Timer.hxx>
685 #include <Zeni/Video.hxx>
686
687 #endif
Zeni::Point2i::y
Sint32 y
Definition: Coordinate.h:94
Zeni::Widget_Input_Repeater::set_repeat_delay
void set_repeat_delay(const int &repeat_delay_=SDL_DEFAULT_REPEAT_DELAY)
Definition: Widget.hxx:650
Zeni::Widget_Renderer_Pair::get_duplicate
virtual Widget_Renderer_Pair< T1, T2 > * get_duplicate() const
Definition: Widget.hxx:229
SDL_KEYDOWN
Definition: SDL_events.h:93
Zeni::Widget::get_Renderer
const Widget_Render_Function * get_Renderer() const
Get the current Widget_Render_Function.
Definition: Widget.hxx:122
Zeni::Widget_Renderer_Tricolor::Widget_Renderer_Tricolor
Widget_Renderer_Tricolor()
Definition: Widget.hxx:274
Zeni::Widget_Rectangle::Widget_Rectangle
Widget_Rectangle(const Point2f &upper_left_, const Point2f &lower_right_)
Definition: Widget.hxx:142
SDL_MouseMotionEvent::y
Sint32 y
Definition: SDL_events.h:226
Zeni::Widget_Renderer_Color::Widget_Renderer_Color
Widget_Renderer_Color(const Color &color_)
Definition: Widget.hxx:247
Zeni::Widget_Renderer_Text::text
String text
Definition: Widget.h:346
Zeni::make_Widget_Renderer_Pair
Widget_Renderer_Pair< T1, T2 > * make_Widget_Renderer_Pair(const T1 *const &first_, const bool &delete_first_, const T2 *const &second_, const bool &delete_second_)
Definition: Widget.hxx:234
Zeni::Widget_Input_Repeater::get_repeat_delay
const int & get_repeat_delay() const
Definition: Widget.hxx:646
Zeni::Slider::get_end_point_b
Point2f get_end_point_b() const
Definition: Widget.hxx:391
color
GLuint color
Definition: glew.h:7185
Zeni::Video
The Video Rendering Singleton.
Definition: Video.h:71
Zeni::Widget::is_editable
const bool & is_editable() const
Definition: Widget.hxx:52
Zeni::get_Colors
Colors & get_Colors()
Get access to the singleton.
Definition: Colors.cpp:51
Zeni::Radio_Button
A Radio Button.
Definition: Widget.h:558
f
GLclampf f
Definition: glew.h:3390
Zeni::Check_Box
A Check Box.
Definition: Widget.h:501
Zeni::Slider::set_slider_radius
void set_slider_radius(const float &radius_)
Definition: Widget.hxx:407
Zeni::Widget_Rectangle::get_center
Point2f get_center() const
Definition: Widget.hxx:172
SDL_MouseButtonEvent::y
Sint32 y
Definition: SDL_events.h:245
Zeni::Radio_Button_Set
A Set of Radio Buttons.
Definition: Widget.h:527
Zeni::Text_Box::get_Font
const Font & get_Font() const
Definition: Widget.hxx:540
invert
GLboolean invert
Definition: glew.h:1408
Zeni::Widget_Rectangle::get_width
float get_width() const
Definition: Widget.hxx:168
Widget.h
Zeni::Selector::lend_Slider_Renderer
void lend_Slider_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget no ownership.
Definition: Widget.hxx:495
Zeni::Widget::lend_Renderer
void lend_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget no ownership.
Definition: Widget.hxx:133
Zeni::Collision::Line_Segment::get_end_point_a
const Point3f & get_end_point_a() const
Definition: Collision.h:260
Zeni::Widget::render
void render() const
Definition: Widget.hxx:111
SDL_MouseButtonEvent::type
Uint32 type
Definition: SDL_events.h:236
Zeni::Widget::on_mouse_motion
virtual void on_mouse_motion(const Point2i &pos)=0
Zeni::Widget_Input_Repeater::set_widget
void set_widget(Widget &widget_)
Definition: Widget.hxx:649
Video.h
Zeni::Text_Box::fax_BG_Renderer
void fax_BG_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget a copy.
Definition: Widget.hxx:624
SDL_MOUSEBUTTONDOWN
Definition: SDL_events.h:100
Zeni::Widget::get_layer
const float & get_layer() const
Definition: Widget.hxx:56
Zeni::Widget::fax_Renderer
void fax_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget a copy.
Definition: Widget.hxx:138
Zeni::Widget_Renderer_Pair::first
const T1 *const & first() const
Definition: Widget.hxx:201
Zeni::Text_Box::give_BG_Renderer
void give_BG_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:612
Zeni::Widget_Rectangle::get_lower_left
Point2f get_lower_left() const
Definition: Widget.hxx:152
Zeni::Widget_Renderer_Tricolor
Definition: Widget.h:383
Zeni::Slider::invert_mouse_wheel
void invert_mouse_wheel(const bool &invert)
Definition: Widget.hxx:424
SDL_MouseMotionEvent::x
Sint32 x
Definition: SDL_events.h:225
Zeni::Widget_Button::State
State
Definition: Widget.h:459
Zeni::Text_Box::set_font_name
void set_font_name(const String &font_name_)
Definition: Widget.hxx:564
Zeni::Widget_Rectangle::get_upper_right
Point2f get_upper_right() const
Definition: Widget.hxx:160
Zeni::Widget::give_Renderer
void give_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:126
Zeni::Widget_Renderer_Pair::render_to
virtual void render_to(const Widget &widget)
Definition: Widget.hxx:221
Zeni::Selector::lend_Text_Button_Renderer
void lend_Text_Button_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget no ownership.
Definition: Widget.hxx:473
Zeni::Collision::Line_Segment::get_end_point_b
const Point3f & get_end_point_b() const
Definition: Collision.h:261
Zeni::Widgets::Widgets
Widgets()
Definition: Widget.hxx:653
Zeni::Slider::set_mouse_wheel_continuous_rate
void set_mouse_wheel_continuous_rate(const float &mouse_wheel_continuous_rate)
Definition: Widget.hxx:432
assert
#define assert(x)
Definition: SDL_malloc.c:1234
Zeni::Slider_Int::get_range
const Range & get_range() const
Definition: Widget.hxx:440
Zeni::Selector::fax_Text_Button_Renderer
void fax_Text_Button_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget a copy.
Definition: Widget.hxx:478
Zeni::JUSTIFY
JUSTIFY
Definition: Font.h:68
Zeni::Widget::Widget
Widget()
Definition: Widget.hxx:39
Zeni::Slider::set_slider_position
void set_slider_position(const float &slider_position_)
Definition: Widget.hxx:411
Zeni::Slider::get_slider_position
const float & get_slider_position() const
Definition: Widget.hxx:399
Projector.hxx
Video.hxx
Zeni::Collision::Line_Segment
Collision Line Segment.
Definition: Collision.h:233
Zeni::Selector::get_Slider_Renderer
const Widget_Render_Function * get_Slider_Renderer() const
Get the current Widget_Render_Function.
Definition: Widget.hxx:482
Zeni::Text_Box::get_max_lines
size_t get_max_lines() const
Definition: Widget.hxx:560
Zeni::String
Definition: String.h:29
Zeni::Widget_Render_Function::get_duplicate
virtual Widget_Render_Function * get_duplicate() const =0
Zeni::Radio_Button_Set::clear
void clear()
Definition: Widget.hxx:373
Zeni::Point3f
A 3D Point represented with floats.
Definition: Coordinate.h:133
Zeni::Text_Box::erase_lines
void erase_lines(const unsigned int &begin, const unsigned int &end)
Definition: Widget.hxx:584
Zeni::Radio_Button::~Radio_Button
~Radio_Button()
Definition: Widget.hxx:363
SDL_GetMouseState
DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y)
Retrieve the current state of the mouse.
Definition: SDL_mouse.c:382
Zeni::Point2f::y
float y
Definition: Coordinate.h:117
Zeni::Selector::give_Slider_BG_Renderer
void give_Slider_BG_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:508
SDL_MouseButtonEvent::button
Uint8 button
Definition: SDL_events.h:240
SDL_KeyboardEvent
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:176
Zeni::Vector3f
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
Zeni::Widget_Renderer_Texture::Widget_Renderer_Texture
Widget_Renderer_Texture(const String &texture_)
Definition: Widget.hxx:252
u
ALuint u
Definition: alMain.h:58
Zeni::Slider::get_mouse_wheel_continuous_rate
const float & get_mouse_wheel_continuous_rate() const
Definition: Widget.hxx:428
Zeni::Widget_Render_Function
Definition: Widget.h:299
Zeni::Widget_Input_Repeater::get_repeat_interval
const int & get_repeat_interval() const
Definition: Widget.hxx:647
int
int
Definition: SDL_systhread.c:37
Zeni::Selector::set_font
void set_font(const String &font_)
Set the current font.
Definition: Widget.hxx:528
Timer.h
Projector.h
Zeni::Selector::give_Slider_Renderer
void give_Slider_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:486
Zeni::Text_Box::set_justify
void set_justify(const JUSTIFY &justify_)
Definition: Widget.hxx:580
Zeni::Video::pop_world_stack
virtual void pop_world_stack()=0
Pop a model view matrix off the stack.
Zeni::Selector::get_Font
const String & get_Font() const
Get the current font.
Definition: Widget.hxx:524
true
#define true
Definition: ftrandom.c:49
Zeni::Slider::set_end_points
void set_end_points(const Point2f &end_point_a_, const Point2f &end_point_b_)
Definition: Widget.hxx:403
Zeni::Widget::on_key
virtual void on_key(const SDL_Keysym &, const bool &)
Definition: Widget.h:271
Zeni::Slider::get_line_segment
const Collision::Line_Segment & get_line_segment() const
Definition: Widget.hxx:436
Zeni::Slider_Int::set_value
void set_value(const int &value)
Definition: Widget.hxx:453
Zeni::Selector::fax_Slider_Renderer
void fax_Slider_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget a copy.
Definition: Widget.hxx:500
Zeni::Widget_Renderer_Text::color
Color color
Definition: Widget.h:347
Zeni::Widget_Renderer_Check_Box::Widget_Renderer_Check_Box
Widget_Renderer_Check_Box()
Definition: Widget.hxx:297
Zeni::Widget_Renderer_Slider::Widget_Renderer_Slider
Widget_Renderer_Slider()
Definition: Widget.hxx:309
Zeni::Widget::on_event
void on_event(const SDL_KeyboardEvent &event)
Definition: Widget.hxx:69
Zeni::Widget
The Widget base class.
Definition: Widget.h:243
format
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl2ext.h:845
Zeni::Projector2D
The 2D Projector.
Definition: Projector.h:86
Zeni::Widget_Input_Repeater::get_widget
Widget *const & get_widget() const
Definition: Widget.hxx:645
Zeni::Font
Font Abstraction.
Definition: Font.h:70
Font.h
Zeni::Text_Box::get_num_lines
size_t get_num_lines() const
Definition: Widget.hxx:556
Zeni::Widget_Button
A Button Widget.
Definition: Widget.h:454
Zeni::Text_Box::get_BG_Renderer
const Widget_Render_Function * get_BG_Renderer() const
Get the current Widget_Render_Function.
Definition: Widget.hxx:608
Zeni::Widgets::lend_Widget
void lend_Widget(Widget &widget)
Definition: Widget.hxx:658
SDL_KeyboardEvent::keysym
SDL_Keysym keysym
Definition: SDL_events.h:185
Zeni::Selector::give_Text_Button_Renderer
void give_Text_Button_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:462
Zeni::Point2f::x
float x
Definition: Coordinate.h:117
Zeni::Text_Box::set_text_color
void set_text_color(const Color &text_color_)
Definition: Widget.hxx:576
Zeni::Widget_Renderer_Text::Widget_Renderer_Text
Widget_Renderer_Text(const String &font_name_, const String &text_, const Color &color_)
Definition: Widget.hxx:240
Zeni::Widget_Rectangle::get_lower_right
const Point2f & get_lower_right() const
Definition: Widget.hxx:156
Zeni::Slider_Int::Range
std::pair< int, int > Range
Definition: Widget.h:629
SDL_MouseWheelEvent
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:251
Zeni::Widget_Renderer_Pair::second
const T2 *const & second() const
Definition: Widget.hxx:206
Zeni::Video::push_world_stack
virtual void push_world_stack()=0
Push a model view matrix onto the stack.
Zeni::Text_Box::get_text_color
const Color & get_text_color() const
Definition: Widget.hxx:548
Zeni::Selector::lend_Slider_BG_Renderer
void lend_Slider_BG_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget no ownership.
Definition: Widget.hxx:515
Zeni::Widget::render_impl
virtual void render_impl() const
Definition: Widget.cpp:40
Zeni::Slider_Int::get_value
int get_value() const
Definition: Widget.hxx:449
Zeni::Projector2D::unproject
Vector3f unproject(const Vector3f &screen_coord) const
Map screen coordinates ([viewport.first.x, viewport.second.x], [viewport.first.y, viewport...
Definition: Projector.hxx:74
Zeni::Check_Box::is_toggling
const bool & is_toggling() const
Definition: Widget.hxx:352
Material.hxx
Zeni::Selector::fax_Slider_BG_Renderer
void fax_Slider_BG_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget a copy.
Definition: Widget.hxx:520
texture
GLenum GLenum GLuint texture
Definition: gl2ext.h:850
Zeni::Widget_Renderer_Pair
Definition: Widget.h:309
Zeni::Widget_Renderer_Pair::~Widget_Renderer_Pair
virtual ~Widget_Renderer_Pair()
Definition: Widget.hxx:193
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
Zeni::Widget_Button::get_State
const State & get_State() const
Get the State of the button.
Definition: Widget.hxx:327
Zeni::Video::translate_scene
virtual void translate_scene(const Vector3f &direction)=0
Translate the scene.
const
#define const
Definition: zconf.h:91
Zeni::Widget::set_layer
void set_layer(const float &layer_=0.0f)
Definition: Widget.hxx:64
Zeni::Radio_Button_Set::accept
void accept(Radio_Button &radio_button)
Definition: Widget.hxx:368
SDL_MouseMotionEvent
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:218
Zeni::Point2i::x
Sint32 x
Definition: Coordinate.h:94
SDL_KeyboardEvent::type
Uint32 type
Definition: SDL_events.h:178
Zeni::Text_Box::lend_BG_Renderer
void lend_BG_Renderer(const Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget no ownership.
Definition: Widget.hxx:619
SDL_MouseButtonEvent
Mouse button event structure (event.button.*)
Definition: SDL_events.h:234
Zeni::Slider::get_end_point_a
Point2f get_end_point_a() const
Definition: Widget.hxx:387
Zeni::Check_Box::set_checked
void set_checked(const bool &checked_)
Definition: Widget.hxx:351
Zeni::Text_Box::set_text
void set_text(const String &text_)
Definition: Widget.hxx:570
Font.hxx
Zeni::Slider_Int::set_range
void set_range(const Range &range_)
Definition: Widget.hxx:444
Zeni::Text_Box::get_text
const String & get_text() const
Definition: Widget.hxx:544
Zeni::Widget::is_busy
const bool & is_busy() const
Definition: Widget.hxx:48
Zeni::Widget_Input_Repeater::set_repeat_interval
void set_repeat_interval(const int &repeat_interval_=SDL_DEFAULT_REPEAT_INTERVAL)
Definition: Widget.hxx:651
SDL_MouseButtonEvent::x
Sint32 x
Definition: SDL_events.h:244
end
GLuint GLuint end
Definition: glew.h:1239
Zeni::Text_Box::get_font_name
const String & get_font_name() const
Definition: Widget.hxx:536
Zeni::Widget::on_mouse_button
virtual void on_mouse_button(const Point2i &pos, const bool &down, const int &button)=0
Zeni::Widget_Renderer_Text
Definition: Widget.h:336
Zeni::Widget_Rectangle::is_inside
bool is_inside(const Point2i &pos) const
Definition: Widget.hxx:177
SDL_MouseWheelEvent::y
Sint32 y
Definition: SDL_events.h:258
Zeni::Widget_Renderer_Check_Box
Definition: Widget.h:402
Zeni::get_Fonts
Fonts & get_Fonts()
Get access to the singleton.
Definition: Fonts.cpp:60
Zeni::Check_Box::is_checked
const bool & is_checked() const
Definition: Widget.hxx:350
Zeni::Widget::set_editable
virtual void set_editable(const bool &editable_)
Definition: Widget.cpp:36
Fonts.h
Zeni::get_Video
Video & get_Video()
Get access to the singleton.
Definition: Video.cpp:149
Zeni::Text_Box::seek
void seek(const int &edit_pos)
Definition: Widget.cpp:1274
min
#define min(x, y)
Definition: os.h:75
i
int i
Definition: pngrutil.c:1377
Zeni::Widget::set_busy
void set_busy(const bool &busy_)
Definition: Widget.hxx:60
Zeni::Slider::get_slider_radius
const float & get_slider_radius() const
Definition: Widget.hxx:395
Zeni::Widgets::unlend_Widget
void unlend_Widget(Widget &widget)
Definition: Widget.hxx:668
Zeni::Slider::is_mouse_wheel_inverted
const bool & is_mouse_wheel_inverted() const
Definition: Widget.hxx:420
Zeni::Text_Box::get_max_seek
int get_max_seek() const
Definition: Widget.cpp:1259
Zeni::Widget_Rectangle::get_height
float get_height() const
Definition: Widget.hxx:164
Zeni::Point2f
A 2D Point represented with floats.
Definition: Coordinate.h:98
Timer.hxx
Zeni::Widget_Renderer_Color
Definition: Widget.h:350
Colors.h
Zeni::Widget_Rectangle::get_upper_left
const Point2f & get_upper_left() const
Definition: Widget.hxx:148
Material.h
Zeni::Widget_Renderer_Pair::Widget_Renderer_Pair
Widget_Renderer_Pair(const T1 *const &first_, const bool &delete_first_, const T2 *const &second_, const bool &delete_second_)
Definition: Widget.hxx:183
Zeni::Widget_Rectangle
Rectangle positioning.
Definition: Widget.h:430
false
#define false
Definition: ftrandom.c:50
Zeni::Color
Color.
Definition: Color.h:41
event
cl_event event
Definition: glew.h:3556
Zeni::Selector::get_Text_Button_Renderer
const Widget_Render_Function * get_Text_Button_Renderer() const
Get the current Widget_Render_Function.
Definition: Widget.hxx:458
size_t
unsigned int size_t
Definition: SDL_config_windows.h:67
Zeni::Text_Box::get_justify
const JUSTIFY & get_justify() const
Definition: Widget.hxx:552
Zeni::Selector::get_Slider_BG_Renderer
const Widget_Render_Function * get_Slider_BG_Renderer() const
Get the current Widget_Render_Function.
Definition: Widget.hxx:504
Zeni::Widget_Renderer_Text::font_name
String font_name
Definition: Widget.h:345
Zeni::Point2i
A 2D Point represented with integers.
Definition: Coordinate.h:85