]>
Commit | Line | Data |
---|---|---|
caaa4cfd RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: checklst.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
ff8bfdbb | 7 | // Licence: wxWindows licence |
caaa4cfd RR |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "checklst.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/checklst.h" | |
15 | ||
dcf924a3 RR |
16 | #if wxUSE_CHECKLISTBOX |
17 | ||
83624f79 RR |
18 | #include "gdk/gdk.h" |
19 | #include "gtk/gtk.h" | |
20 | ||
caaa4cfd RR |
21 | //----------------------------------------------------------------------------- |
22 | // wxCheckListBox | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
25 | IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox) | |
26 | ||
88ac883a | 27 | wxCheckListBox::wxCheckListBox() : wxListBox() |
caaa4cfd RR |
28 | { |
29 | m_hasCheckBoxes = TRUE; | |
30 | } | |
bbe0af5b | 31 | |
caaa4cfd | 32 | wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id, |
bbe0af5b RR |
33 | const wxPoint& pos, |
34 | const wxSize& size, | |
3f263f45 VZ |
35 | int nStrings, |
36 | const wxString *choices, | |
bbe0af5b RR |
37 | long style, |
38 | const wxValidator& validator, | |
39 | const wxString& name ) | |
caaa4cfd RR |
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 | { | |
93c5dd39 | 47 | wxCHECK_MSG( m_list != NULL, FALSE, _T("invalid checklistbox") ); |
ff8bfdbb | 48 | |
caaa4cfd RR |
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 ); | |
ff8bfdbb | 54 | |
002f4218 | 55 | wxString str = wxString(label->label,*wxConv_current); |
ff8bfdbb | 56 | |
002f4218 | 57 | return (str[1] == _T('X')); |
caaa4cfd | 58 | } |
ff8bfdbb | 59 | |
93c5dd39 | 60 | wxFAIL_MSG(_T("wrong checklistbox index")); |
caaa4cfd RR |
61 | return FALSE; |
62 | } | |
63 | ||
64 | void wxCheckListBox::Check( int index, bool check ) | |
65 | { | |
93c5dd39 | 66 | wxCHECK_RET( m_list != NULL, _T("invalid checklistbox") ); |
ff8bfdbb | 67 | |
caaa4cfd RR |
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 ); | |
ff8bfdbb | 73 | |
dcf924a3 | 74 | wxString str = wxString(label->label,*wxConvCurrent); |
ff8bfdbb | 75 | |
93c5dd39 | 76 | if (check == (str[1] == _T('X'))) return; |
ff8bfdbb VZ |
77 | |
78 | if (check) | |
93c5dd39 | 79 | str.SetChar( 1, _T('X') ); |
ff8bfdbb | 80 | else |
93c5dd39 | 81 | str.SetChar( 1, _T('-') ); |
ff8bfdbb | 82 | |
93c5dd39 | 83 | gtk_label_set( label, str.mbc_str() ); |
ff8bfdbb VZ |
84 | |
85 | return; | |
caaa4cfd | 86 | } |
ff8bfdbb | 87 | |
93c5dd39 | 88 | wxFAIL_MSG(_T("wrong checklistbox index")); |
caaa4cfd RR |
89 | } |
90 | ||
ff8bfdbb | 91 | int wxCheckListBox::GetItemHeight() const |
4f22cf8d | 92 | { |
ff8bfdbb | 93 | // FIXME |
4f22cf8d RR |
94 | return 22; |
95 | } | |
dcf924a3 RR |
96 | |
97 | #endif |