src/widget/widget_composite.cpp
branchcpp_gui
changeset 6264 9fc3b5467396
parent 6260 740c702f6871
child 6278 c09f5e53af9b
equal deleted inserted replaced
6263:19dab6a68886 6264:9fc3b5467396
    13 #include "../console.h"
    13 #include "../console.h"
    14 #include "../variables.h"
    14 #include "../variables.h"
    15 #include "../table/sprites.h"
    15 #include "../table/sprites.h"
    16 #include "../genworld.h"
    16 #include "../genworld.h"
    17 #include "../helpers.hpp"
    17 #include "../helpers.hpp"
       
    18 #include "window_events.hpp"
    18 
    19 
       
    20 namespace gui {
    19 
    21 
    20 void CompositeWidget::AddWidget(Widget *wd)
    22 void CompositeWidget::AddWidget(Widget *wd)
    21 {
    23 {
    22 	WidgetId id = wd->GetId();
    24 	WidgetId id = wd->GetId();
    23 	std::pair<WidgetIterator, bool> pib = m_widgets.insert(Widgets::value_type(id, wd));
    25 	std::pair<WidgetIterator, bool> pib = m_widgets.insert(Widgets::value_type(id, wd));
    76 	m_widgets.clear();
    78 	m_widgets.clear();
    77 	/* mark self as closed */
    79 	/* mark self as closed */
    78 	super::Close();
    80 	super::Close();
    79 }
    81 }
    80 
    82 
    81 /*virtual*/ bool CompositeWidget::OnLeftClick(WindowEvent *ev)
    83 /*virtual*/ void CompositeWidget::OnPaint(EvtPaint &ev)
       
    84 {
       
    85 	/* paint background */
       
    86 	DrawBackground(ev);
       
    87 
       
    88 	/* paint all children */
       
    89 	for (WidgetIterator it_next = m_widgets.begin(); it_next != m_widgets.end(); ) {
       
    90 		/* save the iterator (it can be invalidated) and move forward */
       
    91 		WidgetIterator it = it_next++;
       
    92 		/* get child */
       
    93 		Widget *wd_child = (*it).second;
       
    94 		/* tell him we are closing */
       
    95 		wd_child->OnPaint(ev);
       
    96 	}
       
    97 }
       
    98 
       
    99 /*virtual*/ void CompositeWidget::OnLeftClick(EvtClick &ev)
    82 {
   100 {
    83 	//Point16 pt(ev->we.click.pt.x, ev->we.click.pt.y);
   101 	//Point16 pt(ev->we.click.pt.x, ev->we.click.pt.y);
    84 	Widget *wd_child = WidgetFromPt(ev->we.click.pt);
   102 	Widget *wd_child = WidgetFromPt(ev.m_pt);
    85 	if (wd_child != NULL) {
   103 	if (wd_child != NULL && wd_child != this) {
    86 		return wd_child->OnLeftClick(ev);
   104 		wd_child->OnLeftClick(ev);
       
   105 		return;
    87 	}
   106 	}
    88 	return false;
   107 	super::OnLeftClick(ev);
    89 }
   108 }
       
   109 
       
   110 /*virtual*/ void CompositeWidget::OnRightClick(EvtRightClick &ev)
       
   111 {
       
   112 	//Point16 pt(ev->we.click.pt.x, ev->we.click.pt.y);
       
   113 	Widget *wd_child = WidgetFromPt(ev.m_pt);
       
   114 	if (wd_child != NULL && wd_child != this) {
       
   115 		wd_child->OnRightClick(ev);
       
   116 		return;
       
   117 	}
       
   118 	super::OnRightClick(ev);
       
   119 }
       
   120 
       
   121 }; // namespace gui