2 * Simulator of microcontrollers (group.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
32 cl_group::cl_group(class cl_box *ipos, char *iname, class cl_app *iapp):
33 cl_view(ipos, iname, iapp)
38 cl_group::cl_group(char *iname, class cl_app *iapp):
44 cl_group::~cl_group(void)
56 cl_group::mk_views(class cl_group *ins_to)
63 * Make output by drawing all subviews
66 static void do_draw_view(class cl_view *view)
76 for (i= 0; i < views->count; i++)
78 class cl_view *v= (class cl_view *)(views->at(i));
82 for_each(do_draw_view);
87 cl_group::update(void)
96 cl_group::handle_event(struct t_event *event)
100 if (event->what & (EV_KEY|EV_COMMAND))
103 handled= current->handle_event(event);
105 else if (event->what & EV_MESSAGE)
107 class cl_view *v= last;
110 handled= v->handle_event(event);
126 cl_group::insert(class cl_view *view)
131 views->add_at(0, view);
138 insert_before(view, first());
139 if (view->options & OF_SELECTABLE)
145 cl_group::insert_before(class cl_view *view, class cl_view *target)
152 target->parent == this))
156 insert_view(view, target);
157 /*if (ss & SF_VISIBLE)
159 if (state & SF_ACTIVE)
160 view->change_state(SF_ACTIVE, 1);
165 cl_group::insert_view(class cl_view *view, class cl_view *target)
170 target= target->prev();
171 view->next= target->next;
180 view->next= last->next;
188 cl_group::first(void)
197 cl_group::get_by_state(unsigned int what, int enabled)
201 for (i= 0; i < views->count; i++)
203 class cl_view *v= (class cl_view *)(views->at(i));
216 cl_group::select(void)
221 cl_group::unselect(void)
226 cl_group::select_next()
231 if (views->count <= 1)
234 start= views->index_of(current);
236 if ((v= get_by_state(SF_SELECTED, 1)))
237 start= views->index_of(v);
239 if ((v= get_by_state(SF_FOCUSED, 1)))
240 start= views->index_of(v);
243 i= (start+1)%(views->count);
246 v= (class cl_view *)(views->at(i));
247 if ((v->options & OF_SELECTABLE) &&
253 i= (i+1)%(views->count);
259 cl_group::select_prev()
264 if (views->count <= 1)
267 start= views->index_of(current);
269 if ((v= get_by_state(SF_SELECTED, 1)))
270 start= views->index_of(v);
272 if ((v= get_by_state(SF_FOCUSED, 1)))
273 start= views->index_of(v);
276 i= start-1; if (i < 0) i= views->count-1;
279 v= (class cl_view *)(views->at(i));
280 if ((v->options & OF_SELECTABLE) &&
286 i= start-1; if (i < 0) i= views->count-1;
292 cl_group::current_sub_view(void)
298 cl_group::for_each(void (*func)(class cl_view *view))
314 cl_group::set_current(class cl_view *view)
320 /*focus_view(view, 0);*/
321 if ((state & SF_FOCUSED) &&
323 current->change_state(SF_FOCUSED, 0);
324 //if (mode!=ENTER_SELECT) select_view(current, 0);
326 current->change_state(SF_SELECTED, 0);
327 //if (mode!=LEAVE_SELECT) select_view(view, 1);
329 view->change_state(SF_SELECTED, 1);
330 //focuse_view(view, 1);
331 if ((state & SF_FOCUSED) &&
333 view->change_state(SF_SELECTED, 1);
339 cl_group::terminal_view(void)
341 return(views->count == 0);
344 static unsigned int grp_what, grp_en;
347 do_set_state(class cl_view *v)
349 v->change_state(grp_what, grp_en);
353 cl_group::change_state(unsigned int what, int enable)
355 cl_view::change_state(what, enable);
357 (what & SF_SELECTED))
359 class cl_view *v= get_by_state(SF_SELECTED, 1);
363 current->change_state(SF_FOCUSED, 1);
364 current->change_state(SF_SELECTED, 1);
368 if ((v= get_by_state(SF_FOCUSED, 1)))
371 current->change_state(SF_SELECTED, 1);
381 for_each(do_set_state);
386 current->change_state(SF_FOCUSED, enable);
393 /* End of gui.src/group.cc */