wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget, const wxWindow* window ) { Dimension xmargin, ymargin, highlight, shadow; char* value; XtVaGetValues( textWidget, XmNmarginWidth, &xmargin, XmNmarginHeight, &ymargin, XmNvalue, &value, XmNhighlightThickness, &highlight, XmNshadowThickness, &shadow, NULL ); if( !value ) value = wxMOTIF_STR("|"); int x, y; window->GetTextExtent( value, &x, &y ); if( x < 90 ) x = 90; return wxSize( x + 2 * xmargin + 2 * highlight + 2 * shadow, // MBN: +2 necessary: Lesstif bug or mine? y + 2 * ymargin + 2 * highlight + 2 * shadow + 2 ); }
// Create menubar bool wxMenuBar::CreateMenuBar(wxFrame* parent) { m_parent = parent; // bleach... override it! PreCreation(); m_parent = NULL; if (m_mainWidget) { XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); /* if (!XtIsManaged((Widget) m_mainWidget)) XtManageChild((Widget) m_mainWidget); */ XtMapWidget((Widget) m_mainWidget); return true; } Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), wxMOTIF_STR("MenuBar"), NULL, 0); m_mainWidget = (WXWidget) menuBarW; size_t menuCount = GetMenuCount(); for (size_t i = 0; i < menuCount; i++) { wxMenu *menu = GetMenu(i); wxString title(m_titles[i]); menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, i, title, true)); if (strcmp (wxStripMenuCodes(title), "Help") == 0) XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL); // tear off menu support #if (XmVersion >= 1002) if ( menu->IsTearOff() ) { XtVaSetValues(GetWidget(menu), XmNtearOffModel, XmTEAR_OFF_ENABLED, NULL); Widget tearOff = XmGetTearOffControl(GetWidget(menu)); wxDoChangeForegroundColour((Widget) tearOff, m_foregroundColour); wxDoChangeBackgroundColour((Widget) tearOff, m_backgroundColour, true); } #endif } PostCreation(); XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); XtRealizeWidget ((Widget) menuBarW); XtManageChild ((Widget) menuBarW); SetMenuBarFrame(parent); return true; }
WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topMenu, size_t menuIndex, const wxString& title, bool pullDown) { Widget menu = (Widget) 0; Widget buttonWidget = (Widget) 0; Display* dpy = XtDisplay((Widget)parent); Arg args[5]; XtSetArg (args[0], XmNnumColumns, m_numColumns); XtSetArg (args[1], XmNpacking, (m_numColumns > 1) ? XmPACK_COLUMN : XmPACK_TIGHT); if ( !m_font.IsOk() ) { if ( menuBar ) m_font = menuBar->GetFont(); else if ( GetInvokingWindow() ) m_font = GetInvokingWindow()->GetFont(); } XtSetArg (args[2], (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) ); if (!pullDown) { menu = XmCreatePopupMenu ((Widget) parent, wxMOTIF_STR("popup"), args, 3); #if 0 XtAddCallback(menu, XmNunmapCallback, (XtCallbackProc)wxMenuPopdownCallback, (XtPointer)this); #endif } else { char mnem = wxFindMnemonic (title); menu = XmCreatePulldownMenu ((Widget) parent, wxMOTIF_STR("pulldown"), args, 3); wxString title2(wxStripMenuCodes(title)); wxXmString label_str(title2); buttonWidget = XtVaCreateManagedWidget(title2, #if wxUSE_GADGETS xmCascadeButtonGadgetClass, (Widget) parent, #else xmCascadeButtonWidgetClass, (Widget) parent, #endif XmNlabelString, label_str(), XmNsubMenuId, menu, (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy), XmNpositionIndex, menuIndex, NULL); if (mnem != 0) XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL); } m_menuWidget = (WXWidget) menu; m_topLevelMenu = topMenu; size_t i = 0; for ( wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); node; node = node->GetNext(), ++i ) { wxMenuItem *item = node->GetData(); item->CreateItem(menu, menuBar, topMenu, i); } ChangeFont(); return buttonWidget; }
wxString wxGetXEventName(XEvent& event) { #if wxUSE_NANOX wxString str(wxT("(some event)")); return str; #else int type = event.xany.type; static char* event_name[] = { wxMOTIF_STR(""), wxMOTIF_STR("unknown(-)"), // 0-1 wxMOTIF_STR("KeyPress"), wxMOTIF_STR("KeyRelease"), wxMOTIF_STR("ButtonPress"), wxMOTIF_STR("ButtonRelease"), // 2-5 wxMOTIF_STR("MotionNotify"), wxMOTIF_STR("EnterNotify"), wxMOTIF_STR("LeaveNotify"), wxMOTIF_STR("FocusIn"), // 6-9 wxMOTIF_STR("FocusOut"), wxMOTIF_STR("KeymapNotify"), wxMOTIF_STR("Expose"), wxMOTIF_STR("GraphicsExpose"), // 10-13 wxMOTIF_STR("NoExpose"), wxMOTIF_STR("VisibilityNotify"), wxMOTIF_STR("CreateNotify"), // 14-16 wxMOTIF_STR("DestroyNotify"), wxMOTIF_STR("UnmapNotify"), wxMOTIF_STR("MapNotify"), wxMOTIF_STR("MapRequest"),// 17-20 wxMOTIF_STR("ReparentNotify"), wxMOTIF_STR("ConfigureNotify"), wxMOTIF_STR("ConfigureRequest"), // 21-23 wxMOTIF_STR("GravityNotify"), wxMOTIF_STR("ResizeRequest"), wxMOTIF_STR("CirculateNotify"), // 24-26 wxMOTIF_STR("CirculateRequest"), wxMOTIF_STR("PropertyNotify"), wxMOTIF_STR("SelectionClear"), // 27-29 wxMOTIF_STR("SelectionRequest"), wxMOTIF_STR("SelectionNotify"), wxMOTIF_STR("ColormapNotify"), // 30-32 wxMOTIF_STR("ClientMessage"), wxMOTIF_STR("MappingNotify"), // 33-34 wxMOTIF_STR("unknown(+)")}; // 35 type = wxMin(35, type); type = wxMax(1, type); wxString str(event_name[type]); return str; #endif }
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; }
int wxMessageDialog::ShowModal() { const long style = GetMessageDialogStyle(); DialogCreateFunction dialogCreateFunction; if ( style & wxYES_NO ) { // if we have [Yes], it must be a question dialogCreateFunction = XmCreateQuestionDialog; } else if ( style & wxICON_STOP ) { // error dialog is the one with error icon... dialogCreateFunction = XmCreateErrorDialog; } else if ( style & wxICON_EXCLAMATION ) { // ...and the warning dialog too dialogCreateFunction = XmCreateWarningDialog; } else { // finally, use the info dialog by default dialogCreateFunction = XmCreateInformationDialog; } Widget wParent = m_parent ? GetWidget(m_parent) : (Widget) 0; if ( !wParent ) { wxWindow *window = wxTheApp->GetTopWindow(); if ( !window ) { wxFAIL_MSG("can't show message box without parent window"); return wxID_CANCEL; } wParent = GetWidget(window); } // prepare the arg list Arg args[10]; int ac = 0; wxXmString text(m_message); wxXmString title(m_caption); XtSetArg(args[ac], XmNmessageString, text()); ac++; XtSetArg(args[ac], XmNdialogTitle, title()); ac++; Display* dpy = XtDisplay(wParent); wxComputeColours (dpy, & m_backgroundColour, (wxColour*) NULL); XtSetArg(args[ac], XmNbackground, g_itemColors[wxBACK_INDEX].pixel); ac++; XtSetArg(args[ac], XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel); ac++; XtSetArg(args[ac], XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel); ac++; XtSetArg(args[ac], XmNforeground, g_itemColors[wxFORE_INDEX].pixel); ac++; wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #if __WXMOTIF20__ && !__WXLESSTIF__ XtSetArg(args[ac], XmNbuttonRenderTable, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNlabelRenderTable, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNtextRenderTable, font.GetFontTypeC(dpy)); ac++; #else XtSetArg(args[ac], XmNbuttonFontList, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNlabelFontList, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNtextFontList, font.GetFontTypeC(dpy)); ac++; #endif // do create message box Widget wMsgBox = (*dialogCreateFunction)(wParent, wxMOTIF_STR(""), args, ac); wxCHECK_MSG( wMsgBox, wxID_CANCEL, "msg box creation failed" ); // get the buttons which we might either remove or rename // depending on the requested style // Widget wBtnOk = XmMessageBoxGetChild(wMsgBox, XmDIALOG_OK_BUTTON); Widget wBtnHelp = XmMessageBoxGetChild(wMsgBox, XmDIALOG_HELP_BUTTON); Widget wBtnCancel = XmMessageBoxGetChild(wMsgBox, XmDIALOG_CANCEL_BUTTON); if ( style & wxYES_NO ) { wxXmString yes(_("Yes")), no(_("No")), cancel(_("Cancel")); if ( style & wxCANCEL ) { // use the cancel button for No and the help button for // Cancel Yuk :-) MB // XtVaSetValues(wBtnOk, XmNlabelString, yes(), NULL); XtVaSetValues(wBtnCancel, XmNlabelString, no(), NULL); XtVaSetValues(wBtnHelp, XmNlabelString, cancel(), NULL); } else { // no cancel button requested... // remove the help button and use cancel for no // XtVaSetValues(wBtnCancel, XmNlabelString, no(), NULL); XtUnmanageChild(wBtnHelp); } } else { // remove the help button and the cancel button (unless it was // requested) // XtUnmanageChild(wBtnHelp); if ( !(style & wxCANCEL ) ) XtUnmanageChild(wBtnCancel); } // set the callbacks for the message box buttons XtAddCallback(wMsgBox, XmNokCallback, (XtCallbackProc)msgboxCallBackOk, (XtPointer)this); XtAddCallback(wMsgBox, XmNcancelCallback, (XtCallbackProc)msgboxCallBackCancel, (XtPointer)this); XtAddCallback(wMsgBox, XmNhelpCallback, (XtCallbackProc)msgboxCallBackHelp, (XtPointer)this); XtAddCallback(wMsgBox, XmNunmapCallback, (XtCallbackProc)msgboxCallBackClose, (XtPointer)this); // show it as a modal dialog XtManageChild(wMsgBox); XtAddGrab(wMsgBox, True, False); // the m_result will be changed when message box goes away m_result = -1; // local message loop XtAppContext context = XtWidgetToApplicationContext(wParent); XEvent event; while ( m_result == -1 ) { XtAppNextEvent(context, &event); XtDispatchEvent(&event); } // translate the result if necessary if ( style & wxYES_NO ) { if ( m_result == wxID_OK ) m_result = wxID_YES; else if ( m_result == wxID_CANCEL ) m_result = wxID_NO; else if ( m_result == wxID_HELP ) m_result = wxID_CANCEL; } return m_result; }
int wxFileDialog::ShowModal() { wxBeginBusyCursor(); // static char fileBuf[512]; Widget parentWidget = (Widget) 0; if (m_parent) parentWidget = (Widget) m_parent->GetTopWidget(); else parentWidget = (Widget) wxTheApp->GetTopLevelWidget(); // prepare the arg list Display* dpy = XtDisplay(parentWidget); Arg args[10]; int ac = 0; if (m_backgroundColour.IsOk()) { wxComputeColours (dpy, & m_backgroundColour, NULL); XtSetArg(args[ac], XmNbackground, g_itemColors[wxBACK_INDEX].pixel); ac++; XtSetArg(args[ac], XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel); ac++; XtSetArg(args[ac], XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel); ac++; XtSetArg(args[ac], XmNforeground, g_itemColors[wxFORE_INDEX].pixel); ac++; } wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #if __WXMOTIF20__ && !__WXLESSTIF__ XtSetArg(args[ac], XmNbuttonRenderTable, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNlabelRenderTable, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNtextRenderTable, font.GetFontTypeC(dpy)); ac++; #else XtSetArg(args[ac], XmNbuttonFontList, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNlabelFontList, font.GetFontTypeC(dpy)); ac++; XtSetArg(args[ac], XmNtextFontList, font.GetFontTypeC(dpy)); ac++; #endif Widget fileSel = XmCreateFileSelectionDialog(parentWidget, wxMOTIF_STR("file_selector"), args, ac); #define wxFSChild( name ) \ XmFileSelectionBoxGetChild(fileSel, name) XtUnmanageChild(wxFSChild(XmDIALOG_HELP_BUTTON)); Widget filterWidget = wxFSChild(XmDIALOG_FILTER_TEXT); Widget selectionWidget = wxFSChild(XmDIALOG_TEXT); Widget dirListWidget = wxFSChild(XmDIALOG_DIR_LIST); Widget fileListWidget = wxFSChild(XmDIALOG_LIST); // for changing labels Widget okWidget = wxFSChild(XmDIALOG_OK_BUTTON); Widget applyWidget = wxFSChild(XmDIALOG_APPLY_BUTTON); Widget cancelWidget = wxFSChild(XmDIALOG_CANCEL_BUTTON); Widget dirlistLabel = wxFSChild(XmDIALOG_DIR_LIST_LABEL); Widget filterLabel = wxFSChild(XmDIALOG_FILTER_LABEL); Widget listLabel = wxFSChild(XmDIALOG_LIST_LABEL); Widget selectionLabel = wxFSChild(XmDIALOG_SELECTION_LABEL); #undef wxFSChild // change labels wxXmString btnOK( wxGetStockLabel( wxID_OK, false ) ), btnCancel( wxGetStockLabel( wxID_CANCEL, false ) ), btnFilter( _("Filter") ), lblFilter( _("Filter") ), lblDirectories( _("Directories") ), lblFiles( _("Files" ) ), lblSelection( _("Selection") ); XtVaSetValues( okWidget, XmNlabelString, btnOK(), NULL ); XtVaSetValues( applyWidget, XmNlabelString, btnFilter(), NULL ); XtVaSetValues( cancelWidget, XmNlabelString, btnCancel(), NULL ); XtVaSetValues( dirlistLabel, XmNlabelString, lblDirectories(), NULL ); XtVaSetValues( filterLabel, XmNlabelString, lblFilter(), NULL ); XtVaSetValues( listLabel, XmNlabelString, lblFiles(), NULL ); XtVaSetValues( selectionLabel, XmNlabelString, lblSelection(), NULL ); Widget shell = XtParent(fileSel); if ( !m_message.empty() ) XtVaSetValues(shell, XmNtitle, (const char*)m_message.mb_str(), NULL); if (!m_wildCard.empty()) { // return something understandable by Motif wxString wildCard = ParseWildCard( m_wildCard ); wxString filter; if (!m_dir.empty()) filter = m_dir + wxString("/") + wildCard; else filter = wildCard; XmTextSetString(filterWidget, filter.char_str()); XmFileSelectionDoSearch(fileSel, NULL); } // Suggested by Terry Gitnick, 16/9/97, because of change in Motif // file selector on Solaris 1.5.1. if ( !m_dir.empty() ) { wxXmString thePath( m_dir ); XtVaSetValues (fileSel, XmNdirectory, thePath(), NULL); } wxString entirePath; if (!m_dir.empty()) { entirePath = m_dir + wxString("/") + m_fileName; } else { entirePath = m_fileName; } if (!entirePath.empty()) { XmTextSetString(selectionWidget, entirePath.char_str()); } XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL); XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL); XtAddCallback(fileSel, XmNunmapCallback, (XtCallbackProc)wxFileSelClose, (XtPointer)this); //#if XmVersion > 1000 // I'm not sure about what you mean with XmVersion. // If this is for Motif1.1/Motif1.2, then check XmVersion>=1200 // (Motif1.1.4 ==> XmVersion 1100 ) // Nevertheless, I put here a #define, so anyone can choose in (I)makefile. // #if !DEFAULT_FILE_SELECTOR_SIZE int width = wxFSB_WIDTH; int height = wxFSB_HEIGHT; XtVaSetValues(fileSel, XmNwidth, width, XmNheight, height, XmNresizePolicy, XmRESIZE_NONE, NULL); #endif wxDoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE); wxDoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE); wxChangeListBoxColours(this, dirListWidget); wxChangeListBoxColours(this, fileListWidget); XtManageChild(fileSel); m_fileSelectorAnswer = wxEmptyString; m_fileSelectorReturned = false; wxEndBusyCursor(); XtAddGrab(XtParent(fileSel), True, False); XtAppContext context = (XtAppContext) wxTheApp->GetAppContext(); XEvent event; while (!m_fileSelectorReturned) { XtAppNextEvent(context, &event); XtDispatchEvent(&event); } XtRemoveGrab(XtParent(fileSel)); XtUnmapWidget(XtParent(fileSel)); XtDestroyWidget(XtParent(fileSel)); // Now process all events, because otherwise // this might remain on the screen wxFlushEvents(XtDisplay(fileSel)); m_path = m_fileSelectorAnswer; m_fileName = wxFileNameFromPath(m_fileSelectorAnswer); m_dir = wxPathOnly(m_path); if (m_fileName.empty()) return wxID_CANCEL; else return wxID_OK; }
WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topMenu, size_t WXUNUSED(index), const wxString& title, bool pullDown) { Widget menu = (Widget) 0; Widget buttonWidget = (Widget) 0; Arg args[5]; XtSetArg (args[0], XmNnumColumns, m_numColumns); XtSetArg (args[1], XmNpacking, (m_numColumns > 1) ? XmPACK_COLUMN : XmPACK_TIGHT); if (!pullDown) { menu = XmCreatePopupMenu ((Widget) parent, wxMOTIF_STR("popup"), args, 2); #if 0 XtAddCallback(menu, XmNunmapCallback, (XtCallbackProc)wxMenuPopdownCallback, (XtPointer)this); #endif } else { char mnem = wxFindMnemonic (title); menu = XmCreatePulldownMenu ((Widget) parent, wxMOTIF_STR("pulldown"), args, 2); wxString title2(wxStripMenuCodes(title)); wxXmString label_str(title2); buttonWidget = XtVaCreateManagedWidget(title2, #if wxUSE_GADGETS xmCascadeButtonGadgetClass, (Widget) parent, #else xmCascadeButtonWidgetClass, (Widget) parent, #endif XmNlabelString, label_str(), XmNsubMenuId, menu, NULL); if (mnem != 0) XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL); } m_menuWidget = (WXWidget) menu; m_topLevelMenu = topMenu; size_t i = 0; for ( wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); node; node = node->GetNext(), ++i ) { wxMenuItem *item = node->GetData(); item->CreateItem(menu, menuBar, topMenu, i); } SetBackgroundColour(m_backgroundColour); SetForegroundColour(m_foregroundColour); SetFont(m_font); return buttonWidget; }
bool wxApp::Initialize(int& argc_, wxChar **argv_) { #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif if ( !wxAppBase::Initialize(argc_, argv_) ) return false; wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); #ifdef __HPUX__ // under HP-UX creating XmFontSet fails when the system locale is C and // we're using a remote DISPLAY, presumably because HP-UX uses its own // names for C and ISO locales (roman8 and iso8859n respectively) and so // its Motif libraries have troubles with non-HP X server // // whatever the reason, the fact is that without this hack any wxMotif // program crashes on startup because it can't create any font (HP programs // still work but they do spit out messages about failing to create font // sets and failing back on "fixed" font too) // // notice that calling setlocale() here is not enough because X(m) init // functions call setlocale() later so we really have to change environment bool fixAll = false; // tweak LC_ALL (or just LC_CTYPE)? const char *loc = getenv("LC_CTYPE"); if ( !loc ) { loc = getenv("LC_ALL"); if ( loc ) fixAll = true; } if ( !loc || (loc[0] == 'C' && loc[1] == '\0') || strcmp(loc, "POSIX") == 0 ) { // we're using C locale, "fix" it wxLogDebug(wxT("HP-UX fontset hack: forcing locale to en_US.iso88591")); putenv(fixAll ? "LC_ALL=en_US.iso88591" : "LC_CTYPE=en_US.iso88591"); } #endif // __HPUX__ XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize() ; wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext(); static char *fallbackResources[] = { // better defaults for CDE under Irix // // TODO: do something similar for the other systems, the hardcoded defaults // below are ugly #ifdef __SGI__ wxMOTIF_STR("*sgiMode: True"), wxMOTIF_STR("*useSchemes: all"), #else // !__SGI__ #if !wxMOTIF_USE_RENDER_TABLE wxMOTIF_STR("*.fontList: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"), #else wxMOTIF_STR("*wxDefaultRendition.fontName: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"), wxMOTIF_STR("*wxDefaultRendition.fontType: FONT_IS_FONTSET"), wxMOTIF_STR("*.renderTable: wxDefaultRendition"), #endif wxMOTIF_STR("*listBox.background: white"), wxMOTIF_STR("*text.background: white"), wxMOTIF_STR("*comboBox.Text.background: white"), wxMOTIF_STR("*comboBox.List.background: white"), #endif // __SGI__/!__SGI__ NULL }; XtAppSetFallbackResources((XtAppContext) wxTheApp->m_appContext, fallbackResources); // we shouldn't pass empty application/class name as it results in // immediate crash inside XOpenIM() (if XIM is used) under IRIX wxString appname = wxTheApp->GetAppName(); if ( appname.empty() ) appname = wxT("wxapp"); wxString clsname = wxTheApp->GetClassName(); if ( clsname.empty() ) clsname = wxT("wx"); // FIXME-UTF8: This code is taken from wxGTK and duplicated here. This // is just a temporary fix to make wxX11 compile in Unicode // build, the real fix is to change Initialize()'s signature // to use char* on Unix. #if wxUSE_UNICODE // XtOpenDisplay() wants char*, not wchar_t*, so convert int i; char **argvX11 = new char *[argc + 1]; for ( i = 0; i < argc; i++ ) { argvX11[i] = strdup(wxConvLibc.cWX2MB(argv_[i])); } argvX11[argc] = NULL; int argcX11 = argc; Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, (String)NULL, appname.c_str(), clsname.c_str(), NULL, 0, // no options # if XtSpecificationRelease < 5 (Cardinal*) &argcX11, # else &argcX11, # endif argvX11); if ( argcX11 != argc ) { // we have to drop the parameters which were consumed by X11+ for ( i = 0; i < argcX11; i++ ) { while ( strcmp(wxConvLibc.cWX2MB(argv_[i]), argvX11[i]) != 0 ) { memmove(argv_ + i, argv_ + i + 1, (argc - i)*sizeof(*argv_)); } } argc = argcX11; // update internal arg[cv] as X11 may have removed processed options: argc = argc_; argv = argv_; } //else: XtOpenDisplay() didn't modify our parameters // free our copy for ( i = 0; i < argcX11; i++ ) { free(argvX11[i]); } delete [] argvX11; #else // ANSI Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, (String)NULL, appname.c_str(), clsname.c_str(), NULL, 0, // no options # if XtSpecificationRelease < 5 (Cardinal*) &argc, # else &argc, # endif argv); #endif // Unicode/ANSI if (!dpy) { // if you don't log to stderr, nothing will be shown... delete wxLog::SetActiveTarget(new wxLogStderr); wxString className(wxTheApp->GetClassName()); wxLogError(_("wxWidgets could not open display for '%s': exiting."), className.c_str()); exit(-1); } m_initialDisplay = (WXDisplay*) dpy; // install the X error handler gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler); // Add general resize proc XtActionsRec rec; rec.string = wxMOTIF_STR("resize"); rec.proc = (XtActionProc)wxWidgetResizeProc; XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1); GetMainColormap(dpy); wxAddIdleCallback(); return true; }
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; }