]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
old makefiles removed
[wxWidgets.git] / src / gtk1 / checklst.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: checklst.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "checklst.h"
12 #endif
13
14 #include "wx/checklst.h"
15
16 #include "gdk/gdk.h"
17 #include "gtk/gtk.h"
18
19 //-----------------------------------------------------------------------------
20 // wxCheckListBox
21 //-----------------------------------------------------------------------------
22
23 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
24
25 wxCheckListBox::wxCheckListBox() :
26 wxListBox()
27 {
28 m_hasCheckBoxes = TRUE;
29 }
30
31 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
32 const wxPoint& pos,
33 const wxSize& size,
34 int nStrings,
35 const wxString *choices,
36 long style,
37 const wxValidator& validator,
38 const wxString& name )
39 {
40 m_hasCheckBoxes = TRUE;
41 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
42 }
43
44 bool wxCheckListBox::IsChecked( int index ) const
45 {
46 wxCHECK_MSG( m_list != NULL, FALSE, _T("invalid checklistbox") );
47
48 GList *child = g_list_nth( m_list->children, index );
49 if (child)
50 {
51 GtkBin *bin = GTK_BIN( child->data );
52 GtkLabel *label = GTK_LABEL( bin->child );
53
54 wxString str = label->label;
55
56 return (str[1] == 'X');
57 }
58
59 wxFAIL_MSG(_T("wrong checklistbox index"));
60 return FALSE;
61 }
62
63 void wxCheckListBox::Check( int index, bool check )
64 {
65 wxCHECK_RET( m_list != NULL, _T("invalid checklistbox") );
66
67 GList *child = g_list_nth( m_list->children, index );
68 if (child)
69 {
70 GtkBin *bin = GTK_BIN( child->data );
71 GtkLabel *label = GTK_LABEL( bin->child );
72
73 wxString str = label->label;
74
75 if (check == (str[1] == _T('X'))) return;
76
77 if (check)
78 str.SetChar( 1, _T('X') );
79 else
80 str.SetChar( 1, _T('-') );
81
82 gtk_label_set( label, str.mbc_str() );
83
84 return;
85 }
86
87 wxFAIL_MSG(_T("wrong checklistbox index"));
88 }
89
90 int wxCheckListBox::GetItemHeight() const
91 {
92 // FIXME
93 return 22;
94 }