⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkmacscrlbr.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 3 页
字号:
/*  * tkMacScrollbar.c -- * *	This file implements the Macintosh specific portion of the scrollbar *	widget.  The Macintosh scrollbar may also draw a windows grow *	region under certain cases. * * Copyright (c) 1996 by Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tkMacScrlbr.c 1.9 96/12/10 20:04:39 */#include "tkScrollbar.h"#include "tkMacInt.h"#include <Controls.h>/* * The following definitions should really be in MacOS * header files.  They are included here as this is the only * file that needs the declarations. */typedef	pascal void (*ThumbActionFunc)(void);#if GENERATINGCFMtypedef UniversalProcPtr ThumbActionUPP;#elsetypedef ThumbActionFunc ThumbActionUPP;#endifenum {	uppThumbActionProcInfo = kPascalStackBased};#if GENERATINGCFM#define NewThumbActionProc(userRoutine)		\		(ThumbActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppThumbActionProcInfo, GetCurrentArchitecture())#else#define NewThumbActionProc(userRoutine)		\		((ThumbActionUPP) (userRoutine))#endif/* * Minimum slider length, in pixels (designed to make sure that the slider * is always easy to grab with the mouse). */#define MIN_SLIDER_LENGTH	5/* * Declaration of Windows specific scrollbar structure. */typedef struct MacScrollbar {    TkScrollbar info;		/* Generic scrollbar info. */    ControlRef sbHandle;	/* Handle to the Scrollbar control struct. */    int macFlags;		/* Various flags; see below. */} MacScrollbar;/* * Flag bits for scrollbars on the Mac: *  * ALREADY_DEAD:		Non-zero means this scrollbar has been *				destroyed, but has not been cleaned up. * IN_MODAL_LOOP:		Non-zero means this scrollbar is in the middle *				of a modal loop. * ACTIVE:			Non-zero means this window is currently *				active (in the foreground). * FLUSH_TOP:			Flush with top of Mac window. * FLUSH_BOTTOM:		Flush with bottom of Mac window. * FLUSH_RIGHT:			Flush with right of Mac window. * FLUSH_LEFT:			Flush with left of Mac window. * SCROLLBAR_GROW:		Non-zero means this window draws the grow *				region for the toplevel window. * AUTO_ADJUST:			Non-zero means we automatically adjust *				the size of the widget to align correctly *				along a Mac window. * DRAW_GROW:			Non-zero means we draw the grow region. */#define ALREADY_DEAD		1#define IN_MODAL_LOOP		2#define ACTIVE			4#define FLUSH_TOP		8#define FLUSH_BOTTOM		16#define FLUSH_RIGHT		32#define FLUSH_LEFT		64#define SCROLLBAR_GROW		128#define AUTO_ADJUST		256#define DRAW_GROW		512/* * Globals uses locally in this file. */static ControlActionUPP scrollActionProc = NULL; /* Pointer to func. */static ThumbActionUPP thumbActionProc = NULL;    /* Pointer to func. */static TkScrollbar *activeScrollPtr = NULL;        /* Non-null when in thumb */						 /* proc. *//* * Forward declarations for procedures defined later in this file: */static pascal void	ScrollbarActionProc _ANSI_ARGS_((ControlRef theControl,			    ControlPartCode partCode));static int		ScrollbarBindProc _ANSI_ARGS_((ClientData clientData,			    Tcl_Interp *interp, XEvent *eventPtr,			    Tk_Window tkwin, KeySym keySym));static void		ScrollbarEventProc _ANSI_ARGS_((			    ClientData clientData, XEvent *eventPtr));static pascal void	ThumbActionProc _ANSI_ARGS_((void));static void		UpdateControlValues _ANSI_ARGS_((MacScrollbar *macScrollPtr));		    /* * The class procedure table for the scrollbar widget. */TkClassProcs tkpScrollbarProcs = {     NULL,			/* createProc. */    NULL,			/* geometryProc. */    NULL			/* modalProc */};/* *---------------------------------------------------------------------- * * TkpCreateScrollbar -- * *	Allocate a new TkScrollbar structure. * * Results: *	Returns a newly allocated TkScrollbar structure. * * Side effects: *	None. * *---------------------------------------------------------------------- */TkScrollbar *TkpCreateScrollbar(    Tk_Window tkwin)	/* New Tk Window. */{    MacScrollbar * macScrollPtr;    TkWindow *winPtr = (TkWindow *)tkwin;        if (scrollActionProc == NULL) {	scrollActionProc = NewControlActionProc(ScrollbarActionProc);	thumbActionProc = NewThumbActionProc(ThumbActionProc);    }    macScrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar));    macScrollPtr->sbHandle = NULL;    macScrollPtr->macFlags = 0;    Tk_CreateEventHandler(tkwin, ActivateMask|ExposureMask|	    StructureNotifyMask|FocusChangeMask,	    ScrollbarEventProc, (ClientData) macScrollPtr);    if (!Tcl_GetAssocData(winPtr->mainPtr->interp, "TkScrollbar", NULL)) {	Tcl_SetAssocData(winPtr->mainPtr->interp, "TkScrollbar", NULL,		(ClientData)1);	TkCreateBindingProcedure(winPtr->mainPtr->interp,		winPtr->mainPtr->bindingTable,		(ClientData)Tk_GetUid("Scrollbar"), "<ButtonPress>",		ScrollbarBindProc, NULL, NULL);    }    return (TkScrollbar *) macScrollPtr;}/* *-------------------------------------------------------------- * * TkpDisplayScrollbar -- * *	This procedure redraws the contents of a scrollbar window. *	It is invoked as a do-when-idle handler, so it only runs *	when there's nothing else for the application to do. * * Results: *	None. * * Side effects: *	Information appears on the screen. * *-------------------------------------------------------------- */voidTkpDisplayScrollbar(    ClientData clientData)	/* Information about window. */{    register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;    register MacScrollbar *macScrollPtr = (MacScrollbar *) clientData;    register Tk_Window tkwin = scrollPtr->tkwin;        MacDrawable *macDraw;    CGrafPtr saveWorld;    GDHandle saveDevice;    GWorldPtr destPort;    WindowRef windowRef;        if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {	goto done;    }    /*     * Draw the focus or any 3D relief we may have.     */    if (scrollPtr->highlightWidth != 0) {	GC gc;	if (scrollPtr->flags & GOT_FOCUS) {	    gc = Tk_GCForColor(scrollPtr->highlightColorPtr,		    Tk_WindowId(tkwin));	} else {	    gc = Tk_GCForColor(scrollPtr->highlightBgColorPtr,		    Tk_WindowId(tkwin));	}	Tk_DrawFocusHighlight(tkwin, gc, scrollPtr->highlightWidth,		Tk_WindowId(tkwin));    }    Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder,	    scrollPtr->highlightWidth, scrollPtr->highlightWidth,	    Tk_Width(tkwin) - 2*scrollPtr->highlightWidth,	    Tk_Height(tkwin) - 2*scrollPtr->highlightWidth,	    scrollPtr->borderWidth, scrollPtr->relief);    /*     * Set up port for drawing Macintosh control.     */    macDraw = (MacDrawable *) Tk_WindowId(tkwin);    destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin));    GetGWorld(&saveWorld, &saveDevice);    SetGWorld(destPort, NULL);    TkMacSetUpClippingRgn(Tk_WindowId(tkwin));    if (macScrollPtr->sbHandle == NULL) {        Rect r;                r.left = r.top = 0;        r.right = r.bottom = 1;	macScrollPtr->sbHandle = NewControl((WindowRef) destPort, &r, "\p",		false, (short) 500, 0, 1000,		scrollBarProc, (SInt32) scrollPtr);	/*	 * If we are foremost than make us active.	 */	if ((WindowPtr) destPort == FrontWindow()) {	    macScrollPtr->macFlags |= ACTIVE;	}    }    /*     * Update the control values before we draw.     */    windowRef  = (**macScrollPtr->sbHandle).contrlOwner;        UpdateControlValues(macScrollPtr);        if (macScrollPtr->macFlags & ACTIVE) {	Draw1Control(macScrollPtr->sbHandle);	if (macScrollPtr->macFlags & DRAW_GROW) {	    DrawGrowIcon(windowRef);	}    } else {	(**macScrollPtr->sbHandle).contrlHilite = 255;	Draw1Control(macScrollPtr->sbHandle);	if (macScrollPtr->macFlags & DRAW_GROW) {	    DrawGrowIcon(windowRef);	    Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder,		Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13,		Tk_Width(tkwin), Tk_Height(tkwin),		0, TK_RELIEF_FLAT);	}    }        SetGWorld(saveWorld, saveDevice);         done:    scrollPtr->flags &= ~REDRAW_PENDING;}/* *---------------------------------------------------------------------- * * TkpConfigureScrollbar -- * *	This procedure is called after the generic code has finished *	processing configuration options, in order to configure *	platform specific options. * * Results: *	None. * * Side effects: *	None. * *---------------------------------------------------------------------- */voidTkpConfigureScrollbar(scrollPtr)    register TkScrollbar *scrollPtr;	/* Information about widget;  may or					 * may not already have values for					 * some fields. */{}/* *---------------------------------------------------------------------- * * TkpComputeScrollbarGeometry -- * *	After changes in a scrollbar's size or configuration, this *	procedure recomputes various geometry information used in *	displaying the scrollbar. * * Results: *	None. * * Side effects: *	The scrollbar will be displayed differently. * *---------------------------------------------------------------------- */voidTkpComputeScrollbarGeometry(    register TkScrollbar *scrollPtr)	/* Scrollbar whose geometry may					 * have changed. */{    MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr;    int width, fieldLength, adjust = 0;    if (scrollPtr->highlightWidth < 0) {	scrollPtr->highlightWidth = 0;    }    scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth;    width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin)	    : Tk_Height(scrollPtr->tkwin);    scrollPtr->arrowLength = width - 2*scrollPtr->inset + 1;    fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin)	    : Tk_Width(scrollPtr->tkwin))	    - 2*(scrollPtr->arrowLength + scrollPtr->inset);    if (fieldLength < 0) {	fieldLength = 0;    }    scrollPtr->sliderFirst = fieldLength*scrollPtr->firstFraction;    scrollPtr->sliderLast = fieldLength*scrollPtr->lastFraction;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -