File: mainfrm.h

package info (click to toggle)
freespace2 25.0.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 47,232 kB
  • sloc: cpp: 657,500; ansic: 22,305; sh: 293; python: 200; makefile: 198; xml: 181
file content (206 lines) | stat: -rw-r--r-- 4,691 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#ifndef _MAINFRM_H
#define _MAINFRM_H
/*
 * Copyright (C) Volition, Inc. 1999.  All rights reserved.
 *
 * All source code herein is the property of Volition, Inc. You may not sell
 * or otherwise commercially exploit the source or things you created based on the
 * source.
 *
 */



#define	WM_MENU_POPUP_TEST	(WM_USER+9)

/**
 * @class color_combo_box
 *
 * @brief Our flavor of the combo box, Items are highlighted with their species color.
 *
 * @detail Shivans are Red, Terrans are blue, the Vasudans are green, and uh, FRED loves you? Such a terrible ryhme.
 *  Er, anyway. The colors for each species are defined in their respective species_info, which is from species_defs.tbl
 *
 * @TODO Maybe move this to its own .h and .cpp
 */
class color_combo_box : public CComboBox
{
public:
	/**
	 * Gets the ship class corresponding to the item index
	 */
	int GetShipClass(int item_index);

	/**
	 * Gets the item index corresponding to the ship class
	 */
	int GetItemIndex(int ship_class);

private:
	/**
	 * @brief Draws the given item
	 *
	 * @param[in] lpDrawItemStruct Item to draw
	 */
	void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);

	/**
	 * @brief Calculates the minimum height required to fit all items. This is determined by the "tallest" character
	 */
	int  CalcMinimumItemHeight();

	/**
	 * @brief Measures the given item
	 *
	 * @details Er, actually does nothing other than Assert that the style of the combo box is LBS_ONWERDRAWFIXED and CBS_HASSTRINGS
	 */
	void MeasureItem(LPMEASUREITEMSTRUCT);
};

/**
 * @class CMainFrame
 *
 * @brief The main FRED window
 */
class CMainFrame : public CFrameWnd
{
public:

	void init_tools();

	/**
	 * @breif Standard deconstructor
	 */
	virtual ~CMainFrame();

	//{{AFX_VIRTUAL(CMainFrame)
	/**
	 * @brief Handler for pre-creation
	 *
	 * @details Can alter the window styles from this function. Currently we just pass the CS on to CFrameWnd
	 */
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

#ifdef _DEBUG
	/**
	 * @brief Asserts the window is valid
	 */
	virtual void AssertValid() const;

	/**
	 * @brief Presumably called when a stack dump is required
	 */
	virtual void Dump(CDumpContext& dc) const;
#endif

	CToolBar    m_wndToolBar;   //!< Instance of the tool bar
	CStatusBar  m_wndStatusBar; //!< Instance of the status bar

protected:
	/**
	 * @brief Constructor. Create from serialization only
	 */
	CMainFrame();
	DECLARE_DYNCREATE(CMainFrame)

	//{{AFX_MSG(CMainFrame)
	/**
	 * @brief OnCreate Handler. Creates the frame, toolbar, status bar, etc.
	 */
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

	/**
	 * @brief Opens the CMissionNotes dialog
	 */
	afx_msg void OnFileMissionnotes();

	/**
	 * @brief Handler for LButtonUp events
	 *
	 * @note Seems to be dead code
	 * @TODO Verify and remove
	 */
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);

	/**
	 * @brief OnDestroy handler. Invoked when the Close button is clicked or from File->Exit
	 */
	afx_msg void OnDestroy();

	/**
	 * @brief Handler for View->Status Bar. Shows/Hides the status bar
	 */
	afx_msg void OnViewStatusBar();

	/**
	 * @brief Checks/unchecks the Status Bar menu item on the View menu
	 */
	afx_msg void OnUpdateViewStatusBar(CCmdUI* pCmdUI);

	/**
	 * @brief Called when the Left Mouse Button is pressed
	 */
	afx_msg void OnUpdateLeft(CCmdUI* pCmdUI);

	/**
	 * @brief Called when the Right Mouse Button is pressed
	 */
	afx_msg void OnUpdateRight(CCmdUI* pCmdUI);

	/**
	 * @brief Handler for Misc->Adjust Grid
	 */
	afx_msg void OnMikeGridcontrol();

	/**
	 * @brief Toggles the popup menu variable
	 */
	afx_msg void OnMenuPopupToggle1();

	/**
	 * @brief
	 */
	afx_msg void OnUpdateMenuPopupToggle1(CCmdUI* pCmdUI);

	/**
	 * @brief Handler for Right button clicks. Shows a popup menu at the mouse cursor's location
	 */
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);

	/**
	 * @brief Handler for OnClose() events. called by ON_WM_CLOSE()
	 */
	afx_msg void OnClose();

	/**
	 * @brief Handler for menu intialiation
	 */
	afx_msg void OnInitMenu(CMenu* pMenu);

	/**
	 * @brief Handler for Help->Help Topics. Opens .html documentation in the default browser
	 */
	afx_msg void OnFredHelp();
	//}}AFX_MSG

	/**
	 * @brief Handler for when the combobox selection changes. Brings the main FRED window back infocus
	 */
	afx_msg void OnNewShipTypeChange();

	/**
	 * @brief Related to the popup menu
	 */
	LRESULT OnMenuPopupTest(WPARAM wParam, LPARAM lParam);

	DECLARE_MESSAGE_MAP()
};


extern CMainFrame *Fred_main_wnd;   //!< The main FRED window

extern color_combo_box m_new_ship_type_combo_box;  //!< The combo box
extern size_t ship_type_combo_box_size;

#endif // _MAINFRM_H