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