Browse Source

Merge pull request #1246 from JimMarlowe/JM-TBUPDATE-1205

Capture TurboBadger hashtable fix and more #1205
JoshEngebretson 9 years ago
parent
commit
8b49877633

+ 7 - 1
Source/Atomic/UI/UIWidget.h

@@ -119,7 +119,13 @@ enum UI_EVENT_TYPE {
     UI_EVENT_TYPE_TAB_CHANGED = 14, // tb::EVENT_TYPE_TAB_CHANGED,
     UI_EVENT_TYPE_TAB_CHANGED = 14, // tb::EVENT_TYPE_TAB_CHANGED,
 
 
     /** Custom event. Not used internally. ref_id may be used for additional type info. */
     /** Custom event. Not used internally. ref_id may be used for additional type info. */
-    UI_EVENT_TYPE_CUSTOM = 15 // tb::EVENT_TYPE_CUSTOM
+    UI_EVENT_TYPE_CUSTOM = 15, // tb::EVENT_TYPE_CUSTOM
+
+    /** Local Turbobadger touch events */
+    UI_EVENT_TYPE_TOUCH_DOWN,
+    UI_EVENT_TYPE_TOUCH_UP,
+    UI_EVENT_TYPE_TOUCH_MOVE,
+    UI_EVENT_TYPE_TOUCH_CANCEL
 };
 };
 
 
 /** Defines widget z level relative to another widget, used with TBWidget::AddChildRelative. */
 /** Defines widget z level relative to another widget, used with TBWidget::AddChildRelative. */

+ 2 - 2
Source/ThirdParty/TurboBadger/image/tb_image_manager.cpp

@@ -60,7 +60,7 @@ TBImage::~TBImage()
 
 
 bool TBImage::IsEmpty() const
 bool TBImage::IsEmpty() const
 {
 {
-    return m_image_rep && m_image_rep->fragment;
+    return !(m_image_rep && m_image_rep->fragment);
 }
 }
 
 
 int TBImage::Width() const
 int TBImage::Width() const
@@ -171,6 +171,6 @@ void TBImageManager::OnContextRestored()
     // No need to do anything. The bitmaps will be created when drawing.
     // No need to do anything. The bitmaps will be created when drawing.
 }
 }
 
 
-}; // namespace tb
+} // namespace tb
 
 
 #endif // TB_IMAGE
 #endif // TB_IMAGE

+ 4 - 0
Source/ThirdParty/TurboBadger/tb_debug.cpp

@@ -188,6 +188,10 @@ public:
         case EVENT_TYPE_POINTER_MOVE:	return "POINTER_MOVE";
         case EVENT_TYPE_POINTER_MOVE:	return "POINTER_MOVE";
         case EVENT_TYPE_RIGHT_POINTER_UP: return "RIGHT_POINTER_UP";
         case EVENT_TYPE_RIGHT_POINTER_UP: return "RIGHT_POINTER_UP";
         case EVENT_TYPE_RIGHT_POINTER_DOWN:	return "RIGHT_POINTER_DOWN";
         case EVENT_TYPE_RIGHT_POINTER_DOWN:	return "RIGHT_POINTER_DOWN";
+        case EVENT_TYPE_TOUCH_DOWN:		return "TOUCH_DOWN";
+        case EVENT_TYPE_TOUCH_UP:		return "TOUCH_UP";
+        case EVENT_TYPE_TOUCH_MOVE:		return "TOUCH_MOVE";
+        case EVENT_TYPE_TOUCH_CANCEL:	return "TOUCH_CANCEL";
         case EVENT_TYPE_WHEEL:			return "WHEEL";
         case EVENT_TYPE_WHEEL:			return "WHEEL";
         case EVENT_TYPE_CHANGED:		return "CHANGED";
         case EVENT_TYPE_CHANGED:		return "CHANGED";
         case EVENT_TYPE_KEY_DOWN:		return "KEY_DOWN";
         case EVENT_TYPE_KEY_DOWN:		return "KEY_DOWN";

+ 3 - 2
Source/ThirdParty/TurboBadger/tb_hashtable.cpp

