예제 #1
0
int XFE_ReadAttachDrag::dragStart(int,int)
{
    if (!_dragWidget || !XmIsPushButton(_dragWidget))
        return FALSE;

    // If drag widget is an AttachPanelItem, extract the URL
    XtPointer userData;
    XtVaGetValues(_dragWidget,XmNuserData,&userData,NULL);
    XFE_AttachPanelItem *item=(XFE_AttachPanelItem*)userData;

    if (item && item->data()) {
        _attachPanel->selectItem(item);
        _dragDataURL=XP_STRDUP(item->data());
        if (item->dataLabel())
            _dragDataName=XP_STRDUP(item->dataLabel());
        else
            _dragDataName=XP_STRDUP("noname");
            
        setDragIconForType(item->dataType());
        return TRUE;
    }

    return FALSE;
}
예제 #2
0
static void
save_geometry(void)
{
    int x_off, y_off;
    Dimension w, h;
    Window dummy;
    /*     char *geom_str; */
    
    (void)XTranslateCoordinates(DISP, XtWindow(globals.widgets.top_level),
				RootWindowOfScreen(SCRN),
				0, 0,
				&x_off, &y_off,
				&dummy);
    XtVaGetValues(globals.widgets.top_level,
		  XtNwidth, &w,
		  XtNheight, &h,
#ifdef MOTIF
		  /* 		  XmNgeometry, &geom_str, */
#endif
		  NULL);
    TRACE_GUI((stderr, "geometry: %dx%d+%d+%d", w, h, x_off, y_off));

    store_preference(NULL, "windowSize", "%dx%d", w, h);
}
예제 #3
0
void fileToggle(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
  int i;
  FileWindowRec *fw;
  Pixel pix;
  extern int Faking;
	
  i = findWidget(w, &fw);
  if (!fw) {
/*
    error("Internal error:", "widget not found in fileToggle");
*/
    return;
  }
	if(Faking)
	{
		fileRestoreSelect(w, event, NULL, 0);
		Faking =0;
	}
	
  XtVaGetValues(w, fw->files[i]->selected?XtNbackground:XtNforeground, &pix,
		NULL);
  XtVaSetValues(w, XtNborder, (XtArgVal) pix, NULL);

  if (fw->files[i]->selected) {
    fw->files[i]->selected = False;
    fw->n_selections--;
    fw->n_bytes_selected -= fw->files[i]->stats.st_size;
  }
  else {
    fw->files[i]->selected = True;
    fw->n_selections++;
    fw->n_bytes_selected += fw->files[i]->stats.st_size;
  }
  updateStatus(fw);
}
예제 #4
0
void XNavMotif::popup_button_cb(Widget w, XNav* xnav, XmAnyCallbackStruct* data)
{
  Widget menu;
  int idx;
  pwr_tStatus sts;

  // Find the menu widget
  menu = XtParent(w);
  while (1) {
    if (strcmp(XtName(menu), "_popup") == 0
        || strcmp(XtName(menu), "_pulldown") == 0)
      break;
    menu = XtParent(menu);
  }

  XtVaGetValues(w, XmNuserData, &idx, NULL);

  mcp->ChosenItem = idx;
  // xnav->set_clock_cursor();
  sts = CallMenuMethod(mcp, mcp->ChosenItem);
  if (EVEN(sts))
    xnav->message('E', XNav::get_message(sts));
  // xnav->reset_cursor();
}
예제 #5
0
파일: test29.c 프로젝트: melanj/lesstif
static void ChangeLabels(void)
{
WidgetList kids;
int numKids;
int i;
XmString string;
char buf[1024];

	printf("ChangeLabels()\n");
	XtVaGetValues(Pulldown,
		XmNchildren, &kids,
		XmNnumChildren, &numKids,
		NULL);
	printf("ChangeLabels() - %i\n", numKids);
	for (i=0 ; i<numKids; i++)
	{
		sprintf(buf, "New_%i", i);
		string = XmStringCreateSimple(buf);
		XtVaSetValues(kids[i],
			XmNlabelString, string,
			NULL);
		XmStringFree(string);
	}
}
예제 #6
0
/* Figure out a title for the given URL.  'ref', if it exists,
   was the text used for the anchor that pointed us to this URL;
   it is not required to exist. */
