]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/checklst.cpp
Same typo.
[wxWidgets.git] / src / gtk / 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/defs.h"
15
16 #if wxUSE_CHECKLISTBOX
17
18 #include "wx/checklst.h"
19 #include "wx/gtk/private.h"
20
21 #include <gdk/gdk.h>
22 #include <gtk/gtk.h>
23
24 //-----------------------------------------------------------------------------
25 // wxCheckListBox
26 //-----------------------------------------------------------------------------
27
28 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
29
30 wxCheckListBox::wxCheckListBox() : wxListBox()
31 {
32 m_hasCheckBoxes = TRUE;
33 }
34
35 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
36 const wxPoint& pos,
37 const wxSize& size,
38 int nStrings,
39 const wxString *choices,
40 long style,
41 const wxValidator& validator,
42 const wxString& name )
43 {
44 m_hasCheckBoxes = TRUE;
45 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
46 }
47
48 bool wxCheckListBox::IsChecked( int index ) const
49 {
50 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
51
52 GList *child = g_list_nth( m_list->children, index );
53 if (child)
54 {
55 GtkBin *bin = GTK_BIN( child->data );
56 GtkLabel *label = GTK_LABEL( bin->child );
57
58 wxString str( wxGTK_CONV_BACK( label->label ) );
59
60 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
61 }
62
63 wxFAIL_MSG(wxT("wrong checklistbox index"));
64 return FALSE;
65 }
66
67 void wxCheckListBox::Check( int index, bool check )
68 {
69 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
70
71 GList *child = g_list_nth( m_list->children, index );
72 if (child)
73 {
74 GtkBin *bin = GTK_BIN( child->data );
75 GtkLabel *label = GTK_LABEL( bin->child );
76
77 wxString str( wxGTK_CONV_BACK( label->label ) );
78
79 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
80 return;
81
82 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
83
84 gtk_label_set( label, wxGTK_CONV( str ) );
85
86 return;
87 }
88
89 wxFAIL_MSG(wxT("wrong checklistbox index"));
90 }
91
92 int wxCheckListBox::GetItemHeight() const
93 {
94 // FIXME
95 return 22;
96 }
97
98 #endif