@@ -16,7 +16,7 @@ namespace tb {
 // == TBHashTable =======================================================================
 // == TBHashTable =======================================================================
 
 
 TBHashTable::TBHashTable()
 TBHashTable::TBHashTable()
-    : m_buckets(0)
+    : m_buckets(nullptr)
     , m_num_buckets(0)
     , m_num_buckets(0)
     , m_num_items(0)
     , m_num_items(0)
 {
 {
@@ -141,6 +141,7 @@ void *TBHashTable::Remove(uint32 key)
                 prev_item->next = item->next;
                 prev_item->next = item->next;
             else
             else
                 m_buckets[bucket] = item->next;
                 m_buckets[bucket] = item->next;
+            m_num_items--;
             void *content = item->content;
             void *content = item->content;
             delete item;
             delete item;
             return content;
             return content;
@@ -216,4 +217,4 @@ void *TBHashTableIterator::GetNextContent()
     return m_current_item ? m_current_item->content : nullptr;
     return m_current_item ? m_current_item->content : nullptr;
 }
 }
 
 
-}; // namespace tb
+} // namespace tb

+ 6 - 3
Source/ThirdParty/TurboBadger/tb_hashtable.h

@@ -51,6 +51,9 @@ public:
         the current number of items. */
         the current number of items. */
     uint32 GetSuitableBucketsCount() const;
     uint32 GetSuitableBucketsCount() const;
 
 
+    /** Get the number of items in the hash table. */
+    uint32 GetNumItems() const { return m_num_items; }
+
 #ifdef TB_RUNTIME_DEBUG_INFO
 #ifdef TB_RUNTIME_DEBUG_INFO
     /** Print out some debug info about the hash table. */
     /** Print out some debug info about the hash table. */
     void Debug();
     void Debug();
@@ -98,10 +101,10 @@ public:
 template<class T>
 template<class T>
 class TBHashTableOf : public TBHashTable
 class TBHashTableOf : public TBHashTable
 {
 {
-    // FIX: Don't do public inheritance! Either inherit privately and forward, or use a private member backend!
+// FIX: Don't do public inheritance! Either inherit privately and forward, or use a private member backend!
 public:
 public:
     T *Get(uint32 key) const { return (T*) TBHashTable::Get(key); }
     T *Get(uint32 key) const { return (T*) TBHashTable::Get(key); }
-
+    T *Remove(uint32 key) { return (T*) TBHashTable::Remove(key); }
 protected:
 protected:
     virtual void DeleteContent(void *content) { delete (T*) content; }
     virtual void DeleteContent(void *content) { delete (T*) content; }
 };
 };
@@ -120,6 +123,6 @@ protected:
     virtual void DeleteContent(void *content) { delete (T*) content; }
     virtual void DeleteContent(void *content) { delete (T*) content; }
 };
 };
 
 
-}; // namespace tb
+} // namespace tb
 
 
 #endif // TB_HASHTABLE_H
 #endif // TB_HASHTABLE_H

+ 137 - 3
Source/ThirdParty/TurboBadger/tb_widgets.cpp

@@ -32,6 +32,27 @@ bool TBWidget::update_widget_states = true;
 bool TBWidget::update_skin_states = true;
 bool TBWidget::update_skin_states = true;
 bool TBWidget::show_focus_state = false;
 bool TBWidget::show_focus_state = false;
 
 
+static TBHashTableAutoDeleteOf<TBWidget::TOUCH_INFO> s_touch_info;
+
+TBWidget::TOUCH_INFO *TBWidget::GetTouchInfo(uint32 id)
+{
+    return s_touch_info.Get(id);
+}
+
+static TBWidget::TOUCH_INFO *NewTouchInfo(uint32 id)
+{
+    assert(!s_touch_info.Get(id));
+    TBWidget::TOUCH_INFO *ti = new TBWidget::TOUCH_INFO;
+    memset(ti, 0, sizeof(TBWidget::TOUCH_INFO));
+    s_touch_info.Add(id, ti);
+    return ti;
+}
+
+static void DeleteTouchInfo(uint32 id)
+{
+    s_touch_info.Delete(id);
+}
+
 // == TBLongClickTimer ==================================================================
 // == TBLongClickTimer ==================================================================
 
 
 /** One shot timer for long click event */
 /** One shot timer for long click event */
