本文整理汇总了C++中Tk_Width函数的典型用法代码示例。如果您正苦于以下问题:C++ Tk_Width函数的具体用法?C++ Tk_Width怎么用?C++ Tk_Width使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tk_Width函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TkDrawInsetFocusHighlight
void
TkDrawInsetFocusHighlight(
Tk_Window tkwin, /* Window whose focus highlight ring is to be
* drawn. */
GC gc, /* Graphics context to use for drawing the
* highlight ring. */
int width, /* Width of the highlight ring, in pixels. */
Drawable drawable, /* Where to draw the ring (typically a pixmap
* for double buffering). */
int padding) /* Width of padding outside of widget. */
{
XRectangle rects[4];
rects[0].x = padding;
rects[0].y = padding;
rects[0].width = Tk_Width(tkwin) - (2 * padding);
rects[0].height = width;
rects[1].x = padding;
rects[1].y = Tk_Height(tkwin) - width - padding;
rects[1].width = Tk_Width(tkwin) - (2 * padding);
rects[1].height = width;
rects[2].x = padding;
rects[2].y = width + padding;
rects[2].width = width;
rects[2].height = Tk_Height(tkwin) - 2*width - 2*padding;
rects[3].x = Tk_Width(tkwin) - width - padding;
rects[3].y = rects[2].y;
rects[3].width = width;
rects[3].height = rects[2].height;
XFillRectangles(Tk_Display(tkwin), drawable, gc, rects, 4);
}
示例2: Tk_Width
void callGraphDisplay::rethink_nominal_centerx() {
// using Tk_Width(theTkWindow) as the available screen width, and
// using root->myEntireWidthAsDrawn(consts) as the amount of screen real
// estate used, this routine rethinks this->nominal_centerx.
const int horizSpaceUsedByTree = rootPtr->entire_width(consts);
// If the entire tree fits, then set center-x to window-width / 2.
// Otherwise, set center-x to used-width / 2;
if (horizSpaceUsedByTree <= Tk_Width(consts.theTkWindow))
nominal_centerx = Tk_Width(consts.theTkWindow) / 2;
else
nominal_centerx = horizSpaceUsedByTree / 2;
}
示例3: C_StretchBoxProc
int C_StretchBoxProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv)
{
double x2,y2,xtemp2,ytemp2;
Pixmap pm;
XRectangle theClientArea;
Tk_Window tkwin;
WindowType theWindow = theWindowArray[atoi(argv[1])];
tkwin = theWindow->tkwin;
theClientArea.x = 0;
theClientArea.y = 0;
theClientArea.width = Tk_Width(tkwin);
theClientArea.height = Tk_Height(tkwin);
XSetClipRectangles(theDisplay, theWindow->xwingc, 0, 0, &theClientArea,
1, Unsorted);
pm = XCreatePixmap(theDisplay, Tk_WindowId(tkwin), Tk_Width(tkwin),
Tk_Height(tkwin), Tk_Depth(tkwin));
XCopyArea(theDisplay, theWindow->pixmap_buffer, pm, theWindow->xwingc, 0,
0, Tk_Width(tkwin), Tk_Height(tkwin), 0, 0);
x2 = atof(argv[2]);
y2 = atof(argv[3]);
if (Is_X_Log(theWindow)) {
xtemp2 = theWindow->c1 * log10(max(x2, DBL_MIN)) + theWindow->d1;
} else {
xtemp2 = theWindow->c1 * x2 + theWindow->d1;
}
if (Is_Y_Log(theWindow)) {
ytemp2 = theWindow->c2 * log10(max(y2, DBL_MIN)) + theWindow->d2;
} else {
ytemp2 = theWindow->c2 * y2 + theWindow->d2;
}
XSetForeground(theDisplay, theWindow->xwingc, theWhitePixel);
XDrawRectangle(theDisplay, pm, theWindow->xwingc, min(xtemp1,xtemp2),
min(ytemp1,ytemp2), fabs(xtemp2 - xtemp1),
fabs(ytemp2 - ytemp1));
XCopyArea(theDisplay, pm, Tk_WindowId(tkwin), theWindow->xwingc, 0, 0,
Tk_Width(tkwin), Tk_Height(tkwin), 0, 0);
XFlush(theDisplay);
XFreePixmap(theDisplay, pm);
return TCL_OK;
}
示例4: TkScaleValueToPixel
int
TkScaleValueToPixel(
register TkScale *scalePtr, /* Information about widget. */
double value) /* Reading of the widget. */
{
int y, pixelRange;
double valueRange;
valueRange = scalePtr->toValue - scalePtr->fromValue;
pixelRange = ((scalePtr->orient == ORIENT_VERTICAL)
? Tk_Height(scalePtr->tkwin) : Tk_Width(scalePtr->tkwin))
- scalePtr->sliderLength - 2*scalePtr->inset - 2*scalePtr->borderWidth;
if (valueRange == 0) {
y = 0;
} else {
y = (int) ((value - scalePtr->fromValue) * pixelRange
/ valueRange + 0.5);
if (y < 0) {
y = 0;
} else if (y > pixelRange) {
y = pixelRange;
}
}
y += scalePtr->sliderLength/2 + scalePtr->inset + scalePtr->borderWidth;
return y;
}
示例5: HtmlMapControls
/*
** Map any control that should be visible according to the
** current scroll position. At the same time, if any controls that
** should not be visible are mapped, unmap them. After this routine
** finishes, all <INPUT> controls should be in their proper places
** regardless of where they might have been before.
**
** Return the number of controls that are currently visible.
*/
int HtmlMapControls(HtmlWidget *htmlPtr){
HtmlElement *p; /* For looping over all controls */
int x, y, w, h; /* Part of the virtual canvas that is visible */
int cnt = 0; /* Number of visible controls */
x = htmlPtr->xOffset;
y = htmlPtr->yOffset;
w = Tk_Width(htmlPtr->clipwin);
h = Tk_Height(htmlPtr->clipwin);
for(p=htmlPtr->firstInput; p; p=p->input.pNext){
if( p->input.tkwin==0 ) continue;
if( p->input.y < y+h
&& p->input.y + p->input.h > y
&& p->input.x < x+w
&& p->input.x + p->input.w > x
){
/* The control should be visible. Make is so if it isn't already */
Tk_MoveResizeWindow(p->input.tkwin,
p->input.x - x, p->input.y - y,
p->input.w, p->input.h);
if( !Tk_IsMapped(p->input.tkwin) ){
Tk_MapWindow(p->input.tkwin);
}
cnt++;
}else{
/* This control should not be visible. Unmap it. */
if( Tk_IsMapped(p->input.tkwin) ){
Tk_UnmapWindow(p->input.tkwin);
}
}
}
return cnt;
}
示例6: PlacePanes
/* PlacePanes --
* Places slave panes based on sash positions.
*/
static void PlacePanes(Paned *pw)
{
int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
int width = Tk_Width(pw->core.tkwin), height = Tk_Height(pw->core.tkwin);
int sashThickness = pw->paned.sashThickness;
int pos = 0;
int index;
for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
int size = pane->sashPos - pos;
if (size > 0) {
if (horizontal) {
Ttk_PlaceSlave(pw->paned.mgr, index, pos, 0, size, height);
} else {
Ttk_PlaceSlave(pw->paned.mgr, index, 0, pos, width, size);
}
} else {
Ttk_UnmapSlave(pw->paned.mgr, index);
}
pos = pane->sashPos + sashThickness;
}
}
示例7: DisplayHorizontalValue
static void
DisplayHorizontalValue(
register TkScale *scalePtr, /* Information about widget in which to
* display value. */
Drawable drawable, /* Pixmap or window in which to draw the
* value. */
double value, /* X-coordinate of number to display,
* specified in application coords, not in
* pixels (we'll compute pixels). */
int top) /* Y-coordinate of top edge of text, specified
* in pixels. */
{
register Tk_Window tkwin = scalePtr->tkwin;
int x, y, length, width;
char valueString[PRINT_CHARS];
Tk_FontMetrics fm;
x = TkScaleValueToPixel(scalePtr, value);
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
y = top + fm.ascent;
sprintf(valueString, scalePtr->format, value);
length = (int) strlen(valueString);
width = Tk_TextWidth(scalePtr->tkfont, valueString, length);
/*
* Adjust the x-coordinate if necessary to keep the text entirely inside
* the window.
*/
x -= (width)/2;
if (x < (scalePtr->inset + SPACING)) {
x = scalePtr->inset + SPACING;
}
/*
* Check the right border so use starting point +text width for the check.
*/
if (x + width >= (Tk_Width(tkwin) - scalePtr->inset)) {
x = Tk_Width(tkwin) - scalePtr->inset - SPACING - width;
}
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC,
scalePtr->tkfont, valueString, length, x, y);
}
示例8: Tk_WindowId
void callGraphDisplay::draw(bool doubleBuffer,
bool xsynchronize // are we debugging?
) const {
Drawable theDrawable =
(doubleBuffer && !xsynchronize) ? consts.offscreenPixmap :
Tk_WindowId(consts.theTkWindow);
if (doubleBuffer || xsynchronize)
// clear the offscreen pixmap before drawing onto it
XFillRectangle(consts.display, theDrawable, consts.erasingGC,
0, // x-offset relative to drawable
0, // y-offset relative to drawable
Tk_Width(consts.theTkWindow),
Tk_Height(consts.theTkWindow)
);
const int overallWindowBorderPix = 0;
if (rootPtr)
rootPtr->draw(consts.theTkWindow, consts, theDrawable,
nominal_centerx + horizScrollBarOffset,
// relative (not absolute) coord
overallWindowBorderPix + vertScrollBarOffset,
// relative (not absolute) coord
false, // not root only
false // not listbox only
);
if (doubleBuffer && !xsynchronize) {
// copy from offscreen pixmap onto the 'real' window
XCopyArea(consts.display,
theDrawable, // source pixmap
Tk_WindowId(consts.theTkWindow), // dest pixmap
consts.listboxCopyAreaGC,
0, 0, // source x,y pix
Tk_Width(consts.theTkWindow),
Tk_Height(consts.theTkWindow),
0, 0 // dest x,y offset pix
);
}
}
示例9: pdstring
void callGraphDisplay::resizeScrollbars() {
pdstring commandStr = pdstring("resize1Scrollbar ") + horizSBName + " " +
pdstring(rootPtr->entire_width(consts)) + " " +
pdstring(Tk_Width(consts.theTkWindow));
myTclEval(interp, commandStr);
commandStr = pdstring("resize1Scrollbar ") + vertSBName + " " +
pdstring(rootPtr->entire_height(consts)) + " " +
pdstring(Tk_Height(consts.theTkWindow));
myTclEval(interp, commandStr);
}
示例10: TkpDrawFrame
void
TkpDrawFrame(
Tk_Window tkwin,
Tk_3DBorder border,
int highlightWidth,
int borderWidth,
int relief)
{
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth,
highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth,
Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief);
}
示例11: ImageDraw
static void ImageDraw(
ImageElement *image, Tk_Window tkwin,Drawable d,Ttk_Box b,Ttk_State state)
{
int width = image->width, height = image->height;
/* Clip width and height to remain within window bounds:
*/
if (b.x + width > Tk_Width(tkwin)) {
width = Tk_Width(tkwin) - b.x;
}
if (b.y + height > Tk_Height(tkwin)) {
height = Tk_Height(tkwin) - b.y;
}
if (height <= 0 || width <= 0) {
/* Completely clipped - bail out.
*/
return;
}
Tk_RedrawImage(image->tkimg, 0,0, width, height, d, b.x, b.y);
/* If we're disabled there's no state-specific 'disabled' image,
* stipple the image.
* @@@ Possibly: Don't do disabled-stippling at all;
* @@@ it's ugly and out of fashion.
* Do not stipple at all under Aqua, just draw the image: it shows up
* as a white rectangle otherwise.
*/
if (state & TTK_STATE_DISABLED) {
if (TtkSelectImage(image->imageSpec, 0ul) == image->tkimg) {
#ifndef MAC_OSX_TK
StippleOver(image, tkwin, d, b.x,b.y);
#endif
}
}
}
示例12: BackgroundElementDraw
static void BackgroundElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
if (qApp == NULL) NULL_Q_APP;
NULL_PROXY_WIDGET(TileQt_QWidget_Widget);
Tcl_MutexLock(&tileqtMutex);
int width = Tk_Width(tkwin), height = Tk_Height(tkwin);
QPixmap pixmap(width, height);
QPainter painter(&pixmap);
TILEQT_PAINT_BACKGROUND(width, height);
TileQt_CopyQtPixmapOnToDrawable(pixmap, d, tkwin,
0, 0, width, height, 0, 0);
Tcl_MutexUnlock(&tileqtMutex);
}
示例13: ButtonBackgroundDrawCB
/*
*--------------------------------------------------------------
*
* ButtonBackgroundDrawCB --
*
* This function draws the background that
* lies under checkboxes and radiobuttons.
*
* Results:
* None.
*
* Side effects:
* The background gets updated to the current color.
*
*--------------------------------------------------------------
*/
static void
ButtonBackgroundDrawCB (
const HIRect * btnbounds,
MacButton *ptr,
SInt16 depth,
Boolean isColorDev)
{
MacButton* mbPtr = (MacButton*)ptr;
TkButton* butPtr = (TkButton*)mbPtr;
Tk_Window tkwin = butPtr->tkwin;
Pixmap pixmap;
int usehlborder = 0;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
pixmap = (Pixmap)Tk_WindowId(tkwin);
if (butPtr->type != TYPE_LABEL) {
switch (mbPtr->btnkind) {
case kThemeSmallBevelButton:
case kThemeBevelButton:
case kThemeRoundedBevelButton:
case kThemePushButton:
usehlborder = 1;
break;
}
}
if (usehlborder) {
Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
} else {
Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
}
}
示例14: SashLayout
/* SashLayout --
* Place the sash sublayout after the specified pane,
* in preparation for drawing.
*/
static Ttk_Layout SashLayout(Paned *pw, int index)
{
Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
int thickness = pw->paned.sashThickness,
height = Tk_Height(pw->core.tkwin),
width = Tk_Width(pw->core.tkwin),
sashPos = pane->sashPos;
Ttk_PlaceLayout(
pw->paned.sashLayout, pw->core.state,
pw->paned.orient == TTK_ORIENT_HORIZONTAL
? Ttk_MakeBox(sashPos, 0, thickness, height)
: Ttk_MakeBox(0, sashPos, width, thickness));
return pw->paned.sashLayout;
}
示例15: PanedPostConfigure
/* Post-configuration hook.
*/
static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
Paned *pw = clientData;
if (mask & GEOMETRY_CHANGED) {
/* User has changed -width or -height.
* Recalculate sash positions based on requested size.
*/
Tk_Window tkwin = pw->core.tkwin;
PlaceSashes(pw,
pw->paned.width > 0 ? pw->paned.width : Tk_Width(tkwin),
pw->paned.height > 0 ? pw->paned.height : Tk_Height(tkwin));
}
return TCL_OK;
}