## Tcl8.6.17/Tk8.6.17 Documentation > Tk C API > CanvTkwin

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

  NAME
    Tk_CanvasTkwin, Tk_CanvasGetCoord, Tk_CanvasDrawableCoords, Tk_CanvasSetStippleOrigin, Tk_CanvasWindowCoords, Tk_CanvasEventuallyRedraw, Tk_CanvasTagsOption — 画布型管理譜の為の便益の手続函数 utility procedures for canvas type managers
  SYNOPSIS
    #include <tk.h>
    Tk_Window
    Tk_CanvasTkwin(canvas)
    int
    Tk_CanvasGetCoord(interp, canvas, string, doublePtr)
    Tk_CanvasDrawableCoords(canvas, x, y, drawableXPtr, drawableYPtr)
    Tk_CanvasSetStippleOrigin(canvas, gc)
    Tk_CanvasWindowCoords(canvas, x, y, screenXPtr, screenYPtr)
    Tk_CanvasEventuallyRedraw(canvas, x1, y1, x2, y2)
    Tk_OptionParseProc *Tk_CanvasTagsParseProc;
    Tk_OptionPrintProc *Tk_CanvasTagsPrintProc;
  引数 ARGUMENTS
    Tk_Canvas canvas (入力in)
    Tcl_Interp *interp (入出力in/out)
    const char *string (入力in)
    double *doublePtr (出力out)
    double x (入力in)
    double y (入力in)
    short *drawableXPtr (出力out)
    short *drawableYPtr (出力out)
    GC gc (出力out)
    short *screenXPtr (出力out)
    short *screenYPtr (出力out)
    int x1 (入力in)
    int y1 (入力in)
    int x2 (入力in)
    int y2 (入力in)
  説明 DESCRIPTION
  KEYWORDS

### NAME

Tk_CanvasTkwin, Tk_CanvasGetCoord, Tk_CanvasDrawableCoords, Tk_CanvasSetStippleOrigin, Tk_CanvasWindowCoords, Tk_CanvasEventuallyRedraw, Tk_CanvasTagsOption — 画布型管理譜の為の便益の手続函数 utility procedures for canvas type managers

### SYNOPSIS

#include <tk.h>
Tk_Window
Tk_CanvasTkwin(canvas)
int
Tk_CanvasGetCoord(interp, canvas, string, doublePtr)
Tk_CanvasDrawableCoords(canvas, x, y, drawableXPtr, drawableYPtr)
Tk_CanvasSetStippleOrigin(canvas, gc)
Tk_CanvasWindowCoords(canvas, x, y, screenXPtr, screenYPtr)
Tk_CanvasEventuallyRedraw(canvas, x1, y1, x2, y2)
Tk_OptionParseProc *Tk_CanvasTagsParseProc;
Tk_OptionPrintProc *Tk_CanvasTagsPrintProc;

### 引数 ARGUMENTS

Tk_Canvas canvas (入力in)
  画布部品を識別する符牒語｡ A token that identifies a canvas widget.

Tcl_Interp *interp (入出力in/out)
  不都合を報告する為に使われる解釈実行機能｡ Interpreter to use for error reporting.

const char *string (入力in)
  画布座標の文書記述｡ Textual description of a canvas coordinate.

double *doublePtr (出力out)
  変換された座標を保存する場所を指す｡ Points to place to store a converted coordinate.

double x (入力in)
  画布の空間内の x 座標｡ An x coordinate in the space of the canvas.

double y (入力in)
  画布の空間内の y 座標｡ A y coordinate in the space of the canvas.

short *drawableXPtr (出力out)
  画布を再表示する為に現在の所使われている描画可能な空間内の x 座標を保存する為の場所への指示子｡ Pointer to a location in which to store an x coordinate in the space of the drawable currently being used to redisplay the canvas.

short *drawableYPtr (出力out)
  画布を再表示する為に現在の所使われている描画可能な空間内の y 座標を保存する為の場所への指示子｡ Pointer to a location in which to store a y coordinate in the space of the drawable currently being used to redisplay the canvas.

