The rounded corners look really dumb at this size.
[wxWidgets.git] / src / gtk1 / checklst.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/checklst.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #if wxUSE_CHECKLISTBOX
13
14 #include "wx/checklst.h"
15 #include "wx/gtk1/private.h"
16
17 #include <gdk/gdk.h>
18 #include <gtk/gtk.h>
19
20 //-----------------------------------------------------------------------------
21 // wxCheckListBox
22 //-----------------------------------------------------------------------------
23
24 wxCheckListBox::wxCheckListBox() : wxCheckListBoxBase()
25 {
26 m_hasCheckBoxes = true;
27 }
28
29 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
30 const wxPoint& pos,
31 const wxSize& size,
32 int nStrings,
33 const wxString *choices,
34 long style,
35 const wxValidator& validator,
36 const wxString& name )
37 {
38 m_hasCheckBoxes = true;
39 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
40 }
41
42 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
43 const wxPoint& pos,
44 const wxSize& size,
45 const wxArrayString& choices,
46 long style,
47 const wxValidator& validator,
48 const wxString& name )
49 {
50 m_hasCheckBoxes = true;
51 wxListBox::Create( parent, id, pos, size, choices,
52 style, validator, name );
53 }
54
55 bool wxCheckListBox::IsChecked(unsigned int index) const
56 {
57 wxCHECK_MSG( m_list != NULL, false, wxT("invalid checklistbox") );
58
59 GList *child = g_list_nth( m_list->children, index );
60 if (child)
61 {
62 GtkBin *bin = GTK_BIN( child->data );
63 GtkLabel *label = GTK_LABEL( bin->child );
64
65 wxString str( wxGTK_CONV_BACK( label->label ) );
66
67 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
68 }
69
70 wxFAIL_MSG(wxT("wrong checklistbox index"));
71 return false;
72 }
73
74 void wxCheckListBox::Check(unsigned int index, bool check )
75 {
76 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
77
78 GList *child = g_list_nth( m_list->children, index );
79 if (child)
80 {
81 GtkBin *bin = GTK_BIN( child->data );
82 GtkLabel *label = GTK_LABEL( bin->child );
83
84 wxString str( wxGTK_CONV_BACK( label->label ) );
85
86 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
87 return;
88
89 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
90
91 gtk_label_set( label, wxGTK_CONV( str ) );
92
93 return;
94 }
95
96 wxFAIL_MSG(wxT("wrong checklistbox index"));
97 }
98
99 int wxCheckListBox::GetItemHeight() const
100 {
101 // FIXME
102 return 22;
103 }
104
105 #endif