]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "control.h"
16 #include "wx/control.h"
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
25 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
30 wxControl::wxControl()
32 m_backgroundColour
= *wxWHITE
;
33 m_foregroundColour
= *wxBLACK
;
38 wxControl::~wxControl()
40 // If we delete an item, we should initialize the parent panel,
41 // because it could now be invalid.
42 wxPanel
*panel
= wxDynamicCast(GetParent(), wxPanel
);
45 if (panel
->GetDefaultItem() == this)
46 panel
->SetDefaultItem((wxButton
*) NULL
);
50 void wxControl::SetLabel(const wxString
& label
)
52 Widget widget
= (Widget
) GetLabelWidget() ;
56 wxStripMenuCodes((char*) (const char*) label
, wxBuffer
);
58 XmString text
= XmStringCreateSimple (wxBuffer
);
59 XtVaSetValues (widget
,
61 XmNlabelType
, XmSTRING
,
66 wxString
wxControl::GetLabel() const
68 Widget widget
= (Widget
) GetLabelWidget() ;
74 XtVaGetValues (widget
,
75 XmNlabelString
, &text
,
78 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
87 // XmStringFree(text);
92 void wxControl::ProcessCommand (wxCommandEvent
& event
)
95 // 1) A callback function (to become obsolete)
96 // 2) OnCommand, starting at this window and working up parent hierarchy
97 // 3) OnCommand then calls ProcessEvent to search the event tables.
100 (void) (*(m_callback
)) (*this, event
);
104 GetEventHandler()->OnCommand(*this, event
);
108 void wxControl::Centre (int direction
)
110 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
112 wxWindow
*parent
= (wxWindow
*) GetParent ();
116 parent
->GetClientSize (&panel_width
, &panel_height
);
117 GetSize (&width
, &height
);
118 GetPosition (&x
, &y
);
123 if (direction
& wxHORIZONTAL
)
124 new_x
= (int) ((panel_width
- width
) / 2);
126 if (direction
& wxVERTICAL
)
127 new_y
= (int) ((panel_height
- height
) / 2);
129 SetSize (new_x
, new_y
, width
, height
);