GC gc (出力out)
  修正すべき画面文脈｡ Graphics context to modify.

short *screenXPtr (出力out)
  xに対応する画布窓内の画面座標を保存する為の場所を指す｡ Points to a location in which to store the screen coordinate in the canvas window that corresponds to x.

short *screenYPtr (出力out)
  yに対応する画布窓内の画面座標を保存する為の場所を指す｡ Points to a location in which to store the screen coordinate in the canvas window that corresponds to y.

int x1 (入力in)
  再表示に要する領域の左縁｡この画素とこれより右の座標のみが再描画される為に必要である｡ Left edge of the region that needs redisplay. Only pixels at or to the right of this coordinate need to be redisplayed.

int y1 (入力in)
  再表示に要する領域の上縁｡この画素とこれより下の座標のみが再描画される為に必要である｡ Top edge of the region that needs redisplay. Only pixels at or below this coordinate need to be redisplayed.

int x2 (入力in)
  再表示に要する領域の右縁｡この座標より左の画素のみが再描画される為に必要である｡ Right edge of the region that needs redisplay. Only pixels to the left of this coordinate need to be redisplayed.

int y2 (入力in)
  再表示に要する領域の下縁｡この座標より上の画素のみが再描画される為に必要である｡ Bottom edge of the region that needs redisplay. Only pixels above this coordinate need to be redisplayed.

### 説明 DESCRIPTION

これ等の手続函数は画布型管理譜に呼ばれ種々の便利な機能を遂行する｡ These procedures are called by canvas type managers to perform various utility functions.

Tk_CanvasTkwin は特定の画布と結合した Tk_Window を返す｡ Tk_CanvasTkwin returns the Tk_Window associated with a particular canvas.

Tk_CanvasGetCoord は座標の文字指定( 2p や 1.6c の様な)を倍精度画布座標に変換する｡ string が適正な座標記述であると Tk_CanvasGetCoord は対応する画布座標を *doublePtr の位置に保存し TCL_OK を返す｡それ以外の場合､不都合伝言文を解釈実行機能の結果に保存し TCL_ERROR を返す｡ Tk_CanvasGetCoord translates a string specification of a coordinate (such as 2p or 1.6c) into a double-precision canvas coordinate. If string is a valid coordinate description then Tk_CanvasGetCoord stores the corresponding canvas coordinate at *doublePtr and returns TCL_OK. Otherwise it stores an error message in the interpreter result and returns TCL_ERROR.

Tk_CanvasDrawableCoords はものを描く位置を算出する為に再表示する間､型管理譜によって呼ばれる｡画布空間内の x と y 座標が与えられて Tk_CanvasDrawableCoords は再表示の為に現在使われている描画可能物に対応する画素を算出する; それは *drawableXPtr and *drawableYPtr 内の座標を返す｡この手続函数は再表示の間以外は起動されない｡ Tk_CanvasDrawableCoords is called by type managers during redisplay to compute where to draw things. Given x and y coordinates in the space of the canvas, Tk_CanvasDrawableCoords computes the corresponding pixel in the drawable that is currently being used for redisplay; it returns those coordinates in *drawableXPtr and *drawableYPtr. This procedure should not be invoked except during redisplay.

