]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/checklst.cpp
placeholder
[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
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
caaa4cfd
RR
11#pragma implementation "checklst.h"
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
1e6feb95 17#include "wx/defs.h"
caaa4cfd 18
dcf924a3
RR
19#if wxUSE_CHECKLISTBOX
20
1e6feb95 21#include "wx/checklst.h"
fab591c5 22#include "wx/gtk/private.h"
1e6feb95 23
071a2d78
RR
24#include <gdk/gdk.h>
25#include <gtk/gtk.h>
83624f79 26
caaa4cfd
RR
27//-----------------------------------------------------------------------------
28// wxCheckListBox
29//-----------------------------------------------------------------------------
30
31IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
32
88ac883a 33wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
34{
35 m_hasCheckBoxes = TRUE;
36}
bbe0af5b 37
caaa4cfd 38wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
d752a3c3
VZ
39 const wxPoint& pos,
40 const wxSize& size,
41 int nStrings,
42 const wxString *choices,
43 long style,
44 const wxValidator& validator,
45 const wxString& name )
caaa4cfd
RR
46{
47 m_hasCheckBoxes = TRUE;
48 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
49}
50
584ad2a3
MB
51wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
52 const wxPoint& pos,
53 const wxSize& size,
54 const wxArrayString& choices,
55 long style,
56 const wxValidator& validator,
57 const wxString& name )
58{
59 m_hasCheckBoxes = TRUE;
60 wxListBox::Create( parent, id, pos, size, choices,
61 style, validator, name );
62}
63
caaa4cfd
RR
64bool wxCheckListBox::IsChecked( int index ) const
65{
223d09f6 66 wxCHECK_MSG( m_list != NULL, FALSE, 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
fab591c5 74 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 75
d752a3c3 76 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 77 }
ff8bfdbb 78
223d09f6 79 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
80 return FALSE;
81}
82
83void wxCheckListBox::Check( int index, bool check )
84{
223d09f6 85 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 86
caaa4cfd
RR
87 GList *child = g_list_nth( m_list->children, index );
88 if (child)
89 {
90 GtkBin *bin = GTK_BIN( child->data );
91 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 92
fab591c5 93 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 94
d752a3c3
VZ
95 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
96 return;
ff8bfdbb 97
d752a3c3 98 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 99
fab591c5 100 gtk_label_set( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
101
102 return;
caaa4cfd 103 }
ff8bfdbb 104
223d09f6 105 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
106}
107
ff8bfdbb 108int wxCheckListBox::GetItemHeight() const
4f22cf8d 109{
ff8bfdbb 110 // FIXME
4f22cf8d
RR
111 return 22;
112}
dcf924a3
RR
113
114#endif