Esempio n. 1
0
boolean MotifUI::SetSelected(boolean flag)
{
   if (!_w)
      return false;

   if (GuiIsIcon(_w))
      XtVaSetValues(_w, GuiNselected, flag, NULL);
   else if (XmIsToggleButton(_w))
      XmToggleButtonSetState(_w, flag, False);

   return true;
}
Esempio n. 2
0
boolean MotifUI::SetActivity(boolean flag)
{
   if (!_w)
      return false;

   if (GuiIsIcon(_w))
      XtVaSetValues(_w, GuiNactive, flag, NULL);
   else
      XtSetSensitive(_w, flag);

   return true;
}
Esempio n. 3
0
void Container::CreateContainer(MotifUI *parent, char * /*name*/,
				char * /*category*/,
		                ContainerType container_type,
		                SelectionType select_type)
{
   Arg args[15];
   int n;
   Pixel pixel;
   Widget parentW;
   Widget superNode;
   int radio_behavior = false;
   int _shadowThickness;

   if (!trans_tbl)
    {
      action_table[0].proc = (XtActionProc) ResizeRC;
      trans_tbl = XtParseTranslationTable("<Configure>:ResizeRC()");
      XtAppAddActions(appContext, action_table, XtNumber(action_table));
    }

   _xm_update_message = NULL;
   _select_type = select_type;
   _last_selected = NULL;
   parentW = parent->InnerWidget();
   if (GuiIsIcon(parentW))
      superNode = parentW;
   else
      superNode = NULL;
   if (!XtIsComposite(parentW))
      parentW = XtParent(parentW);
   if (select_type == SINGLE_SELECT)
      radio_behavior = true;

   switch (_container_type = container_type)
    {
     case FORM:
       _w = XtVaCreateManagedWidget("form", xmFormWidgetClass,
				    parentW, NULL);
       _workArea = _w;
       break;
     case SCROLLED_FORM:
       _w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass,
				    parentW, NULL);
       _workArea = XtVaCreateManagedWidget("form", xmFormWidgetClass,
				           _w, NULL);
       break;
     case CANVAS:
       _w = XtVaCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
				    parentW, NULL);
       _workArea = _w;
       break;
     case SCROLLED_CANVAS:
       _w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass,
				    parentW, NULL);
       _workArea = XtVaCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
				           _w, NULL);
       break;
     case HORIZONTAL_ROW_COLUMN:
       _w = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, parentW,
				    XmNorientation, XmHORIZONTAL,
                                    XmNradioBehavior, radio_behavior, NULL);
       _workArea = _w;
       break;
     case SCROLLED_HORIZONTAL_ROW_COLUMN:
       _w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, parentW,
				    GuiNisOpened, false, GuiNisWorkArea, true,
				    GuiNsuperNode, superNode, XmNspacing, 0,
				    XmNscrollBarDisplayPolicy, XmAS_NEEDED,
				    XmNscrollingPolicy, XmAUTOMATIC,
				    XmNheight, Parent()->Height(), NULL);
       XtAddCallback(_w, XmNtraverseObscuredCallback, MakeChildVisible, NULL);
       _workArea = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, _w,
					   XmNorientation, XmHORIZONTAL, 
                                           XmNradioBehavior, radio_behavior,
                                           XmNpacking, XmPACK_TIGHT,
					   XmNadjustLast, False,
					   XmNuserData, this, NULL);
       XtAddCallback(XtParent(_workArea), XmNresizeCallback, 
	             ResizeSW, (XtPointer) this);
       XtOverrideTranslations(_workArea, trans_tbl);
       break;
     case VERTICAL_ROW_COLUMN:
       _w = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, parentW,
                                    XmNradioBehavior, radio_behavior, NULL);
       _workArea = _w;
       break;
     case SCROLLED_VERTICAL_ROW_COLUMN:
       _w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, parentW, 
				    GuiNisOpened, false, GuiNisWorkArea, true,
				    GuiNsuperNode, superNode, XmNspacing, 0,
                                    XmNradioBehavior, radio_behavior,
				    XmNscrollBarDisplayPolicy, XmAS_NEEDED,
				    XmNscrollingPolicy, XmAUTOMATIC, NULL);
       _workArea = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, _w,
                                           XmNradioBehavior, radio_behavior,
					   NULL);
       break;
     case PANE:
       _w = XtVaCreateManagedWidget("pane", xmPanedWindowWidgetClass,
				    parentW, NULL);
       _workArea = _w;
       break;
     case SCROLLED_PANE:
       _w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass,
				    parentW, NULL);
       _workArea = XtVaCreateManagedWidget("form", xmPanedWindowWidgetClass,
				           _w, NULL);
       break;
     case WORK_AREA:
       _w = XtVaCreateManagedWidget("form", workAreaWidgetClass,
				    parentW, NULL);
       _workArea = _w;
       break;
     case ICON_LIST:
       _w = XtVaCreateManagedWidget("form", workAreaWidgetClass,
				    parentW, GuiNisList, True, NULL);
       _workArea = _w;
       break;
     case SCROLLED_ICON_LIST:
     case SCROLLED_WORK_AREA:
       if (Parent()->UIClass() == DIALOG)
	  _shadowThickness = 0;
       else
	  _shadowThickness = shadowThickness;
       _w = XtVaCreateManagedWidget("form", xmFormWidgetClass,
				    parentW,
				    XmNshadowThickness, _shadowThickness,
				    XmNshadowType, XmSHADOW_OUT, NULL);
       n = 0;
       if (_container_type == SCROLLED_ICON_LIST)
	{
          XtSetArg(args[n], GuiNisList, True); n++;
	}
       else
	{
          XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
          XtSetArg(args[n], XmNentryVerticalAlignment, 
		   XmALIGNMENT_CONTENTS_BOTTOM);
          n++;
	}
       XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
       XtSetArg(args[n], XmNtopOffset, 6); n++;
       XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
       XtSetArg(args[n], XmNleftOffset, 6); n++;
       XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
       XtSetArg(args[n], XmNrightOffset, 6); n++;
       XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
       XtSetArg(args[n], XmNbottomOffset, 6); n++;
       XtSetArg(args[n], GuiNlineOffset, 20); n++;
       XtSetArg(args[n], GuiNlineThickness, 2); n++;
       XtSetArg(args[n], XmNuserData, this); n++;
       
       _workArea = GuiCreateScrolledWorkArea(_w, "workArea", args, n);
       XtManageChild(_workArea);
       break;
    }

   if (_workArea == _w)
    {
      _clipWidget = _sw = _vbar = _hbar = NULL;
    }
   else
    {
      _clipWidget = XtParent(_workArea);
      _sw = XtParent(_clipWidget);
      XtVaGetValues(_sw, XmNverticalScrollBar, &_vbar, 
                    XmNhorizontalScrollBar, &_hbar, NULL);
      if (container_type == SCROLLED_HORIZONTAL_ROW_COLUMN)
	 XtUnmanageChild(_vbar);

      if (depth > 1 &&
	  (container_type == SCROLLED_WORK_AREA ||
           container_type == SCROLLED_ICON_LIST))
       {
          XtVaGetValues(_vbar, XmNtroughColor, &pixel, NULL);
          XtVaSetValues(_workArea, XmNbackground, pixel, NULL);
          XtVaSetValues(_clipWidget, XmNbackground, pixel, NULL);
       }
    }
   InstallHelpCB();
   InstallDestroyCB();
}
Esempio n. 4
0
void IconObj::CreateIconObj(MotifUI *parent, char *name, char * /*category*/,
                            char *iconFile, char *details, char *topString,
			    char *bottomString, IconFields _fields)
{
   Pixmap pixmap;
   Pixmap mask;
   Pixel bg;
   Widget p, super_node;
   XmString xm_string, xm_topString, xm_bottomString;
   char *s;
   int shrinkOutline = false;
   int pixmapPlacement;
   int alignment;
   int isOpened;
   GuiIconFields gui_fields;

   if (fields = _fields)
    {
      int i;
      gui_fields = new GuiIconFieldsStruct;
      gui_fields->free_data = True;
      gui_fields->name_width = fields->name_width;
      gui_fields->field_spacing = fields->field_spacing;
      gui_fields->n_fields = fields->n_fields;
      gui_fields->selected = new Boolean[fields->n_fields];
      gui_fields->draw_fields = new Boolean[fields->n_fields];
      gui_fields->active = new Boolean[fields->n_fields];
      gui_fields->widths = new Dimension[fields->n_fields];
      gui_fields->alignments = new unsigned char[fields->n_fields];
      gui_fields->fields = new XmString[fields->n_fields];

      unsigned char alignment;
      for (i = 0; i < fields->n_fields; i++)
       {
	 gui_fields->widths[i] = fields->fields_widths[i];
	 switch (fields->alignments[i])
	 {
	 case LEFT_JUSTIFIED: alignment = XmALIGNMENT_BEGINNING; break;
	 case CENTERED: alignment = XmALIGNMENT_CENTER; break;
	 case RIGHT_JUSTIFIED: alignment = XmALIGNMENT_END; break;
	 }
	 gui_fields->alignments[i] = alignment;
	 if (fields->active)
	    gui_fields->active[i] = (Boolean)fields->active[i];
	 else
	    gui_fields->active[i] = True;
	 if (fields->draw_fields)
	    gui_fields->draw_fields[i] = (Boolean)fields->draw_fields[i];
	 else
	    gui_fields->draw_fields[i] = True;
	 gui_fields->selected[i] = False;
	 gui_fields->fields[i] = StringCreate(fields->fields[i]);
       }
    }
   else
      gui_fields = NULL;

   // Get small and large pixmaps and masks
   char icon_type = 'p';
   if (depth == 1)
       icon_type = 'b';
   _iconFile = new char [strlen(iconFile) + 6];
   _topString = STRDUP(topString);
   _bottomString = STRDUP(bottomString);
   _details = STRDUP(details);

   if (display == NULL)
    {
      strcpy(_iconFile, iconFile);
      _stateIconName = NULL;
      return;
    }

   sprintf(_iconFile, "%s.t.%cm", iconFile, icon_type);
   GetPixmaps(parent->BaseWidget(), _iconFile, &_smallPixmap, &_smallMask);
   sprintf(_iconFile, "%s.m.%cm", iconFile, icon_type);
   GetPixmaps(parent->BaseWidget(), _iconFile, &_largePixmap, &_largeMask);
   strcpy(_iconFile, iconFile);

   s = name;

   BaseUI *par = Parent();
   if (par && par->UISubClass() == ICON_LIST ||
       par->UISubClass() == SCROLLED_ICON_LIST)
      isOpened = true;
   else
      isOpened = false;
   switch (IconView())
    {
     case NAME_ONLY: 
        pixmapPlacement = GuiPIXMAP_LEFT;
        alignment = XmALIGNMENT_BEGINNING;
	pixmap = mask = XmUNSPECIFIED_PIXMAP;
	break;
     case LARGE_ICON:
	if (ContainerView() == TREE ||
	    (Parent()->UIClass() == CONTAINER &&
	     Parent()->UISubClass() == SCROLLED_VERTICAL_ROW_COLUMN))
	 {
	   isOpened = true;
           pixmapPlacement = GuiPIXMAP_LEFT;
	 }
	else
           pixmapPlacement = GuiPIXMAP_TOP;
	if (isOpened)
           alignment = XmALIGNMENT_BEGINNING;
	else
	   alignment = LargeIconJustification;
        shrinkOutline = true;
	pixmap = _largePixmap;
	mask = _largeMask;
	break;
     case DETAILS:
        s = new char [STRLEN(name) + STRLEN(details) + 2];
	if (details)
           sprintf(s, "%s %s", name, details);
	else
           strcpy(s, name);
	// no break
     case SMALL_ICON:
        alignment = XmALIGNMENT_BEGINNING;
        pixmapPlacement = GuiPIXMAP_LEFT;
	pixmap = _smallPixmap;
	mask = _smallMask;
	break;
    }
   // Get Parent and colors
   p = parent->InnerWidget();
   if (!XtIsComposite(p))
      p = XtParent(p);
   XtVaGetValues(p, XmNbackground, &bg, NULL);

   // If p is a icon then set superNode to it, otherwise set superNode to NULL
   super_node = GuiIsIcon(parent->BaseWidget()) ? parent->BaseWidget() : NULL;
   xm_string = StringCreate(s);
   xm_topString = StringCreate(topString);
   xm_bottomString = StringCreate(bottomString);
   Pixel text_select_color = black;
   Pixel select_color = white;
   if (select_color == bg)
    {
      text_select_color = white;
      select_color = black;
    }

   _w = XtVaCreateManagedWidget(name, iconWidgetClass, p, GuiNiconMask, mask,
				XmNlabelPixmap, pixmap, GuiNisOpened, isOpened,
				XmNalignment, alignment,
				GuiNsuperNode, super_node,
				GuiNpixmapPlacement, pixmapPlacement, 
				GuiNshrinkOutline, shrinkOutline,
				GuiNselectColorPersistent, true,
				GuiNselectColor, select_color,
				GuiNtextSelectColor, text_select_color,
				XmNlabelString, xm_string, 
                                GuiNfields, gui_fields,
				XmNbackground, bg,
				GuiNtopLabelString, xm_topString,
				GuiNbottomLabelString, xm_bottomString,
				XmNuserData, this, NULL);

   StringFree(xm_string);
   StringFree(xm_topString);
   StringFree(xm_bottomString);
   // Delete s if style = details
   if (IconView() == DETAILS)
      delete s;
   _previous_style = IconView();
   XtAddCallback(_w, GuiNsingleClickCallback, &IconObj::SingleClickCB, 
      (XtPointer) this);
   XtAddCallback(_w, GuiNdoubleClickCallback, &IconObj::DoubleClickCB, 
      (XtPointer) this);
   InstallHelpCB();
   _stateIconName = NULL;
}