]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
Changed code to get rid of a compiler warning about statement always being FALSE
[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,
d752a3c3
VZ
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 )
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
d752a3c3 57 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
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
d752a3c3
VZ
76 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
77 return;
ff8bfdbb 78
d752a3c3 79 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 80
93c5dd39 81 gtk_label_set( label, str.mbc_str() );
ff8bfdbb
VZ
82
83 return;
caaa4cfd 84 }
ff8bfdbb 85
223d09f6 86 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
87}
88
ff8bfdbb 89int wxCheckListBox::GetItemHeight() const
4f22cf8d 90{
ff8bfdbb 91 // FIXME
4f22cf8d
RR
92 return 22;
93}
dcf924a3
RR
94
95#endif