Tk_CanvasSetStippleOrigin も再表示の間に使われる｡それは gc 内に点描の原点を設定して､現在の面外画素地図内に gc により描かれる点描は画布の実際の窓内に原点(0,0)を伴って描かれた点描が整列するようになる｡Tk_CanvasSetStippleOrigin は画布が小さな破片内に再表示される時点描紋様が適切に整列することを保障する為に必要である｡再表示は２重緩衝様式で遂行される､そこで画布の一片は画面外画素地図内に再描画され､次に画面上に逆複写する｡この方法では､画像状況内の点描の原点は､窓に相対的な画面外の画素地図の位置を補償するためにそれぞれの再表示の間に調整を要する｡もし品目が点描により描かれた場合､その型管理譜は典型的には､ gc を使用して何かを描く直前に Tk_CanvasSetStippleOrigin を呼ぶ; 描画が終った後､型管理譜は XSetTSOrigin を呼出し､ gc 内の原点を (0,0) に再保存する(再保存は必要である､理由は画像状況は共有されているので永久には修正できないから)｡ Tk_CanvasSetStippleOrigin is also used during redisplay. It sets the stipple origin in gc so that stipples drawn with gc in the current offscreen pixmap will line up with stipples drawn with origin (0,0) in the canvas's actual window. Tk_CanvasSetStippleOrigin is needed in order to guarantee that stipple patterns line up properly when the canvas is redisplayed in small pieces. Redisplays are carried out in double-buffered fashion where a piece of the canvas is redrawn in an offscreen pixmap and then copied back onto the screen. In this approach the stipple origins in graphics contexts need to be adjusted during each redisplay to compensate for the position of the off-screen pixmap relative to the window. If an item is being drawn with stipples, its type manager typically calls Tk_CanvasSetStippleOrigin just before using gc to draw something; after it is finished drawing, the type manager calls XSetTSOrigin to restore the origin in gc back to (0,0) (the restore is needed because graphics contexts are shared, so they cannot be modified permanently).

Tk_CanvasWindowCoords は Tk_CanvasDrawableCoords に似ているが､違いは､画面外画素地図内の座標を返すのではなく画面上の画布の窓内の座標を返すことである｡ Tk_CanvasWindowCoords is similar to Tk_CanvasDrawableCoords except that it returns coordinates in the canvas's window on the screen, instead of coordinates in an off-screen pixmap.

Tk_CanvasEventuallyRedraw は再描画される必要のある画布の部位を Tk に伝えるために起動される｡ x1 と y1 と x2 と y2 引数は再描画される必要のある領域を画布座標で指定する｡品目が変更されその為に再表示が要求される時は､通常 Tk が解決するので､型管理譜が Tk_CanvasEventuallyRedraw を起動する必要は稀である(それが起るのは､譬えば､何時であれ Tk は configureProc or scaleProc を呼ぶ)｡型管理譜が Tk_CanvasEventuallyRedraw を呼ぶ必要があるのは､もし所有する品目がその Tk_ItemType 内の手続函数の一つを通して起動されることなく変更された時のみである; それが起こりうるのは､譬えば､影像品目内でもし影像が影像命令を使って修正された時である｡ Tk_CanvasEventuallyRedraw may be invoked by a type manager to inform Tk that a portion of a canvas needs to be redrawn. The x1, y1, x2, and y2 arguments specify the region that needs to be redrawn, in canvas coordinates. Type managers rarely need to invoke Tk_CanvasEventuallyRedraw, since Tk can normally figure out when an item has changed and make the redisplay request on its behalf (this happens, for example whenever Tk calls a configureProc or scaleProc). The only time that a type manager needs to call Tk_CanvasEventuallyRedraw is if an item has changed on its own without being invoked through one of the procedures in its Tk_ItemType; this could happen, for example, in an image item if the image is modified using image commands.

Tk_CanvasTagsParseProc and Tk_CanvasTagsPrintProc は画布品目の為に -tags 指示項目を処理する手続函数である｡画布型管理譜の符号命令はこれ等の手続函数を直接には呼ばないが､ -tags 指示項目の為に Tk_CustomOption 構造を作成する為にその番地を使う｡その命令符号は典型的にはこのようになる: Tk_CanvasTagsParseProc and Tk_CanvasTagsPrintProc are procedures that handle the -tags option for canvas items. The code of a canvas type manager will not call these procedures directly, but will use their addresses to create a Tk_CustomOption structure for the -tags option. The code typically looks like this:

    static const Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
        Tk_CanvasTagsPrintProc, NULL
    };

    static const Tk_ConfigSpec configSpecs[] = {
        ...
        {TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
            NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
        ...
    };

### KEYWORDS

canvas, focus, item type, redisplay, selection, type manager
Copyright © 1994-1996 Sun Microsystems, Inc.