net: data reception system, fixed bugs in rtl8139
[quarnos.git] / hydra / form.cpp
blob06890c5e7a6518603a356fbef9926c4e7ffd05b7
1 /* Quarn OS / Hydra
3 * Form class implementation
5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "form.h"
24 #include "manes/error.h"
26 using namespace hydra;
28 form::form(p<application> app, delegate<void, p<form> > on_filled) : ui_element("form"), owner(app), used(1) {
29 onfilled = on_filled;
30 app->get_ui()->add(this);
33 form::form(p<application> app) : ui_element("form"), owner(app), used(1) {
34 app->get_ui()->add(this);
37 void form::add(p<ui_element> el) {
38 elements.add(el);
41 p<ui_element> form::get_element(string name) {
42 for (int i = 0; i < elements.get_count(); i++)
43 if (!strcmp(elements[i]->element_name, name)) return elements[i];
45 debug("ui: required element not found");
47 /* throw */
48 while(1);
51 void form::render(ui::ui_type) {
52 for (int i = 0; i < elements.get_count(); i++)
53 elements[i]->render(ui::ui_console);
55 onfilled(this);
58 void form::keep() {
59 used++;
60 owner->get_ui()->add(this);
63 bool form::dispose() {
64 used--;
66 return used < 1;