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