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