Tk

 view release on metacpan or  search on metacpan

pTk/mTk/win/tkWinX.c  view on Meta::CPAN

static TkWinProcs asciiProcs = {
    0,

    (LRESULT (WINAPI *)(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg,
	    WPARAM wParam, LPARAM lParam)) CallWindowProcA,
    (LRESULT (WINAPI *)(HWND hWnd, UINT Msg, WPARAM wParam,
	    LPARAM lParam)) DefWindowProcA,
    (ATOM (WINAPI *)(CONST WNDCLASS *lpWndClass)) RegisterClassA,
    (BOOL (WINAPI *)(HWND hWnd, LPCTSTR lpString)) SetWindowTextA,
    (HWND (WINAPI *)(DWORD dwExStyle, LPCTSTR lpClassName,
	    LPCTSTR lpWindowName, DWORD dwStyle, int x, int y,
	    int nWidth, int nHeight, HWND hWndParent, HMENU hMenu,
	    HINSTANCE hInstance, LPVOID lpParam)) CreateWindowExA,
    (BOOL (WINAPI *)(HMENU hMenu, UINT uPosition, UINT uFlags,
	    UINT uIDNewItem, LPCTSTR lpNewItem)) InsertMenuA,
};

static TkWinProcs unicodeProcs = {
    1,

    (LRESULT (WINAPI *)(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg,
	    WPARAM wParam, LPARAM lParam)) CallWindowProcW,
    (LRESULT (WINAPI *)(HWND hWnd, UINT Msg, WPARAM wParam,
	    LPARAM lParam)) DefWindowProcW,
    (ATOM (WINAPI *)(CONST WNDCLASS *lpWndClass)) RegisterClassW,
    (BOOL (WINAPI *)(HWND hWnd, LPCTSTR lpString)) SetWindowTextW,
    (HWND (WINAPI *)(DWORD dwExStyle, LPCTSTR lpClassName,
	    LPCTSTR lpWindowName, DWORD dwStyle, int x, int y,
	    int nWidth, int nHeight, HWND hWndParent, HMENU hMenu,
	    HINSTANCE hInstance, LPVOID lpParam)) CreateWindowExW,
    (BOOL (WINAPI *)(HMENU hMenu, UINT uPosition, UINT uFlags,
	    UINT uIDNewItem, LPCTSTR lpNewItem)) InsertMenuW,
};

TkWinProcs *tkWinProcs;

/*
 * Declarations of static variables used in this file.
 */

static char winScreenName[] = ":0"; /* Default name of windows display. */
static HINSTANCE tkInstance = NULL; /* Application instance handle. */
static int childClassInitialized;   /* Registered child class? */
static WNDCLASS childClass;         /* Window class for child windows. */
static WNDCLASS ownDCClass;         /* Window class for child windows with private DC. */
static int tkPlatformId = 0;        /* version of Windows platform */
static Tcl_Encoding keyInputEncoding = NULL;/* The current character
				     * encoding for keyboard input */
static int keyInputCharset = -1;    /* The Win32 CHARSET for the keyboard
				     * encoding */
static Tcl_Encoding unicodeEncoding = NULL; /* unicode encoding */

/*
 * Thread local storage.  Notice that now each thread must have its
 * own TkDisplay structure, since this structure contains most of
 * the thread-specific date for threads.
 */
typedef struct ThreadSpecificData {
    TkDisplay *winDisplay;       /* TkDisplay structure that *
				  *  represents Windows screen. */
    int updatingClipboard;      /* If 1, we are updating the clipboard */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

/*
 * Forward declarations of procedures used in this file.
 */

#ifdef __CYGWIN__
static void             DisplayFileProc _ANSI_ARGS_((ClientData clientData,
			    int flags));
#endif
static void             GenerateXEvent _ANSI_ARGS_((HWND hwnd, UINT message,
			    WPARAM wParam, LPARAM lParam));
static unsigned int     GetState _ANSI_ARGS_((UINT message, WPARAM wParam,
			    LPARAM lParam));
static void             GetTranslatedKey _ANSI_ARGS_((XKeyEvent *xkey));
static void             UpdateInputLanguage _ANSI_ARGS_((int charset));
static int              HandleIMEComposition _ANSI_ARGS_((HWND hwnd,
			    LPARAM lParam));

/*
 *----------------------------------------------------------------------
 *
 * TkGetServerInfo --
 *
 *      Given a window, this procedure returns information about
 *      the window server for that window.  This procedure provides
 *      the guts of the "winfo server" command.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      None.
 *
 *----------------------------------------------------------------------
 */

void
TkGetServerInfo(interp, tkwin)
    Tcl_Interp *interp;         /* The server information is returned in
				 * this interpreter's result. */
    Tk_Window tkwin;            /* Token for window;  this selects a
				 * particular display and server. */
{
    char buffer[60];
    OSVERSIONINFO os;

    os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&os);
    sprintf(buffer, "Windows %d.%d %d %s", os.dwMajorVersion,
	    os.dwMinorVersion, os.dwBuildNumber,
#ifdef _WIN64
	    "Win64"
#else
	    "Win32"
#endif
	);
    Tcl_SetResult(interp, buffer, TCL_VOLATILE);
}

