]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
compilation fix for yet another broken version of mingw (ENSESSION_LOGOFF not defined)
[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
1e6feb95 14#include "wx/defs.h"
caaa4cfd 15
dcf924a3
RR
16#if wxUSE_CHECKLISTBOX
17
1e6feb95 18#include "wx/checklst.h"
fab591c5 19#include "wx/gtk/private.h"
1e6feb95 20
071a2d78
RR
21#include <gdk/gdk.h>
22#include <gtk/gtk.h>
83624f79 23
caaa4cfd
RR
24//-----------------------------------------------------------------------------
25// wxCheckListBox
26//-----------------------------------------------------------------------------
27
28IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
29
88ac883a 30wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
31{
32 m_hasCheckBoxes = TRUE;
33}
bbe0af5b 34
caaa4cfd 35wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
d752a3c3
VZ
36 const wxPoint& pos,
37 const wxSize& size,
38 int nStrings,
39 const wxString *choices,
40 long style,
41 const wxValidator& validator,
42 const wxString& name )
caaa4cfd
RR
43{
44 m_hasCheckBoxes = TRUE;
45 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
46}
47
48bool wxCheckListBox::IsChecked( int index ) const
49{
223d09f6 50 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
ff8bfdbb 51
caaa4cfd
RR
52 GList *child = g_list_nth( m_list->children, index );
53 if (child)
54 {
55 GtkBin *bin = GTK_BIN( child->data );
56 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 57
fab591c5 58 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 59
d752a3c3 60 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 61 }
ff8bfdbb 62
223d09f6 63 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
64 return FALSE;
65}
66
67void wxCheckListBox::Check( int index, bool check )
68{
223d09f6 69 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 70
caaa4cfd
RR
71 GList *child = g_list_nth( m_list->children, index );
72 if (child)
73 {
74 GtkBin *bin = GTK_BIN( child->data );
75 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 76
fab591c5 77 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 78
d752a3c3
VZ
79 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
80 return;
ff8bfdbb 81
d752a3c3 82 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 83
fab591c5 84 gtk_label_set( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
85
86 return;
caaa4cfd 87 }
ff8bfdbb 88
223d09f6 89 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
90}
91
ff8bfdbb 92int wxCheckListBox::GetItemHeight() const
4f22cf8d 93{
ff8bfdbb 94 // FIXME
4f22cf8d
RR
95 return 22;
96}
dcf924a3
RR
97
98#endif