Exemplo n.º 1
0
ControlRef
TkMacOSXGetRootControl(
    Drawable drawable)
{
    /*
     * will probably need to fix this up for embedding
     */

    MacDrawable *macWin = (MacDrawable *) drawable;
    TkWindow *contWinPtr;

    if (macWin == NULL) {
	return NULL;
    }

    if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
	return macWin->toplevel->rootControl;
    }

    contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
    if (contWinPtr == NULL) {
	return NULL;
    }

    return TkMacOSXGetRootControl((Drawable) contWinPtr->privatePtr);
}
Exemplo n.º 2
0
static int
TkMacOSXInitControl(
    MacButton *mbPtr,		/* Mac button. */
    GWorldPtr destPort,
    GC gc,
    Pixmap pixmap,
    Rect *paneRect,
    Rect *cntrRect)
{
    TkButton *butPtr = (TkButton *) mbPtr;
    ControlRef rootControl;
    SInt16 procID, initialValue, minValue, maxValue;
    Boolean initiallyVisible;
    SInt32 controlReference;

    rootControl = TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin));
    mbPtr->windowRef = TkMacOSXDrawableWindow(Tk_WindowId(butPtr->tkwin));

    /*
     * Set up the user pane.
     */

    initiallyVisible = false;
    initialValue = kControlSupportsEmbedding|kControlHasSpecialBackground;
    minValue = 0;
    maxValue = 1;
    procID = kControlUserPaneProc;
    controlReference = (SInt32)mbPtr;
    mbPtr->userPane = NewControl(mbPtr->windowRef, paneRect, "\p",
	    initiallyVisible, initialValue, minValue, maxValue, procID,
	    controlReference);

    if (!mbPtr->userPane) {
	TkMacOSXDbgMsg("Failed to create user pane control");
	return 1;
    }
    if (ChkErr(EmbedControl, mbPtr->userPane,rootControl) != noErr) {
	return 1;
    }

    SetUserPaneSetUpSpecialBackgroundProc(mbPtr->userPane,
	    UserPaneBackgroundProc);
    SetUserPaneDrawProc(mbPtr->userPane,UserPaneDraw);
    initiallyVisible = false;
    TkMacOSXComputeControlParams(butPtr,&mbPtr->params);
    mbPtr->control = NewControl(mbPtr->windowRef, cntrRect, "\p",
	    initiallyVisible, mbPtr->params.initialValue,
	    mbPtr->params.minValue, mbPtr->params.maxValue,
	    mbPtr->params.procID, controlReference);

    if (!mbPtr->control) {
	TkMacOSXDbgMsg("Failed to create control of type %d\n", procID);
	return 1;
    }
    if (ChkErr(EmbedControl, mbPtr->control,mbPtr->userPane) != noErr ) {
	return 1;
    }

    mbPtr->flags |= (CONTROL_INITIALIZED | FIRST_DRAW);
    if (IsWindowActive(mbPtr->windowRef)) {
	mbPtr->flags |= ACTIVE;
    }
    return 0;
}