Beispiel #1
0
void DtPrinterIcon::OpenCloseCB(void *data) 
{
   BaseUI *obj = ((BaseUI *)data)->Parent();
   if (obj->Open())
      obj->Open(false);
   else
      obj->Open(true);
}
Beispiel #2
0
boolean IconObj::SetOpen(boolean flag)
{
   int pixmapPlacement;
   int alignment;
   int isOpened;

   BaseUI *parent = Parent();
   if (ContainerView() == TREE)
      isOpened = flag;
   else if (parent && parent->UISubClass() == ICON_LIST ||
            parent->UISubClass() == SCROLLED_ICON_LIST)
      isOpened = true;
   else
      isOpened = flag;
   if (IconView() == 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;
    }
   else
    {
      alignment = XmALIGNMENT_BEGINNING;
      pixmapPlacement = GuiPIXMAP_LEFT;
    }
   XtVaSetValues(_w, XmNalignment, alignment, GuiNisOpened, isOpened,
		 GuiNpixmapPlacement, pixmapPlacement, NULL);
   return true;
}
Beispiel #3
0
void MotifUI::DoContextualHelp()
{
   Widget context_widget, shell;
#ifdef NO_CDE
   XEvent event;
   static Cursor cursor = (Cursor) NULL;

   if (cursor == (Cursor) NULL)
      cursor =  XCreateFontCursor(display, XC_question_arrow);
#endif

   BaseUI *window = this;
   while (window->UIClass() != MAIN_WINDOW)
      window = window->Parent();
   shell = ((MotifUI *)window)->_w;
#ifdef NO_CDE
   context_widget = XmTrackingEvent(shell, cursor, False, &event);

   if (event.type == KeyPress || event.type == KeyRelease)
    {
      int offset;
      KeySym keySym;

      // Look for ESC key press and stop if we get one 
      if (event.xkey.state & ShiftMask)
         offset = 1;
      else
         offset = 0;

      keySym = XLookupKeysym((XKeyEvent *)&event, offset);
      if (keySym == XK_Escape)
	 return;
    }

   if (context_widget != NULL)
    {
#else
   int returnVal = DtHelpReturnSelectedWidgetId(shell, NULL, &context_widget);
   if (returnVal == DtHELP_SELECT_VALID)
    {
#endif
      XmAnyCallbackStruct cb;

      cb.reason = XmCR_HELP;
#ifdef NO_CDE
      cb.event = &event;
#endif
      while (context_widget != NULL)
       {
         // If there is no help at this widget, back track to find help 
         if (XtHasCallbacks(context_widget, XmNhelpCallback) ==
                            XtCallbackHasSome)
          {
            XtCallCallbacks(context_widget, XmNhelpCallback, &cb);
            break;
          }
         else
            context_widget = XtParent(context_widget);
       }
    }
}

void MotifUI::WidgetHelpCB(Widget,
			   XtPointer clientData,
			   XtPointer)
{
   MotifUI * obj = (MotifUI *) clientData;

   obj->HandleHelpRequest();
}
Beispiel #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;
}
Beispiel #5
0
boolean IconObj::SetIcon(IconStyle style)
{
   Pixmap pixmap, mask;
   int shrinkOutline = false;
   int pixmapPlacement;
   int alignment;
   int isOpened;

   BaseUI *parent = Parent();
   if (ContainerView() == TREE)
      isOpened = true;
   else if (parent && parent->UISubClass() == ICON_LIST ||
            parent->UISubClass() == SCROLLED_ICON_LIST)
      isOpened = true;
   else
      isOpened = Open();
   switch (style)
    {
     case NAME_ONLY: 
        pixmapPlacement = GuiPIXMAP_LEFT;
        alignment = XmALIGNMENT_BEGINNING;
	if (_name)
	 {
	   pixmap = XmUNSPECIFIED_PIXMAP;
	   mask = XmUNSPECIFIED_PIXMAP;
	 }
	else
	 {
	   pixmap = _smallPixmap;
	   mask = _smallMask;
	 }
	break;
     case VERY_LARGE_ICON:
     case LARGE_ICON:
     case MEDIUM_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;
        if (style == VERY_LARGE_ICON)
	 {
            if (depth == 1)
               strcat(_iconFile, ".l.bm");
	    else
               strcat(_iconFile, ".l.pm");
            GetPixmaps(_w, _iconFile, &pixmap, &mask);
	    _iconFile[strlen(_iconFile) - 5] = '\0';
	 }
	else
	 {
	   pixmap = _largePixmap;
	   mask = _largeMask;
	 }
	break;
     case DETAILS:
	SetDetail();
	// no break
     case SMALL_ICON:
     case TINY_ICON:
        alignment = XmALIGNMENT_BEGINNING;
        pixmapPlacement = GuiPIXMAP_LEFT;
	pixmap = _smallPixmap;
	mask = _smallMask;
	break;
    }
   if (_previous_style == DETAILS)
    {
       XmString xm_string = StringCreate(_name);
       XtVaSetValues(_w, XmNlabelPixmap, pixmap, GuiNiconMask, mask,
                     XmNlabelString, xm_string, XmNalignment, alignment,
		     GuiNpixmapPlacement, pixmapPlacement, 
		     GuiNisOpened, isOpened,
                     GuiNshrinkOutline, shrinkOutline, NULL);
       StringFree(xm_string);
    }
   else
      XtVaSetValues(_w, XmNlabelPixmap, pixmap, GuiNiconMask, mask,
		    GuiNpixmapPlacement, pixmapPlacement,
		    XmNalignment, alignment, GuiNisOpened, isOpened,
                    GuiNshrinkOutline, shrinkOutline, NULL);

   _previous_style = style;
   if (_stateIconName)
      SetStateIconFile(style);

   return true;
}