@@ -89,6 +110,7 @@ TBWidget::~TBWidget()
     assert(!m_parent); ///< A widget must be removed from parent before deleted
     assert(!m_parent); ///< A widget must be removed from parent before deleted
     m_packed.is_dying = true;
     m_packed.is_dying = true;
 
 
+    // Unreference from pointer capture
     if (this == hovered_widget)
     if (this == hovered_widget)
         hovered_widget = nullptr;
         hovered_widget = nullptr;
     if (this == captured_widget)
     if (this == captured_widget)
@@ -96,6 +118,16 @@ TBWidget::~TBWidget()
     if (this == focused_widget)
     if (this == focused_widget)
         focused_widget = nullptr;
         focused_widget = nullptr;
 
 
+    // Unreference from touch info
+    TBHashTableIteratorOf<TOUCH_INFO> it(&s_touch_info);
+    while (TOUCH_INFO *ti = it.GetNextContent())
+    {
+        if (this == ti->hovered_widget)
+            ti->hovered_widget = nullptr;
+        if (this == ti->captured_widget)
+            ti->captured_widget = nullptr;
+    }
+
     if (m_delegate)
     if (m_delegate)
         m_delegate->OnDelete();
         m_delegate->OnDelete();
 
 
@@ -1083,7 +1115,7 @@ PreferredSize TBWidget::GetPreferredSize(const SizeConstraints &in_constraints)
     // Override the calculated ps with any specified layout parameter.
     // Override the calculated ps with any specified layout parameter.
     if (m_layout_params)
     if (m_layout_params)
     {
     {
-#define LP_OVERRIDE(param)	if (m_layout_params->param != LayoutParams::UNSPECIFIED) \
+#define LP_OVERRIDE(param)  if (m_layout_params->param != LayoutParams::UNSPECIFIED) \
     m_cached_ps.param = m_layout_params->param;
     m_cached_ps.param = m_layout_params->param;
         LP_OVERRIDE(min_w);
         LP_OVERRIDE(min_w);
         LP_OVERRIDE(min_h);
         LP_OVERRIDE(min_h);
@@ -1316,7 +1348,7 @@ void TBWidget::StopLongClickTimer()
     m_long_click_timer = nullptr;
     m_long_click_timer = nullptr;
 }
 }
 
 
-void TBWidget::InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch, int touchId)
+bool TBWidget::InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch, int touchId)
 {
 {
     TBWidget* down_widget = GetWidgetAt(x, y, true);
     TBWidget* down_widget = GetWidgetAt(x, y, true);
     if (!captured_widget && down_widget && down_widget->needCapturing_)
     if (!captured_widget && down_widget && down_widget->needCapturing_)
@@ -1397,10 +1429,15 @@ void TBWidget::InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS mo
         TBWidgetEvent ev(EVENT_TYPE_POINTER_DOWN, x, y, touch, modifierkeys);
         TBWidgetEvent ev(EVENT_TYPE_POINTER_DOWN, x, y, touch, modifierkeys);
         ev.count = click_count;
         ev.count = click_count;
         down_widget->InvokeEvent(ev);
         down_widget->InvokeEvent(ev);
+
+		// Return true when captured instead of InvokeEvent result. If a widget is
+		// hit is more interesting for callers than if the event was handled or not.
+        return true;
     }
     }
+    return false;
 }
 }
 
 
