]> icculus.org git repositories - taylor/freespace2.git/blob - src/fred2/shipchecklistbox.cpp
The Great Newline Fix
[taylor/freespace2.git] / src / fred2 / shipchecklistbox.cpp
1 /*
2  * $Logfile: /Freespace2/code/FRED2/ShipCheckListBox.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * A custom check list box class that allows space bar to toggle the state of all
8  * the selected checkboxes.
9  *
10  * $Log$
11  * Revision 1.2  2002/05/07 03:16:44  theoddone33
12  * The Great Newline Fix
13  *
14  * Revision 1.1.1.1  2002/05/03 03:28:08  root
15  * Initial import.
16  *
17  * 
18  * 2     10/07/98 6:28p Dave
19  * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
20  * Fred. Globalized mission and campaign file extensions. Removed Silent
21  * Threat specific code.
22  * 
23  * 1     10/07/98 3:01p Dave
24  * 
25  * 1     10/07/98 3:00p Dave
26  * 
27  * 4     2/17/97 5:28p Hoffoss
28  * Checked RCS headers, added them were missing, changing description to
29  * something better, etc where needed.
30  *
31  * $NoKeywords: $
32  */
33
34 #include "stdafx.h"
35 #include "shipchecklistbox.h"
36
37 BEGIN_MESSAGE_MAP(ShipCheckListBox, CCheckListBox)
38         //{{AFX_MSG_MAP(CCheckListBox)
39         ON_WM_KEYDOWN()
40         //}}AFX_MSG_MAP
41 END_MESSAGE_MAP()
42
43 BOOL ShipCheckListBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
44 {
45         BOOL b;
46
47         b = CCheckListBox::Create(LBS_OWNERDRAWFIXED | dwStyle, rect, pParentWnd, nID);
48         SetCheckStyle(BS_AUTOCHECKBOX);
49         return b;
50 }
51
52 void ShipCheckListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
53 {
54         if (nChar == VK_SPACE)
55         {
56                 int i, list_size;
57
58                 list_size = GetCount();
59                 for (i=0; i<list_size; i++)
60                         if (GetSel(i) > 0)
61                         {
62                                 if (GetCheck(i))
63                                         SetCheck(i, 0);
64                                 else
65                                         SetCheck(i, 1);
66                         }
67
68         } else
69                 CCheckListBox::OnKeyDown(nChar, nRepCnt, nFlags);
70 }
71