]> git.saurik.com Git - wxWidgets.git/blame - src/motif/statbox.cpp
Remove now unnecessary comment.
[wxWidgets.git] / src / motif / statbox.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
7520f3da 2// Name: src/motif/statbox.cpp
4bb6408c
JS
3// Purpose: wxStaticBox
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
1248b41f
MB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
4bb6408c 15#include "wx/statbox.h"
de6185e2
WS
16
17#ifndef WX_PRECOMP
18 #include "wx/utils.h"
19#endif
47bc1060 20
338dd992
JJ
21#ifdef __VMS__
22#pragma message disable nosimpint
23#endif
47bc1060 24#include <Xm/Frame.h>
47bc1060 25#include <Xm/Label.h>
338dd992
JJ
26#ifdef __VMS__
27#pragma message enable nosimpint
28#endif
47bc1060 29
3096bd2f 30#include "wx/motif/private.h"
4bb6408c 31
4bb6408c 32BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
31528cd3 33//EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
4bb6408c
JS
34END_EVENT_TABLE()
35
483561c5
MB
36// ----------------------------------------------------------------------------
37// wxXmSizeKeeper
38// ----------------------------------------------------------------------------
39
40// helper class to reduce code duplication
41class wxXmSizeKeeper
42{
43 Dimension m_x, m_y;
44 Widget m_widget;
45public:
46 wxXmSizeKeeper( Widget w )
47 : m_widget( w )
48 {
49 XtVaGetValues( m_widget,
50 XmNwidth, &m_x,
51 XmNheight, &m_y,
52 NULL );
53 }
54
55 void Restore()
56 {
57 int x, y;
58
59 XtVaGetValues( m_widget,
60 XmNwidth, &x,
61 XmNheight, &y,
62 NULL );
63 if( x != m_x || y != m_y )
64 XtVaSetValues( m_widget,
65 XmNwidth, m_x,
66 XmNheight, m_y,
67 NULL );
68 }
69};
4bb6408c
JS
70
71/*
72 * Static box
73 */
31528cd3 74
47bc1060
JS
75wxStaticBox::wxStaticBox()
76{
47bc1060
JS
77 m_labelWidget = (WXWidget) 0;
78}
79
4bb6408c
JS
80bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
81 const wxString& label,
82 const wxPoint& pos,
83 const wxSize& size,
84 long style,
85 const wxString& name)
86{
483561c5
MB
87 if( !CreateControl( parent, id, pos, size, style,
88 wxDefaultValidator, name ) )
89 return false;
105fbe1f
MB
90 m_labelWidget = (WXWidget) 0;
91 PreCreation();
4bb6408c 92
47bc1060
JS
93 Widget parentWidget = (Widget) parent->GetClientWidget();
94
2b5f62a0
VZ
95 m_mainWidget = XtVaCreateManagedWidget ("staticboxframe",
96 xmFrameWidgetClass, parentWidget,
483561c5
MB
97 // MBN: why override default?
98 // XmNshadowType, XmSHADOW_IN,
31528cd3 99 NULL);
47bc1060 100
7520f3da 101 if (!label.empty())
47bc1060 102 {
32cd189d 103 wxString label1(GetLabelText(label));
2b5f62a0 104 wxXmString text(label1);
73608949 105 Display* dpy = XtDisplay( parentWidget );
483561c5
MB
106
107 m_labelWidget = (WXWidget) XtVaCreateManagedWidget ("staticboxlabel",
2b5f62a0 108 xmLabelWidgetClass, (Widget)m_mainWidget,
73608949 109 wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
2b5f62a0 110 XmNlabelString, text(),
483561c5 111#if wxCHECK_MOTIF_VERSION( 2, 0 )
2b5f62a0
VZ
112 XmNframeChildType, XmFRAME_TITLE_CHILD,
113#else
7520f3da 114 XmNchildType, XmFRAME_TITLE_CHILD,
2b5f62a0 115#endif
31528cd3 116 NULL);
47bc1060 117 }
03647350 118
105fbe1f 119 PostCreation();
2b5f62a0 120 AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y);
47bc1060 121
96be256b 122 return true;
4bb6408c
JS
123}
124
b412f9be
JS
125wxStaticBox::~wxStaticBox()
126{
15d5ab67
JS
127 DetachWidget(m_mainWidget);
128 XtDestroyWidget((Widget) m_mainWidget);
15d5ab67
JS
129
130 m_mainWidget = (WXWidget) 0;
131 m_labelWidget = (WXWidget) 0;
b412f9be
JS
132}
133
483561c5 134void wxStaticBox::SetLabel( const wxString& label )
47bc1060 135{
483561c5 136 wxXmSizeKeeper sk( (Widget)GetMainWidget() );
47bc1060 137
483561c5 138 wxStaticBoxBase::SetLabel( label );
47bc1060 139
483561c5 140 sk.Restore();
0d57be45 141}
13abe5c0
MB
142
143void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
144{
145 Dimension shadow, border;
146
147 XtVaGetValues( (Widget) GetMainWidget(),
148 XmNshadowThickness, &shadow,
149 XmNborderWidth, &border,
150 NULL);
151
152 *borderOther = shadow + border;
153
154 if( GetLabelWidget() )
155 {
156 XtWidgetGeometry preferred;
157 XtQueryGeometry( (Widget) GetLabelWidget(), NULL, &preferred );
158
159 *borderTop = preferred.height;
160 }
161 else
162 {
163 *borderTop = shadow;
164 }
165}