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