-void TBWidget::InvokePointerUp(int x, int y, MODIFIER_KEYS modifierkeys, bool touch, int touchId)
+bool TBWidget::InvokePointerUp(int x, int y, MODIFIER_KEYS modifierkeys, bool touch, int touchId)
 {
 {
     //get down_widget before making handling captured_widget event to make sure that down_widget won't be changed
     //get down_widget before making handling captured_widget event to make sure that down_widget won't be changed
     TBWidget* down_widget = GetWidgetAt(x, y, true);
     TBWidget* down_widget = GetWidgetAt(x, y, true);
@@ -1452,7 +1489,12 @@ void TBWidget::InvokePointerUp(int x, int y, MODIFIER_KEYS modifierkeys, bool to
         //ReleaseCapture
         //ReleaseCapture
         down_widget->Invalidate();
         down_widget->Invalidate();
         down_widget->InvalidateSkinStates();
         down_widget->InvalidateSkinStates();
+ 
+        // Return true when captured instead of InvokeEvent result. If a widget is
+        // hit is more interesting for callers than if the event was handled or not.
+       return true;
     }
     }
+    return false;
 }
 }
 
 
 void TBWidget::InvokeRightPointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys)
 void TBWidget::InvokeRightPointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys)
@@ -1593,6 +1635,98 @@ void TBWidget::HandlePanningOnMove(int x, int y)
     }
     }
 }
 }
 
 
