// Scrollbar bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; wxSize newSize = ( style & wxHORIZONTAL ) ? wxSize( 140, 16 ) : wxSize( 16, 140 ); if( size.x != -1 ) newSize.x = size.x; if( size.y != -1 ) newSize.y = size.y; Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = DoCreateScrollBar( (WXWidget)parentWidget, (wxOrientation)(style & (wxHORIZONTAL|wxVERTICAL)), (void (*)())wxScrollBarCallback ); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, newSize.x, newSize.y); ChangeBackgroundColour(); return true; }
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; m_bmpNormal = m_bmpNormalOriginal = bitmap; m_bmpSelected = m_bmpSelectedOriginal = bitmap; Widget parentWidget = (Widget) parent->GetClientWidget(); /* * Patch Note (important) * There is no major reason to put a defaultButtonThickness here. * Not requesting it give the ability to put wxButton with a spacing * as small as requested. However, if some button become a DefaultButton, * other buttons are no more aligned -- This is why we set * defaultButtonThickness of ALL buttons belonging to the same wxPanel, * in the ::SetDefaultButton method. */ Widget buttonWidget = XtVaCreateManagedWidget ("button", // Gadget causes problems for default button operation. #if wxUSE_GADGETS xmPushButtonGadgetClass, parentWidget, #else xmPushButtonWidgetClass, parentWidget, #endif // See comment for wxButton::SetDefault // XmNdefaultButtonShadowThickness, 1, XmNrecomputeSize, False, NULL); m_mainWidget = (WXWidget) buttonWidget; ChangeFont(false); ChangeBackgroundColour (); DoSetBitmap(); XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); wxSize best = m_bmpNormal.Ok() ? GetBestSize() : wxSize(30, 30); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); return true; }
bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; Widget parentWidget = (Widget) parent->GetClientWidget(); Arg args[7]; int count = 4; if (style & wxGA_HORIZONTAL) { XtSetArg (args[0], XmNorientation, XmHORIZONTAL); XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT); } else { XtSetArg (args[0], XmNorientation, XmVERTICAL); XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_TOP); } XtSetArg(args[2], XmNminimum, 0); XtSetArg(args[3], XmNmaximum, range); #if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF() XtSetArg(args[4], XmNeditable, False); ++count; XtSetArg(args[5], XmNslidingMode, XmTHERMOMETER); ++count; // XtSetArg(args[6], XmNsliderVisual, XmFOREGROUND_COLOR ); ++count; Widget gaugeWidget = XtCreateManagedWidget("gauge", xmScaleWidgetClass, parentWidget, args, count); #else Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count); #endif m_mainWidget = (WXWidget) gaugeWidget ; XtManageChild (gaugeWidget); int x = pos.x; int y = pos.y; wxSize best = GetBestSize(); if( size.x != wxDefaultCoord ) best.x = size.x; if( size.y != wxDefaultCoord ) best.y = size.y; ChangeFont(false); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, best.x, best.y); ChangeBackgroundColour(); return true; }
bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; m_noStrings = n; Widget parentWidget = (Widget) parent->GetClientWidget(); Widget buttonWidget = XtVaCreateManagedWidget(name.c_str(), xmComboBoxWidgetClass, parentWidget, XmNmarginHeight, 0, XmNmarginWidth, 0, XmNshowLabel, False, XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY), XmNsorted, ((style & wxCB_SORT) == wxCB_SORT), XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE), NULL); int i; for (i = 0; i < n; i++) { wxXmString str( choices[i] ); XmComboBoxAddItem(buttonWidget, str(), 0); m_stringList.Add(choices[i]); } m_mainWidget = (Widget) buttonWidget; XtManageChild (buttonWidget); SetValue(value); ChangeFont(false); XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, (XtPointer) this); XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, (XtPointer) this); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); return true; }
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if( !wxControl::CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); Widget parentWidget = (Widget) parent->GetClientWidget(); Widget toolbar = XtVaCreateManagedWidget("toolbar", xmBulletinBoardWidgetClass, (Widget) parentWidget, XmNmarginWidth, 0, XmNmarginHeight, 0, XmNresizePolicy, XmRESIZE_NONE, NULL); /* Widget toolbar = XtVaCreateManagedWidget("toolbar", xmFormWidgetClass, (Widget) m_clientWidget, XmNtraversalOn, False, XmNhorizontalSpacing, 0, XmNverticalSpacing, 0, XmNleftOffset, 0, XmNrightOffset, 0, XmNmarginWidth, 0, XmNmarginHeight, 0, NULL); */ m_mainWidget = (WXWidget) toolbar; ChangeFont(false); wxPoint rPos = pos; wxSize rSize = size; if( rPos.x == -1 ) rPos.x = 0; if( rPos.y == -1 ) rPos.y = 0; if( rSize.x == -1 && GetParent() ) rSize.x = GetParent()->GetSize().x; AttachWidget (parent, m_mainWidget, (WXWidget) NULL, rPos.x, rPos.y, rSize.x, rSize.y); ChangeBackgroundColour(); return true; }
bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID WXUNUSED(id), ArrowDirection d, const wxPoint& pos, const wxSize& size ) { wxCHECK_MSG( parent, false, wxT("must have a valid parent") ); int arrow_dir = XmARROW_UP; switch( d ) { case wxARROW_UP: arrow_dir = XmARROW_UP; break; case wxARROW_DOWN: arrow_dir = XmARROW_DOWN; break; case wxARROW_LEFT: arrow_dir = XmARROW_LEFT; break; case wxARROW_RIGHT: arrow_dir = XmARROW_RIGHT; break; } parent->AddChild( this ); PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = (WXWidget) XtVaCreateManagedWidget( "XmArrowButton", xmArrowButtonWidgetClass, parentWidget, XmNarrowDirection, arrow_dir, XmNborderWidth, 0, XmNshadowThickness, 0, NULL ); XtAddCallback( (Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) SpinButtonCallback, (XtPointer) this ); XtAddCallback( (Widget) m_mainWidget, XmNarmCallback, (XtCallbackProc) StartTimerCallback, (XtPointer) this ); XtAddCallback( (Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) StopTimerCallback, (XtPointer) this ); PostCreation(); AttachWidget( parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y ); return true; }
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { wxString label(lbl); if (label.empty() && wxIsStockID(id)) label = wxGetStockLabel(id); if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; wxXmString text( GetLabelText(label) ); Widget parentWidget = (Widget) parent->GetClientWidget(); /* * Patch Note (important) * There is no major reason to put a defaultButtonThickness here. * Not requesting it give the ability to put wxButton with a spacing * as small as requested. However, if some button become a DefaultButton, * other buttons are no more aligned -- This is why we set * defaultButtonThickness of ALL buttons belonging to the same wxPanel, * in the ::SetDefaultButton method. */ m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button", xmPushButtonWidgetClass, parentWidget, wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), XmNlabelString, text(), XmNrecomputeSize, False, // See comment for wxButton::SetDefault // XmNdefaultButtonShadowThickness, 1, NULL); XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); wxSize best = GetBestSize(); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); ChangeBackgroundColour(); return true; }
bool wxSlider::Create(wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if ( !((style & wxSL_HORIZONTAL) || (style & wxSL_VERTICAL)) ) style |= wxSL_HORIZONTAL; if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; m_lineSize = 1; m_windowStyle = style; m_rangeMax = maxValue; m_rangeMin = minValue; // Not used in Motif, I think m_pageSize = (int)((maxValue-minValue)/10); Widget parentWidget = (Widget) parent->GetClientWidget(); Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget", xmScaleWidgetClass, parentWidget, XmNorientation, (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL), XmNprocessingDirection, (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT), XmNmaximum, maxValue, XmNminimum, minValue, XmNvalue, value, XmNshowValue, True, NULL); m_mainWidget = (WXWidget) sliderWidget; XtAddCallback (sliderWidget, XmNvalueChangedCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); ChangeFont(false); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); return true; }
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; m_labelWidget = (WXWidget) 0; PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = XtVaCreateManagedWidget ("staticboxframe", xmFrameWidgetClass, parentWidget, // MBN: why override default? // XmNshadowType, XmSHADOW_IN, NULL); if (!label.empty()) { wxString label1(GetLabelText(label)); wxXmString text(label1); Display* dpy = XtDisplay( parentWidget ); m_labelWidget = (WXWidget) XtVaCreateManagedWidget ("staticboxlabel", xmLabelWidgetClass, (Widget)m_mainWidget, wxFont::GetFontTag(), m_font.GetFontTypeC(dpy), XmNlabelString, text(), #if wxCHECK_MOTIF_VERSION( 2, 0 ) XmNframeChildType, XmFRAME_TITLE_CHILD, #else XmNchildType, XmFRAME_TITLE_CHILD, #endif NULL); } PostCreation(); AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y); return true; }
bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; m_labelWidget = (WXWidget) 0; PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); Widget borderWidget = (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style ); m_labelWidget = XtVaCreateManagedWidget (name.mb_str(), xmLabelWidgetClass, borderWidget ? borderWidget : parentWidget, wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), XmNalignment, ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END : ((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER : XmALIGNMENT_BEGINNING)), XmNrecomputeSize, ((style & wxST_NO_AUTORESIZE) ? TRUE : FALSE), NULL); m_mainWidget = borderWidget ? borderWidget : m_labelWidget; SetLabel(label); wxSize best = GetBestSize(); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); return true; }
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; m_messageBitmap = bitmap; m_messageBitmapOriginal = bitmap; Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("staticBitmap", #if wxUSE_GADGETS xmLabelGadgetClass, parentWidget, #else xmLabelWidgetClass, parentWidget, #endif XmNalignment, XmALIGNMENT_BEGINNING, NULL); ChangeBackgroundColour (); DoSetBitmap(); ChangeFont(false); wxSize actualSize(size); // work around the cases where the bitmap is a wxNull(Icon/Bitmap) if (actualSize.x == -1) actualSize.x = bitmap.Ok() ? bitmap.GetWidth() : 1; if (actualSize.y == -1) actualSize.y = bitmap.Ok() ? bitmap.GetHeight() : 1; AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, actualSize.x, actualSize.y); return true; }
// Single check box item bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !wxControl::CreateControl( parent, id, pos, size, style, validator, name ) ) return false; PreCreation(); wxXmString text( GetLabelText(label) ); Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle", xmToggleButtonWidgetClass, parentWidget, wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), XmNlabelString, text(), XmNrecomputeSize, False, // XmNindicatorOn, XmINDICATOR_CHECK_BOX, // XmNfillOnSelect, False, #if wxHAS_3STATE XmNtoggleMode, Is3State() ? XmTOGGLE_INDETERMINATE : XmTOGGLE_BOOLEAN, #endif NULL); XtAddCallback( (Widget)m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxCheckBoxCallback, (XtPointer)this ); XmToggleButtonSetState ((Widget) m_mainWidget, False, True); PostCreation(); AttachWidget( parent, m_mainWidget, (WXWidget)NULL, pos.x, pos.y, size.x, size.y ); return true; }
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; Widget parentWidget = (Widget) parent->GetClientWidget(); Display* dpy = XtDisplay(parentWidget); wxString label1(wxStripMenuCodes(label)); wxXmString text( label1 ); Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle", #if wxUSE_GADGETS xmToggleButtonGadgetClass, parentWidget, #else xmToggleButtonWidgetClass, parentWidget, #endif wxFont::GetFontTag(), m_font.GetFontTypeC(dpy), XmNlabelString, text(), XmNfillOnSelect, True, XmNindicatorType, XmONE_OF_MANY, // diamond-shape NULL); XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc)wxRadioButtonCallback, (XtPointer)this); m_mainWidget = (WXWidget) radioButtonWidget; XtManageChild (radioButtonWidget); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); //copied from mac/radiobut.cpp (from here till "return true;") m_cycle = this ; if (HasFlag(wxRB_GROUP)) { AddInCycle( NULL ) ; } else { /* search backward for last group start */ wxRadioButton *chief = (wxRadioButton*) NULL; wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) ) { chief = (wxRadioButton*) child; if (child->HasFlag(wxRB_GROUP)) break; } node = node->GetPrevious(); } AddInCycle( chief ) ; } return true; }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; PreCreation(); m_tempCallbackStruct = NULL; m_modified = false; m_processedDefault = false; Widget parentWidget = (Widget) parent->GetClientWidget(); Bool wantHorizScroll = (m_windowStyle & wxHSCROLL) != 0 ? True : False; // If we don't have horizontal scrollbars, we want word wrap. // OpenMotif 2.1 crashes if wantWordWrap is True in Japanese // locale (and probably other multibyte locales). The check might be // more precise #if wxCHECK_LESSTIF() || wxCHECK_MOTIF_VERSION( 2, 2 ) Bool wantWordWrap = wantHorizScroll == True ? False : True; #else Bool wantWordWrap = False; #endif if (m_windowStyle & wxTE_MULTILINE) { Arg args[8]; int count = 0; XtSetArg (args[count], XmNscrollHorizontal, wantHorizScroll); ++count; if( m_font.IsOk() ) XtSetArg (args[count], (String) wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ) ); ++count; XtSetArg (args[count], XmNwordWrap, wantWordWrap); ++count; XtSetArg (args[count], XmNvalue, (const char*)value.mb_str()); ++count; XtSetArg (args[count], XmNeditable, style & wxTE_READONLY ? False : True); ++count; XtSetArg (args[count], XmNeditMode, XmMULTI_LINE_EDIT ); ++count; m_mainWidget = (WXWidget) XmCreateScrolledText(parentWidget, name.char_str(), args, count); XtManageChild ((Widget) m_mainWidget); } else { m_mainWidget = (WXWidget)XtVaCreateManagedWidget ( name.mb_str(), xmTextWidgetClass, parentWidget, wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ), XmNvalue, (const char*)value.mb_str(), XmNeditable, (style & wxTE_READONLY) ? False : True, NULL ); #if 0 // TODO: Is this relevant? What does it do? int noCols = 2; if (!value.IsNull() && (value.length() > (unsigned int) noCols)) noCols = value.length(); XtVaSetValues((Widget) m_mainWidget, XmNcolumns, noCols, NULL); #endif } // remove border if asked for if ( style & wxNO_BORDER ) { XtVaSetValues((Widget)m_mainWidget, XmNshadowThickness, 0, NULL); } // install callbacks XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this); PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); return true; }
bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); m_formWidget = (WXWidget) XtVaCreateManagedWidget(name.c_str(), xmRowColumnWidgetClass, parentWidget, XmNmarginHeight, 0, XmNmarginWidth, 0, XmNpacking, XmPACK_TIGHT, XmNorientation, XmHORIZONTAL, XmNresizeWidth, False, XmNresizeHeight, False, NULL); XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL); /* * Create the popup menu */ m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, wxMOTIF_STR("choiceMenu"), NULL, 0); if (n > 0) { int i; for (i = 0; i < n; i++) Append (choices[i]); } /* * Create button */ Arg args[10]; Cardinal argcnt = 0; XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget); ++argcnt; XtSetArg (args[argcnt], XmNmarginWidth, 0); ++argcnt; XtSetArg (args[argcnt], XmNmarginHeight, 0); ++argcnt; XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT); ++argcnt; m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, wxMOTIF_STR("choiceButton"), args, argcnt); m_mainWidget = m_buttonWidget; XtManageChild ((Widget) m_buttonWidget); // New code from Roland Haenel ([email protected]) // Some time ago, I reported a problem with wxChoice-items under // Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems // that I have found the code responsible for this behaviour. #if XmVersion >= 1002 #if XmVersion < 2000 // JACS, 24/1/99: this seems to cause a malloc crash later on, e.g. // in controls sample. // // Widget optionLabel = XmOptionLabelGadget ((Widget) m_buttonWidget); // XtUnmanageChild (optionLabel); #endif #endif wxSize bestSize = GetBestSize(); if( size.x > 0 ) bestSize.x = size.x; if( size.y > 0 ) bestSize.y = size.y; XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL); PostCreation(); AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, bestSize.x, bestSize.y); return true; }
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { SetName(name); SetWindowStyleFlag(style); m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); m_foregroundColour = *wxBLACK; m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); if ( id > -1 ) m_windowId = id; else m_windowId = (int)NewControlId(); wxMDIClientWindow* clientWindow = parent->GetClientWindow(); wxASSERT_MSG( (clientWindow != (wxWindow*) NULL), "Missing MDI client window."); if (clientWindow) clientWindow->AddChild(this); SetMDIParentFrame(parent); int width = size.x; int height = size.y; if (width == -1) width = 200; // TODO: give reasonable default if (height == -1) height = 200; // TODO: give reasonable default // We're deactivating the old child wxMDIChildFrame* oldActiveChild = parent->GetActiveChild(); if (oldActiveChild) { wxActivateEvent event(wxEVT_ACTIVATE, false, oldActiveChild->GetId()); event.SetEventObject( oldActiveChild ); oldActiveChild->GetEventHandler()->ProcessEvent(event); } // This is the currently active child parent->SetActiveChild((wxMDIChildFrame*) this); // This time we'll try a bog-standard bulletin board for // the 'frame'. A main window doesn't seem to work. m_mainWidget = (WXWidget) XtVaCreateWidget("client", xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(), XmNmarginWidth, 0, XmNmarginHeight, 0, /* XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, */ XmNresizePolicy, XmRESIZE_NONE, NULL); XtAddEventHandler((Widget) m_mainWidget, ExposureMask,False, wxUniversalRepaintProc, (XtPointer) this); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); XtManageChild((Widget) m_mainWidget); SetTitle(title); clientWindow->AddPage(this, title, true); clientWindow->Refresh(); // Positions the toolbar and status bar -- but we don't have any. // PreResize(); wxModelessWindows.Append(this); return true; }
bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if( !wxControl::CreateControl( parent, id, pos, size, style, validator, name ) ) return false; m_noItems = (unsigned int)n; m_backgroundColour = * wxWHITE; Widget parentWidget = (Widget) parent->GetClientWidget(); Display* dpy = XtDisplay(parentWidget); Arg args[4]; int count = 0; XtSetArg( args[count], XmNlistSizePolicy, XmCONSTANT ); ++count; XtSetArg( args[count], XmNselectionPolicy, ( m_windowStyle & wxLB_MULTIPLE ) ? XmMULTIPLE_SELECT : ( m_windowStyle & wxLB_EXTENDED ) ? XmEXTENDED_SELECT : XmBROWSE_SELECT ); ++count; if( m_font.Ok() ) { XtSetArg( args[count], (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) ); ++count; } if( m_windowStyle & wxLB_ALWAYS_SB ) { XtSetArg( args[count], XmNscrollBarDisplayPolicy, XmSTATIC ); ++count; } Widget listWidget = XmCreateScrolledList(parentWidget, wxConstCast(name.c_str(), char), args, count); m_mainWidget = (WXWidget) listWidget; Set(n, choices); XtManageChild (listWidget); wxSize best = GetBestSize(); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; XtAddCallback (listWidget, XmNbrowseSelectionCallback, (XtCallbackProc) wxListBoxCallback, (XtPointer) this); XtAddCallback (listWidget, XmNextendedSelectionCallback, (XtCallbackProc) wxListBoxCallback, (XtPointer) this); XtAddCallback (listWidget, XmNmultipleSelectionCallback, (XtCallbackProc) wxListBoxCallback, (XtPointer) this); XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxCallback, (XtPointer) this); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); ChangeBackgroundColour(); return true; }
BridgeWidget::BridgeWidget(int w, int h, Widget* widget): _widget(widget) { AttachWidget(widget); SetDimensions( w, h); }
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, val, name ) ) return false; PreCreation(); m_noItems = (unsigned int)n; m_noRowsOrCols = majorDim; SetMajorDim(majorDim == 0 ? n : majorDim, style); Widget parentWidget = (Widget) parent->GetClientWidget(); Display* dpy = XtDisplay(parentWidget); m_mainWidget = XtVaCreateWidget ("radioboxframe", xmFrameWidgetClass, parentWidget, XmNresizeHeight, True, XmNresizeWidth, True, NULL); wxString label1(GetLabelText(title)); if (!label1.empty()) { wxXmString text(label1); m_labelWidget = (WXWidget) XtVaCreateManagedWidget( label1.mb_str(), #if wxUSE_GADGETS style & wxCOLOURED ? xmLabelWidgetClass : xmLabelGadgetClass, (Widget)m_mainWidget, #else xmLabelWidgetClass, (Widget)m_mainWidget, #endif wxFont::GetFontTag(), m_font.GetFontTypeC(dpy), XmNlabelString, text(), // XmNframeChildType is not in Motif 1.2, nor in Lesstif, // if it was compiled with 1.2 compatibility // TODO: check this still looks OK for Motif 1.2. #if (XmVersion > 1200) XmNframeChildType, XmFRAME_TITLE_CHILD, #else XmNchildType, XmFRAME_TITLE_CHILD, #endif XmNchildVerticalAlignment, XmALIGNMENT_CENTER, NULL); } Arg args[3]; XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ? XmHORIZONTAL : XmVERTICAL)); XtSetArg (args[1], XmNnumColumns, GetMajorDim()); XtSetArg (args[2], XmNadjustLast, False); Widget radioBoxWidget = XmCreateRadioBox ((Widget)m_mainWidget, wxMOTIF_STR("radioBoxWidget"), args, 3); m_radioButtons.reserve(n); m_radioButtonLabels.reserve(n); int i; for (i = 0; i < n; i++) { wxString str(GetLabelText(choices[i])); m_radioButtonLabels.push_back(str); Widget radioItem = XtVaCreateManagedWidget ( str.mb_str(), #if wxUSE_GADGETS xmToggleButtonGadgetClass, radioBoxWidget, #else xmToggleButtonWidgetClass, radioBoxWidget, #endif wxFont::GetFontTag(), m_font.GetFontTypeC(dpy), NULL); m_radioButtons.push_back((WXWidget)radioItem); XtAddCallback (radioItem, XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback, (XtPointer) this); } SetSelection (0); XtRealizeWidget((Widget)m_mainWidget); XtManageChild (radioBoxWidget); XtManageChild ((Widget)m_mainWidget); PostCreation(); AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y); return true; }