]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
changed Mac Mouse Moved Hysteresis (area in which mouse movements do NOT generate...
[wxWidgets.git] / src / gtk1 / 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) == wxCHECKLBOX_CHECKED;
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) == wxCHECKLBOX_CHECKED))
77 return;
78
79 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
80
81 gtk_label_set( label, str.mbc_str() );
82
83 return;
84 }
85
86 wxFAIL_MSG(wxT("wrong checklistbox index"));
87 }
88
89 int wxCheckListBox::GetItemHeight() const
90 {
91 // FIXME
92 return 22;
93 }
94
95 #endif