+void TBWidget::InvokePointerCancel()
+{
+    if (captured_widget)
+        captured_widget->ReleaseCapture();
+}
+
+bool TBWidget::InvokeTouchDown(int x, int y, uint32 id, int click_count, MODIFIER_KEYS modifierkeys)
+{
+    if (id == 0)
+        return InvokePointerDown(x, y, click_count, modifierkeys, true);
+
+    TOUCH_INFO *ti = NewTouchInfo(id);
+    if (!ti)
+        return false;
+
+    if (!ti->captured_widget)
+        ti->captured_widget = GetWidgetAt(x, y, true);
+    if (ti->captured_widget && !ti->captured_widget->GetState(WIDGET_STATE_DISABLED))
+        ti->hovered_widget = ti->captured_widget;
+
+    if (ti->captured_widget)
+    {
+        ti->captured_widget->ConvertFromRoot(x, y);
+        ti->move_widget_x = ti->down_widget_x = x;
+        ti->move_widget_y = ti->down_widget_y = y;
+        TBWidgetEvent ev(EVENT_TYPE_TOUCH_DOWN, x, y, true, modifierkeys);
+        ev.count = click_count;
+        ev.ref_id = id;
+        ti->captured_widget->InvokeEvent(ev);
+        return true;
+    }
+    return false;
+}
+
+bool TBWidget::InvokeTouchUp(int x, int y, uint32 id, MODIFIER_KEYS modifierkeys)
+{
+    if (id == 0)
+        return InvokePointerUp(x, y, modifierkeys, true);
+    TOUCH_INFO *ti = GetTouchInfo(id);
+    if (ti && ti->captured_widget)
+    {
+        ti->captured_widget->ConvertFromRoot(x, y);
+        TBWidgetEvent ev(EVENT_TYPE_TOUCH_UP, x, y, true, modifierkeys);
+        ev.ref_id = id;
+        ti->captured_widget->InvokeEvent(ev);
+        DeleteTouchInfo(id);
+        return true;
+    }
+    return false;
+}
+
+void TBWidget::InvokeTouchMove(int x, int y, uint32 id, MODIFIER_KEYS modifierkeys)
+{
+    if (id == 0)
+        return InvokePointerMove(x, y, modifierkeys, true);
+
+    TOUCH_INFO *ti = GetTouchInfo(id);
+    if (!ti)
+        return;
+
+    ti->hovered_widget = GetWidgetAt(x, y, true);
+    if (ti->captured_widget)
+    {
+        ti->captured_widget->ConvertFromRoot(x, y);
+        ti->move_widget_x = x;
+        ti->move_widget_y = y;
+        TBWidgetEvent ev(EVENT_TYPE_TOUCH_MOVE, x, y, true, modifierkeys);
+        ev.ref_id = id;
+        if (ti->captured_widget->InvokeEvent(ev))
+            return;
+    }
+}
+
+void TBWidget::InvokeTouchCancel(uint32 id)
+{
+    if (id == 0)
+        return InvokePointerCancel();
+
+    TOUCH_INFO *ti = GetTouchInfo(id);
+    if (ti)
+    {
+        if (ti->captured_widget)
+        {
+            TBWidgetEvent ev(EVENT_TYPE_TOUCH_CANCEL, 0, 0, true);
+            ev.ref_id = id;
+            ti->captured_widget->InvokeEvent(ev);
+        }
+        DeleteTouchInfo(id);
+    }
+}
+
+
 void TBWidget::InvokeWheel(int x, int y, int delta_x, int delta_y, MODIFIER_KEYS modifierkeys)
 void TBWidget::InvokeWheel(int x, int y, int delta_x, int delta_y, MODIFIER_KEYS modifierkeys)
 {
 {
     SetHoveredWidget(GetWidgetAt(x, y, true), true);
     SetHoveredWidget(GetWidgetAt(x, y, true), true);

+ 38 - 6
Source/ThirdParty/TurboBadger/tb_widgets.h

@@ -86,7 +86,14 @@ enum EVENT_TYPE {
     EVENT_TYPE_TAB_CHANGED,
     EVENT_TYPE_TAB_CHANGED,
 
 
     /** Custom event. Not used internally. ref_id may be used for additional type info. */
     /** Custom event. Not used internally. ref_id may be used for additional type info. */
-    EVENT_TYPE_CUSTOM
+    EVENT_TYPE_CUSTOM,
+    
+    /** Turbobadger implementation for touch events */
+    EVENT_TYPE_TOUCH_DOWN,
+    EVENT_TYPE_TOUCH_UP,
+    EVENT_TYPE_TOUCH_MOVE,
+    EVENT_TYPE_TOUCH_CANCEL
+
 };
 };
 
 
 enum MODIFIER_KEYS {
 enum MODIFIER_KEYS {
@@ -144,6 +151,10 @@ public:
     bool IsPointerEvent() const { return	type == EVENT_TYPE_POINTER_DOWN ||
     bool IsPointerEvent() const { return	type == EVENT_TYPE_POINTER_DOWN ||
                 type == EVENT_TYPE_POINTER_UP ||
                 type == EVENT_TYPE_POINTER_UP ||
                 type == EVENT_TYPE_POINTER_MOVE; }
                 type == EVENT_TYPE_POINTER_MOVE; }
+	bool IsTouchEvent() const { return  type == EVENT_TYPE_TOUCH_DOWN ||
+                type == EVENT_TYPE_TOUCH_UP ||
+                type == EVENT_TYPE_TOUCH_MOVE ||
+                type == EVENT_TYPE_TOUCH_CANCEL; }
     bool IsKeyEvent() const { return	type == EVENT_TYPE_KEY_DOWN ||
     bool IsKeyEvent() const { return	type == EVENT_TYPE_KEY_DOWN ||
                 type == EVENT_TYPE_KEY_UP; }
                 type == EVENT_TYPE_KEY_UP; }
 };
 };
@@ -943,9 +954,20 @@ public:
         this call and are not sure what the event will cause, use TBWidgetSafePointer to detect self deletion. */
         this call and are not sure what the event will cause, use TBWidgetSafePointer to detect self deletion. */
     bool InvokeEvent(TBWidgetEvent &ev);
     bool InvokeEvent(TBWidgetEvent &ev);
 
 
-    void InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch, int touchId = 0);
-    void InvokePointerUp(int x, int y, MODIFIER_KEYS modifierkeys, bool touch, int touchId = 0);
+    bool InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch, int touchId = 0);
+    bool InvokePointerUp(int x, int y, MODIFIER_KEYS modifierkeys, bool touch, int touchId = 0);
     void InvokePointerMove(int x, int y, MODIFIER_KEYS modifierkeys, bool touch, int touchId = 0);
     void InvokePointerMove(int x, int y, MODIFIER_KEYS modifierkeys, bool touch, int touchId = 0);
