The Unicode handling fixes my app seemed to need.
[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() : wxListBox()
26 {
27 m_hasCheckBoxes = TRUE;
28 }
29
30 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
31 const wxPoint& pos,
32 const wxSize& size,
33 int nStrings,
34 const wxString *choices,
35 long style,
36 const wxValidator& validator,
37 const wxString& name )
38 {
39 m_hasCheckBoxes = TRUE;
40 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
41 }
42
43 bool wxCheckListBox::IsChecked( int index ) const
44 {
45 wxCHECK_MSG( m_list != NULL, FALSE, _T("invalid checklistbox") );
46
47 GList *child = g_list_nth( m_list->children, index );
48 if (child)
49 {
50 GtkBin *bin = GTK_BIN( child->data );
51 GtkLabel *label = GTK_LABEL( bin->child );
52
53 wxString str = wxString(label->label,*wxConv_current);
54
55 return (str[1] == _T('X'));
56 }
57
58 wxFAIL_MSG(_T("wrong checklistbox index"));
59 return FALSE;
60 }
61
62 void wxCheckListBox::Check( int index, bool check )
63 {
64 wxCHECK_RET( m_list != NULL, _T("invalid checklistbox") );
65
66 GList *child = g_list_nth( m_list->children, index );
67 if (child)
68 {
69 GtkBin *bin = GTK_BIN( child->data );
70 GtkLabel *label = GTK_LABEL( bin->child );
71
72 wxString str = wxString(label->label,*wxConv_current);
73
74 if (check == (str[1] == _T('X'))) return;
75
76 if (check)
77 str.SetChar( 1, _T('X') );
78 else
79 str.SetChar( 1, _T('-') );
80
81 gtk_label_set( label, str.mbc_str() );
82
83 return;
84 }
85
86 wxFAIL_MSG(_T("wrong checklistbox index"));
87 }
88
89 int wxCheckListBox::GetItemHeight() const
90 {
91 // FIXME
92 return 22;
93 }