summaryrefslogtreecommitdiffhomepage
path: root/nGenEx/ComboList.h
blob: e288ec9f0e83b1cddc5f4a8032eac7f1a613e00b (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
92
/*  Project nGenEx
	Destroyer Studios LLC
	Copyright © 1997-2004. All Rights Reserved.

	SUBSYSTEM:    nGenEx.lib
	FILE:         ComboList.h
	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