+	void InvokePointerCancel();
+
+	/** Invoke touch events with ref_id set as the given id.
+		Note: For id 0, it will invoke EVENT_TYPE_POINTER_DOWN (with touch flag set to true), and EVENT_TYPE_TOUCH_DOWN
+		for other id > 0. This results in normal interaction for first finger, and optional handling of other
+		simultaneous interaction. GetTouchInfo(id) can be used to get additional interaction info. */
+	bool InvokeTouchDown(int x, int y, uint32 id, int click_count, MODIFIER_KEYS modifierkeys);
+	bool InvokeTouchUp(int x, int y, uint32 id, MODIFIER_KEYS modifierkeys);
+	void InvokeTouchMove(int x, int y, uint32 id, MODIFIER_KEYS modifierkeys);
+	void InvokeTouchCancel(uint32 id);
+
     void InvokeWheel(int x, int y, int delta_x, int delta_y, MODIFIER_KEYS modifierkeys);
     void InvokeWheel(int x, int y, int delta_x, int delta_y, MODIFIER_KEYS modifierkeys);
 
 
     void InvokeRightPointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys);
     void InvokeRightPointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys);
@@ -1069,9 +1091,9 @@ public:
 #endif // TB_RUNTIME_DEBUG_INFO
 #endif // TB_RUNTIME_DEBUG_INFO
 
 
     // TBWidget related globals
     // TBWidget related globals
-    static TBWidget *hovered_widget;		///< The currently hovered widget, or nullptr.
-    static TBWidget *captured_widget;		///< The currently captured widget, or nullptr.
-    static TBWidget *focused_widget;		///< The currently focused widget, or nullptr.
+    static TBWidget *hovered_widget;	///< The currently hovered widget, or nullptr.
+    static TBWidget *captured_widget;	///< The currently captured widget, or nullptr.
+    static TBWidget *focused_widget;	///< The currently focused widget, or nullptr.
     static int pointer_down_widget_x;	///< Pointer x position on down event, relative to the captured widget.
     static int pointer_down_widget_x;	///< Pointer x position on down event, relative to the captured widget.
     static int pointer_down_widget_y;	///< Pointer y position on down event, relative to the captured widget.
     static int pointer_down_widget_y;	///< Pointer y position on down event, relative to the captured widget.
     static int pointer_move_widget_x;	///< Pointer x position on last pointer event, relative to the captured widget (if any) or hovered widget.
     static int pointer_move_widget_x;	///< Pointer x position on last pointer event, relative to the captured widget (if any) or hovered widget.
@@ -1080,6 +1102,16 @@ public:
     static bool update_widget_states;	///< true if something has called InvalidateStates() and it still hasn't been updated.
     static bool update_widget_states;	///< true if something has called InvalidateStates() and it still hasn't been updated.
     static bool update_skin_states;		///< true if something has called InvalidateStates() and skin still hasn't been updated.
     static bool update_skin_states;		///< true if something has called InvalidateStates() and skin still hasn't been updated.
     static bool show_focus_state;		///< true if the focused state should be painted automatically.
     static bool show_focus_state;		///< true if the focused state should be painted automatically.
+    struct TOUCH_INFO {
+        TBWidget *hovered_widget;       ///< The currently hovered widget, or nullptr.
+        TBWidget *captured_widget;      ///< The currently captured widget, or nullptr.
+        int down_widget_x;              ///< Touch x position on down event, relative to the captured widget.
+        int down_widget_y;              ///< Touch y position on down event, relative to the captured widget.
+        int move_widget_x;              ///< Touch x position on last touch event, relative to the captured widget.
+        int move_widget_y;              ///< Touch y position on last touch event, relative to the captured widget.
+    };
+    /** Return TOUCH_INFO for the given id, or nullptr if no touch is active for that id. */
+    static TOUCH_INFO *GetTouchInfo(uint32 id);
 private:
 private:
     /** Return this widget or the nearest parent that is scrollable
     /** Return this widget or the nearest parent that is scrollable
         in the given axis, or nullptr if there is none. */
         in the given axis, or nullptr if there is none. */

+ 11 - 11
Source/ThirdParty/TurboBadger/tb_window.h

