示例#1
0
文件: test9.c 项目: melanj/lesstif
static void
mytest(Widget w, XtPointer p, XtPointer s)
{
    Pixel fg, bg;
    int height, width;
    Pixmap pixmap;

    printf("hi\n");

    XtVaGetValues(w,
		  XmNwidth, &width,
		  XmNheight, &height,
		  NULL);
    printf("height == %d, width == %d\n", height, width);

    fg = XBlackPixelOfScreen(XtScreen(w));
    bg = XWhitePixelOfScreen(XtScreen(w));
    pixmap = XmGetPixmap(XtScreen(w), "xlogo64", fg, bg);

    XtVaSetValues(w,
		  XmNwidth, 0,
		  XmNheight, 0,
		  XmNlabelPixmap, pixmap,
		  XmNlabelType,XmPIXMAP,
		  NULL);

    XtVaGetValues(w,
		  XmNwidth, &width,
		  XmNheight, &height,
		  NULL);
    printf("height == %d, width == %d\n", height, width);
}
示例#2
0
文件: test19.c 项目: melanj/lesstif
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget label;
  Pixel fg,bg;
  
  toplevel = XtVaAppInitialize(&theApp, "drawingArea", NULL, 0,
			       &argc, argv, NULL, NULL);

  label= XtVaCreateManagedWidget("Button1", 
                                 xmPushButtonWidgetClass, toplevel, 
				 NULL);
  XtRealizeWidget(toplevel);

  theDisplay = XtDisplay(toplevel);
  theRootWindow = XDefaultRootWindow(theDisplay);

  fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(theDisplay));
  bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(theDisplay));

  Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
                    "xlogo64",
                    fg, bg);

  XtVaSetValues(label,
	        XmNlabelPixmap,Pix, 
                XmNlabelType,XmPIXMAP,
                NULL);

  {
  static XtWidgetGeometry Expected[] = {
  	CWWidth | CWHeight,		0,	0,	54,	25,	0,0,0,	/* Form */
  	CWWidth | CWHeight | CWX | CWY,	45,	30,	30,	25,	0,0,0,	/* two */
};

  PrintDetails(toplevel, Expected);
  }
  fprintf(stderr, "Button %p VendorExt %p ButtonFontList %p TextFontList %p (r %p) LabelFontList %p\n",
	label,
	_LtFindVendorExt(label),
	((XmVendorShellExtObject)_LtFindVendorExt(label))->vendor.button_font_list,
	((XmVendorShellExtObject)_LtFindVendorExt(label))->vendor.text_font_list,
	((XmVendorShellExtObject)_LtFindVendorExt(label))->vendor.label_font_list,
	((XmVendorShellExtObject)_LtFindVendorExt(label))->vendor.text_font_list->renditions[0]);
  LessTifTestMainLoop(toplevel);
  /*
  XtAppMainLoop(theApp);
  */

  exit(0);
}
示例#3
0
    ///////////////////////////////////////////////////////////////////////
    ///  Function: AttachWhiteOfScreen
    ///
    ///    Author: $author$
    ///      Date: 2/8/2013
    ///////////////////////////////////////////////////////////////////////
    virtual XosError AttachWhiteOfScreen(Screen* xScreen, bool onlyFreed=false) 
    {
        XosError error = XOS_ERROR_FAILED;
        XosError error2;

        if ((error2 = Freed(onlyFreed)))
            return error2;

        if ((xScreen)) {
            Attach(XWhitePixelOfScreen(xScreen));
            error = XOS_ERROR_NONE;
        }
        return error;
    }
示例#4
0
文件: test4.c 项目: melanj/lesstif
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget toplevel;
  Widget butt;
  Pixmap pixmap;
  Pixel fg, bg;

  toplevel = XtVaAppInitialize(&theApp, "test3", NULL, 0,
			       &argc, argv, NULL, NULL);

  fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(XtDisplay(toplevel)));
  bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(XtDisplay(toplevel)));

  pixmap = XmGetPixmap(DefaultScreenOfDisplay(XtDisplay(toplevel)),
		       "xlogo64", fg, bg);
  if (pixmap == XmUNSPECIFIED_PIXMAP)
	printf("Pixmap unspecified\n");

  butt= XtVaCreateManagedWidget("Button1", xmDrawnButtonWidgetClass, toplevel, 
				XmNwidth, 100,
				XmNheight, 100,
			        XmNshadowThickness, 4,
			        XmNshadowType, XmSHADOW_ETCHED_OUT,
				XmNlabelType, XmPIXMAP,
				XmNlabelPixmap, pixmap,
				NULL);


  XtRealizeWidget(toplevel);


