XFE_Dialog::XFE_Dialog(Widget parent, // dialog parent char *name, // dialog name Boolean ok, // show OK button? Boolean cancel, // show cancel button? Boolean help, // show help button? Boolean apply, // show apply button? Boolean separator, // show separator? Boolean modal, // modal dialog? Widget chrome_widget) : XFE_Component() { m_wParent = parent; // Create the chrome if (chrome_widget == NULL) m_chrome = createDialogChromeWidget(parent, name, ok, cancel, help, apply, separator, modal); else m_chrome = chrome_widget; // Register base widget and parent widget setBaseWidget(XtParent(m_chrome)); installDestroyHandler(); }
MenuBar::MenuBar ( Widget parent, char *name, unsigned char type ) : UIComponent ( name ) { // Base widget is a Motif menu bar widget if(parent == NULL) return; if( type == XmMENU_POPUP) { Arg args[1]; int i = 0; XtSetArg(args[i], XmNwhichButton, theApplication->bMenuButton()); i++; _w = XmCreatePopupMenu( parent, _name, args, i ); // XtVaSetValues(_w, XmNwhichButton, theApplication->bMenuButton(), NULL); } else { type = XmMENU_BAR; // Force it to menu bar _w = XmCreateMenuBar ( parent, _name, NULL, 0 ); } printHelpId("_w", _w); /* install callback */ // XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId); installDestroyHandler(); }
void DialogShell::initialize() { _w = XtVaCreatePopupShell( _name, _widgetClass, _parent->baseWidget(), XmNdefaultPosition, False, NULL, NULL ); #ifdef USE_EDITRES XtAddEventHandler( _w, (EventMask) 0, True, (XtEventHandler) _XEditResCheckMessages, NULL); #endif installDestroyHandler(); _workArea = createWorkArea ( _w ); assert ( _workArea != NULL ); XtVaSetValues( _w, XmNdefaultPosition, False, NULL ); XtAddCallback( _w, XmNpopupCallback, ( XtCallbackProc ) &DialogShell::popupCallback, XtPointer( this ) ); XtAddCallback( _w, XmNpopdownCallback, ( XtCallbackProc ) &DialogShell::popdownCallback, XtPointer( this ) ); Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ), "WM_DELETE_WINDOW", False ); XmAddWMProtocolCallback( _w, WM_DELETE_WINDOW, ( XtCallbackProc ) quitCallback, this ); // if (!XtIsManaged(_workArea)) XtManageChild(_workArea); }
////////////////////////////////////////////////////////////////////////// // // XFE_TaskBar Public Methods // ////////////////////////////////////////////////////////////////////////// XFE_TaskBar::XFE_TaskBar(Widget parent, XFE_Frame * parent_frame, XP_Bool is_floating) : XFE_Component(parent_frame), m_isFloating(is_floating), m_parentFrame(parent_frame) #ifdef MOZ_MAIL_NEWS ,m_biffNoticeInstalled(False) #endif { XP_ASSERT( parent_frame != NULL ); // Create widgets according to docking state if (!m_isFloating) { createDockedWidgets(parent); } else { createFloatingWidgets(parent); XFE_MozillaApp::theApp()->registerInterest( XFE_MozillaApp::appBusyCallback, this, updateFloatingBusyState_cb, (void*)True); XFE_MozillaApp::theApp()->registerInterest( XFE_MozillaApp::appNotBusyCallback, this, updateFloatingBusyState_cb, (void*)False); } installDestroyHandler(); }
DmxPrintOutput::DmxPrintOutput ( Widget pshell ) : UIComponent( "PrintOutput" ) { Widget w; DtMailBoolean parse_error; _w = NULL; _pshell = pshell; w = XtVaCreateWidget("Page", xmFormWidgetClass, _pshell, XmNresizePolicy, XmRESIZE_NONE, NULL); _form = w; _w = _form; w = XtVaCreateWidget("InnerPage", xmFormWidgetClass, _form, XmNresizePolicy, XmRESIZE_NONE, NULL); _inner_form = w; w = XtVaCreateManagedWidget("HeaderLeft", xmLabelWidgetClass, _inner_form, XmNalignment, XmALIGNMENT_BEGINNING, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); _header_left = w; w = XtVaCreateManagedWidget("HeaderRight", xmLabelWidgetClass, _inner_form, XmNalignment, XmALIGNMENT_END, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, _header_left, XmNtopAttachment, XmATTACH_FORM, NULL); _header_right = w; w = XtVaCreateManagedWidget("Editor", #ifdef USE_DTEDITOR dtEditorWidgetClass, #else xmTextWidgetClass, #endif _inner_form, DtNscrollVertical, FALSE, DtNscrollHorizontal, FALSE, DtNshowStatusLine, FALSE, DtNwordWrap, TRUE, XmNeditMode, XmMULTI_LINE_EDIT, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, _header_left, NULL); _editor = w; w = XtVaCreateManagedWidget("FooterLeft", xmLabelWidgetClass, _inner_form, XmNalignment, XmALIGNMENT_BEGINNING, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); _footer_left = w; w = XtVaCreateManagedWidget("FooterRight", xmLabelWidgetClass, _inner_form, XmNalignment, XmALIGNMENT_END, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, _footer_left, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); _footer_right = w; XtVaSetValues( _editor, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, _footer_left, NULL); installDestroyHandler(); XtManageChild(_inner_form); XtManageChild(_form); setPageMargins( _default_margin, _default_margin, _default_margin, _default_margin, &parse_error ); assert(!parse_error); }
NAMESPACEHACK #include <Xm/Xm.h> #include <Xm/Form.h> #include <Xm/Frame.h> #ifdef HYPFREE #include <GL/GLwMDrawA.h> #else #include <X11/GLw/GLwMDrawA.h> #endif #include "VkHypViewer.h" #ifdef HYPVK VkHypViewer::VkHypViewer(const char* name, Widget top, Widget parent, XVisualInfo *vi) : VkComponent(name) { #else VkHypViewer::VkHypViewer(const char* name, Widget top, Widget parent, XVisualInfo *vi) { #endif hv = NULL; if (!vi) { static int fallback[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1, None}; XVisualInfo *visinfo; Display *d = XtDisplay(top); if (!(visinfo = glXChooseVisual(d, DefaultScreen(d), fallback))) { XtAppError(XtDisplayToApplicationContext(XtDisplay(top)), "HypViewer: no suitable RGB visual"); return; } vi = visinfo; } Pixel bg = WhitePixelOfScreen(XtScreen(top)); int pfwidth = 0; int pfheight = 0; XtVaGetValues(top, /* get width, height of parent_form */ XmNwidth, &pfwidth, XmNheight, &pfheight, NULL); glxarea = XtVaCreateManagedWidget("glxwidget", glwMDrawingAreaWidgetClass, parent, GLwNrgba, TRUE, GLwNdoublebuffer, TRUE, GLwNredSize, 1, GLwNgreenSize, 1, GLwNblueSize, 1, GLwNdepthSize, 15, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNbackground, bg, NULL); par = parent; #ifdef HYPVK _baseWidget = glxarea; installDestroyHandler(); #endif // XtAddCallback(glxarea, GLwNginitCallback, initCallback, (XtPointer)this); XtAddEventHandler(glxarea, PointerMotionMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | ExposureMask, FALSE, eventHandlerCB, (XtPointer) this); hv = new HypView(glxarea); cx = NULL; }
XFE_FolderDropdown::XFE_FolderDropdown(XFE_Component *toplevel_component, Widget parent, XP_Bool allowServerSelection, XP_Bool showNewsgroups, XP_Bool boldWithNew) : XFE_Component(toplevel_component) { m_popupServer = True; Widget combo; Colormap cmap; Cardinal depth; Visual *v; XtVaGetValues(getToplevel()->getBaseWidget(), XmNvisual, &v, XmNcolormap, &cmap, XmNdepth, &depth, NULL); m_allowServerSelection = allowServerSelection; m_showNewsgroups = showNewsgroups; m_boldWithNew = boldWithNew; m_foldersHaveChanged = FALSE; combo = XtVaCreateWidget("folderDropdown", dtComboBoxWidgetClass, parent, XmNshadowThickness, 1, XmNmarginWidth, 0, XmNmarginHeight, 0, XmNarrowType, XmMOTIF, XmNtype, XmDROP_DOWN_LIST_BOX, XmNcolumns, 30, XmNvisibleItemCount, 20, XmNvisual, v, XmNcolormap, cmap, XmNdepth, depth, NULL); m_lastSelectedPosition = 0; m_numNewsHosts = 0; m_numinfos = 0; m_infos = 0; XFE_MozillaApp::theApp()->registerInterest(XFE_MNView::foldersHaveChanged, this, (XFE_FunctionNotification)rebuildFolderDropdown_cb); XFE_MozillaApp::theApp()->registerInterest(XFE_MNView::newsgroupsHaveChanged, this, (XFE_FunctionNotification)rebuildFolderDropdown_cb); if (m_boldWithNew) XFE_MozillaApp::theApp()->registerInterest(XFE_MNView::folderChromeNeedsUpdating, this, (XFE_FunctionNotification)boldFolderInfo_cb); XtAddCallback(combo, XmNselectionCallback, folderSelect_cb, this); XtAddCallback(combo, XmNmenuPostCallback, folderMenuPost_cb, this); setBaseWidget(combo); installDestroyHandler(); resyncDropdown(); }
void Application::initialize ( int *argcp, char **argv ) { DebugPrintf(2, "Application::initialize(%p %d, %p)\n", argcp, *argcp, argv); DebugPrintf(3, "Application::initialize - Initializing privileges.\n"); // The Solaris sendmail operates differently than the HP/IBM sendmail. // sendmail on Solaris runs as 'root' and so has access permissions // to any file on the system. sendmail on HP/IBM runs as set-group-id // 'mail' and so requires that all mailboxes that it may deliver e-mail // to be writable either by being group mail group writable, or by being // writable by the world. On those platforms, then, dtmail is required // to always run with set-group-id mail otherwise, when mailboxes are // saved, they will loose their group ownership and sendmail will no // onger be able to deliver to those mailboxes. // we have to be set-gid to group "mail" when opening and storing // folders. But we don't want to do everything as group mail. // here we record our original gid, and set the effective gid // back the the real gid. We'll set it back when we're dealing // with folders... // _originalEgid = getegid(); // remember effective group ID _originalRgid = getgid(); // remember real group ID disableGroupPrivileges(); // disable group privileges from here on DebugPrintf(3, "Application::initialize - Initializing Xt.\n"); _w = XtOpenApplication ( &_appContext, _applicationClass, (XrmOptionDescList) NULL, 0, argcp, argv, ApplicationFallbacks, sessionShellWidgetClass, (ArgList) NULL, 0 ); // Extract and save a pointer to the X display structure DebugPrintf(3, "Application::initialize - Extracting display.\n"); _display = XtDisplay ( _w ); // Set virtual BMenu mouse binding int numButtons = XGetPointerMapping(_display, (unsigned char *)NULL, 0); _bMenuButton = (numButtons < 3) ? Button2 : Button3; // The Application class is less likely to need to handle // "surprise" widget destruction than other classes, but // we might as well install a callback to be safe and consistent DebugPrintf(3, "Application::initialize - Installing destroy handler.\n"); installDestroyHandler(); // Center the shell, and make sure it isn't visible DebugPrintf(3, "Application::initialize - Setting window size.\n"); XtVaSetValues ( _w, XmNmappedWhenManaged, FALSE, XmNx, DisplayWidth ( _display, 0 ) / 2, XmNy, DisplayHeight ( _display, 0 ) / 2, XmNwidth, 1, XmNheight, 1, NULL ); // The instance name of this object was set in the UIComponent // constructor, before the name of the program was available // Free the old name and reset it to argv[0] DebugPrintf(3, "Application::initialize - Deleting name %p\n", _name); free(_name); _name = strdup ( argv[0] ); // Force the shell window to exist so dialogs popped up from // this shell behave correctly DebugPrintf(3, "Application::initialize - Realizing shell window.\n"); XtRealizeWidget ( _w ); getResources(_appResources, XtNumber(_appResources)); // Initialize and manage any windows registered // with this application. for ( int i = 0; i < _numWindows; i++ ) { DebugPrintf(3, "Application::initialize - Initializing windows[%d]\n", i); _windows[i]->initialize(); DebugPrintf(3, "Application::initialize - Managing windows[%d]\n", i); _windows[i]->manage(); } }
void AttachArea::initialize() { // We're making the assumption here that this widget's parent` // is also a form XtWidgetGeometry size; Dimension parWid, parHeight; Dimension txt_w, txt_h; XmFontList fl; XmString xms; int colorUse; short act, inact, prim, second, text; XmPixelSet pixels[XmCO_NUM_COLORS]; _w = XtVaCreateManagedWidget ( "AttachPane", xmFormWidgetClass, _parent, NULL); // Get pixel data. XmeGetColorObjData(XtScreen(_parent), &colorUse, pixels, XmCO_NUM_COLORS, &act, &inact, &prim, &second, &text); _foreground = pixels[text].fg; _background = pixels[text].sc; parWid = _myOwner->textEditor()->get_text_width(); fl = _myOwner->textEditor()->get_text_fontList(); xms = XmStringCreateLocalized("Xyb"); XmStringExtent(fl, xms, &txt_w, &txt_h); parHeight = txt_h + Icon::maxIconHeight() + (2*VSPACE); _appBackground = _background; _appForeground = _foreground; _sw = XtVaCreateManagedWidget ( "AttachPane_ScrolledWindow", xmScrolledWindowWidgetClass, _w, XmNscrollingPolicy, XmAPPLICATION_DEFINED, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNshadowThickness, (Dimension)1, XmNspacing, 2, XmNwidth, parWid, XmNheight, parHeight, NULL); rowOfAttachmentsStatus = XtCreateManagedWidget("Attachments_Status", xmFormWidgetClass, _w, NULL, 0); XtVaSetValues(rowOfAttachmentsStatus, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, _sw, XmNtopOffset, 5, XmNbottomOffset, 5, NULL ); this->addToRowOfAttachmentsStatus(); size.request_mode = CWHeight; XtQueryGeometry(rowOfAttachmentsStatus, NULL, &size); XtVaSetValues( rowOfAttachmentsStatus, XmNpaneMaximum, size.height, XmNpaneMinimum, size.height, NULL ); _vsb = XtVaCreateManagedWidget("vsb", xmScrollBarWidgetClass, _sw, XmNorientation, XmVERTICAL, XmNsliderSize, 1, XmNmaximum, 1, XmNpageIncrement, 1, NULL); XtAddCallback( _vsb, XmNvalueChangedCallback,&AttachArea::valueChangedCallback, (XtPointer) this ); XtAddCallback( _vsb, XmNdragCallback, &AttachArea::dragCallback, (XtPointer) this ); _clipWindow = XtVaCreateManagedWidget("AttachArea_clipWindow", xmDrawingAreaWidgetClass, _sw, XmNresizePolicy, XmRESIZE_NONE, XmNbackground, _background, XmNwidth, parWid, XmNheight, parHeight, NULL); XmScrolledWindowSetAreas(_sw, NULL, _vsb, _clipWindow); XtManageChild(_clipWindow); XtManageChild(_vsb); XtManageChild(_sw); // Set RowCol to NULL here. // It gets set in the expose_all_attachments. _rc = NULL; CalcSizeOfAttachPane(); installDestroyHandler(); }
ToggleButtonInterface::ToggleButtonInterface ( Widget parent, Cmd *cmd ) : CmdInterface ( cmd ) { // We need to generate a button name that doesn't have illegal characters. // char *w_name = new char[200]; strcpy(w_name, _name); for (char * cur = w_name; *cur; cur++) { if (isspace(*cur) || *cur == ',') { *cur = '_'; continue; } if (*cur == '.') { *cur = 0; break; } } XmString label = XmStringCreateLocalized(cmd->getLabel()); if (0 == strcmp(cmd->className(),"ToggleButtonCmd")) { ToggleButtonCmd *tbc = (ToggleButtonCmd*) cmd; Boolean visible_when_off = tbc->visibleWhenOff(); unsigned char indicator_type = tbc->indicatorType(); _w = XtVaCreateWidget (w_name, xmToggleButtonWidgetClass, parent, XmNlabelString, label, XmNvisibleWhenOff, visible_when_off, XmNindicatorType, indicator_type, NULL); } else _w = XtVaCreateWidget (w_name, xmToggleButtonWidgetClass, parent, XmNlabelString, label, XmNvisibleWhenOff, TRUE, NULL); XmStringFree(label); printHelpId("_w", _w); // XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId); // free(helpId); installDestroyHandler(); // The _active member is set when each instance is registered // with an associated Cmd object. Now that a widget exists, // set the widget's sensitivity according to its active state. if ( _active ) activate(); else deactivate(); #ifdef GNU_CC // No idea what the right ifdef is for automatically recognizing g++ // G++ reportedly doesn't like the form expected by cfront. I'm // told this will work, but I haven't tested it myself. XtAddCallback ( _w, XmNvalueChangedCallback, executeCmdCallback, (XtPointer) this ); #else XtAddCallback ( _w, XmNvalueChangedCallback, &CmdInterface::executeCmdCallback, (XtPointer) this ); #endif delete [] w_name; }
void XFE_Toolbox::createMain(Widget parent) { XP_ASSERT( XfeIsAlive(parent) ); // The main frame m_widget = XtVaCreateWidget("toolBox", xfeToolBoxWidgetClass, parent, XmNusePreferredWidth, False, // XmNusePreferredHeight, True, XmNusePreferredHeight, False, XmNheight, 200, NULL); // Create all the tab icons Pixel fg = XfeForeground(m_widget); Pixel bg = XfeBackground(m_widget); Widget shell = XfeAncestorFindByClass(parent, shellWidgetClass, XfeFIND_ANY); IconGroup_createAllIcons(&BOTTOM_ICON,shell,fg,bg); IconGroup_createAllIcons(&HORIZONTAL_ICON,shell,fg,bg); IconGroup_createAllIcons(&LEFT_ICON,shell,fg,bg); IconGroup_createAllIcons(&RIGHT_ICON,shell,fg,bg); IconGroup_createAllIcons(&TOP_ICON,shell,fg,bg); IconGroup_createAllIcons(&VERTICAL_ICON,shell,fg,bg); XtVaSetValues( m_widget, XmNbottomPixmap, BOTTOM_ICON.pixmap_icon.pixmap, XmNbottomRaisedPixmap, BOTTOM_ICON.pixmap_mo_icon.pixmap, XmNtopPixmap, TOP_ICON.pixmap_icon.pixmap, XmNtopRaisedPixmap, TOP_ICON.pixmap_mo_icon.pixmap, XmNleftPixmap, LEFT_ICON.pixmap_icon.pixmap, XmNleftRaisedPixmap, LEFT_ICON.pixmap_mo_icon.pixmap, XmNrightPixmap, RIGHT_ICON.pixmap_icon.pixmap, XmNrightRaisedPixmap, RIGHT_ICON.pixmap_mo_icon.pixmap, XmNverticalPixmap, VERTICAL_ICON.pixmap_icon.pixmap, XmNverticalRaisedPixmap, VERTICAL_ICON.pixmap_mo_icon.pixmap, XmNhorizontalPixmap, HORIZONTAL_ICON.pixmap_icon.pixmap, XmNhorizontalRaisedPixmap, HORIZONTAL_ICON.pixmap_mo_icon.pixmap, NULL); #if notyet // Set the hand cursor Cursor hand_cursor = XfeCursorGetDragHand(parent); if (hand_cursor != None) { XtVaSetValues(m_widget,XmNdragCursor,hand_cursor,NULL); } #endif // Add new item callback XtAddCallback(m_widget, XmNnewItemCallback, &XFE_Toolbox::newItemCallback, (XtPointer) this); // Add swap callback XtAddCallback(m_widget, XmNswapCallback, &XFE_Toolbox::swapCallback, (XtPointer) this); // Add snap callback XtAddCallback(m_widget, XmNsnapCallback, &XFE_Toolbox::snapCallback, (XtPointer) this); // Add close callback XtAddCallback(m_widget, XmNcloseCallback, &XFE_Toolbox::closeCallback, (XtPointer) this); // Add open callback XtAddCallback(m_widget, XmNopenCallback, &XFE_Toolbox::openCallback, (XtPointer) this); installDestroyHandler(); }