]> git.tdb.fi Git - r2c2.git/commitdiff
Base the train list item on MultiColumnItem
authorMikko Rasa <tdb@tdb.fi>
Fri, 15 Nov 2013 22:44:31 +0000 (00:44 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 15 Nov 2013 22:44:31 +0000 (00:44 +0200)
source/engineer/trainlistdialog.cpp

index fccfbfb645288c15deb0117efabcadca8a9d9e1f..f4fbb102fe580b2f114ae0810f2852eb519aa07e 100644 (file)
@@ -11,20 +11,12 @@ using namespace std;
 using namespace Msp;
 using namespace R2C2;
 
-class TrainItem: public GLtk::List::Item
+class TrainItem: public GLtk::List::MultiColumnItem
 {
-private:
-       GLtk::Label protocol;
-       GLtk::Label address;
-       GLtk::Label name;
-
-public:        
+public:
        typedef R2C2::Train *ValueType;
 
        TrainItem(ValueType);
-
-private:
-       virtual void on_style_change();
 };
 
 
@@ -95,30 +87,10 @@ void TrainListDialog::train_name_changed(Train &train)
 }
 
 
-TrainItem::TrainItem(ValueType train):
-       protocol(train->get_protocol()),
-       address(lexical_cast<string>(train->get_address())),
-       name(train->get_name())
+TrainItem::TrainItem(ValueType train)
 {
-       add(protocol);
-       add(address);
-       add(name);
+       add(*new GLtk::Label(train->get_protocol()));
+       add(*new GLtk::Label(lexical_cast<string>(train->get_address())));
+       add(*new GLtk::Label(train->get_name()));
 }
 
-void TrainItem::on_style_change()
-{
-       if(!style)
-               return;
-
-       protocol.autosize();
-       address.autosize();
-       name.autosize();
-
-       if(const GLtk::Part *part = style->get_part("children"))
-       {
-               const GLtk::Sides &margin = part->get_margin();
-               protocol.set_position(margin.left, margin.bottom);
-               address.set_position(margin.left+30, margin.bottom);
-               name.set_position(margin.left+60, margin.bottom);
-       }
-}