File: list.hpp

package info (click to toggle)
openmw 0.47.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,276 kB
  • sloc: cpp: 249,935; xml: 1,978; sh: 1,327; python: 63; makefile: 26
file content (72 lines) | stat: -rw-r--r-- 2,234 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef OPENMW_COMPONENTS_WIDGETS_LIST_HPP
#define OPENMW_COMPONENTS_WIDGETS_LIST_HPP

#include <MyGUI_ScrollView.h>

namespace Gui
{
    /**
     * \brief a very simple list widget that supports word-wrapping entries
     * \note if the width or height of the list changes, you must call adjustSize() method
     */
    class MWList : public MyGUI::Widget
    {
        MYGUI_RTTI_DERIVED(MWList)
    public:
        MWList();

        typedef MyGUI::delegates::CMultiDelegate2<const std::string&, int> EventHandle_StringInt;
        typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget;

        /**
         * Event: Item selected with the mouse.
         * signature: void method(std::string itemName, int index)
         */
        EventHandle_StringInt eventItemSelected;

        /**
         * Event: Item selected with the mouse.
         * signature: void method(MyGUI::Widget* sender)
         */
        EventHandle_Widget eventWidgetSelected;


        /**
         * Call after the size of the list changed, or items were inserted/removed
         */
        void adjustSize();

        void addItem(const std::string& name);
        void addSeparator(); ///< add a seperator between the current and the next item.
        void removeItem(const std::string& name);
        unsigned int getItemCount();
        std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is
        void clear();

        MyGUI::Button* getItemWidget(const std::string& name);
        ///< get widget for an item name, useful to set up tooltip

        void scrollToTop();

        void setPropertyOverride(const std::string& _key, const std::string& _value) override;

    protected:
        void initialiseOverride() override;

        void redraw(bool scrollbarShown = false);

        void onMouseWheelMoved(MyGUI::Widget* _sender, int _rel);
        void onItemSelected(MyGUI::Widget* _sender);

    private:
        MyGUI::ScrollView* mScrollView;
        MyGUI::Widget* mClient;
        std::string mListItemSkin;

        std::vector<std::string> mItems;

        int mItemHeight; // height of all items
    };
}

#endif