@@ -12,11 +12,11 @@
 namespace tb {
 namespace tb {
 
 
 enum WINDOW_SETTINGS {
 enum WINDOW_SETTINGS {
-    WINDOW_SETTINGS_NONE			= 0,	///< Chrome less window without any other settings.
-    WINDOW_SETTINGS_TITLEBAR		= 1,	///< Show a title bar that can also move the window.
-    WINDOW_SETTINGS_RESIZABLE		= 2,	///< Show a widget for resizing the window.
-    WINDOW_SETTINGS_CLOSE_BUTTON	= 4,	///< Show a widget for closing the window.
-    WINDOW_SETTINGS_CAN_ACTIVATE	= 8,	///< Can be activated and deactivate other windows.
+    WINDOW_SETTINGS_NONE            = 0,    ///< Chrome less window without any other settings.
+    WINDOW_SETTINGS_TITLEBAR        = 1,    ///< Show a title bar that can also move the window.
+    WINDOW_SETTINGS_RESIZABLE       = 2,    ///< Show a widget for resizing the window.
+    WINDOW_SETTINGS_CLOSE_BUTTON    = 4,    ///< Show a widget for closing the window.
+    WINDOW_SETTINGS_CAN_ACTIVATE    = 8,    ///< Can be activated and deactivate other windows.
 
 
     WINDOW_SETTINGS_DEFAULT = WINDOW_SETTINGS_TITLEBAR | WINDOW_SETTINGS_RESIZABLE |
     WINDOW_SETTINGS_DEFAULT = WINDOW_SETTINGS_TITLEBAR | WINDOW_SETTINGS_RESIZABLE |
     WINDOW_SETTINGS_CLOSE_BUTTON | WINDOW_SETTINGS_CAN_ACTIVATE
     WINDOW_SETTINGS_CLOSE_BUTTON | WINDOW_SETTINGS_CAN_ACTIVATE
@@ -37,7 +37,7 @@ public:
     TBOBJECT_SUBCLASS(TBWindow, TBWidget);
     TBOBJECT_SUBCLASS(TBWindow, TBWidget);
 
 
     TBWindow();
     TBWindow();
-    ~TBWindow();
+    virtual ~TBWindow();
 
 
     /** Close this window.
     /** Close this window.
         Warning: This window will be deleted after this call! */
         Warning: This window will be deleted after this call! */
@@ -69,9 +69,9 @@ public:
 
 
     /** RESIZE_FIT specifies how ResizeToFitContent should resize the window. */
     /** RESIZE_FIT specifies how ResizeToFitContent should resize the window. */
     enum RESIZE_FIT {
     enum RESIZE_FIT {
-        RESIZE_FIT_PREFERRED,			///< Fit the preferred size of all content
-        RESIZE_FIT_MINIMAL,				///< Fit the minimal size of all content
-        RESIZE_FIT_CURRENT_OR_NEEDED	///< Fit the minimal or maximum size only if needed. Will keep
+        RESIZE_FIT_PREFERRED,           ///< Fit the preferred size of all content
+        RESIZE_FIT_MINIMAL,             ///< Fit the minimal size of all content
+        RESIZE_FIT_CURRENT_OR_NEEDED    ///< Fit the minimal or maximum size only if needed. Will keep
         ///< the new size as close as possible to the current size.
         ///< the new size as close as possible to the current size.
     };
     };
 
 
@@ -103,7 +103,7 @@ protected:
     TBMover m_mover;
     TBMover m_mover;
     TBResizer m_resizer;
     TBResizer m_resizer;
     TBTextField m_textfield;
     TBTextField m_textfield;
-    TBButton m_close_button;
+    TBWidget m_close_button;
     WINDOW_SETTINGS m_settings;
     WINDOW_SETTINGS m_settings;
     TBWidgetSafePointer m_last_focus;
     TBWidgetSafePointer m_last_focus;
     TBWindow *GetTopMostOtherWindow(bool only_activable_windows);
     TBWindow *GetTopMostOtherWindow(bool only_activable_windows);
@@ -111,6 +111,6 @@ protected:
     void DeActivate();
     void DeActivate();
 };
 };
 
 
-}; // namespace tb
+} // namespace tb
 
 
 #endif // TB_WINDOW_H
 #endif // TB_WINDOW_H