summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/ComboList.h
blob: 9a4f25ce2b41ceb2b2e33749203547e4dc96617d (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*  Starshatter: The Open Source Project
    Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors
    Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
    Copyright (c) 1997-2006, Destroyer Studios LLC.

    AUTHOR:       John DiCamillo


    OVERVIEW
    ========
    ComboList class
*/

#ifndef ComboList_h
#define ComboList_h

#include "Types.h"
#include "ScrollWindow.h"
#include "Bitmap.h"

#include "List.h"
#include "Text.h"

// +--------------------------------------------------------------------+

class ComboBox;

// +--------------------------------------------------------------------+

class ComboList : public ScrollWindow
{
public:
    static const char* TYPENAME() { return "ComboList"; }

    ComboList(ComboBox* ctrl, ActiveWindow* p, int ax, int ay, int aw, int ah, int maxentries);
    ComboList(ComboBox* ctrl, Screen* s,       int ax, int ay, int aw, int ah, int maxentries);
    virtual ~ComboList();

    // Operations:
    virtual void         Draw();
    virtual void         Show();
    virtual void         Hide();

    // Event Target Interface:
    virtual int          OnMouseMove(int x, int y);
    virtual int          OnLButtonDown(int x, int y);
    virtual int          OnLButtonUp(int x, int y);
    virtual int          OnClick();
    virtual int          OnMouseEnter(int x, int y);
    virtual int          OnMouseExit(int x, int y);
    virtual void         KillFocus();

    // Property accessors:
    virtual void         ClearItems();
    virtual void         AddItem(const char* item);
    virtual void         AddItems(ListIter<Text> item_list);
    virtual void         SetItems(ListIter<Text> item_list);
    virtual const char*  GetItem(int index);
    virtual void         SetItem(int index, const char* item);

    virtual int          GetCount();
    virtual const char*  GetSelectedItem();
    virtual int          GetSelectedIndex();
    virtual void         SetSelection(int index);

protected:
    void  DrawRectSimple(Rect& rect, int stat);
    void  DrawItem(Text label, Rect& btn_rect, int state);
    Rect  CalcLabelRect(const Rect& btn_rect);
    int   CalcSeln(int x, int y);
    void  CopyStyle(const ComboBox& ctrl);

    ComboBox*      combo_box;
    List<Text>     items;
    bool           animated;
    bool           border;
    int            seln;
    int            captured;
    int            bevel_width;
    int            button_state;
    int            button_height;
    int            max_entries;
    int            scroll;
    int            scrolling;

    Color          active_color;
    Color          border_color;
};

#endif  // ComboList_h