3 * Copyright (C) 2007, Harbour, All rights reserved.
6 #include <F_Text_Display.H>
11 void F_Window::draw_border(F_Border_t brd)
13 if (brd == F_NO_BORDER)
15 F_Text_Symbol lu('x', fg(), bg());
16 F_Text_Symbol ru('x', fg(), bg());
17 F_Text_Symbol ll('x', fg(), bg());
18 F_Text_Symbol rl('x', fg(), bg());
19 F_Text_Symbol hs('x', fg(), bg());
20 F_Text_Symbol vs('x', fg(), bg());
21 if (brd == F_DOUBLE_BORDER) {
22 // TODO: replace by recode()
29 } else if ((brd == F_SINGLE_BORDER) || (brd == F_MOVING_BORDER)) {
36 } /* else if (brd == F_MOVING_BORDER) {
50 p.move(w() - 1, h() - 1);
52 F_Region r(1, 0, w() - 2, 1);
64 void F_Window::draw_label()
66 if (!label_.size() || (label_type_ == F_NO_ALIGN))
69 if (label_type_ & F_ALIGN_LEFT)
70 x = (border_ == F_NO_BORDER) ? 0 : 1;
71 else if (label_type_ & F_ALIGN_RIGHT)
72 unimplemented("F_ALIGN_RIGHT");
73 if (label_type_ & F_ALIGN_TOP)
75 else if (label_type_ & F_ALIGN_BOTTOM)
78 std::string s(" " + label_ + " ");
79 put_string(p, s); //, label_type_);
87 for (unsigned int i = 0; i < widgets.size(); i++) {
88 if (widgets[i]->visible())
91 F_Widget::damage(F_DAMAGE_FLUSH);
94 bool F_Window::handle(F_Event_t &ev)
96 F_Event_Type_t t = ev.type;
99 if (ev.kbd.key == F_Tab) { // send FOCUS to next widget
100 if (ev.kbd.modifiers & F_SHIFT)
101 take_focus(focus_prev());
103 take_focus(focus_next());
107 if (focus() && focus()->handle(ev))
111 debug("F_FOCUS: wid - %d, depth - %d", id(), depth());
114 debug("F_UNFOCUS: wid - %d, depth - %d", id(), depth());
117 debug("F_ENTER: wid - %d, depth - %d", id(), depth());
120 debug("F_LEAVE: wid - %d, depth - %d", id(), depth());
122 case F_POINTER_PRESS:
123 // debug("F_POINTER_PRESS: wid - %d", id());
124 // check for window moving
125 if (!(ev.mouse.y - y()) && (ev.mouse.x - x()) &&
126 ((ev.mouse.x - x()) < (w() - 1))) {
129 last_mx = ev.mouse.x;
130 last_my = ev.mouse.y;
131 f_text_display->cursor(0);
136 case F_POINTER_RELEASE:
137 debug("F_POINTER_RELEASE: wid - %d", id());
145 debug("F_POINTER_MOVE: wid - %d", id());
146 // ÐÒÏ×ÅÒÑÅÍ widget'Ù É ÐÏÓÙÌÁÅÍ ÉÍ F_ENTER/F_LEAVE
147 for (unsigned int i = 0; i < widgets.size(); i++) {
148 if (widgets[i]->visible()) {
149 if ((widget_belowmouse() == widgets[i]) &&
150 !widgets[i]->inside(F_Point(ev.mouse.x - x(), ev.mouse.y - y()))) {
152 widget_belowmouse()->handle(ev);
154 widget_belowmouse(0);
157 if (widgets[i]->inside(F_Point(ev.mouse.x - x(), ev.mouse.y - y())) &&
158 (widget_belowmouse() != widgets[i])) {
159 if (widget_belowmouse()) {
161 widget_belowmouse()->handle(ev);
164 widget_belowmouse(widgets[i]);
166 return widget_belowmouse()->handle(ev);
168 // propagate F_POINTER_MOVE event
169 if (widget_belowmouse() == widgets[i])
170 if (widget_belowmouse()->handle(ev))
176 // debug("F_POINTER_DRAG: wid - %d", id());
179 move(x() + (ev.mouse.x - last_mx), y() + (ev.mouse.y - last_my));
180 last_mx = ev.mouse.x;
181 last_my = ev.mouse.y;
187 debug("F_POINTER_DROP: wid - %d", id());
197 for (unsigned int i = 0; i < widgets.size(); i++) {
198 if (widgets[i]->visible()) {
199 if (widget_belowmouse() == widgets[i]) {
200 if (widget_belowmouse()->handle(ev))
202 } else if ((ev.type == F_KEY_PRESS) || (ev.type == F_KEY_RELEASE)) {
203 if (widgets[i]->handle(ev))
209 return F_Widget::handle(ev);
212 void F_Window::add(F_Widget *w)
216 widgets.push_back(w, wid_);
218 for (unsigned int i = 0; i < w->children.size(); i++) {
219 w->children[i]->parent(this);
220 w->children[i]->id(++wid_);
221 widgets.push_back(w->children[i], wid_);