]>
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"
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
24 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
29 wxControl::wxControl()
31 m_backgroundColour
= *wxWHITE
;
32 m_foregroundColour
= *wxBLACK
;
37 wxControl::~wxControl()
39 // If we delete an item, we should initialize the parent panel,
40 // because it could now be invalid.
41 wxWindow
*parent
= (wxWindow
*)GetParent();
44 if (parent
->GetDefaultItem() == (wxButton
*) this)
45 parent
->SetDefaultItem((wxButton
*) NULL
);
49 void wxControl::SetLabel(const wxString
& label
)
51 Widget widget
= (Widget
) GetLabelWidget() ;
55 wxStripMenuCodes((char*) (const char*) label
, wxBuffer
);
57 XmString text
= XmStringCreateSimple (wxBuffer
);
58 XtVaSetValues (widget
,
60 XmNlabelType
, XmSTRING
,
65 wxString
wxControl::GetLabel() const
67 Widget widget
= (Widget
) GetLabelWidget() ;
73 XtVaGetValues (widget
,
74 XmNlabelString
, &text
,
77 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
86 // XmStringFree(text);
91 void wxControl::ProcessCommand (wxCommandEvent
& event
)
94 // 1) A callback function (to become obsolete)
95 // 2) OnCommand, starting at this window and working up parent hierarchy
96 // 3) OnCommand then calls ProcessEvent to search the event tables.
99 (void) (*(m_callback
)) (*this, event
);
103 GetEventHandler()->OnCommand(*this, event
);
107 void wxControl::Centre (int direction
)
109 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
111 wxWindow
*parent
= (wxWindow
*) GetParent ();
115 parent
->GetClientSize (&panel_width
, &panel_height
);
116 GetSize (&width
, &height
);
117 GetPosition (&x
, &y
);
122 if (direction
& wxHORIZONTAL
)
123 new_x
= (int) ((panel_width
- width
) / 2);
125 if (direction
& wxVERTICAL
)
126 new_y
= (int) ((panel_height
- height
) / 2);
128 SetSize (new_x
, new_y
, width
, height
);