char *mo_grok_title (mo_window *win, char *url, char *ref)
{
  char *title = NULL, *t;

  XtVaGetValues (win->scrolled_win, WbNtitleText, &title, NULL);
  if (!title)
    t = mo_grok_alternate_title (url, ref);
  else if (!strcmp (title, "Document"))
    t = mo_grok_alternate_title (url, ref);
  else
    {
      char *tmp = title;
      while (*tmp && (*tmp == ' ' || *tmp == '\t'))
        tmp++;
      if (*tmp)
        t = strdup (tmp);
      else
        t = mo_grok_alternate_title (url, ref);
    }

  mo_convert_newlines_to_spaces (t);

  return t;
}
예제 #7
0
파일: UISymbols.C 프로젝트: bandi13/RGIS
static void _UISymbolListSelectCBK (Widget widget,Widget dShell,XmListCallbackStruct *callData)

	{
	int symbol = callData->item_position - 1;
	char symString [20];
	UISymbol **editSymbols;
	Widget menu, option;

	if (callData->reason != XmCR_BROWSE_SELECT) return;

	XtVaGetValues (widget,XmNuserData,	&editSymbols, NULL);

	option = XtNameToWidget (dShell,UISymForegroundMenuName);
	XtVaGetValues (option,XmNsubMenuId, &menu, NULL);
	_UISymSetButtonString (symString,editSymbols [symbol]->Foreground ());
	XtVaSetValues (option, XmNmenuHistory, XtNameToWidget (menu,symString), NULL);

	option = XtNameToWidget (dShell,UISymBackgroundMenuName);
	XtVaGetValues (option,XmNsubMenuId, &menu, NULL);
	_UISymSetButtonString (symString,editSymbols [symbol]->Background ());
	XtVaSetValues (option, XmNmenuHistory, XtNameToWidget (menu,symString), NULL);

	_UISymSetButtonString (symString,editSymbols [symbol]->Style ());
	if (XtIsManaged (option = XtNameToWidget (dShell,UISymMarkerMenuName)))
		{
		XtVaGetValues (option,XmNsubMenuId, &menu, NULL);
		XtVaSetValues (option, XmNmenuHistory, XtNameToWidget (menu,symString), NULL);
		}
	if (XtIsManaged (option = XtNameToWidget (dShell,UISymLineMenuName)))
		{
		XtVaGetValues (option,XmNsubMenuId, &menu, NULL);
		XtVaSetValues (option, XmNmenuHistory, XtNameToWidget (menu,symString), NULL);
		}
	if (XtIsManaged (option = XtNameToWidget (dShell,UISymShadeMenuName)))
		{
		XtVaGetValues (option,XmNsubMenuId, &menu, NULL);
		XtVaSetValues (option, XmNmenuHistory, XtNameToWidget (menu,symString), NULL);
		}
	XtVaSetValues (XtNameToWidget (dShell,UISymTextFieldName),XmNuserData, editSymbols [symbol], NULL);
	XmTextFieldSetString (XtNameToWidget (dShell,UISymTextFieldName),editSymbols [symbol]->Name ());
	}
