]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
wxMenu::Insert() seems to work, bug in wxMenuBase::Insert() is corrected
[wxWidgets.git] / src / gtk / 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
dcf924a3
RR
16#if wxUSE_CHECKLISTBOX
17
071a2d78
RR
18#include <gdk/gdk.h>
19#include <gtk/gtk.h>
83624f79 20
caaa4cfd
RR
21//-----------------------------------------------------------------------------
22// wxCheckListBox
23//-----------------------------------------------------------------------------
24
25IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
26
88ac883a 27wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
28{
29 m_hasCheckBoxes = TRUE;
30}
bbe0af5b 31
caaa4cfd 32wxCheckListBox::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
45bool wxCheckListBox::IsChecked( int index ) const
46{
223d09f6 47 wxCHECK_MSG( m_list != NULL, FALSE, wxT("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
9b7e522a 55 wxString str = wxString(label->label,*wxConvCurrent);
ff8bfdbb 56
11e1c70d 57 return (str.GetChar(1) == wxT('X'));
caaa4cfd 58 }
ff8bfdbb 59
223d09f6 60 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
61 return FALSE;
62}
63
64void wxCheckListBox::Check( int index, bool check )
65{
223d09f6 66 wxCHECK_RET( m_list != NULL, wxT("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
11e1c70d 76 if (check == (str.GetChar(1) == wxT('X'))) return;
ff8bfdbb
VZ
77
78 if (check)
223d09f6 79 str.SetChar( 1, wxT('X') );
ff8bfdbb 80 else
223d09f6 81 str.SetChar( 1, wxT('-') );
ff8bfdbb 82
93c5dd39 83 gtk_label_set( label, str.mbc_str() );
ff8bfdbb
VZ
84
85 return;
caaa4cfd 86 }
ff8bfdbb 87
223d09f6 88 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
89}
90
ff8bfdbb 91int wxCheckListBox::GetItemHeight() const
4f22cf8d 92{
ff8bfdbb 93 // FIXME
4f22cf8d
RR
94 return 22;
95}
dcf924a3
RR
96
97#endif