]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.cpp
Minor refactoring
[libs/gltk.git] / source / widget.cpp
index 6ac4d2aa7d7679bc39512614ff32705f835891b6..b7dcfc5e0d1ed6d104dde077195fe5f7c79b4870 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/gl/matrix.h>
 #include <msp/strings/format.h>
+#include <msp/strings/utils.h>
 #include "container.h"
 #include "resources.h"
 #include "root.h"
@@ -10,21 +11,12 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-Widget::Widget():
-       style(0),
-       state(NORMAL),
-       visible(true),
-       input_type(INPUT_NONE),
-       parent(0),
-       rebuild_needed(false)
-{ }
-
 Widget::~Widget()
 {
        if(parent)
        {
                Container *p = parent;
-               parent = 0;
+               parent = nullptr;
                p->remove(*this);
        }
 }
@@ -119,7 +111,7 @@ void Widget::set_parent(Container *p)
        catch(...)
        {
                // The container has not yet added the widget as its child
-               parent = 0;
+               parent = nullptr;
                throw;
        }
 }
@@ -136,15 +128,11 @@ void Widget::update_style()
        for(top=this; top->parent; top=top->parent) ;
        Root *root = dynamic_cast<Root *>(top);
        if(!root)
-               style = 0;
+               style = nullptr;
        else
        {
                string sname = get_class();
-               if(!style_name.empty())
-               {
-                       sname += '-';
-                       sname += style_name;
-               }
+               append(sname, "-", style_name);
 
                style = &root->get_resources().get<Style>(sname);
        }