]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
Ensure that the native font is initialized so the face name and such
[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
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
51bool wxCheckListBox::IsChecked( int index ) const
52{
223d09f6 53 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
ff8bfdbb 54
caaa4cfd
RR
55 GList *child = g_list_nth( m_list->children, index );
56 if (child)
57 {
58 GtkBin *bin = GTK_BIN( child->data );
59 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 60
fab591c5 61 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 62
d752a3c3 63 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 64 }
ff8bfdbb 65
223d09f6 66 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
67 return FALSE;
68}
69
70void wxCheckListBox::Check( int index, bool check )
71{
223d09f6 72 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 73
caaa4cfd
RR
74 GList *child = g_list_nth( m_list->children, index );
75 if (child)
76 {
77 GtkBin *bin = GTK_BIN( child->data );
78 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 79
fab591c5 80 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 81
d752a3c3
VZ
82 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
83 return;
ff8bfdbb 84
d752a3c3 85 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 86
fab591c5 87 gtk_label_set( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
88
89 return;
caaa4cfd 90 }
ff8bfdbb 91
223d09f6 92 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
93}
94
ff8bfdbb 95int wxCheckListBox::GetItemHeight() const
4f22cf8d 96{
ff8bfdbb 97 // FIXME
4f22cf8d
RR
98 return 22;
99}
dcf924a3
RR
100
101#endif