~haggai-eran/nux/rtl

« back to all changes in this revision

Viewing changes to Nux/Layout.cpp

  • Committer: Haggai Eran
  • Date: 2011-10-15 21:01:00 UTC
  • mfrom: (413.1.84 nux)
  • Revision ID: haggai.eran@gmail.com-20111015210100-4amf0pdxuzkynotw
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
  Layout::~Layout()
50
50
  {
51
 
    // It is possible that this layout object is in the refresh list. Remove it here before it is deleted.
52
 
    GetWindowThread()->RemoveObjectFromLayoutQueue(this);
 
51
    // It is possible that this layout object is in the refresh list. Remove
 
52
    // it here before it is deleted.
 
53
    WindowThread* wt = GetWindowThread();
 
54
    if (wt)
 
55
      wt->RemoveObjectFromLayoutQueue(this);
53
56
 
54
57
    std::list<Area *>::iterator it;
55
58
 
64
67
 
65
68
  void Layout::RemoveChildObject (Area *bo)
66
69
  {
67
 
    bool was_focused = GetFocused ();
68
70
    std::list<Area *>::iterator it;
69
71
    it = std::find (_layout_element_list.begin(), _layout_element_list.end(), bo);
70
72
 
71
 
    if ((*it)->GetFocused ())
72
 
    {
73
 
      // the child was focused, oh dear. lets handle that gracefully
74
 
      if (_layout_element_list.size() > 1)
75
 
      {
76
 
        if (it == _layout_element_list.end ())
77
 
        {
78
 
          FocusPreviousChild ((*it));
79
 
        }
80
 
        else
81
 
        {
82
 
          FocusNextChild ((*it));
83
 
        }
84
 
      }
85
 
 
86
 
      (*it)->SetFocused (false);
87
 
    }
88
 
 
89
 
    sigc::connection onchildfocuscon = _connection_map[bo];
90
 
    onchildfocuscon.disconnect ();
91
 
 
92
73
    if (it != _layout_element_list.end())
93
74
    {
94
75
      /* we need to emit the signal before the unparent, just in case
97
78
      bo->UnParentObject();
98
79
      _layout_element_list.erase (it);
99
80
    }
100
 
 
101
 
    if (IsEmpty () && was_focused)
102
 
    {
103
 
      // we are now empty, so we need to handle our focus state
104
 
      Area *area = GetParentObject ();
105
 
      if (area == NULL)
106
 
        return;
107
 
 
108
 
 
109
 
      if (area->IsLayout ())
110
 
      {
111
 
        Layout *parent = (Layout *)area;
112
 
        parent->SetFocused (true);
113
 
      }
114
 
    }
115
81
  }
116
82
 
117
83
  bool Layout::FindWidget (Area *WidgetObject) const
223
189
    }
224
190
    else
225
191
    {
 
192
#if defined(NUX_OS_WINDOWS) && !defined(NUX_VISUAL_STUDIO_2010)
 
193
      std::list<Area *>::iterator pos = _layout_element_list.begin();
 
194
#else
226
195
      auto pos = _layout_element_list.begin();
 
196
#endif
227
197
      int idx = index;
228
198
      while (pos != _layout_element_list.end() && idx > 0)
229
199
      {
311
281
    }
312
282
    else
313
283
    {
 
284
#if defined(NUX_OS_WINDOWS) && !defined(NUX_VISUAL_STUDIO_2010)
 
285
      std::list<Area *>::iterator pos = _layout_element_list.begin();
 
286
#else
314
287
      auto pos = _layout_element_list.begin();
 
288
#endif
315
289
      int idx = index;
316
290
      while (pos != _layout_element_list.end() && idx > 0)
317
291
      {
775
749
    return ret;
776
750
  }
777
751
 
778
 
  long Layout::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
779
 
  {
780
 
    long ret = TraverseInfo;
781
 
    std::list<Area *>::iterator it;
782
 
 
783
 
    for (it = _layout_element_list.begin(); it != _layout_element_list.end(); it++)
784
 
    {
785
 
      if (!(*it)->IsVisible () || !(*it)->IsSensitive ())
786
 
        continue;
787
 
 
788
 
      if ((*it)->IsView())
789
 
      {
790
 
        View *ic = NUX_STATIC_CAST (View*, (*it));
791
 
        ret = ic->ProcessEvent (ievent, ret, ProcessEventInfo);
792
 
      }
793
 
      else if ( (*it)->IsLayout() )
794
 
      {
795
 
        Layout *layout = NUX_STATIC_CAST (Layout*, (*it));
796
 
        ret = layout->ProcessEvent (ievent, ret, ProcessEventInfo);
797
 
      }
798
 
      // InputArea should be tested last
799
 
      else if ((*it)->IsInputArea())
800
 
      {
801
 
        InputArea *input_area = NUX_STATIC_CAST (InputArea*, (*it));
802
 
        ret = input_area->OnEvent (ievent, ret, ProcessEventInfo);
803
 
      }
804
 
    }
805
 
 
806
 
    /* must do focus processing after sending events to children */
807
 
    if ((ievent.e_event == NUX_KEYDOWN) && HasFocusControl () && (_ignore_focus == false))
808
 
    {
809
 
      ret |= ProcessFocusEvent (ievent, ret, ProcessEventInfo);
810
 
    }
811
 
 
812
 
    if (_ignore_focus)
813
 
      _ignore_focus = false;
814
 
 
815
 
    return ret;
816
 
  }
817
 
 
818
752
  Area* Layout::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
819
753
  {
820
754
    bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);