int main(int argc, char **argv) { XtAppContext app; XmFontList fontlist; XmString xmstr1 = XmStringCreateLtoR("Here\nIs\nA\nLabel", "MY_FONT"); Atom XA_MWM_MESSAGES, PUNT; char buf[256]; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, FallBack, NULL); fontlist = XmFontListAppendEntry(NULL, XmFontListEntryCreate("MY_FONT", XmFONT_IS_FONT, XLoadQueryFont(XtDisplay(toplevel), "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1"))); one = XtVaCreateManagedWidget("One", xmPushButtonWidgetClass, toplevel, XmNfontList, fontlist, XmNlabelString, xmstr1, XtNborderWidth, 20, NULL); XtAddCallback(one, XmNactivateCallback, cb, NULL); XA_MWM_MESSAGES = XmInternAtom(XtDisplay(toplevel), _XA_MWM_MESSAGES, False); XmAddWMProtocols(toplevel, &XA_MWM_MESSAGES, 1); PUNT = XmInternAtom(XtDisplay(toplevel), "PUNT", False); XmAddProtocolCallback(toplevel, XA_MWM_MESSAGES, PUNT, punt, NULL); sprintf(buf, MENU, PUNT); XtVaSetValues(toplevel, XmNmwmMenu, buf, NULL); XtRealizeWidget(toplevel); { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 50, 50, 57, 84, 0,0,0, /* One */ }; PrintDetails( toplevel ,Expected); }; LessTifTestMainLoop( toplevel ); exit(0); }
bool wxTopLevelWindowMotif::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { SetName(name); m_windowStyle = style; if ( parent ) parent->AddChild(this); wxTopLevelWindows.Append(this); m_windowId = ( id > -1 ) ? id : NewControlId(); // MBN: More backward compatible, but uglier m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_inheritFont = true; bool retval = XmDoCreateTLW( parent, id, title, pos, size, style, name ); if( !retval ) return false; // Intercept CLOSE messages from the window manager Widget shell = (Widget)GetShellWidget(); Atom WM_DELETE_WINDOW = XmInternAtom( XtDisplay( shell ), "WM_DELETE_WINDOW", False ); // Remove and add WM_DELETE_WINDOW so ours is only handler // This only appears to be necessary for wxDialog, but does not hurt // for wxFrame XmRemoveWMProtocols( shell, &WM_DELETE_WINDOW, 1 ); XmAddWMProtocols( shell, &WM_DELETE_WINDOW, 1 ); XmActivateWMProtocol( shell, WM_DELETE_WINDOW ); // Modified Steve Hammes for Motif 2.0 #if (XmREVISION > 1 || XmVERSION > 1) XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW, (XtCallbackProc)wxCloseTLWCallback, (XtPointer)this ); #elif XmREVISION == 1 XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW, (XtCallbackProc)wxCloseTLWCallback, (caddr_t)this ); #else XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW, (void (*)())wxCloseTLWCallback, (caddr_t)this ); #endif // This patch come from Torsten Liermann [email protected] if( XmIsMotifWMRunning( shell ) ) { int decor = 0 ; if( !(m_windowStyle & wxNO_BORDER) ) decor |= MWM_DECOR_BORDER; if( m_windowStyle & wxRESIZE_BORDER ) decor |= MWM_DECOR_RESIZEH; if( m_windowStyle & wxSYSTEM_MENU ) decor |= MWM_DECOR_MENU; if( ( m_windowStyle & wxCAPTION ) || ( m_windowStyle & wxTINY_CAPTION_HORIZ ) || ( m_windowStyle & wxTINY_CAPTION_VERT ) ) decor |= MWM_DECOR_TITLE; if( m_windowStyle & wxRESIZE_BORDER ) decor |= MWM_DECOR_BORDER; if( m_windowStyle & wxMINIMIZE_BOX ) decor |= MWM_DECOR_MINIMIZE; if( m_windowStyle & wxMAXIMIZE_BOX ) decor |= MWM_DECOR_MAXIMIZE; XtVaSetValues( shell, XmNmwmDecorations, decor, NULL ); } else { // This allows non-Motif window managers to support at least the // no-decorations case. if( ( m_windowStyle & wxCAPTION ) != wxCAPTION ) XtVaSetValues( shell, XmNoverrideRedirect, True, NULL ); } XtAddEventHandler( (Widget)GetClientWidget(), ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, False, wxTLWEventHandler, (XtPointer)this ); return retval; }
void main(unsigned int argc, char **argv) { Arg args[10]; int n; int i; XmString message; XmString cancel_label, ok_label, help_label; char message_begin[120]; n = 0; CommonTestInit(argc, argv); n = 0; XtSetArg(args[n], XmNwidth, 10); n++; XtSetArg(args[n], XmNheight, 10); n++; XtSetValues(Shell1, args, n); XtRealizeWidget(Shell1); CommonPause(); XSetErrorHandler(ErrorHandle); /* * Initialize the PIInfo data values */ for (i = 0; i < NUM_TESTS; i++) PIInfo[i].actual_return = False; /* * Create top level shell widget as parent for test_button widgets */ n = 0; XtSetArg(args[n], XtNallowShellResize, TRUE); n++; test_top = XtAppCreateShell("test_top", /* application name */ "Test_top", /* application class */ topLevelShellWidgetClass, /* widget class */ display, /* display */ args, n); /* arguments */ /* * Create button1 widget */ display = XtDisplay(test_top); screen = DefaultScreenOfDisplay(display); test1_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow, btn1_bits, btn1_width, btn1_height, CommonGetColor("red"), CommonGetColor("yellow"), DefaultDepth(display, DefaultScreen(display))); test2_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow, btn2_bits, btn2_width, btn2_height, CommonGetColor("yellow"), CommonGetColor("red"), DefaultDepth(display, DefaultScreen(display))); n = 0; XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; XtSetArg(args[n], XmNlabelPixmap, test1_btn1_icon); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; test1_btn1 = XmCreatePushButton(test_top, "test1_btn1", args, n); XtManageChild(test1_btn1); XtRealizeWidget(test_top); /* * Create top level shell widget as parent for test_button2 widget */ n = 0; XtSetArg(args[n], XtNallowShellResize, TRUE); n++; test_top2 = XtAppCreateShell("test_top2", /* application name */ "Test_top2", /* application class */ topLevelShellWidgetClass, /* widget class */ display, /* display */ args, n); /* arguments */ /* * Create button2 widget */ n = 0; XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; XtSetArg(args[n], XmNlabelPixmap, test2_btn1_icon); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; test2_btn1 = XmCreatePushButton(test_top2, "test2_btn1", args, n); XtManageChild(test2_btn1); XtRealizeWidget(test_top2); test_wdw = XtWindow(test_top); top_wdw = XtWindow(Shell1); test_wdw2 = XtWindow(test_top2); XtAddEventHandler(Shell1, NoEventMask, True, CMEventHandler, NULL); XtAddEventHandler(test_top, NoEventMask, True, CMEventHandler, NULL); XtAddEventHandler(test_top2, NoEventMask, True, CMEventHandler, NULL); /* * Move the test_top shell window and the Shell1 window */ XMoveWindow(display, test_wdw, 100, 100); XMoveWindow(display, test_wdw2, 100, 300); /* * set protocols - WM_DELETE_WINDOW */ proto_atom = XmInternAtom(display, "WM_PROTOCOLS", False); delwin_atom = XmInternAtom(display, "WM_DELETE_WINDOW", False); XmAddWMProtocols(test_top, &delwin_atom, 1); #ifdef DONT /* * set protocols - WM_SAVE_YOURSELF */ savylf_atom = XmInternAtom(display, "WM_SAVE_YOURSELF", False); XmAddWMProtocols(test_top2, &savylf_atom, 1); /* * set protocols - WM_TAKE_FOCUS */ takfoc_atom = XmInternAtom(display, "WM_TAKE_FOCUS", False); /* change it on test_wdw2 */ XChangeProperty(display, test_wdw2, proto_atom, proto_atom, 32, PropModeReplace, (unsigned char *)&takfoc_atom, 1); #endif /* DONT */ CommonPause(); iteration++; /* * Check if window is not deleted after f.kill WM_DELETE_WINDOW */ ret_stat = XGetWindowAttributes(display, test_wdw, &win_attrs); /* * Actual return is if the window is still mapped and * recognizable. */ PIInfo[PIInfo_DW2].actual_return = ret_stat; /* * set protocols - _MOTIF_WM_MESSAGES */ /* add to the menu with the _MOTIF_WM_MENU property */ strcpy(menu_item, send_msg1); menu_atom = XmInternAtom(display, "_MOTIF_WM_MENU", False); XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, PropModeReplace, (unsigned char *)menu_item, strlen(menu_item) + 1); /* add a message acceptance to widget */ motif_msg_atom = XmInternAtom(display, "_MOTIF_WM_MESSAGES", False); XmAddWMProtocols(test_top2, &motif_msg_atom, 1); msg_num = MSG_NUMBER; XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num, HandleMsgCB, NULL); PIUnmapWindow(test_wdw2); wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = NormalState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); XMoveWindow(display, test_wdw2, 100, 300); #ifdef DONT /* * Iconify test_wdw2, see if save_yourself works */ /* * Unmap the window to change state */ PIUnmapWindow(test_wdw2); /* * Map the window into iconic state */ wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = IconicState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); #endif /* DONT */ CommonPause(); #ifdef SHOW_P899 iteration++; /* * set protocols - _MOTIF_WM_MENU */ /* add to the menu with the _MOTIF_WM_MENU property */ strcpy(menu_item2, send_msg2); XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, PropModeAppend, (unsigned char *)menu_item2, strlen(menu_item2) + 1); /* * Turn on acceptance of send_message2 */ msg_num = MSG_NUMBER2; XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num, HandleMsg2CB, NULL); PIUnmapWindow(test_wdw2); wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = NormalState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); XMoveWindow(display, test_wdw2, 100, 300); CommonPause(); #endif /* P899 */ iteration++; /* * set protocols - _MOTIF_WM_MENU */ /* add to the menu with the _MOTIF_WM_MENU property */ strcpy(menu_item2, send_msg3); XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, PropModeReplace, (unsigned char *)menu_item2, strlen(menu_item2) + 1); #ifndef P899 /* * Turn on acceptance of send_message2 */ msg_num = MSG_NUMBER2; XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num, HandleMsg2CB, NULL); #endif /* P899 */ PIUnmapWindow(test_wdw2); wm_set_hints.flags = (StateHint); wm_set_hints.initial_state = NormalState; XSetWMHints(display, test_wdw2, &wm_set_hints); XMapWindow(display, test_wdw2); XMoveWindow(display, test_wdw2, 100, 300); CommonPause(); iteration++; /* * Put up a message box with the results of the test. */ display_summary(NUM_TESTS, TEST_DESCRIP_LENGTH, PIInfo); CommonPause(); /* * Loop and process events. */ XtAppMainLoop(app_context); }