pTk/mTk/win/tkWinX.c  view on Meta::CPAN

	    screen->root_visual->map_entries = 256;
	    screen->root_visual->red_mask = 0xff;
	    screen->root_visual->green_mask = 0xff00;
	    screen->root_visual->blue_mask = 0xff0000;
	}
    }
    screen->root_visual->bits_per_rgb = screen->root_depth;
    ReleaseDC(NULL, dc);

    /*
     * Note that these pixel values are not palette relative.
     */

    screen->white_pixel = RGB(255, 255, 255);
    screen->black_pixel = RGB(0, 0, 0);

    display->screens            = screen;
    display->nscreens           = 1;
    display->default_screen     = 0;
    screen->cmap = XCreateColormap(display, None, screen->root_visual,
	    AllocNone);
    tsdPtr->winDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay));
    ZeroMemory(tsdPtr->winDisplay, sizeof(TkDisplay));
    tsdPtr->winDisplay->display = display;
    tsdPtr->updatingClipboard = FALSE;
    return tsdPtr->winDisplay;
}

/*
 *----------------------------------------------------------------------
 *
 * TkpCloseDisplay --
 *
 *      Closes and deallocates a Display structure created with the
 *      TkpOpenDisplay function.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Frees up memory.
 *
 *----------------------------------------------------------------------
 */

void
TkpCloseDisplay(dispPtr)
    TkDisplay *dispPtr;
{
    Display *display = dispPtr->display;
    HWND hwnd;
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    if (dispPtr != tsdPtr->winDisplay) {
	panic("TkpCloseDisplay: tried to call TkpCloseDisplay on another display");
	return;
    }

    /*
     * Force the clipboard to be rendered if we are the clipboard owner.
     */

    if (dispPtr->clipWindow) {
	hwnd = Tk_GetHWND(Tk_WindowId(dispPtr->clipWindow));
	if (GetClipboardOwner() == hwnd) {
	    OpenClipboard(hwnd);
	    EmptyClipboard();
	    TkWinClipboardRender(dispPtr, CF_TEXT);
	    CloseClipboard();
	}
    }

    tsdPtr->winDisplay = NULL;

    if (display->display_name != (char *) NULL) {
	ckfree(display->display_name);
    }
    if (display->screens != (Screen *) NULL) {
	if (display->screens->root_visual != NULL) {
	    ckfree((char *) display->screens->root_visual);
	}
	if (display->screens->root != None) {
	    ckfree((char *) display->screens->root);
	}
	if (display->screens->cmap != None) {
	    XFreeColormap(display, display->screens->cmap);
	}
	ckfree((char *) display->screens);
    }
#ifdef __CYGWIN__
    if (dispPtr->display != 0) {
	Tcl_DeleteFileHandler(ConnectionNumber(dispPtr->display));
	close(ConnectionNumber(dispPtr->display));
    }
#endif
    ckfree((char *) display);
}


#ifdef __CYGWIN__
/*
 *----------------------------------------------------------------------
 *
 * DisplayFileProc --
 *
 *      This procedure implements the file handler for the /dev/windows
 *      connection.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Process Win32 message queue.  Compare to tclWin/tclWinNotify.c
 *      Tcl_WaitForEvent() event loop.
 *
 *----------------------------------------------------------------------
 */

static void
DisplayFileProc(clientData, flags)



( run in 2.350 seconds using v1.01-cache-2.11-cpan-84e82930d8c )