예제 #8
0
bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
{
    tool->Detach();

    bool isVertical = GetWindowStyle() & wxTB_VERTICAL;
    const int separatorSize = GetToolSeparation(); // 8;
    int packing = GetToolPacking();
    int offset = 0;

    for( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
         node; node = node->GetNext() )
    {
        wxToolBarTool *t = (wxToolBarTool*)node->GetData();

        if( t == tool )
        {
            switch ( t->GetStyle() )
            {
            case wxTOOL_STYLE_CONTROL:
            {
                wxSize size = t->GetControl()->GetSize();
                offset = isVertical ? size.y : size.x;
                offset += packing;
                break;
            }
            case wxTOOL_STYLE_SEPARATOR:
                offset = isVertical ? 0 : separatorSize;
                break;
            case wxTOOL_STYLE_BUTTON:
            {
                Widget w = t->GetButtonWidget();
                Dimension width, height;

                XtVaGetValues( w,
                               XmNwidth, &width,
                               XmNheight, &height,
                               NULL );

                offset = isVertical ? height : width;
                offset += packing;
                break;
            }
            }
        }
        else if( offset )
        {
            switch ( t->GetStyle() )
            {
            case wxTOOL_STYLE_CONTROL:
            {
                wxPoint location = t->GetControl()->GetPosition();

                if( isVertical )
                    location.y -= offset;
                else
                    location.x -= offset;

                t->GetControl()->Move( location );
                break;
            }
            case wxTOOL_STYLE_SEPARATOR:
                break;
            case wxTOOL_STYLE_BUTTON:
            {
                Dimension x, y;
                XtVaGetValues( t->GetButtonWidget(),
                               XmNx, &x,
                               XmNy, &y,
                               NULL );

                if( isVertical )
                    y = (Dimension)(y - offset);
                else
                    x = (Dimension)(x - offset);

                XtVaSetValues( t->GetButtonWidget(),
                               XmNx, x,
                               XmNy, y,
                               NULL );
                break;
            }
            }
        }
    }

    return true;
}
예제 #9
0
bool wxToolBar::Realize()
{
    if ( m_tools.GetCount() == 0 )
    {
        // nothing to do
        return true;
    }

    bool isVertical = GetWindowStyle() & wxTB_VERTICAL;

    // Separator spacing
    const int separatorSize = GetToolSeparation(); // 8;
    wxSize margins = GetToolMargins();
    int packing = GetToolPacking();
    int marginX = margins.x;
    int marginY = margins.y;

    int currentX = marginX;
    int currentY = marginY;

    int buttonHeight = 0, buttonWidth = 0;

    Widget button;
    Pixmap pixmap, insensPixmap;
    wxBitmap bmp, insensBmp;

    wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
    while ( node )
    {
        wxToolBarTool *tool = (wxToolBarTool *)node->GetData();

        switch ( tool->GetStyle() )
        {
            case wxTOOL_STYLE_CONTROL:
            {
                wxControl* control = tool->GetControl();
                wxSize sz = control->GetSize();
                wxPoint pos = control->GetPosition();
                // Allow a control to specify a y[x]-offset by setting
                // its initial position, but still don't allow it to
                // position itself above the top[left] margin.
                int controlY = (pos.y > 0) ? pos.y : currentY;
                int controlX = (pos.x > 0) ? pos.x : currentX;
                control->Move( isVertical ? controlX : currentX,
                               isVertical ? currentY : controlY );
                if ( isVertical )
                    currentY += sz.y + packing;
                else
                    currentX += sz.x + packing;

                break;
            }
            case wxTOOL_STYLE_SEPARATOR:
                // skip separators for vertical toolbars
                if( !isVertical )
                {
                    currentX += separatorSize;
                }
                break;

            case wxTOOL_STYLE_BUTTON:
                button = (Widget) 0;

                if ( tool->CanBeToggled() && !tool->GetButtonWidget() )
                {
                    button = XtVaCreateWidget("toggleButton",
                            xmToggleButtonWidgetClass, (Widget) m_mainWidget,
                            XmNx, currentX, XmNy, currentY,
                            XmNindicatorOn, False,
                            XmNshadowThickness, 2,
                            XmNborderWidth, 0,
                            XmNspacing, 0,
                            XmNmarginWidth, 0,
                            XmNmarginHeight, 0,
                            XmNmultiClick, XmMULTICLICK_KEEP,
                            XmNlabelType, XmPIXMAP,
                            NULL);
                    XtAddCallback ((Widget) button,
                                   XmNvalueChangedCallback,
                                   (XtCallbackProc) wxToolButtonCallback,
                                   (XtPointer) this);

                    XtVaSetValues ((Widget) button,
                                   XmNselectColor,
                                   m_backgroundColour.AllocColour
                                       (XtDisplay((Widget) button)),
                                   NULL);
                }
                else if( !tool->GetButtonWidget() )
                {
                    button = XtVaCreateWidget("button",
                            xmPushButtonWidgetClass, (Widget) m_mainWidget,
                            XmNx, currentX, XmNy, currentY,
                            XmNpushButtonEnabled, True,
                            XmNmultiClick, XmMULTICLICK_KEEP,
                            XmNlabelType, XmPIXMAP,
                            NULL);
                    XtAddCallback (button,
                                   XmNactivateCallback,
                                   (XtCallbackProc) wxToolButtonCallback,
                                   (XtPointer) this);
                }

                if( !tool->GetButtonWidget() )
                {
                    wxDoChangeBackgroundColour((WXWidget) button,
                                               m_backgroundColour, true);

                    tool->SetWidget(button);
                }
                else
                {
                    button = (Widget)tool->GetButtonWidget();
                    XtVaSetValues( button,
                                   XmNx, currentX, XmNy, currentY,
                                   NULL );
                }

                // For each button, if there is a mask, we must create
                // a new wxBitmap that has the correct background colour
                // for the button. Otherwise the background will just be
                // e.g. black if a transparent XPM has been loaded.
                bmp = tool->GetNormalBitmap();
                insensBmp = tool->GetDisabledBitmap();
                if ( bmp.GetMask() || insensBmp.GetMask() )
                {
                    WXPixel backgroundPixel;
                    XtVaGetValues(button, XmNbackground, &backgroundPixel,
                                  NULL);

                    wxColour col;
                    col.SetPixel(backgroundPixel);

                    if( bmp.IsOk() && bmp.GetMask() )
                    {
                        bmp = wxCreateMaskedBitmap(bmp, col);
                        tool->SetNormalBitmap(bmp);
                    }

                    if( insensBmp.IsOk() && insensBmp.GetMask() )
                    {
                        insensBmp = wxCreateMaskedBitmap(insensBmp, col);
                        tool->SetDisabledBitmap(insensBmp);
                    }
                }

                // Create a selected/toggled bitmap. If there isn't a 2nd
                // bitmap, we need to create it (with a darker, selected
                // background)
                WXPixel backgroundPixel;
                if ( tool->CanBeToggled() )
                    XtVaGetValues(button, XmNselectColor, &backgroundPixel,
                                  NULL);
                else
                    XtVaGetValues(button, XmNarmColor, &backgroundPixel,
                                  NULL);
                wxColour col;
                col.SetPixel(backgroundPixel);

                pixmap = (Pixmap) bmp.GetDrawable();
                {
                    wxBitmap tmp = tool->GetDisabledBitmap();

                    insensPixmap = tmp.IsOk() ?
                            (Pixmap)tmp.GetDrawable() :
                            tool->GetInsensPixmap();
                }

                if (tool->CanBeToggled())
                {
                    // Toggle button
                    Pixmap pixmap2 = tool->GetArmPixmap();
                    Pixmap insensPixmap2 = tool->GetInsensPixmap();

                    XtVaSetValues (button,
                            XmNfillOnSelect, True,
                            XmNlabelPixmap, pixmap,
                            XmNselectPixmap, pixmap2,
                            XmNlabelInsensitivePixmap, insensPixmap,
                            XmNselectInsensitivePixmap, insensPixmap2,
                            XmNlabelType, XmPIXMAP,
                            NULL);
                }
                else
                {
                    Pixmap pixmap2 = tool->GetArmPixmap();

                    // Normal button
                    XtVaSetValues(button,
                            XmNlabelPixmap, pixmap,
                            XmNlabelInsensitivePixmap, insensPixmap,
                            XmNarmPixmap, pixmap2,
                            NULL);
                }

                XtManageChild(button);

                {
                    Dimension width, height;
                    XtVaGetValues(button,
                                  XmNwidth, &width,
                                  XmNheight, & height,
                                  NULL);
                    if ( isVertical )
                        currentY += height + packing;
                    else
                        currentX += width + packing;
                    buttonHeight = wxMax(buttonHeight, height);
                    buttonWidth = wxMax(buttonWidth, width);
                }

                XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
                        False, wxToolButtonPopupCallback, (XtPointer) this);

                break;
        }

        node = node->GetNext();
    }

    SetSize( -1, -1,
             isVertical ? buttonWidth + 2 * marginX : -1,
             isVertical ? -1 : buttonHeight +  2*marginY );

    return true;
}
예제 #10
0
void guitst_rgstrCanvas ( void )
/************************************************************************
 * guitst_rgstrCanvas   	                                        *
 *                                                                      *
 * This function registers the canvas as a gempak window		*
 *                                                                      *
 * void	guitst_rgstrCanvas()						*
 *                                                                      *
 * Input parameters:                                                    *
 * Output parameters:                                                   *
 * Return parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 ** Log:                                                                *
 *   C. Lin/EAI      04/96                                              *
 *   S. Wang/GSC     10/97	modified for guitst                     *
 *   H. Zeng/EAI     04/00      changed cursor change function          *
 * T. Piper/SAIC	10/04	Moved gg_panl after gclear		*
 ***********************************************************************/
{

Window    gwin;
GC	  gemgc;
char      wname[20];
int       iret, xdpth;
Dimension width, height;

/*---------------------------------------------------------------------*/

        /*
         * set the cursor to the default
         */
        NxmCursor_setCursor(_canvasW, CURS_DEFAULT);

        strcpy(wname, "guitst");

        /*
         * get the window info
         */
        gwin = XtWindow(_canvasW);
        gemgc = XCreateGC(gemdisplay, gwin, 0, 0);
        xdpth = DefaultDepth((XtPointer)gemdisplay,
			     DefaultScreen((XtPointer)gemdisplay));

        XtVaGetValues(_canvasW, XmNwidth,  &width,
                         XmNheight, &height,
                         NULL );

        /*
         * call GEMPAK to register the window (drawing area)
         * from now on, this drawing area will be GEMPAK's
         * window identified by name = wname.
         */
        xmotifw( gwin, wname, gemgc, (int)width, (int)height,
              			  xdpth, &iret );

        /*
         * set DEVICE in gempak
         */
        gg_motf(wname, &iret, strlen(wname));

        /*
         * clear screen and set panel
         */

	gclear(&iret);
        gg_panl("0", &iret, 1);

	
}