Esempio n. 1
0
int
GraphViewCmd(CLIENT_ARGS)
{
  SimGraph *graph;
  Tk_Window tkwin = (Tk_Window) clientData;

  if (argc < 2) {
    Tcl_AppendResult(interp, "wrong # args:  should be \"",
		     argv[0], " pathName ?options?\"", (char *) NULL);
    return TCL_ERROR;
  }

  tkwin = Tk_CreateWindowFromPath(interp, tkwin,
				  argv[1], (char *) NULL);
  if (tkwin == NULL) {
    return TCL_ERROR;
  }

  graph = (SimGraph *)ckalloc(sizeof (SimGraph));

  graph->tkwin = tkwin;
  graph->interp = interp;
  graph->flags = 0;
  
  Tk_SetClass(graph->tkwin, "GraphView");
  Tk_CreateEventHandler(graph->tkwin,
			VisibilityChangeMask |
			ExposureMask |
			StructureNotifyMask,
			SimGraphEventProc, (ClientData) graph);
  Tcl_CreateCommand(interp, Tk_PathName(graph->tkwin),
		    DoGraphCmd, (ClientData) graph, (void (*)()) NULL);

/*
  Tk_MakeWindowExist(graph->tkwin);
*/
  
  if (getenv("XSYNCHRONIZE") != NULL) {
    XSynchronize(Tk_Display(tkwin), 1);
  }

  InitNewGraph(graph);
  DoNewGraph(graph);

  if (ConfigureSimGraph(interp, graph, argc-2, argv+2, 0) != TCL_OK) {
    /* XXX: destroy graph */
    Tk_DestroyWindow(graph->tkwin);
    return TCL_ERROR;
  }

  interp->result = Tk_PathName(graph->tkwin);
  return TCL_OK;
}
Esempio n. 2
0
int
Tk_ScaleObjCmd(
    ClientData clientData,	/* NULL. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument values. */
{
    register TkScale *scalePtr;
    Tk_OptionTable optionTable;
    Tk_Window tkwin;

    if (objc < 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
        return TCL_ERROR;
    }

    tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp),
                                    Tcl_GetString(objv[1]), NULL);
    if (tkwin == NULL) {
        return TCL_ERROR;
    }

    /*
     * Create the option table for this widget class. If it has already been
     * created, the cached pointer will be returned.
     */

    optionTable = Tk_CreateOptionTable(interp, optionSpecs);

    Tk_SetClass(tkwin, "Scale");
    scalePtr = TkpCreateScale(tkwin);

    /*
     * Initialize fields that won't be initialized by ConfigureScale, or which
     * ConfigureScale expects to have reasonable values (e.g. resource
     * pointers).
     */

    scalePtr->tkwin		= tkwin;
    scalePtr->display		= Tk_Display(tkwin);
    scalePtr->interp		= interp;
    scalePtr->widgetCmd		= Tcl_CreateObjCommand(interp,
                              Tk_PathName(scalePtr->tkwin), ScaleWidgetObjCmd,
                              scalePtr, ScaleCmdDeletedProc);
    scalePtr->optionTable	= optionTable;
    scalePtr->orient		= ORIENT_VERTICAL;
    scalePtr->width		= 0;
    scalePtr->length		= 0;
    scalePtr->value		= 0.0;
    scalePtr->varNamePtr	= NULL;
    scalePtr->fromValue		= 0.0;
    scalePtr->toValue		= 0.0;
    scalePtr->tickInterval	= 0.0;
    scalePtr->resolution	= 1.0;
    scalePtr->digits		= 0;
    scalePtr->bigIncrement	= 0.0;
    scalePtr->command		= NULL;
    scalePtr->repeatDelay	= 0;
    scalePtr->repeatInterval	= 0;
    scalePtr->label		= NULL;
    scalePtr->labelLength	= 0;
    scalePtr->state		= STATE_NORMAL;
    scalePtr->borderWidth	= 0;
    scalePtr->bgBorder		= NULL;
    scalePtr->activeBorder	= NULL;
    scalePtr->sliderRelief	= TK_RELIEF_RAISED;
    scalePtr->troughColorPtr	= NULL;
    scalePtr->troughGC		= None;
    scalePtr->copyGC		= None;
    scalePtr->tkfont		= NULL;
    scalePtr->textColorPtr	= NULL;
    scalePtr->textGC		= None;
    scalePtr->relief		= TK_RELIEF_FLAT;
    scalePtr->highlightWidth	= 0;
    scalePtr->highlightBorder	= NULL;
    scalePtr->highlightColorPtr	= NULL;
    scalePtr->inset		= 0;
    scalePtr->sliderLength	= 0;
    scalePtr->showValue		= 0;
    scalePtr->horizLabelY	= 0;
    scalePtr->horizValueY	= 0;
    scalePtr->horizTroughY	= 0;
    scalePtr->horizTickY	= 0;
    scalePtr->vertTickRightX	= 0;
    scalePtr->vertValueRightX	= 0;
    scalePtr->vertTroughX	= 0;
    scalePtr->vertLabelX	= 0;
    scalePtr->fontHeight	= 0;
    scalePtr->cursor		= None;
    scalePtr->takeFocusPtr	= NULL;
    scalePtr->flags		= NEVER_SET;

    Tk_SetClassProcs(scalePtr->tkwin, &scaleClass, scalePtr);
    Tk_CreateEventHandler(scalePtr->tkwin,
                          ExposureMask|StructureNotifyMask|FocusChangeMask,
                          ScaleEventProc, scalePtr);

    if ((Tk_InitOptions(interp, (char *) scalePtr, optionTable, tkwin)
            != TCL_OK) ||
            (ConfigureScale(interp, scalePtr, objc - 2, objv + 2) != TCL_OK)) {
        Tk_DestroyWindow(scalePtr->tkwin);
        return TCL_ERROR;
    }

    Tcl_SetObjResult(interp, TkNewWindowObj(scalePtr->tkwin));
    return TCL_OK;
}
Esempio n. 3
0
bool
ParadynTkGUI::Init( void )
{
    // initialize our base class
    if( !ParadynTclUI::Init() )
    {
        return false;
    }

    // do our own initialization
    if( Tk_Init( interp ) == TCL_ERROR )
    {
        Panic( "Tk_Init() failed (perhaps TK_LIBRARY not set?)" );
    }

#if READY
    Tk_Window mainWin = Tk_MainWindow( interp );
    if( mainWin == NULL )
    {
        Panic( "Tk_MainWindow gave NULL after Tk_Init" );
    }
    Tk_SetClass( mainWin, "Paradyn" );
#endif // READY

    tunableBooleanConstantDeclarator* tcWaShowTips = 
        new tunableBooleanConstantDeclarator("showWhereAxisTips",
        "If true, the WhereAxis window will be drawn with helpful reminders"
        " on shortcuts for expanding, unexpanding, selecting, and scrolling."
        "  A setting of false saves screen real estate.",
        true, // default value
        ShowWhereAxisTipsCallback,
        userConstant);

	// initialize tunable constants
    tunableBooleanConstantDeclarator* tcHideRetiredRes = 
        new tunableBooleanConstantDeclarator("whereAxisHideRetiredRes",
        "If true, the WhereAxis window will not display resource"
        " on shortcuts for expanding, unexpanding, selecting, and scrolling."
        "  A setting of false saves screen real estate.",
        false, // default value
        HideWhereAxisRetiredResCallback,
        userConstant);
                          
    tunableBooleanConstantDeclarator* tcShgShowKey = 
        new tunableBooleanConstantDeclarator("showShgKey",
    "If true, the search history graph will be drawn with a key for"
        " decoding the meaning of the several background colors, text colors,"
        " italics, etc.  A setting of false saves screen real estate.",
    true, // default value
    ShowShgKeyCallback,
    userConstant);

    tunableBooleanConstantDeclarator* tcShgShowTips = 
        new tunableBooleanConstantDeclarator("showShgTips",
    "If true, the search history graph will be drawn with reminders"
        " on shortcuts for expanding, unexpanding, selecting, and scrolling."
        "  A setting of false saves screen real estate.",
    true, // default value
    ShowShgTipsCallback,
    userConstant);

    tunableBooleanConstantDeclarator* tcShowTrue = 
        new tunableBooleanConstantDeclarator("showShgTrueNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all true nodes"
        " (background colored blue).",
        true, // default value
        ShowShgTrueCallback,
        userConstant);

    tunableBooleanConstantDeclarator* tcHideFalse = 
        new tunableBooleanConstantDeclarator("showShgFalseNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all false nodes"
        " (background colored pink).",
        true, // default value
        ShowShgFalseCallback,
        userConstant);

    tunableBooleanConstantDeclarator* tcHideUnknown = 
        new tunableBooleanConstantDeclarator("showShgUnknownNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all nodes with"
        " an unknown value (background colored green).",
        true, // default value
        ShowShgUnknownCallback,
        userConstant);

    tunableBooleanConstantDeclarator* tcHideNever =
        new tunableBooleanConstantDeclarator("showShgNeverSeenNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all"
        " never-before-seen nodes (background colored gray).",
        true, // default value
        ShowShgNeverCallback,
        userConstant);

    tunableBooleanConstantDeclarator* tcHideActive =
        new tunableBooleanConstantDeclarator("showShgActiveNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all active nodes"
        " (foreground text white).",
        true, // default value
        ShowShgActiveCallback,
        userConstant);

    tunableBooleanConstantDeclarator* tcHideInactive = 
        new tunableBooleanConstantDeclarator("showShgInactiveNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all inactive nodes"
        " (foreground text black).",
        true, // default value
        ShowShgInactiveCallback,
        userConstant);

    tunableBooleanConstantDeclarator* tcHideShadow =
        new tunableBooleanConstantDeclarator("showShgShadowNodes",
        "To save space in the Performance Consultant Search History Graph,"
        " a false setting of this tunable constant will hide all true nodes.",
        true, // default value
        ShowShgShadowCallback,
        userConstant);
    

    // load the TCL sources into the interpreter
    if(initialize_tcl_sources( interp ) != TCL_OK)
    {
        // we already indicated the error to the user
        return false;
    }

    // Initialize the bitmaps we use
    pdLogo::install_fixed_logo("paradynLogo", logo_bits,
                                logo_width, logo_height);
    pdLogo::install_fixed_logo("dont", error_bits,
                                error_width, error_height);
    
    // now install the tcl cmd "createPdLogo" (must be done before anyone
    // tries to create a logo)
    tcl_cmd_installer createPdLogo( interp, "makeLogo", pdLogo::makeLogoCommand,
                   (ClientData)Tk_MainWindow( interp ));

    /* display the paradyn main menu tool bar */
    myTclEval( interp, "buildMainWindow");
    
    // New Where Axis: --ari
    installWhereAxisCommands( interp );
    myTclEval( interp, "whereAxisInitialize");

    // New Search History Graph: --ari
    installShgCommands( interp );

    // New Call Graph --trey
    installCallGraphCommands( interp );

    //
    // initialize status lines library
    // it is assumed that by this point, all the appropriate
    // containing frames have been created and packed into place
    //
    // after this point onwards, any thread may make use of
    // status lines.
    // if any thread happens to create status_lines before here,
    // it should be prepared for a core dump.
    //
    // --krishna
    //
    status_line::status_init( interp );

    ui_status = new status_line("UIM status");
    assert(ui_status);
    ui_status->message("ready");

    // set our version number
    char buf[32];
    sprintf( buf, "setTitleVersion %s", (V_id.OK() ? V_id.release() : "v4") );
    myTclEval( interp, buf);

    // register fd for X events with threadlib as special
#if !defined(i386_unknown_nt4_0)
    Display *UIMdisplay = Tk_Display( Tk_MainWindow( interp ) );
    int xfd = XConnectionNumber( UIMdisplay );
    msg_bind_socket( xfd,
                       1, // libthread leaves it to us to manually dequeue
                       NULL,
                       NULL,
                       &xtid );
#else // !defined(i386_unknown_nt4_0)
    msg_bind_wmsg( &xtid );
#endif // !defined(i386_unknown_nt4_0)

    return true;
}
Esempio n. 4
0
File: tkBusy.c Progetto: das/tk
static Busy *
CreateBusy(
    Tcl_Interp *interp,		/* Interpreter to report error to */
    Tk_Window tkRef)		/* Window hosting the busy window */
{
    Busy *busyPtr;
    int length, x, y;
    const char *fmt;
    char *name;
    Tk_Window tkBusy, tkChild, tkParent;
    Window parent;
    Tk_FakeWin *winPtr;

    busyPtr = (Busy *) ckalloc(sizeof(Busy));
    x = y = 0;
    length = strlen(Tk_Name(tkRef));
    name = ckalloc(length + 6);
    if (Tk_IsTopLevel(tkRef)) {
        fmt = "_Busy";		/* Child */
        tkParent = tkRef;
    } else {
        Tk_Window tkwin;

        fmt = "%s_Busy";	/* Sibling */
        tkParent = Tk_Parent(tkRef);
        for (tkwin = tkRef; (tkwin != NULL) && !Tk_IsTopLevel(tkwin);
                tkwin = Tk_Parent(tkwin)) {
            if (tkwin == tkParent) {
                break;
            }
            x += Tk_X(tkwin) + Tk_Changes(tkwin)->border_width;
            y += Tk_Y(tkwin) + Tk_Changes(tkwin)->border_width;
        }
    }
    for (tkChild = FirstChild(tkParent); tkChild != NULL;
            tkChild = NextChild(tkChild)) {
        Tk_MakeWindowExist(tkChild);
    }
    sprintf(name, fmt, Tk_Name(tkRef));
    tkBusy = Tk_CreateWindow(interp, tkParent, name, NULL);
    ckfree(name);

    if (tkBusy == NULL) {
        return NULL;
    }
    Tk_MakeWindowExist(tkRef);
    busyPtr->display = Tk_Display(tkRef);
    busyPtr->interp = interp;
    busyPtr->tkRef = tkRef;
    busyPtr->tkParent = tkParent;
    busyPtr->tkBusy = tkBusy;
    busyPtr->width = Tk_Width(tkRef);
    busyPtr->height = Tk_Height(tkRef);
    busyPtr->x = Tk_X(tkRef);
    busyPtr->y = Tk_Y(tkRef);
    busyPtr->cursor = None;
    Tk_SetClass(tkBusy, "Busy");
    busyPtr->optionTable = Tk_CreateOptionTable(interp, busyOptionSpecs);
    if (Tk_InitOptions(interp, (char *) busyPtr, busyPtr->optionTable,
                       tkBusy) != TCL_OK) {
        Tk_DestroyWindow(tkBusy);
        return NULL;
    }
    SetWindowInstanceData(tkBusy, busyPtr);
    winPtr = (Tk_FakeWin *) tkRef;

    TkpCreateBusy(winPtr, tkRef, &parent, tkParent, busyPtr);

    MakeTransparentWindowExist(tkBusy, parent);

    Tk_MoveResizeWindow(tkBusy, x, y, busyPtr->width, busyPtr->height);

    /*
     * Only worry if the busy window is destroyed.
     */

    Tk_CreateEventHandler(tkBusy, StructureNotifyMask, BusyEventProc,
                          busyPtr);

    /*
     * Indicate that the busy window's geometry is being managed. This will
     * also notify us if the busy window is ever packed.
     */

    Tk_ManageGeometry(tkBusy, &busyMgrInfo, busyPtr);
    if (busyPtr->cursor != None) {
        Tk_DefineCursor(tkBusy, busyPtr->cursor);
    }

    /*
     * Track the reference window to see if it is resized or destroyed.
     */

    Tk_CreateEventHandler(tkRef, StructureNotifyMask, RefWinEventProc,
                          busyPtr);
    return busyPtr;
}
Esempio n. 5
0
int
Tk_MenubuttonObjCmd(
    ClientData clientData,	/* NULL. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    register TkMenuButton *mbPtr;
    Tk_OptionTable optionTable;
    Tk_Window tkwin;

    if (objc < 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
        return TCL_ERROR;
    }

    /*
     * Create the new window.
     */

    tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp),
                                    Tcl_GetString(objv[1]), NULL);
    if (tkwin == NULL) {
        return TCL_ERROR;
    }

    /*
     * Create the option table for this widget class. If it has already been
     * created, the cached pointer will be returned.
     */

    optionTable = Tk_CreateOptionTable(interp, optionSpecs);

    Tk_SetClass(tkwin, "Menubutton");
    mbPtr = TkpCreateMenuButton(tkwin);

    Tk_SetClassProcs(tkwin, &tkpMenubuttonClass, mbPtr);

    /*
     * Initialize the data structure for the button.
     */

    mbPtr->tkwin = tkwin;
    mbPtr->display = Tk_Display (tkwin);
    mbPtr->interp = interp;
    mbPtr->widgetCmd = Tcl_CreateObjCommand(interp,
                                            Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, mbPtr,
                                            MenuButtonCmdDeletedProc);
    mbPtr->optionTable = optionTable;
    mbPtr->menuName = NULL;
    mbPtr->text = NULL;
    mbPtr->underline = -1;
    mbPtr->textVarName = NULL;
    mbPtr->bitmap = None;
    mbPtr->imageString = NULL;
    mbPtr->image = NULL;
    mbPtr->state = STATE_NORMAL;
    mbPtr->normalBorder = NULL;
    mbPtr->activeBorder = NULL;
    mbPtr->borderWidth = 0;
    mbPtr->relief = TK_RELIEF_FLAT;
    mbPtr->highlightWidth = 0;
    mbPtr->highlightBgColorPtr = NULL;
    mbPtr->highlightColorPtr = NULL;
    mbPtr->inset = 0;
    mbPtr->tkfont = NULL;
    mbPtr->normalFg = NULL;
    mbPtr->activeFg = NULL;
    mbPtr->disabledFg = NULL;
    mbPtr->normalTextGC = None;
    mbPtr->activeTextGC = None;
    mbPtr->gray = None;
    mbPtr->disabledGC = None;
    mbPtr->stippleGC = None;
    mbPtr->leftBearing = 0;
    mbPtr->rightBearing = 0;
    mbPtr->widthString = NULL;
    mbPtr->heightString = NULL;
    mbPtr->width = 0;
    mbPtr->width = 0;
    mbPtr->wrapLength = 0;
    mbPtr->padX = 0;
    mbPtr->padY = 0;
    mbPtr->anchor = TK_ANCHOR_CENTER;
    mbPtr->justify = TK_JUSTIFY_CENTER;
    mbPtr->textLayout = NULL;
    mbPtr->indicatorOn = 0;
    mbPtr->indicatorWidth = 0;
    mbPtr->indicatorHeight = 0;
    mbPtr->direction = DIRECTION_FLUSH;
    mbPtr->cursor = None;
    mbPtr->takeFocus = NULL;
    mbPtr->flags = 0;

    Tk_CreateEventHandler(mbPtr->tkwin,
                          ExposureMask|StructureNotifyMask|FocusChangeMask,
                          MenuButtonEventProc, mbPtr);

    if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin) != TCL_OK) {
        Tk_DestroyWindow(mbPtr->tkwin);
        return TCL_ERROR;
    }

    if (ConfigureMenuButton(interp, mbPtr, objc-2, objv+2) != TCL_OK) {
        Tk_DestroyWindow(mbPtr->tkwin);
        return TCL_ERROR;
    }

    Tcl_SetObjResult(interp, TkNewWindowObj(mbPtr->tkwin));
    return TCL_OK;
}
Esempio n. 6
0
SCISHARE int
OpenGLCmd(ClientData clientData, Tcl_Interp *interp,
          int argc, CONST84 char **argv)
{
  Tk_Window mainwin = (Tk_Window) clientData;
  OpenGLClientData *OpenGLPtr;
  Colormap cmap;
  Tk_Window tkwin;
  XVisualInfo temp_vi;
  int tempid;
  int n;

#ifndef _WIN32
  int attributes[50];
  int idx = 0;
#endif


  if (argc < 2) 
  {
    Tcl_AppendResult(interp, "wrong # args:  should be \"",
                     argv[0], " pathName ?options?\"",
                     (char *) NULL);
    return TCL_ERROR;
  }

  tkwin = Tk_CreateWindowFromPath(interp, mainwin, argv[1], (char *) NULL);
  if (tkwin == NULL) 
  {
    return TCL_ERROR;
  }
  Tk_SetClass(tkwin, "OpenGL");

  /* Allocate and initialize the widget record. */
  OpenGLPtr = (OpenGLClientData *) ckalloc(sizeof(OpenGLClientData));
  OpenGLPtr->geometry = 0;
  OpenGLPtr->cursor = 0;

  OpenGLPtr->interp = interp;
  OpenGLPtr->tkwin = tkwin;
  OpenGLPtr->display = Tk_Display(tkwin);
  OpenGLPtr->x11_win=0;
  OpenGLPtr->screen_number = Tk_ScreenNumber(tkwin);

#ifndef _WIN32
  OpenGLPtr->glx_win=0;
  OpenGLPtr->fb_configs=glXGetFBConfigs(OpenGLPtr->display, 
                                        OpenGLPtr->screen_number, 
                                        &(OpenGLPtr->num_fb));
#else
  OpenGLPtr->hDC = 0;
#endif
  OpenGLPtr->vi=0;
  OpenGLPtr->cx=0;
  
  Tk_CreateEventHandler(OpenGLPtr->tkwin, 
                        StructureNotifyMask,
                        OpenGLEventProc, 
                        (ClientData) OpenGLPtr);
  
  Tcl_CreateCommand(interp, 
                    Tk_PathName(OpenGLPtr->tkwin), 
                    OpenGLWidgetCmd,
                    (ClientData) OpenGLPtr, 
                    (Tcl_CmdDeleteProc *)0);
  if (OpenGLConfigure(interp, OpenGLPtr, argc-2, argv+2, 0) != TCL_OK) 
  {
    return TCL_ERROR;
  }

  tempid = OpenGLPtr->visualid;

  if (OpenGLPtr->visualid) 
  {
    temp_vi.visualid = OpenGLPtr->visualid;
    OpenGLPtr->vi = 
      XGetVisualInfo(OpenGLPtr->display, VisualIDMask, &temp_vi, &n);
    if(!OpenGLPtr->vi || n!=1)
    {
      Tcl_AppendResult(interp, "Error finding visual", NULL);
      return TCL_ERROR;
    }

  } 
  else 
  {
    /*
     * Pick the right visual...
     */
#ifndef _WIN32
    attributes[idx++]=GLX_BUFFER_SIZE;
    attributes[idx++]=OpenGLPtr->buffersize;
    attributes[idx++]=GLX_LEVEL;
    attributes[idx++]=OpenGLPtr->level;
    if(OpenGLPtr->rgba)
      attributes[idx++]=GLX_RGBA;
    if(OpenGLPtr->doublebuffer)
      attributes[idx++]=GLX_DOUBLEBUFFER;
    if(OpenGLPtr->stereo)
      attributes[idx++]=GLX_STEREO;
    attributes[idx++]=GLX_AUX_BUFFERS;
    attributes[idx++]=OpenGLPtr->auxbuffers;
    attributes[idx++]=GLX_RED_SIZE;
    attributes[idx++]=OpenGLPtr->redsize;
    attributes[idx++]=GLX_GREEN_SIZE;
    attributes[idx++]=OpenGLPtr->greensize;
    attributes[idx++]=GLX_BLUE_SIZE;
    attributes[idx++]=OpenGLPtr->bluesize;
    attributes[idx++]=GLX_ALPHA_SIZE;
    attributes[idx++]=OpenGLPtr->alphasize;
    attributes[idx++]=GLX_DEPTH_SIZE;
    attributes[idx++]=OpenGLPtr->depthsize;
    attributes[idx++]=GLX_STENCIL_SIZE;
    attributes[idx++]=OpenGLPtr->stencilsize;
    attributes[idx++]=GLX_ACCUM_RED_SIZE;
    attributes[idx++]=OpenGLPtr->accumredsize;
    attributes[idx++]=GLX_ACCUM_GREEN_SIZE;
    attributes[idx++]=OpenGLPtr->accumgreensize;
    attributes[idx++]=GLX_ACCUM_BLUE_SIZE;
    attributes[idx++]=OpenGLPtr->accumbluesize;
    attributes[idx++]=GLX_ACCUM_ALPHA_SIZE;
    attributes[idx++]=OpenGLPtr->accumalphasize;
    attributes[idx++]=None;

    OpenGLPtr->vi = glXChooseVisual(OpenGLPtr->display, 
                                    OpenGLPtr->screen_number,
                                    attributes);
    OpenGLPtr->visualid=tempid;

#else // WIN32

    // I am using the *PixelFormat commands from win32 because according
    // to the Windows page, we should prefer this to wgl*PixelFormatARB.
    // Unfortunately, this means that the Windows code will differ
    // substantially from that of other platforms.  However, it has the
    // advantage that we don't have to use the wglGetProc to get
    // the procedure address, or test to see if the applicable extension
    // is supported.  WM:VI

    HWND hWnd = TkWinGetHWND(Tk_WindowId(OpenGLPtr->tkwin));

    // a little ugly, but we need this to be defined before pfd, and
    // we need to follow C initialization rules
    DWORD dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | 
      (OpenGLPtr->doublebuffer ? PFD_DOUBLEBUFFER : 0) |
      (OpenGLPtr->stereo ? PFD_STEREO : 0);
    int iPixelFormat;
    XVisualInfo xvi;
    int n_ret;
    PIXELFORMATDESCRIPTOR pfd = 
    { 
      sizeof(PIXELFORMATDESCRIPTOR),   // size of this pfd 
      1,                     // version number 
      dwFlags,
      PFD_TYPE_RGBA,         // RGBA type 
      OpenGLPtr->buffersize, // color depth
      OpenGLPtr->redsize, 0, 
      OpenGLPtr->greensize, 0, 
      OpenGLPtr->bluesize, 0,  // color bits  
      OpenGLPtr->alphasize,0,  // alpha buffer 
      OpenGLPtr->accumredsize+
      OpenGLPtr->accumgreensize+
      OpenGLPtr->accumbluesize,// accumulation buffer 
      OpenGLPtr->accumredsize, 
      OpenGLPtr->accumgreensize, 
      OpenGLPtr->accumbluesize, 
      OpenGLPtr->accumalphasize,// accum bits 
      OpenGLPtr->depthsize,  // 32-bit z-buffer 
      OpenGLPtr->stencilsize,// no stencil buffer 
      OpenGLPtr->auxbuffers, // no auxiliary buffer 
      PFD_MAIN_PLANE,        // main layer 
      0,                     // reserved 
      0, 0, 0                // layer masks ignored 
    };

    iPixelFormat = ChoosePixelFormat(OpenGLPtr->hDC, &pfd); 
    SetPixelFormat(OpenGLPtr->hDC, iPixelFormat, &pfd);
    OpenGLPtr->visualid = iPixelFormat;
    OpenGLPtr->hDC = GetDC(hWnd);

    xvi.screen = OpenGLPtr->screen_number;
    n_ret=0;
    OpenGLPtr->vi = XGetVisualInfo(OpenGLPtr->display,
                                   VisualScreenMask, &xvi,
                                   &n_ret);
#endif
    if (!OpenGLPtr->vi) 
    {
      Tcl_AppendResult(interp, "Error selecting visual", (char*)NULL);
      return TCL_ERROR;
    }
  }
    
  cmap = XCreateColormap(OpenGLPtr->display,
                         Tk_WindowId(Tk_MainWindow(OpenGLPtr->interp)),
                         OpenGLPtr->vi->visual, 
                         AllocNone);

  if(Tk_SetWindowVisual(OpenGLPtr->tkwin, 
                        OpenGLPtr->vi->visual, 
                        OpenGLPtr->vi->depth, cmap) != 1) 
  {
    Tcl_AppendResult(interp, "Error setting visual for window", (char*)NULL);
    return TCL_ERROR;
  }
  
  XSync(OpenGLPtr->display, False);

  Tcl_SetResult(interp,Tk_PathName(OpenGLPtr->tkwin),TCL_STATIC);
  return TCL_OK;
}
Esempio n. 7
0
int
paxwidget_cmd(ClientData data, Tcl_Interp * interp, int argc, char** argv)
{
    Tk_Window tkmain = (Tk_Window) data;
    Tk_Window tkwin;
    PaxWidget * paxwidget;
    char * class_name = NULL;
    int i;

    if (argc < 2)
    {
	Tcl_AppendResult(interp, "wrong # args: should be \"",
			 argv[0], " pathName ?options?\"", (char *) NULL);
	return TCL_ERROR;
    }

    /* look for the -class option */
    for (i = 2; i < argc; i += 2)
    {
	int length;
	char c;
	char * arg;
	
	arg = argv[i];
	length = strlen(arg);
	if (length < 2)
	    continue;
	c = arg[1];
	if ((c == 'c') && (strncmp(arg, "-class", strlen(arg)) == 0)
	    && (length >= 3))
	{
	    if (i < argc - 1)
		class_name = argv[i+1];
	    else
		fprintf(stderr,
			"No argument for -class option, using defaults");
	}
    }

    tkwin = Tk_CreateWindowFromPath(interp, tkmain, argv[1], (char*)NULL);
    if (tkwin == NULL)
    {
	return TCL_ERROR;
    }
    if (class_name)
	Tk_SetClass(tkwin, class_name);
    else
	Tk_SetClass(tkwin, "PaxWidget");

    paxwidget = (PaxWidget*) ckalloc(sizeof(PaxWidget));
    if (!paxwidget)
	return TCL_ERROR;
    paxwidget->tkwin = tkwin;
    paxwidget->display = Tk_Display(tkwin);
    paxwidget->interp = interp;
    paxwidget->widget_cmd = Tcl_CreateCommand(interp, Tk_PathName(tkwin),
					      paxwidget_widget_cmd,
					      (ClientData) paxwidget, NULL);
    paxwidget->obj = NULL;
    paxwidget->width = paxwidget->height = 0;
    paxwidget->background = NULL;
    paxwidget->background_inited = 0;
    paxwidget->cursor = None;
    paxwidget->class_name = NULL;
    paxwidget->update_pending = 0;
    paxwidget->exposed_region = XCreateRegion();


    Tk_CreateEventHandler(paxwidget->tkwin, ExposureMask|StructureNotifyMask,
			  PaxWidgetEventProc, (ClientData) paxwidget);

    if (PaxWidgetConfigure(interp, paxwidget, argc - 2, argv + 2, 0) != TCL_OK)
    {
	Tk_DestroyWindow(paxwidget->tkwin);
	return TCL_ERROR;
    }

    Tcl_SetResult(interp, Tk_PathName(paxwidget->tkwin), TCL_VOLATILE);
    return TCL_OK;
}
Esempio n. 8
0
int
imfsample_cmd(ClientData cldata, Tcl_Interp *interp, int argc, char *argv[])
{
    Tk_Window mainw = (Tk_Window) cldata;
    Imfsample *imfsample;
    Tk_Window tkwin;

    if (argc < 2) {
	Tcl_AppendResult(interp, "wrong # args: should be \"",
		argv[0], " pathName ?options?\"", (char *) NULL);
	return TCL_ERROR;
    }

    tkwin = Tk_CreateWindowFromPath(interp, mainw, argv[1], (char *) NULL);
    if (tkwin == NULL)
      return TCL_ERROR;

    Tk_SetClass(tkwin, "Imfsample");

    /* Allocate and initialize the widget record.  */

    imfsample = (Imfsample *) ckalloc(sizeof(Imfsample));
    imfsample->tkwin = tkwin;
    imfsample->display = Tk_Display(tkwin);
    imfsample->interp = interp;
    imfsample->widgetCmd =
      Tcl_CreateCommand(interp,
			Tk_PathName(imfsample->tkwin), imfsample_widget_cmd,
			(ClientData) imfsample, imfsample_cmd_deleted_proc);
    imfsample->border_width = 0;
    imfsample->bg_border = NULL;
    imfsample->fg_border = NULL;
    imfsample->cu_border = NULL;
    imfsample->relief = TK_RELIEF_FLAT;
    imfsample->copygc = None;
    imfsample->gc = None;
    imfsample->double_buffer = 1;
    imfsample->update_pending = 0;
    imfsample->show_color = 1;
    imfsample->show_names = 0;
    imfsample->show_masks = 0;
    imfsample->show_grid = 0;
    imfsample->fill_color = NULL;
    
    imfsample->with_terrain = -1;
    imfsample->with_emblem = -1;

    imfsample->main_imf_name = "";
    imfsample->numimages = 0;
    imfsample->imf_list =
      (ImageFamily **) xmalloc(MAXIMAGEFAMILIES * sizeof(ImageFamily *));
    imfsample->numvisrows = 0;
    imfsample->firstvisrow = 0;

    /* IMFApp-specific stuff. */
    imfsample->imfapp = 0;
    imfsample->selected = -1;
    imfsample->previous = -1;
    imfsample->oldfirst = 0;    
    imfsample->redraw = 0;    
    
    Tk_CreateEventHandler(imfsample->tkwin, ExposureMask|StructureNotifyMask,
			  imfsample_event_proc, (ClientData) imfsample);
    if (imfsample_configure(interp, imfsample, argc-2, argv+2, 0) != TCL_OK) {
	Tk_DestroyWindow(imfsample->tkwin);
	return TCL_ERROR;
    }

    Tcl_SetResult(interp, Tk_PathName(imfsample->tkwin), TCL_VOLATILE);
    return TCL_OK;
}