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