/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,    0,    0,  100,  100, 0,0,0, /* Button1 */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
LessTifTestMainLoop(toplevel);
  exit(0);
}
示例#5
0
文件: test6.c 项目: melanj/lesstif
int
main(int argc, char **argv)
{
    XtAppContext theApp;
    Widget toplevel;
    Widget butt;
    Pixmap Pix;
    Display *theDisplay;
    Window theRootWindow;
    Pixel fg,bg;
    Dimension mt, mb, ml, mr, mw, mh, st, ht;
    XtWidgetGeometry geo;

    toplevel = XtVaAppInitialize(&theApp, "toggle1", NULL, 0,
                                 &argc, argv, NULL, NULL);

    butt= XtVaCreateManagedWidget("Button1", xmToggleButtonWidgetClass, toplevel,
#if 0
                                  XmNindicatorOn, False,
#endif
                                  XmNshadowThickness, 5,
                                  XmNfillOnSelect, True,
                                  NULL);

    XtAddCallback(butt,XmNvalueChangedCallback,HiCB,NULL);

    XtRealizeWidget(toplevel);

    theDisplay = XtDisplay(toplevel);
    theRootWindow = XDefaultRootWindow(theDisplay);

    fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(theDisplay));
    bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(theDisplay));

    Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
                      "xlogo64",
                      fg, bg);
    if (Pix == XmUNSPECIFIED_PIXMAP)
        printf("PIX IS UNSPECIFIED\n");

    XtVaGetValues(butt,
                  XmNmarginTop, &mt, XmNmarginBottom, &mb,
                  XmNmarginLeft, &ml, XmNmarginRight, &mr,
                  XmNmarginWidth, &mw, XmNmarginHeight, &mh,
                  XmNshadowThickness, &st, XmNhighlightThickness, &ht,
                  NULL);
    printf("%d %d %d %d %d %d %d %d\n",
           mt, mb, ml, mr, mw, mh, st, ht);

    XtVaSetValues(butt,
#if 0
                  XmNlabelPixmap,Pix,
#endif
                  XmNlabelType, XmPIXMAP,
                  NULL);

    Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
                      "woman",
                      fg, bg);

    XtVaGetValues(butt,
                  XmNmarginTop, &mt, XmNmarginBottom, &mb,
                  XmNmarginLeft, &ml, XmNmarginRight, &mr,
                  XmNmarginWidth, &mw, XmNmarginHeight, &mh,
                  XmNshadowThickness, &st, XmNhighlightThickness, &ht,
                  NULL);
    printf("%d %d %d %d %d %d %d %d\n",
           mt, mb, ml, mr, mw, mh, st, ht);

    XtVaSetValues(butt,
                  XmNselectPixmap, Pix,
                  NULL);

    XtQueryGeometry(butt, NULL, &geo);
    printf("toggle wants: %d %d has %d %d\n",
           geo.width, geo.height, XtWidth(butt), XtHeight(butt));

    XtVaGetValues(butt,
                  XmNmarginTop, &mt, XmNmarginBottom, &mb,
                  XmNmarginLeft, &ml, XmNmarginRight, &mr,
                  XmNmarginWidth, &mw, XmNmarginHeight, &mh,
                  XmNshadowThickness, &st, XmNhighlightThickness, &ht,
                  NULL);
    printf("%d %d %d %d %d %d %d %d\n",
           mt, mb, ml, mr, mw, mh, st, ht);

    /* Note: the following values are the result of
     * querying the current geometry.
     */
    {
        static XtWidgetGeometry Expected[] = {
            CWWidth | CWHeight            ,  387,  402,   77,   45, 0,0,0, /* Button1 */
        };
        /* toplevel should be replaced with to correct applicationShell */
        PrintDetails(toplevel, Expected);
    }
    LessTifTestMainLoop(toplevel);

    exit(0);
}
示例#6
0
int initsystem(void)  /* retourne 1 si initialisation reussie */
{
    int i;
    int windowW;
    int windowH;
    XSetWindowAttributes xswa;
    XGCValues xgcv;
    XSizeHints xsh;

    windowW=WIDTH*RATIO;
    windowH=HEIGHT*RATIO;
    display=XOpenDisplay(0);

    if (!display) return(0);
    else
    {
        mousek=0;
        XAutoRepeatOff(display);
        timestart=last=systime();
        screen=XDefaultScreenOfDisplay(display);
        rdepth=sdepth=XDefaultDepthOfScreen(screen);
        if (emulmono) sdepth=1;
        XSynchronize(display,0);

        black=XBlackPixelOfScreen(screen);
        white=XWhitePixelOfScreen(screen);
        colormap=XDefaultColormapOfScreen(screen);
        visual=XDefaultVisualOfScreen(screen);

        xswa.event_mask=VisibilityChangeMask;
        xswa.background_pixel=black;
        xswa.border_pixel=white;
        xswa.override_redirect=0;
        xswa.backing_store=Always;
        xswa.bit_gravity=StaticGravity;
        xswa.win_gravity=CenterGravity;
        window=XCreateWindow(display,XRootWindowOfScreen(screen),
                             randval(50),randval(100),windowW,windowH,0,
                             XDefaultDepthOfScreen(screen),InputOutput,
                             XDefaultVisualOfScreen(screen),
                             CWWinGravity|CWBitGravity|CWBackingStore|CWEventMask|
                             CWBackPixel|CWOverrideRedirect|CWBorderPixel,&xswa);

        if (sdepth!=1)
            xcolormap=XCreateColormap(display,window,
                                      visual,AllocAll);

        xgcv.foreground = white;
        xgcv.background = black;
        gc=XCreateGC(display,window,GCForeground | GCBackground,&xgcv);

        XSetGraphicsExposures(display,gc,False);
        /* CAPITAL!!! : evite d'accumuler sans cesse des expose events */

        xsh.x=0;
        xsh.y=0;
        xsh.width=windowW;
        xsh.height=windowH;
        xsh.min_width=windowW;
        xsh.max_width=windowW;
        xsh.min_height=windowH;
        xsh.max_height=windowH;
        xsh.flags=PPosition|PSize|PMinSize|PMaxSize;

        XSetNormalHints(display, window, &xsh);
        XStoreName(display,window,"");
        XMapWindow(display, window);
        XSelectInput(display,window,PointerMotionMask|ButtonPressMask|
                     ButtonReleaseMask|KeyPressMask|KeyReleaseMask);
        XFlush(display);
        XSync(display,0);

        for (i=0; i<(NBCOLORS+2); i++)
        {
            if (i&1) pixels[i]=white;
            else pixels[i]=black;
            if (i==NBCOLORS) pixels[i]=0;
            if (i==(NBCOLORS+1)) pixels[i]=(1<<rdepth)-1;
            xgcv.foreground=pixels[i];
            xgcv.background=black;
            gctab[i]=XCreateGC(display,window,
                               GCForeground|GCBackground,&xgcv);
            XSetFunction(display,gctab[i],GXcopy);
            XSetFillStyle(display,gctab[i],FillSolid);
        }

        ecran[0]=XCreatePixmap(display,window,windowW,windowH,rdepth);
        ecran[1]=XCreatePixmap(display,window,windowW,windowH,rdepth);

        for(i=0; i<9; i++)
            graypixmap[i]=XCreatePixmapFromBitmapData(display,window,
                          &graypat[i][0],8,8,white,black,rdepth);

        setpalette(egapal);

        cls();
        swap();
        cls();

        empty();
        waitdelay(500);

        return(1);
    }
}
示例#7
0
/*--------------------------------------------------------*/
void open_gwindow_( )
{
/*
 * create new graphics window on first entry....
 */
  int                          font,black,white;
  int                          scr_width,scr_height;
  int                          j;
  unsigned long                valuemask;
  static int                   depth;    /* number of planes  */
  static Visual               *visual;   /*VISUAL TYPE       */
  static XSizeHints            win_position;   /*position and size for
                                            window manager.*/

/*
 * initialize display id and screen id....
 */
      disp_id = XOpenDisplay(0);
      if (!disp_id) {
         printf("Display not opened!\n");
         exit(-1);
      }
/*
 * next instruction for debugging only....
 */
/*      XSynchronize(disp_id, 1); */
  
  screen_id  =  XDefaultScreenOfDisplay(disp_id);
  root_win_id = XRootWindowOfScreen(screen_id);
  black =       XBlackPixelOfScreen(screen_id);
  white =       XWhitePixelOfScreen(screen_id);
  scr_width =   XWidthOfScreen(screen_id);
  scr_height =  XHeightOfScreen(screen_id);
  depth  =      XDefaultDepthOfScreen(screen_id);
  visual =      XDefaultVisualOfScreen(screen_id);


/*
 * set up backing store....
 */
      valuemask = CWBitGravity | CWBackingStore | CWBackPixel;
      setwinattr.bit_gravity = SouthWestGravity;
      setwinattr.backing_store = Always;
      setwinattr.background_pixel = white;
/*
 * create the window....
 */
      win_id  = XCreateWindow(disp_id,
			      root_win_id,
			      scr_width - win_width - 15,
			      scr_height - win_height - 35,
			      win_width, 
			      win_height, 
			      10,
			      depth,
			      InputOutput,
			      visual,
			      valuemask,
			      &setwinattr);
/* WMHints structure */
  win_position.x = scr_width - win_width - 15;
  win_position.y = scr_height - win_height - 35;
  win_position.width = win_width;
  win_position.height = win_height;
  win_position.flags=USPosition|USSize;
  
  XSetWMNormalHints(disp_id, win_id, &win_position); 

      XStoreName(disp_id, win_id, WINDNAME);
/*
 * get named color values....
 */

      color[1]   = define_color_("BLUE");
      color[2]   = define_color_("DEEP SKY BLUE");
      color[3]   = define_color_("LIGHT SKY BLUE");

      color[4]   = define_color_("SEA GREEN");
      color[5]  = define_color_("MEDIUM SEA GREEN");
      color[6]  = define_color_("GREEN");

      color[7]  = define_color_("BROWN");
      color[8]  = define_color_("CHOCOLATE");
      color[9]  = define_color_("SANDY BROWN");

      color[10]   = define_color_("RED");
      color[11]   = define_color_("CORAL");
      color[12]   = define_color_("ORANGE");

      color[13]  = define_color_("YELLOW3");
      color[14]  = define_color_("YELLOW2");
      color[15]  = define_color_("YELLOW");

      color[16]  = define_color_("PEACH PUFF");
      color[17]  = define_color_("PAPAYA WHIP");
      color[18]  = define_color_("OLD LACE");

      color[19]   = white;
      color[20]   = black;
      color[21]   = black;


/*
 * create graphics context....
 */
      xgcvl.background = color[19];
      xgcvl.foreground = color[20];
      gc_id = XCreateGC(disp_id, win_id, GCForeground | GCBackground, &xgcvl);
      xgcvl.function = GXinvert;
      gc_comp_id = XCreateGC(disp_id, win_id, GCFunction, &xgcvl);
/*
 * load the font for text writing....
 */
      font = XLoadFont(disp_id, FONTNAME);
      XSetFont(disp_id, gc_id, font);

  /* Map the window.... */
  XSelectInput(disp_id,win_id,ExposureMask|VisibilityChangeMask);
  XMapRaised(disp_id,win_id);

  /*
   * Wait for the window to be raised. Some X servers do not 
   * generate an initial expose event, so also check the visibility
   * event.
   */
  XMaskEvent(disp_id,ExposureMask|VisibilityChangeMask,&event);
  XSelectInput(disp_id,win_id,0);
  XSync(disp_id,1);
}
示例#8
0
 unsigned screen::IMPL::white_pixel() const
 {
   return XWhitePixelOfScreen( _xscrn );
 }
