]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/checklst.cpp
improved selection-autodeletion, but backspace handling not perfect
[wxWidgets.git] / src / gtk1 / checklst.cpp
CommitLineData
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
83624f79
RR
16#include "gdk/gdk.h"
17#include "gtk/gtk.h"
18
caaa4cfd
RR
19//-----------------------------------------------------------------------------
20// wxCheckListBox
21//-----------------------------------------------------------------------------
22
23IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
24
88ac883a 25wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
26{
27 m_hasCheckBoxes = TRUE;
28}
bbe0af5b 29
caaa4cfd 30wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
bbe0af5b
RR
31 const wxPoint& pos,
32 const wxSize& size,
3f263f45
VZ
33 int nStrings,
34 const wxString *choices,
bbe0af5b
RR
35 long style,
36 const wxValidator& validator,
37 const wxString& name )
caaa4cfd
RR
38{
39 m_hasCheckBoxes = TRUE;
40 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
41}
42
43bool wxCheckListBox::IsChecked( int index ) const
44{
93c5dd39 45 wxCHECK_MSG( m_list != NULL, FALSE, _T("invalid checklistbox") );
ff8bfdbb 46
caaa4cfd
RR
47 GList *child = g_list_nth( m_list->children, index );
48 if (child)
49 {
50 GtkBin *bin = GTK_BIN( child->data );
51 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb
VZ
52
53 wxString str = label->label;
54
caaa4cfd
RR
55 return (str[1] == 'X');
56 }
ff8bfdbb 57
93c5dd39 58 wxFAIL_MSG(_T("wrong checklistbox index"));
caaa4cfd
RR
59 return FALSE;
60}
61
62void wxCheckListBox::Check( int index, bool check )
63{
93c5dd39 64 wxCHECK_RET( m_list != NULL, _T("invalid checklistbox") );
ff8bfdbb 65
caaa4cfd
RR
66 GList *child = g_list_nth( m_list->children, index );
67 if (child)
68 {
69 GtkBin *bin = GTK_BIN( child->data );
70 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb
VZ
71
72 wxString str = label->label;
73
93c5dd39 74 if (check == (str[1] == _T('X'))) return;
ff8bfdbb
VZ
75
76 if (check)
93c5dd39 77 str.SetChar( 1, _T('X') );
ff8bfdbb 78 else
93c5dd39 79 str.SetChar( 1, _T('-') );
ff8bfdbb 80
93c5dd39 81 gtk_label_set( label, str.mbc_str() );
ff8bfdbb
VZ
82
83 return;
caaa4cfd 84 }
ff8bfdbb 85
93c5dd39 86 wxFAIL_MSG(_T("wrong checklistbox index"));
caaa4cfd
RR
87}
88
ff8bfdbb 89int wxCheckListBox::GetItemHeight() const
4f22cf8d 90{
ff8bfdbb 91 // FIXME
4f22cf8d
RR
92 return 22;
93}