void Line(int mv) { int y = ToPixel(mv); int color = GRAY(0xC0); Graphics.Rectangle(0,y,Graphics.Width(),1,color); DrawVoltage(mv,4,y-10,color); }
void OptionsUnmapCB( Widget wd, XtPointer client_data, XtPointer call_data ) { int i; Dimension width, height; Widget w; XEvent event; #ifdef VG_TRACE vg_TRACE_EXECUTION("main: entered OptionsUnmapCB ..."); #endif /* VG_TRACE */ /* * simulate an exposure event over the Options pushbutton to make sure * the pushbutton elevates. (there is a bug in the toolkit where this * doesn't always happen on some servers)... */ w = options_button; i = 0; XtSetArg(argt[i], XmNwidth, &width ); i++; XtSetArg(argt[i], XmNheight, &height ); i++; XtGetValues(w, argt, i); event.type = Expose; event.xexpose.serial = LastKnownRequestProcessed(XtDisplay(w)); event.xexpose.send_event = True; event.xexpose.display = XtDisplay(w); event.xexpose.window = XtWindow(w); event.xexpose.x = 0; event.xexpose.y = 0; event.xexpose.width = 1; /* one pixel seems to be good enough, */ event.xexpose.height = 1; /* but time will tell... */ #if 0 event.xexpose.width = ToPixel(matte, XmHORIZONTAL, (int)width ); event.xexpose.height = ToPixel(matte, XmVERTICAL, (int)height ); #endif event.xexpose.count = 0; XtDispatchEvent (&event); }
void Sample() { int mv = Hardware.GetBatteryMillivolts(); int s = ToPixel(mv); int color = GetColor(mv); Graphics.Rectangle(_count,s-1,1,2,color); _count++; if (_count == Graphics.Width()) _count = 0; Graphics.Rectangle(180,20,40,20,0xFFFF); DrawVoltage(mv,184,24,color); }
void LayoutCB( Widget w, XtPointer client_data, XtPointer call_data ) { int i, j; Dimension width, height; /* size values returned by XtGetValues */ Dimension shadowThickness;/* size values returned by XtGetValues */ Position x, y; /* position values returned by XtGetValues */ int dpwidth, dpheight; /* JET - display w/h set according to */ int xorg, yorg; /* xinerama usage */ struct { /* position, size of widgets (pixels) */ int x, y; int width; int height; } mw, pw; /* matte, logo, drop shadow, login matte and greeting widgets */ int width1, width2; /* general width variable */ int height1; /* general height variable */ Position x1, y1; /* general position variables */ int offsety; /* general offset variable */ int shadow_offsetx; /* offset for drop shadow (pixels) */ int shadow_offsety; /* offset for drop shadow (pixels) */ int spacing; /* spacing between login & matte bottoms */ Widget buttons[4]; /* pushbutton widgets */ XtWidgetGeometry geometry; /* geometry of a widget */ int max_width; /* maximum width of a set of widgets */ int origin; /* horizontal origin for button placement */ int space; /* total available space left between buttons */ int overlap; /* possible widget overlap */ #ifdef VG_TRACE vg_TRACE_EXECUTION("main: entered LayoutCB ..."); #endif /* VG_TRACE */ #ifdef USE_XINERAMA /* get info on the prefered screen */ if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo, appInfo.xineramaPreferredScreen, &dpwidth, &dpheight, &xorg, &yorg)) { /* no joy here either - setup for normal */ dpwidth = dpyinfo.width; dpheight = dpyinfo.height; xorg = yorg = 0; } #else /* no Xinerama */ dpwidth = dpyinfo.width; dpheight = dpyinfo.height; xorg = yorg = 0; #endif /* * - squeeze dialog to fit onto screen (if necessary) */ i = 0; XtSetArg(argt[i], XmNwidth, &width ); i++; XtGetValues(matte, argt, i); mw.width = ToPixel(matte, XmHORIZONTAL, (int)width ); #define HMARGIN 4 /* min sum horizontal margin of matte */ if (mw.width+HMARGIN > dpwidth) { int delta = mw.width + HMARGIN - dpwidth; /* * Matte width greater than screen so shrink matteFrame * and matte1 width to compensate. */ i=0; XtSetArg(argt[i], XmNwidth, &width ); i++; XtGetValues(matteFrame, argt, i); width1 = ToPixel(matteFrame, XmHORIZONTAL, (int)width ); width1 -= delta; width1 = FromPixel(matteFrame, XmHORIZONTAL, width1 ); i=0; XtSetArg(argt[i], XmNwidth, width1 ); i++; XtSetValues(matteFrame, argt, i); width1 = dpwidth - HMARGIN; mw.width = FromPixel(matte, XmHORIZONTAL, width1 ); i=0; XtSetArg(argt[i], XmNwidth, mw.width ); i++; XtSetValues(matte, argt, i); } /* * - Make sure the login widgets don't overlap. */ if (login_form) { i = 0; XtSetArg(argt[i], XmNy, &y ); i++; XtSetArg(argt[i], XmNheight, &height ); i++; XtGetValues(greeting, argt, i); i = 0; XtSetArg(argt[i], XmNy, &y1 ); i++; XtGetValues(login_form, argt, i); overlap = y + height - y1; if (overlap > -10) { i = 0; XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNbottomWidget, login_form); i++; XtSetArg(argt[i], XmNbottomOffset, 10); i++; XtSetValues(greeting, argt, i); } } /* * - center the main matte horizontally and vertically... */ i = 0; XtSetArg(argt[i], XmNx, &x ); i++; XtSetArg(argt[i], XmNy, &y ); i++; XtSetArg(argt[i], XmNwidth, &width ); i++; XtSetArg(argt[i], XmNheight, &height ); i++; XtSetArg(argt[i], XmNshadowThickness, &shadowThickness ); i++; XtGetValues(matte, argt, i); mw.width = ToPixel(matte, XmHORIZONTAL, (int)width ); mw.height = ToPixel(matte, XmVERTICAL, (int)height ); mw.x = ( x > 0 ? ToPixel(matte, XmHORIZONTAL, (int) x) : (dpwidth - mw.width)/2 ); mw.y = ( y > 0 ? ToPixel(matte, XmVERTICAL, (int) y) : (dpheight - mw.height)/2 ); if ( mw.x < 0 ) mw.x = 0; if ( mw.y < 0 ) mw.y = 0; x1 = FromPixel(matte, XmHORIZONTAL, mw.x ); y1 = FromPixel(matte, XmVERTICAL, mw.y ); x1 += xorg; /* JET - adjust for xinerama */ y1 += yorg; i = 0; XtSetArg(argt[i], XmNx, x1 ); i++; XtSetArg(argt[i], XmNy, y1 ); i++; XtSetValues(matte, argt, i); /* * space the buttons horizontally. Start at the center of the matte * and allow them to grow towards the edges... */ i = 0; XtSetArg(argt[i], XmNwidth, &width ); i++; XtGetValues(matte1, argt, i); max_width = width; i = 0; XtSetArg(argt[i], XmNwidth, &width ); i++; XtGetValues(clear_button, argt, i); space = max_width - 4*width; spacing = space/4; if (spacing < 12) spacing = 12; i = 0; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNleftOffset, spacing/2); i++; XtSetValues(ok_button, argt, i); i = 0; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET ); i++; XtSetArg(argt[i], XmNleftWidget, ok_button); i++; XtSetArg(argt[i], XmNleftOffset, spacing); i++; XtSetValues(clear_button, argt, i); i = 0; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET ); i++; XtSetArg(argt[i], XmNleftWidget, clear_button); i++; XtSetArg(argt[i], XmNleftOffset, spacing); i++; XtSetValues(options_button, argt, i); i = 0; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET ); i++; XtSetArg(argt[i], XmNleftWidget, options_button); i++; XtSetArg(argt[i], XmNleftOffset, spacing); i++; XtSetValues(help_button, argt, i); /* * - adjust the copyright vertically to align top with login_matte... */ if (copyright_msg) { XtQueryGeometry(copyright_msg, NULL, &geometry); i = 0; XtSetArg(argt[i], XmNshadowThickness, &width ); i++; XtGetValues(copyright_msg, argt, i); width1 = ToPixel(copyright_msg, XmHORIZONTAL, width); width1 = (dpwidth - (int) geometry.width - 2 * width1)/2; x1 = FromPixel(copyright_msg, XmHORIZONTAL, width1); y1 = FromPixel(copyright_msg, XmVERTICAL, mw.y); i = 0; XtSetArg(argt[i], XmNdefaultPosition, False ); i++; XtSetArg(argt[i], XmNx, x1 ); i++; XtSetArg(argt[i], XmNy, y1 ); i++; XtSetValues(copyright_msg, argt, i); } }