示例#9
0
文件: test2.c 项目: melanj/lesstif
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget label;
  Pixel fg,bg;
  XmFontList fontlist;

  toplevel = XtVaAppInitialize(&theApp, "drawingArea", NULL, 0,
			       &argc, argv, Fallback, NULL);

  fontlist = XmFontListAppendEntry(NULL,
			   XmFontListEntryCreate("MY_FONT",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));

  fontlist = XmFontListAppendEntry(fontlist,
			   XmFontListEntryCreate("MY_FONT1",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-r-normal--17-0-75-75-p-*-iso8859-1")));

#if 0
  label= XtVaCreateManagedWidget("Button1", xmLabelWidgetClass, toplevel, XmNfontList, fontlist,
				NULL);
#else
  label= XtVaCreateManagedWidget("Button1", xmLabelWidgetClass, toplevel,
				NULL);
#endif
  XtRealizeWidget(toplevel);

  theDisplay = XtDisplay(toplevel);
  theRootWindow = XDefaultRootWindow(theDisplay);

  fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(theDisplay));
  bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(theDisplay));

  Pix = XmGetPixmap(DefaultScreenOfDisplay(theDisplay),
                    "xlogo64",
                    fg, bg);
  if (Pix == XmUNSPECIFIED_PIXMAP) {
	printf("NO PIXMAP!\n");
	exit(0);
  }

  XtVaSetValues(label,
	        XmNlabelPixmap,Pix, 
                XmNlabelType,XmPIXMAP,
                NULL);

  printf("%p\n", XmDragStart(label, NULL, NULL, 0));
  
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   57,   73,   46,   17, 0,0,0, /* Button1 */ 
    };
    PrintDetails(  toplevel ,Expected);
};
   LessTifTestMainLoop(  toplevel );

  exit(0);
}