2 #include <F_Text_Display.H>
7 void F_Window::draw_border(F_Border_t brd)
9 if (brd == F_NO_BORDER)
11 F_Text_Symbol lu('x', fg(), bg());
12 F_Text_Symbol ru('x', fg(), bg());
13 F_Text_Symbol ll('x', fg(), bg());
14 F_Text_Symbol rl('x', fg(), bg());
15 F_Text_Symbol hs('x', fg(), bg());
16 F_Text_Symbol vs('x', fg(), bg());
17 if (brd == F_DOUBLE_BORDER) {
18 // TODO: replace by recode()
25 } else if ((brd == F_SINGLE_BORDER) || (brd == F_MOVING_BORDER)) {
32 } /* else if (brd == F_MOVING_BORDER) {
46 p.move(w() - 1, h() - 1);
48 F_Region r(1, 0, w() - 2, 1);
60 void F_Window::draw_label()
62 if (!label_.size() || (label_type_ == F_NO_ALIGN))
65 if (label_type_ & F_ALIGN_LEFT)
66 x = (border_ == F_NO_BORDER) ? 0 : 1;
67 else if (label_type_ & F_ALIGN_RIGHT)
68 unimplemented("F_ALIGN_RIGHT");
69 if (label_type_ & F_ALIGN_TOP)
71 else if (label_type_ & F_ALIGN_BOTTOM)
74 std::string s(" " + label_ + " ");
75 put_string(p, s); //, label_type_);
83 for (unsigned int i = 0; i < widgets.size(); i++) {
84 if (widgets[i]->visible())
87 F_Widget::damage(F_DAMAGE_FLUSH);
90 bool F_Window::handle(F_Event_t &ev)
92 F_Event_Type_t t = ev.type;
95 if (ev.kbd.key == F_Tab) { // send FOCUS to next widget
96 if (ev.kbd.modifiers & F_SHIFT)
97 take_focus(focus_prev());
99 take_focus(focus_next());
103 if (focus() && focus()->handle(ev))
107 debug("F_FOCUS: wid - %d, depth - %d", id(), depth());
110 debug("F_UNFOCUS: wid - %d, depth - %d", id(), depth());
113 debug("F_ENTER: wid - %d, depth - %d", id(), depth());
116 debug("F_LEAVE: wid - %d, depth - %d", id(), depth());
118 case F_POINTER_PRESS:
119 // debug("F_POINTER_PRESS: wid - %d", id());
120 // check for window moving
121 if (!(ev.mouse.y - y()) && (ev.mouse.x - x()) &&
122 ((ev.mouse.x - x()) < (w() - 1))) {
125 last_mx = ev.mouse.x;
126 last_my = ev.mouse.y;
127 f_text_display->cursor(0);
132 case F_POINTER_RELEASE:
133 debug("F_POINTER_RELEASE: wid - %d", id());
141 debug("F_POINTER_MOVE: wid - %d", id());
142 // ÐÒÏ×ÅÒÑÅÍ widget'Ù É ÐÏÓÙÌÁÅÍ ÉÍ F_ENTER/F_LEAVE
143 for (unsigned int i = 0; i < widgets.size(); i++) {
144 if (widgets[i]->visible()) {
145 if ((widget_belowmouse() == widgets[i]) &&
146 !widgets[i]->inside(F_Point(ev.mouse.x - x(), ev.mouse.y - y()))) {
148 widget_belowmouse()->handle(ev);
150 widget_belowmouse(0);
153 if (widgets[i]->inside(F_Point(ev.mouse.x - x(), ev.mouse.y - y())) &&
154 (widget_belowmouse() != widgets[i])) {
155 if (widget_belowmouse()) {
157 widget_belowmouse()->handle(ev);
160 widget_belowmouse(widgets[i]);
162 return widget_belowmouse()->handle(ev);
164 // propagate F_POINTER_MOVE event
165 if (widget_belowmouse() == widgets[i])
166 if (widget_belowmouse()->handle(ev))
172 // debug("F_POINTER_DRAG: wid - %d", id());
175 move(x() + (ev.mouse.x - last_mx), y() + (ev.mouse.y - last_my));
176 last_mx = ev.mouse.x;
177 last_my = ev.mouse.y;
183 debug("F_POINTER_DROP: wid - %d", id());
193 for (unsigned int i = 0; i < widgets.size(); i++) {
194 if (widgets[i]->visible()) {
195 if (widget_belowmouse() == widgets[i]) {
196 if (widget_belowmouse()->handle(ev))
198 } else if ((ev.type == F_KEY_PRESS) || (ev.type == F_KEY_RELEASE)) {
199 if (widgets[i]->handle(ev))
205 return F_Widget::handle(ev);
208 void F_Window::add(F_Widget *w)
212 widgets.push_back(w, wid_);
214 for (unsigned int i = 0; i < w->children.size(); i++) {
215 w->children[i]->parent(this);
216 w->children[i]->id(++wid_);
217 widgets.push_back(w->children[i], wid_);