Applied [ 590985 ] fix for radiobox under motif
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16400 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -73,21 +73,15 @@ public:
|
|||||||
virtual void ChangeFont(bool keepOriginalSize = TRUE);
|
virtual void ChangeFont(bool keepOriginalSize = TRUE);
|
||||||
virtual void ChangeBackgroundColour();
|
virtual void ChangeBackgroundColour();
|
||||||
virtual void ChangeForegroundColour();
|
virtual void ChangeForegroundColour();
|
||||||
WXWidget GetTopWidget() const { return m_formWidget; }
|
|
||||||
WXWidget GetLabelWidget() const { return m_labelWidget; }
|
|
||||||
WXWidget GetFrameWidget() const { return m_frameWidget; }
|
|
||||||
inline WXWidget* GetRadioButtons() const { return m_radioButtons; }
|
inline WXWidget* GetRadioButtons() const { return m_radioButtons; }
|
||||||
inline void SetSel(int i) { m_selectedButton = i; }
|
inline void SetSel(int i) { m_selectedButton = i; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_majorDim ;
|
int m_majorDim;
|
||||||
int m_noItems;
|
int m_noItems;
|
||||||
int m_noRowsOrCols;
|
int m_noRowsOrCols;
|
||||||
int m_selectedButton;
|
int m_selectedButton;
|
||||||
|
|
||||||
WXWidget m_formWidget;
|
|
||||||
WXWidget m_labelWidget;
|
|
||||||
WXWidget m_frameWidget;
|
|
||||||
WXWidget* m_radioButtons;
|
WXWidget* m_radioButtons;
|
||||||
wxString* m_radioButtonLabels;
|
wxString* m_radioButtonLabels;
|
||||||
|
|
||||||
|
@@ -51,9 +51,6 @@ wxRadioBox::wxRadioBox()
|
|||||||
m_noRowsOrCols = 0;
|
m_noRowsOrCols = 0;
|
||||||
m_majorDim = 0 ;
|
m_majorDim = 0 ;
|
||||||
|
|
||||||
m_formWidget = (WXWidget) 0;
|
|
||||||
m_frameWidget = (WXWidget) 0;
|
|
||||||
m_labelWidget = (WXWidget) 0;
|
|
||||||
m_radioButtons = (WXWidget*) NULL;
|
m_radioButtons = (WXWidget*) NULL;
|
||||||
m_radioButtonLabels = (wxString*) NULL;
|
m_radioButtonLabels = (wxString*) NULL;
|
||||||
}
|
}
|
||||||
@@ -66,9 +63,6 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
|||||||
{
|
{
|
||||||
m_selectedButton = -1;
|
m_selectedButton = -1;
|
||||||
m_noItems = n;
|
m_noItems = n;
|
||||||
m_formWidget = (WXWidget) 0;
|
|
||||||
m_frameWidget = (WXWidget) 0;
|
|
||||||
m_labelWidget = (WXWidget) 0;
|
|
||||||
m_radioButtons = (WXWidget*) NULL;
|
m_radioButtons = (WXWidget*) NULL;
|
||||||
m_radioButtonLabels = (wxString*) NULL;
|
m_radioButtonLabels = (wxString*) NULL;
|
||||||
m_backgroundColour = parent->GetBackgroundColour();
|
m_backgroundColour = parent->GetBackgroundColour();
|
||||||
@@ -96,17 +90,17 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
|||||||
|
|
||||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||||
|
|
||||||
wxString label1(wxStripMenuCodes(title));
|
m_mainWidget = XtVaCreateWidget ("radiobxoframe",
|
||||||
|
xmFrameWidgetClass, parentWidget,
|
||||||
Widget formWidget = XtVaCreateManagedWidget (name.c_str(),
|
XmNshadowType, XmSHADOW_IN,
|
||||||
xmFormWidgetClass, parentWidget,
|
XmNresizeHeight, True,
|
||||||
XmNmarginHeight, 0,
|
XmNresizeWidth, True,
|
||||||
XmNmarginWidth, 0,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
m_formWidget = (WXWidget) formWidget;
|
wxString label1(wxStripMenuCodes(title));
|
||||||
|
|
||||||
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
|
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
|
||||||
|
|
||||||
if (label1 != "")
|
if (label1 != "")
|
||||||
{
|
{
|
||||||
wxXmString text(label1);
|
wxXmString text(label1);
|
||||||
@@ -114,24 +108,17 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
|||||||
#if wxUSE_GADGETS
|
#if wxUSE_GADGETS
|
||||||
style & wxCOLOURED ? xmLabelWidgetClass
|
style & wxCOLOURED ? xmLabelWidgetClass
|
||||||
: xmLabelGadgetClass,
|
: xmLabelGadgetClass,
|
||||||
formWidget,
|
(Widget)m_mainWidget,
|
||||||
#else
|
#else
|
||||||
xmLabelWidgetClass, formWidget,
|
xmLabelWidgetClass, (Widget)m_mainWidget,
|
||||||
#endif
|
#endif
|
||||||
XmNfontList, fontList,
|
XmNfontList, fontList,
|
||||||
XmNlabelString, text(),
|
XmNlabelString, text(),
|
||||||
|
XmNframeChildType, XmFRAME_TITLE_CHILD,
|
||||||
|
XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget frameWidget = XtVaCreateManagedWidget ("frame",
|
|
||||||
xmFrameWidgetClass, formWidget,
|
|
||||||
XmNshadowType, XmSHADOW_IN,
|
|
||||||
// XmNmarginHeight, 0,
|
|
||||||
// XmNmarginWidth, 0,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
m_frameWidget = (WXWidget) frameWidget;
|
|
||||||
|
|
||||||
Arg args[3];
|
Arg args[3];
|
||||||
|
|
||||||
m_majorDim = (n + m_majorDim - 1) / m_majorDim;
|
m_majorDim = (n + m_majorDim - 1) / m_majorDim;
|
||||||
@@ -140,24 +127,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
|||||||
XmHORIZONTAL : XmVERTICAL));
|
XmHORIZONTAL : XmVERTICAL));
|
||||||
XtSetArg (args[1], XmNnumColumns, m_majorDim);
|
XtSetArg (args[1], XmNnumColumns, m_majorDim);
|
||||||
|
|
||||||
Widget radioBoxWidget = XmCreateRadioBox (frameWidget, "radioBoxWidget", args, 2);
|
Widget radioBoxWidget = XmCreateRadioBox ((Widget)m_mainWidget, "radioBoxWidget", args, 2);
|
||||||
m_mainWidget = (WXWidget) radioBoxWidget;
|
|
||||||
|
|
||||||
|
|
||||||
if (m_labelWidget)
|
|
||||||
XtVaSetValues ((Widget) m_labelWidget,
|
|
||||||
XmNtopAttachment, XmATTACH_FORM,
|
|
||||||
XmNleftAttachment, XmATTACH_FORM,
|
|
||||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
XtVaSetValues (radioBoxWidget,
|
|
||||||
XmNtopAttachment, m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM,
|
|
||||||
XmNtopWidget, m_labelWidget ? (Widget) m_labelWidget : formWidget,
|
|
||||||
XmNbottomAttachment, XmATTACH_FORM,
|
|
||||||
XmNleftAttachment, XmATTACH_FORM,
|
|
||||||
XmNrightAttachment, XmATTACH_FORM,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
// if (style & wxFLAT)
|
// if (style & wxFLAT)
|
||||||
// XtVaSetValues (radioBoxWidget, XmNborderWidth, 1, NULL);
|
// XtVaSetValues (radioBoxWidget, XmNborderWidth, 1, NULL);
|
||||||
@@ -180,16 +150,18 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
|||||||
XtAddCallback ((Widget) m_radioButtons[i], XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback,
|
XtAddCallback ((Widget) m_radioButtons[i], XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback,
|
||||||
(XtPointer) this);
|
(XtPointer) this);
|
||||||
}
|
}
|
||||||
SetSelection (0);
|
|
||||||
|
|
||||||
m_font = parent->GetFont();
|
m_font = parent->GetFont();
|
||||||
ChangeFont(FALSE);
|
ChangeFont(FALSE);
|
||||||
|
|
||||||
// XtManageChild((Widget) m_formWidget);
|
SetSelection (0);
|
||||||
|
|
||||||
|
XtRealizeWidget((Widget)m_mainWidget);
|
||||||
XtManageChild (radioBoxWidget);
|
XtManageChild (radioBoxWidget);
|
||||||
|
XtManageChild ((Widget)m_mainWidget);
|
||||||
|
|
||||||
SetCanAddEventHandler(TRUE);
|
SetCanAddEventHandler(TRUE);
|
||||||
AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
|
AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y);
|
||||||
|
|
||||||
ChangeBackgroundColour();
|
ChangeBackgroundColour();
|
||||||
|
|
||||||
@@ -202,17 +174,10 @@ wxRadioBox::~wxRadioBox()
|
|||||||
delete[] m_radioButtonLabels;
|
delete[] m_radioButtonLabels;
|
||||||
delete[] m_radioButtons;
|
delete[] m_radioButtons;
|
||||||
|
|
||||||
DetachWidget(m_formWidget);
|
|
||||||
DetachWidget(m_mainWidget);
|
DetachWidget(m_mainWidget);
|
||||||
|
|
||||||
if (m_labelWidget)
|
|
||||||
XtDestroyWidget((Widget) m_labelWidget);
|
|
||||||
XtDestroyWidget((Widget) m_mainWidget);
|
XtDestroyWidget((Widget) m_mainWidget);
|
||||||
XtDestroyWidget((Widget) m_formWidget);
|
|
||||||
|
|
||||||
m_mainWidget = (WXWidget) 0;
|
m_mainWidget = (WXWidget) 0;
|
||||||
m_formWidget = (WXWidget) 0;
|
|
||||||
m_labelWidget = (WXWidget) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetString(int item, const wxString& label)
|
void wxRadioBox::SetString(int item, const wxString& label)
|
||||||
@@ -277,40 +242,26 @@ wxString wxRadioBox::GetString(int n) const
|
|||||||
|
|
||||||
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
{
|
{
|
||||||
bool managed = XtIsManaged((Widget) m_formWidget);
|
bool managed = XtIsManaged((Widget) m_mainWidget);
|
||||||
|
|
||||||
if (managed)
|
if (managed)
|
||||||
XtUnmanageChild ((Widget) m_formWidget);
|
XtUnmanageChild ((Widget) m_mainWidget);
|
||||||
|
|
||||||
int xx = x; int yy = y;
|
int xx = x; int yy = y;
|
||||||
AdjustForParentClientOrigin(xx, yy, sizeFlags);
|
AdjustForParentClientOrigin(xx, yy, sizeFlags);
|
||||||
|
|
||||||
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||||
XtVaSetValues ((Widget) m_formWidget, XmNleftAttachment, XmATTACH_SELF,
|
XtVaSetValues ((Widget) m_mainWidget, XmNx, xx, NULL);
|
||||||
XmNx, xx, NULL);
|
|
||||||
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||||
XtVaSetValues ((Widget) m_formWidget, XmNtopAttachment, XmATTACH_SELF,
|
XtVaSetValues ((Widget) m_mainWidget, XmNy, yy, NULL);
|
||||||
XmNy, yy, NULL);
|
|
||||||
|
|
||||||
// Must set the actual RadioBox to be desired size MINUS label size
|
if (width > 0)
|
||||||
Dimension labelWidth = 0, labelHeight = 0, actualWidth = 0, actualHeight = 0;
|
XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width, NULL);
|
||||||
|
if (height > 0)
|
||||||
|
XtVaSetValues ((Widget) m_mainWidget, XmNheight, height, NULL);
|
||||||
|
|
||||||
if (m_labelWidget)
|
|
||||||
XtVaGetValues ((Widget) m_labelWidget, XmNwidth, &labelWidth, XmNheight, &labelHeight, NULL);
|
|
||||||
|
|
||||||
actualWidth = width;
|
|
||||||
actualHeight = height - labelHeight;
|
|
||||||
|
|
||||||
if (width > -1)
|
|
||||||
{
|
|
||||||
XtVaSetValues ((Widget) m_mainWidget, XmNwidth, actualWidth, NULL);
|
|
||||||
}
|
|
||||||
if (height > -1)
|
|
||||||
{
|
|
||||||
XtVaSetValues ((Widget) m_mainWidget, XmNheight, actualHeight, NULL);
|
|
||||||
}
|
|
||||||
if (managed)
|
if (managed)
|
||||||
XtManageChild ((Widget) m_formWidget);
|
XtManageChild ((Widget) m_mainWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable a specific button
|
// Enable a specific button
|
||||||
@@ -411,7 +362,6 @@ void wxRadioBox::ChangeFont(bool keepOriginalSize)
|
|||||||
|
|
||||||
XtVaSetValues ((Widget) radioButton,
|
XtVaSetValues ((Widget) radioButton,
|
||||||
XmNfontList, fontList,
|
XmNfontList, fontList,
|
||||||
XmNtopAttachment, XmATTACH_FORM,
|
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,8 +370,6 @@ void wxRadioBox::ChangeBackgroundColour()
|
|||||||
{
|
{
|
||||||
wxWindow::ChangeBackgroundColour();
|
wxWindow::ChangeBackgroundColour();
|
||||||
|
|
||||||
DoChangeBackgroundColour((Widget) m_frameWidget, m_backgroundColour);
|
|
||||||
|
|
||||||
int selectPixel = wxBLACK->AllocColour(wxGetDisplay());
|
int selectPixel = wxBLACK->AllocColour(wxGetDisplay());
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -485,7 +433,8 @@ void wxRadioBoxCallback (Widget w, XtPointer clientData,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wxCommandEvent event (wxEVT_COMMAND_RADIOBOX_SELECTED, item->GetId());
|
wxCommandEvent event (wxEVT_COMMAND_RADIOBOX_SELECTED, item->GetId());
|
||||||
event.m_commandInt = sel;
|
event.SetInt(sel);
|
||||||
|
event.SetString(item->GetStringSelection());
|
||||||
event.SetEventObject(item);
|
event.SetEventObject(item);
|
||||||
item->ProcessCommand (event);
|
item->ProcessCommand (event);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user