Debian Codegraph @

editor/GrListBox.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/GrListBox.h $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:38 $
23 * $Author: kevinb $
24 *
25 * New graphical listbox
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 4 9/04/97 4:39p Matt
30 * Added includes needed as a result of removing includes from d3edit.h
31 *
32 * 3 8/26/97 10:49a Samir
33 * Fixed some small bugs with the scroll bar.
34 *
35 * $NoKeywords: $
36 */
37
38 #if !defined(AFX_GRLISTBOX_H__12166D61_1D56_11D1_BDA4_00A0C96ED595__INCLUDED_)
39 #define AFX_GRLISTBOX_H__12166D61_1D56_11D1_BDA4_00A0C96ED595__INCLUDED_
40
41 #include "gr.h"
42
43 #if _MSC_VER >= 1000
44 #pragma once
45 #endif // _MSC_VER >= 1000
46 // GrListBox.h : header file
47 //
48
49 /////////////////////////////////////////////////////////////////////////////
50 // CGrListBox window
51
52 class CGrListBox : public CWnd {
53 // Construction
54 public:
55 CGrListBox();
56
57 // if selbox is true, then we use a rectangle to hilite the selection.
58 BOOL Create(CWnd *parent_wnd, int id, const RECT &rect, int surf_dim, bool selbox = false);
59
60 // Internal management functions
61 private:
62 // draws all the items in the list (or not). invoking DrawItem and uses the list management functions
63 // also performs check of mouse selection (the reason we give an option NOT to draw it.)
64 void ListBoxProc(bool do_draw);
65
66 // these functions move the list pointer (m_ListItem) up or down a few rows.
67 // optional to refresh display, and returns true if m_ItemSel is in row.
68 bool RowUp(int rows, bool draw = true);
69 bool RowDown(int rows, bool draw = true);
70 int CalcRowOfItem(int item);
71
72 private:
73 int m_ItemSel; // selected item number.
74 int m_HitX, m_HitY; // used to select an item in box via mouse down.
75 bool m_CheckHit; // check for a hit.
76 int m_ScrollPos; // used to check scroll bar
77 bool m_SelectionBox; // do we use the selection box, or scale selection aid.
78 bool m_IsItemSelInBox; // is item selected being displayed?
79
80 // Attributes
81 public:
82 int GetSelectedItem() const { return m_ItemSel; };
83 void SelectItem(int item);
84 void SetItemFirst(int item); // these are accessor functions to the variable m_ListItem.
85 int GetItemFirst() const; // this value is the first item to be drawn in the list box currently.
86
87 // Operations
88 public:
89 // Overrides
90 // ClassWizard generated virtual function overrides
91 //{{AFX_VIRTUAL(CGrListBox)
92 //}}AFX_VIRTUAL
93
94 // Implementation
95 public:
96 virtual ~CGrListBox();
97
98 // Generated message map functions
99 protected:
100 //{{AFX_MSG(CGrListBox)
101 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
102 afx_msg void OnPaint();
103 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar);
104 //}}AFX_MSG
105 DECLARE_MESSAGE_MAP()
106
107 // List management overridables
108 protected:
109 // enumerates items maximum in the list box. this is here to insure that any changes in
110 // the user-managed list.
111 virtual int ListEnumerate() = 0;
112
113 // Specify the first item to be drawn in the box by DrawItem. returns the item #
114 // return -1 if there is no first item (list is empty, maybe)
115 virtual int ListFirstItem(int firstitem) = 0;
116
117 // Specify the next/prev item to be drawn in the box by DrawItem.
118 // Returns the item # following or preceding the passed the item #
119 virtual int ListNextItem(int curitem) = 0;
120 virtual int ListPrevItem(int curitem) = 0;
121
122 // Current first item in box displayed. We are allowed to modify this.
123 int m_ListItem;
124
125 private:
126 int m_ListLen; // number of list items in list box total
127 int items_per_row, items_max_row; // dimensions of listbox in listbox items.
128
129 // Drawing overridables
130 protected:
131 virtual void DrawItem(int x, int y, grHardwareSurface *itemsurf, int item) = 0;
132
133 private:
134 int m_SurfDimension; // Square dimensions of visible item.
135
136 // miscellaneous overridables
137 protected:
138 // if item was selected from the list box, this function is invoked.
139 virtual void OnItemSelected(int item) = 0;
140 };
141
142 /////////////////////////////////////////////////////////////////////////////
143
144 //{{AFX_INSERT_LOCATION}}
145 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
146
147 #endif // !defined(AFX_GRLISTBOX_H__12166D61_1D56_11D1_BDA4_00A0C96ED595__INCLUDED_)