]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/list.h
Use the override specifier when overriding a virtual function
[libs/gltk.git] / source / list.h
index 68a96bf36cb65fb0c9361a0b1a156984cc1cd12f..060fb813f405cc9b29fb762c8a5ac93e7feedc61 100644 (file)
@@ -20,7 +20,6 @@ class MSPGLTK_API incompatible_data: public std::logic_error
 {
 public:
        incompatible_data(const std::type_info &);
-       virtual ~incompatible_data() throw() { }
 };
 
 
@@ -68,33 +67,33 @@ public:
                Item();
 
        public:
-               virtual const char *get_class() const { return "listitem"; }
+               const char *get_class() const override { return "listitem"; }
 
        protected:
-               virtual void autosize_special(const Part &, Geometry &) const;
+               void autosize_special(const Part &, Geometry &) const override;
        public:
                void set_active(bool);
 
-               virtual void render_special(const Part &, GL::Renderer &) const;
+               void render_special(const Part &, GL::Renderer &) const override;
        };
 
        class SimpleItem: public Item
        {
        protected:
-               SimpleItem() { }
+               SimpleItem() = default;
 
-               virtual void on_style_change();
+               void on_style_change() override;
        };
 
        class MultiColumnItem: public Item
        {
        protected:
-               MultiColumnItem() { }
+               MultiColumnItem() = default;
 
                virtual void check_widths(std::vector<unsigned> &) const;
                virtual void set_widths(const std::vector<unsigned> &);
 
-               virtual void on_style_change();
+               void on_style_change() override;
        };
 
 private:
@@ -110,9 +109,9 @@ private:
        class ItemFactory
        {
        protected:
-               ItemFactory() { }
+               ItemFactory() = default;
        public:
-               virtual ~ItemFactory() { }
+               virtual ~ItemFactory() = default;
 
                virtual void set_data(const ListData &) = 0;
                virtual Item *create_item(unsigned) const = 0;
@@ -130,7 +129,7 @@ private:
                TypedItemFactory(const ListData &d)
                { set_data(d); }
 
-               virtual void set_data(const ListData &d)
+               void set_data(const ListData &d) override
                {
                        if(const ListDataStore<ValueType> *ds = dynamic_cast<const ListDataStore<ValueType> *>(&d))
                                data = ds;
@@ -138,7 +137,7 @@ private:
                                throw incompatible_data(typeid(ValueType));
                }
 
-               virtual Item *create_item(unsigned i) const
+               Item *create_item(unsigned i) const override
                {
                        return new I(data->get(i));
                }
@@ -157,22 +156,22 @@ public:
        sigc::signal<void> signal_selection_cleared;
 
 private:
-       ListData *data;
-       bool own_data;
-       DataObserver *observer;
-       ItemFactory *item_factory;
-       ViewMode view_mode;
-       int sel_index;
-       int focus_index;
-       unsigned first_row;
-       unsigned max_scroll;
-       unsigned view_rows;
-       unsigned view_columns;
-       const Part *items_part;
-       bool ignore_slider_change;
-       bool dragging;
-       int drag_start_x;
-       int drag_start_y;
+       ListData *data = nullptr;
+       bool own_data = false;
+       DataObserver *observer = nullptr;
+       ItemFactory *item_factory = nullptr;
+       ViewMode view_mode = LIST;
+       int sel_index = -1;
+       int focus_index = -1;
+       unsigned first_row = 0;
+       unsigned max_scroll = 0;
+       unsigned view_rows = 5;
+       unsigned view_columns = 5;
+       const Part *items_part = nullptr;
+       bool ignore_slider_change = false;
+       bool dragging = false;
+       int drag_start_x = 0;
+       int drag_start_y = 0;
 
        VSlider slider;
        std::vector<Item *> items;
@@ -181,15 +180,12 @@ private:
 public:
        List();
        List(ListData &);
-private:
-       void init();
-public:
        virtual ~List();
 
-       virtual const char *get_class() const { return "list"; }
+       const char *get_class() const override { return "list"; }
 
 private:
-       virtual void autosize_special(const Part &, Geometry &) const;
+       void autosize_special(const Part &, Geometry &) const override;
 
 public:
        void set_data(ListData &);
@@ -220,19 +216,19 @@ public:
 private:
        void set_selected_item(Widget *);
 
-       virtual void rebuild_special(const Part &);
-       virtual void render_special(const Part &, GL::Renderer &) const;
+       void rebuild_special(const Part &) override;
+       void render_special(const Part &, GL::Renderer &) const override;
 
 public:
-       virtual bool key_press(unsigned, unsigned);
-       virtual void button_press(int, int, unsigned);
-       virtual void touch_press(int, int, unsigned);
-       virtual void touch_release(int, int, unsigned);
-       virtual void touch_motion(int, int, unsigned);
-       virtual void focus_in();
-       virtual bool navigate(Navigation);
+       bool key_press(unsigned, unsigned) override;
+       void button_press(int, int, unsigned) override;
+       void touch_press(int, int, unsigned) override;
+       void touch_release(int, int, unsigned) override;
+       void touch_motion(int, int, unsigned) override;
+       void focus_in() override;
+       bool navigate(Navigation) override;
 private:
-       virtual void on_style_change();
+       void on_style_change() override;
 
        void move_focus(Navigation, bool);
        void set_focus_index(int);