Exemple #1
0
RtMainFrame::RtMainFrame(const TGWindow* p) :
    TGMainFrame(p, 800, 600)
{
    // Create canvas
    TRootEmbeddedCanvas* eCanvas = new TRootEmbeddedCanvas("Embedded canvas",this,800,600);
    m_canvas = eCanvas->GetCanvas();
	AddFrame(eCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
                                        10, 10, 10, 1));

    // ========================================
    // Tooltip
    m_canvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
                       "RtMainFrame", this, "eventHandler(Int_t,Int_t,Int_t,TObject*)");
    m_tip = new TGToolTip( gClient->GetDefaultRoot(), eCanvas, "", 0 );

    // ========================================
    // Buttons
	TGHorizontalFrame *hframe= new TGHorizontalFrame(this, 200,40);
    // Exit button
    hframe->AddFrame( new TGTextButton(hframe, "&Quit", "gApplication->Terminate()")
					, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
    // Save button
    TGTextButton* buttonPDF = new TGTextButton(hframe, "Save &PDF");
    TQObject::Connect(buttonPDF, "Clicked()",
                     "RtMainFrame", this, "savePDF()" );
    hframe->AddFrame( buttonPDF
                    , new TGLayoutHints(kLHintsCenterX,5,5,3,4));
    AddFrame(hframe,new TGLayoutHints(kLHintsCenterX,2,2,2,2));
    
	// Sets window name and shows the main frame
	SetWindowName("RT-Biplot");
	MapSubwindows();
	Resize(GetDefaultSize());
	MapWindow();
}
Exemple #2
0
/*
 * Create the overlay window and map it
 */
Bool
compCreateOverlayWindow (ScreenPtr pScreen)
{
    CompScreenPtr   cs = GetCompScreen(pScreen);
    WindowPtr	    pRoot = pScreen->root;
    WindowPtr	    pWin;
    XID		    attrs[] = { None, TRUE }; /* backPixmap, overrideRedirect */
    int		    result;

    pWin = cs->pOverlayWin = 
	CreateWindow (cs->overlayWid, pRoot,
		      0, 0, pScreen->width, pScreen->height, 0, 
		      InputOutput, CWBackPixmap | CWOverrideRedirect, &attrs[0],
		      pRoot->drawable.depth, 
		      serverClient, pScreen->rootVisual, &result);
    if (pWin == NULL)
	return FALSE;

    if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
	return FALSE;

    MapWindow(pWin, serverClient);

    return TRUE;
}
Exemple #3
0
/*
 * Create the overlay window and map it
 */
Bool
compCreateOverlayWindow(ScreenPtr pScreen)
{
    CompScreenPtr cs = GetCompScreen(pScreen);
    WindowPtr pRoot = pScreen->root;
    WindowPtr pWin;
    XID attrs[] = { None, TRUE };       /* backPixmap, overrideRedirect */
    int result;
    int w = pScreen->width;
    int h = pScreen->height;

#ifdef PANORAMIX
    if (!noPanoramiXExtension) {
        w = PanoramiXPixWidth;
        h = PanoramiXPixHeight;
    }
#endif

    pWin = cs->pOverlayWin =
        CreateWindow(cs->overlayWid, pRoot, 0, 0, w, h, 0,
                     InputOutput, CWBackPixmap | CWOverrideRedirect, &attrs[0],
                     pRoot->drawable.depth,
                     serverClient, pScreen->rootVisual, &result);
    if (pWin == NULL)
        return FALSE;

    if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer) pWin))
        return FALSE;

    MapWindow(pWin, serverClient);

    return TRUE;
}
Exemple #4
0
/*
 * Free one of the per-client per-window resources, clearing
 * redirect and the per-window pointer as appropriate
 */
void
compFreeClientWindow (WindowPtr pWin, XID id)
{
    CompWindowPtr	cw = GetCompWindow (pWin);
    CompClientWindowPtr	ccw, *prev;
    Bool		wasMapped = pWin->mapped;

    if (!cw)
	return;
    for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next)
    {
	if (ccw->id == id)
	{
	    *prev = ccw->next;
	    if (ccw->update == CompositeRedirectManual)
		cw->update = CompositeRedirectAutomatic;
	    free(ccw);
	    break;
	}
    }
    if (!cw->clients)
    {
	if (wasMapped)
	{
	    DisableMapUnmapEvents (pWin);
	    UnmapWindow (pWin, FALSE);
	    EnableMapUnmapEvents (pWin);
	}
    
	if (pWin->redirectDraw != RedirectDrawNone)
	    compFreePixmap (pWin);

	if (cw->damage)
	    DamageDestroy (cw->damage);
	
	RegionUninit(&cw->borderClip);
    
	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
	free(cw);
    }
    else if (cw->update == CompositeRedirectAutomatic &&
	     !cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone)
    {
	DamageRegister (&pWin->drawable, cw->damage);
	cw->damageRegistered = TRUE;
	pWin->redirectDraw = RedirectDrawAutomatic;
	DamageRegionAppend(&pWin->drawable, &pWin->borderSize);
    }
    if (wasMapped && !pWin->mapped)
    {
	Bool	overrideRedirect = pWin->overrideRedirect;
	pWin->overrideRedirect = TRUE;
	DisableMapUnmapEvents (pWin);
	MapWindow (pWin, clients[CLIENT_ID(id)]);
	EnableMapUnmapEvents (pWin);
	pWin->overrideRedirect = overrideRedirect;
    }
}
Exemple #5
0
int
ProcCompositeGetOverlayWindow (ClientPtr client)
{
    REQUEST(xCompositeGetOverlayWindowReq); 
    xCompositeGetOverlayWindowReply rep;
    WindowPtr pWin;
    ScreenPtr pScreen;
    CompScreenPtr cs;
    CompOverlayClientPtr pOc;

    REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
    pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
    if (!pWin)
    {
	client->errorValue = stuff->window;
	return BadWindow;
    }
    pScreen = pWin->drawable.pScreen;

    cs = GetCompScreen(pScreen);
    if (cs->pOverlayWin == NULL) {
	cs->pOverlayWin = createOverlayWindow(pScreen);
	if (cs->pOverlayWin == NULL) {
	    return BadAlloc;
	}
    }
    MapWindow(cs->pOverlayWin, serverClient);

    /* Record that client is using this overlay window */
    pOc = findCompOverlayClient(client, pScreen);
    if (pOc == NULL) {
	int ret = createCompOverlayClient(client, pScreen);
	if (ret != Success) {
	    return ret;
	}
    }

    rep.type = X_Reply;
    rep.sequenceNumber = client->sequence;
    rep.length = 0;
    rep.overlayWin = cs->pOverlayWin->drawable.id;

    if (client->swapped)
    {
	int n;
	swaps(&rep.sequenceNumber, n);
    	swapl(&rep.length, n);
	swapl(&rep.overlayWin, n);
    }
    (void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply, (char *)&rep);

    return client->noClientException;
}
Exemple #6
0
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
   TGMainFrame(p, w, h)
{
   // Create a main frame

   TString name = "myicon";
   ULong_t yellow;
   gClient->GetColorByName("yellow", yellow);

   // Create a picture from the XPM data 
   TGPicturePool *picpool = gClient->GetResourcePool()->GetPicturePool();
   const TGPicture *iconpic = picpool->GetPicture(name.Data(),icon1);
   TGIcon *icon = new TGIcon(this, iconpic, 40, 40, kChildFrame, yellow);
   AddFrame(icon, new TGLayoutHints(kLHintsLeft, 1,15,1,1));
   
   TGTextButton *exit = new TGTextButton(this, "&Exit","gApplication->Terminate(0)");
   AddFrame(exit, new TGLayoutHints(kLHintsExpandX,2,0,2,2));
   
   SetWindowName("Icon test");
   MapSubwindows();
   Resize(GetDefaultSize());
   MapWindow();
}
Exemple #7
0
/* for lack of a better way, a window is created that covers the area and
   when its deleted, it's invalidated */
static int
rdpInvalidateArea(ScreenPtr pScreen, int x, int y, int cx, int cy)
{
    WindowPtr pWin;
    int result;
    int attri;
    XID attributes[4];
    Mask mask;

    DEBUG_OUT(("rdpInvalidateArea:\n"));
    mask = 0;
    attri = 0;
    attributes[attri++] = pScreen->blackPixel;
    mask |= CWBackPixel;
    attributes[attri++] = xTrue;
    mask |= CWOverrideRedirect;

    if (g_wid == 0)
    {
        g_wid = FakeClientID(0);
    }

    pWin = CreateWindow(g_wid, pScreen->root,
                        x, y, cx, cy, 0, InputOutput, mask,
                        attributes, 0, serverClient,
                        wVisual(pScreen->root), &result);

    if (result == 0)
    {
        g_invalidate_window = pWin;
        MapWindow(pWin, serverClient);
        DeleteWindow(pWin, None);
        g_invalidate_window = pWin;
    }

    return 0;
}
Exemple #8
0
/*
 * Redirect one window for one client
 */
int
compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
{
    CompWindowPtr	cw = GetCompWindow (pWin);
    CompClientWindowPtr	ccw;
    Bool		wasMapped = pWin->mapped;
    CompScreenPtr       cs = GetCompScreen(pWin->drawable.pScreen);
    
    if (pWin == cs->pOverlayWin) {
	return Success;
    }

    if (!pWin->parent)
	return BadMatch;

    /*
     * Only one Manual update is allowed
     */
    if (cw && update == CompositeRedirectManual)
	for (ccw = cw->clients; ccw; ccw = ccw->next)
	    if (ccw->update == CompositeRedirectManual)
		return BadAccess;
    
    /*
     * Allocate per-client per-window structure 
     * The client *could* allocate multiple, but while supported,
     * it is not expected to be common
     */
    ccw = malloc(sizeof (CompClientWindowRec));
    if (!ccw)
	return BadAlloc;
    ccw->id = FakeClientID (pClient->index);
    ccw->update = update;
    /*
     * Now make sure there's a per-window structure to hang this from
     */
    if (!cw)
    {
	cw = malloc(sizeof (CompWindowRec));
	if (!cw)
	{
	    free(ccw);
	    return BadAlloc;
	}
	cw->damage = DamageCreate (compReportDamage,
				   compDestroyDamage,
				   DamageReportNonEmpty,
				   FALSE,
				   pWin->drawable.pScreen,
				   pWin);
	if (!cw->damage)
	{
	    free(ccw);
	    free(cw);
	    return BadAlloc;
	}
	if (wasMapped)
	{
	    DisableMapUnmapEvents (pWin);
	    UnmapWindow (pWin, FALSE);
	    EnableMapUnmapEvents (pWin);
	}

	RegionNull(&cw->borderClip);
	cw->borderClipX = 0;
	cw->borderClipY = 0;
	cw->update = CompositeRedirectAutomatic;
	cw->clients = 0;
	cw->oldx = COMP_ORIGIN_INVALID;
	cw->oldy = COMP_ORIGIN_INVALID;
	cw->damageRegistered = FALSE;
	cw->damaged = FALSE;
	cw->pOldPixmap = NullPixmap;
	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
    }
    ccw->next = cw->clients;
    cw->clients = ccw;
    if (!AddResource (ccw->id, CompositeClientWindowType, pWin))
	return BadAlloc;
    if (ccw->update == CompositeRedirectManual)
    {
	/* If the window was CompositeRedirectAutomatic, then
	 * unmap the window so that the parent clip list will
	 * be correctly recomputed.
	 */
	if (pWin->mapped) 
	{
	    DisableMapUnmapEvents (pWin);
	    UnmapWindow (pWin, FALSE);
	    EnableMapUnmapEvents (pWin);
	}
	if (cw->damageRegistered)
	{
	    DamageUnregister (&pWin->drawable, cw->damage);
	    cw->damageRegistered = FALSE;
	}
	cw->update = CompositeRedirectManual;
    }

    if (!compCheckRedirect (pWin))
    {
	FreeResource (ccw->id, RT_NONE);
	return BadAlloc;
    }
    if (wasMapped && !pWin->mapped)
    {
	Bool	overrideRedirect = pWin->overrideRedirect;
	pWin->overrideRedirect = TRUE;
	DisableMapUnmapEvents (pWin);
	MapWindow (pWin, pClient);
	EnableMapUnmapEvents (pWin);
	pWin->overrideRedirect = overrideRedirect;
    }
    
    return Success;
}
LRESULT CALLBACK
winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    WindowPtr pWin = NULL;
    win32RootlessWindowPtr pRLWinPriv = NULL;
    ScreenPtr pScreen = NULL;
    winPrivScreenPtr pScreenPriv = NULL;
    winScreenInfo *pScreenInfo = NULL;
    HWND hwndScreen = NULL;
    POINT ptMouse;
    static Bool s_fTracking = FALSE;
    HDC hdcUpdate;
    PAINTSTRUCT ps;
    LPWINDOWPOS pWinPos = NULL;
    RECT rcClient;
    winWMMessageRec wmMsg;
    Bool fWMMsgInitialized = FALSE;

    /* Check if the Windows window property for our X window pointer is valid */
    if ((pRLWinPriv =
         (win32RootlessWindowPtr) GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
        pWin = pRLWinPriv->pFrame->win;
        pScreen = pWin->drawable.pScreen;
        if (pScreen)
            pScreenPriv = winGetScreenPriv(pScreen);
        if (pScreenPriv)
            pScreenInfo = pScreenPriv->pScreenInfo;
        if (pScreenPriv)
            hwndScreen = pScreenPriv->hwndScreen;

        wmMsg.msg = 0;
        wmMsg.hwndWindow = hwnd;
        wmMsg.iWindow = (Window) pWin->drawable.id;

        wmMsg.iX = pRLWinPriv->pFrame->x;
        wmMsg.iY = pRLWinPriv->pFrame->y;
        wmMsg.iWidth = pRLWinPriv->pFrame->width;
        wmMsg.iHeight = pRLWinPriv->pFrame->height;

        fWMMsgInitialized = TRUE;
#if CYGDEBUG
        winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam,
                             lParam);

        winDebug("\thWnd %08X\n", hwnd);
        winDebug("\tpScreenPriv %08X\n", pScreenPriv);
        winDebug("\tpScreenInfo %08X\n", pScreenInfo);
        winDebug("\thwndScreen %08X\n", hwndScreen);
        winDebug("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
                 pRLWinPriv, message, wParam, lParam);
#endif
    }
    /* Branch on message type */
    switch (message) {
    case WM_CREATE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_CREATE\n");
#endif
        /* */
        SetProp(hwnd,
                WIN_WINDOW_PROP,
                (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams);
        return 0;

    case WM_CLOSE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
#endif
        /* Tell window-manager to close window */
        if (pRLWinPriv->fClose) {
            DestroyWindow(hwnd);
        }
        else {
            if (winIsInternalWMRunning(pScreenInfo)) {
                /* Tell our Window Manager thread to kill the window */
                wmMsg.msg = WM_WM_KILL;
                if (fWMMsgInitialized)
                    winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
            }
            winWindowsWMSendEvent(WindowsWMControllerNotify,
                                  WindowsWMControllerNotifyMask,
                                  1,
                                  WindowsWMCloseWindow,
                                  pWin->drawable.id, 0, 0, 0, 0);
        }
        return 0;

    case WM_DESTROY:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_DESTROY\n");
#endif
        /* Free the shaodw DC; which allows the bitmap to be freed */
        DeleteDC(pRLWinPriv->hdcShadow);
        pRLWinPriv->hdcShadow = NULL;

        /* Free the shadow bitmap */
        DeleteObject(pRLWinPriv->hbmpShadow);
        pRLWinPriv->hbmpShadow = NULL;

        /* Free the screen DC */
        ReleaseDC(pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
        pRLWinPriv->hdcScreen = NULL;

        /* Free shadow buffer info header */
        free(pRLWinPriv->pbmihShadow);
        pRLWinPriv->pbmihShadow = NULL;

        pRLWinPriv->fResized = FALSE;
        pRLWinPriv->pfb = NULL;
        free(pRLWinPriv);
        RemoveProp(hwnd, WIN_WINDOW_PROP);
        break;

    case WM_MOUSEMOVE:
#if CYGMULTIWINDOW_DEBUG && 0
        winDebug("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
#endif
        /* Unpack the client area mouse coordinates */
        ptMouse.x = GET_X_LPARAM(lParam);
        ptMouse.y = GET_Y_LPARAM(lParam);

        /* Translate the client area mouse coordinates to screen coordinates */
        ClientToScreen(hwnd, &ptMouse);

        /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
        ptMouse.x -= GetSystemMetrics(SM_XVIRTUALSCREEN);
        ptMouse.y -= GetSystemMetrics(SM_YVIRTUALSCREEN);

        /* We can't do anything without privates */
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;

        /* Has the mouse pointer crossed screens? */
        if (pScreen != miPointerGetScreen(inputInfo.pointer))
             miPointerSetScreen(inputInfo.pointer, pScreenInfo->dwScreen,
                                ptMouse.x - pScreenInfo->dwXOffset,
                                ptMouse.y - pScreenInfo->dwYOffset);

        /* Are we tracking yet? */
        if (!s_fTracking) {
            TRACKMOUSEEVENT tme;

            /* Setup data structure */
            ZeroMemory(&tme, sizeof(tme));
            tme.cbSize = sizeof(tme);
            tme.dwFlags = TME_LEAVE;
            tme.hwndTrack = hwnd;

            /* Call the tracking function */
            if (!TrackMouseEvent(&tme))
                ErrorF("winMWExtWMWindowProc - TrackMouseEvent failed\n");

            /* Flag that we are tracking now */
            s_fTracking = TRUE;
        }

        /* Kill the timer used to poll mouse events */
        if (g_uipMousePollingTimerID != 0) {
            KillTimer(pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
            g_uipMousePollingTimerID = 0;
        }

        /* Deliver absolute cursor position to X Server */
        winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
                         ptMouse.y - pScreenInfo->dwYOffset);

        return 0;

    case WM_NCMOUSEMOVE:
#if CYGMULTIWINDOW_DEBUG && 0
        winDebug("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
#endif
        /*
         * We break instead of returning 0 since we need to call
         * DefWindowProc to get the mouse cursor changes
         * and min/max/close button highlighting in Windows XP.
         * The Platform SDK says that you should return 0 if you
         * process this message, but it fails to mention that you
         * will give up any default functionality if you do return 0.
         */

        /* We can't do anything without privates */
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;

        /*
         * Timer to poll mouse events.  This is needed to make
         * programs like xeyes follow the mouse properly.
         */
        if (g_uipMousePollingTimerID == 0)
            g_uipMousePollingTimerID = SetTimer(pScreenPriv->hwndScreen,
                                                WIN_POLLING_MOUSE_TIMER_ID,
                                                MOUSE_POLLING_INTERVAL, NULL);
        break;

    case WM_MOUSELEAVE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
#endif
        /* Mouse has left our client area */

        /* Flag that we are no longer tracking */
        s_fTracking = FALSE;

        /*
         * Timer to poll mouse events.  This is needed to make
         * programs like xeyes follow the mouse properly.
         */
        if (g_uipMousePollingTimerID == 0)
            g_uipMousePollingTimerID = SetTimer(pScreenPriv->hwndScreen,
                                                WIN_POLLING_MOUSE_TIMER_ID,
                                                MOUSE_POLLING_INTERVAL, NULL);
        return 0;

    case WM_LBUTTONDBLCLK:
    case WM_LBUTTONDOWN:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
#endif
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        SetCapture(hwnd);
        return winMouseButtonsHandle(pScreen, ButtonPress, Button1, wParam);

    case WM_LBUTTONUP:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_LBUTTONUP\n");
#endif
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        ReleaseCapture();
        return winMouseButtonsHandle(pScreen, ButtonRelease, Button1, wParam);

    case WM_MBUTTONDBLCLK:
    case WM_MBUTTONDOWN:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
#endif
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        SetCapture(hwnd);
        return winMouseButtonsHandle(pScreen, ButtonPress, Button2, wParam);

    case WM_MBUTTONUP:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_MBUTTONUP\n");
#endif
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        ReleaseCapture();
        return winMouseButtonsHandle(pScreen, ButtonRelease, Button2, wParam);

    case WM_RBUTTONDBLCLK:
    case WM_RBUTTONDOWN:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
#endif
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        SetCapture(hwnd);
        return winMouseButtonsHandle(pScreen, ButtonPress, Button3, wParam);

    case WM_RBUTTONUP:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_RBUTTONUP\n");
#endif
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        ReleaseCapture();
        return winMouseButtonsHandle(pScreen, ButtonRelease, Button3, wParam);

    case WM_XBUTTONDBLCLK:
    case WM_XBUTTONDOWN:
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        SetCapture(hwnd);
        return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 5,
                                     wParam);
    case WM_XBUTTONUP:
        if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
            break;
        ReleaseCapture();
        return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 5,
                                     wParam);

    case WM_MOUSEWHEEL:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
#endif

        /* Pass the message to the root window */
        SendMessage(hwndScreen, message, wParam, lParam);
        return 0;

    case WM_MOUSEACTIVATE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
#endif
#if 1
        /* Check if this window needs to be made active when clicked */
        if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect) {
#if CYGMULTIWINDOW_DEBUG
            winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
                     "MA_NOACTIVATE\n");
#endif

            /* */
            return MA_NOACTIVATE;
        }
#endif
        if (!winIsInternalWMRunning(pScreenInfo) && !IsMouseActive(pWin))
            return MA_NOACTIVATE;

        break;

    case WM_KILLFOCUS:
        /* Pop any pressed keys since we are losing keyboard focus */
        winKeybdReleaseKeys();
        return 0;

    case WM_SYSDEADCHAR:
    case WM_DEADCHAR:
        /*
         * NOTE: We do nothing with WM_*CHAR messages,
         * nor does the root window, so we can just toss these messages.
         */
        return 0;

    case WM_SYSKEYDOWN:
    case WM_KEYDOWN:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_*KEYDOWN\n");
#endif

        /*
         * Don't pass Alt-F4 key combo to root window,
         * let Windows translate to WM_CLOSE and close this top-level window.
         *
         * NOTE: We purposely don't check the fUseWinKillKey setting because
         * it should only apply to the key handling for the root window,
         * not for top-level window-manager windows.
         *
         * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
         * because that is a key combo that no X app should be expecting to
         * receive, since it has historically been used to shutdown the X server.
         * Passing Ctrl-Alt-Backspace to the root window preserves that
         * behavior, assuming that -unixkill has been passed as a parameter.
         */
        if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000))
            break;

        /* Pass the message to the root window */
        SendMessage(hwndScreen, message, wParam, lParam);
        return 0;

    case WM_SYSKEYUP:
    case WM_KEYUP:

#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_*KEYUP\n");
#endif

        /* Pass the message to the root window */
        SendMessage(hwndScreen, message, wParam, lParam);
        return 0;

    case WM_HOTKEY:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_HOTKEY\n");
#endif

        /* Pass the message to the root window */
        SendMessage(hwndScreen, message, wParam, lParam);
        return 0;

    case WM_ERASEBKGND:
#if CYGDEBUG
        winDebug("winMWExtWMWindowProc - WM_ERASEBKGND\n");
#endif
        /*
         * Pretend that we did erase the background but we don't care,
         * since we repaint the entire region anyhow
         * This avoids some flickering when resizing.
         */
        return TRUE;

    case WM_PAINT:

        /* BeginPaint gives us an hdc that clips to the invalidated region */
        hdcUpdate = BeginPaint(hwnd, &ps);

        /* Try to copy from the shadow buffer */
        if (!BitBlt(hdcUpdate,
                    ps.rcPaint.left, ps.rcPaint.top,
                    ps.rcPaint.right - ps.rcPaint.left,
                    ps.rcPaint.bottom - ps.rcPaint.top,
                    pRLWinPriv->hdcShadow,
                    ps.rcPaint.left, ps.rcPaint.top, SRCCOPY)) {
            LPVOID lpMsgBuf;

            /* Display a fancy error message */
            FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                          FORMAT_MESSAGE_FROM_SYSTEM |
                          FORMAT_MESSAGE_IGNORE_INSERTS,
                          NULL,
                          GetLastError(),
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                          (LPTSTR) &lpMsgBuf, 0, NULL);

            ErrorF("winMWExtWMWindowProc - BitBlt failed: %s\n",
                   (LPSTR) lpMsgBuf);
            LocalFree(lpMsgBuf);
        }

        /* EndPaint frees the DC */
        EndPaint(hwnd, &ps);
        break;

    case WM_ACTIVATE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_ACTIVATE\n");
#endif
        if (LOWORD(wParam) != WA_INACTIVE) {
            if (winIsInternalWMRunning(pScreenInfo)) {
#if 0
                /* Raise the window to the top in Z order */
                wmMsg.msg = WM_WM_RAISE;
                if (fWMMsgInitialized)
                    winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
#endif
                /* Tell our Window Manager thread to activate the window */
                wmMsg.msg = WM_WM_ACTIVATE;
                if (fWMMsgInitialized)
                    if (!pWin || !pWin->overrideRedirect)       /* for OOo menus */
                        winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
            }
            winWindowsWMSendEvent(WindowsWMControllerNotify,
                                  WindowsWMControllerNotifyMask,
                                  1,
                                  WindowsWMActivateWindow,
                                  pWin->drawable.id, 0, 0, 0, 0);
        }
        return 0;

#if 1
    case WM_WINDOWPOSCHANGING:
        pWinPos = (LPWINDOWPOS) lParam;
        if (!(pWinPos->flags & SWP_NOZORDER)) {
            if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking) {
#if CYGMULTIWINDOW_DEBUG
                winDebug("Win %08x is now restacking.\n",
                         (unsigned int) pRLWinPriv);
#endif
                break;
            }

            if (winIsInternalWMRunning(pScreenInfo) || IsRaiseOnClick(pWin)) {
#if CYGMULTIWINDOW_DEBUG
                winDebug("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n",
                         (unsigned int) pRLWinPriv);
#endif
                break;
            }

#if CYGMULTIWINDOW_DEBUG
            winDebug("Win %08x forbid to change z order (%08x).\n",
                     (unsigned int) pRLWinPriv,
                     (unsigned int) pWinPos->hwndInsertAfter);
#endif
            pWinPos->flags |= SWP_NOZORDER;
        }
        break;
#endif

    case WM_MOVE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
                 (unsigned int) GetTickCount());
#endif
        if (g_fNoConfigureWindow)
            break;
#if 0
        /* Bail if Windows window is not actually moving */
        if (pRLWinPriv->dwX == (short) LOWORD(lParam)
            && pRLWinPriv->dwY == (short) HIWORD(lParam))
            break;

        /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
        {
            WINDOWPLACEMENT windPlace;

            windPlace.length = sizeof(WINDOWPLACEMENT);

            /* Get current window placement */
            GetWindowPlacement(hwnd, &windPlace);

            /* Bail if maximizing */
            if (windPlace.showCmd == SW_MAXIMIZE
                || windPlace.showCmd == SW_SHOWMAXIMIZED)
                break;
        }
#endif

#if CYGMULTIWINDOW_DEBUG
        winDebug("\t(%d, %d)\n", (short) LOWORD(lParam),
                 (short) HIWORD(lParam));
#endif
        if (!pRLWinPriv->fMovingOrSizing) {
            if (winIsInternalWMRunning(pScreenInfo))
                winAdjustXWindow(pWin, hwnd);

            winMWExtWMMoveXWindow(pWin, (LOWORD(lParam) - wBorderWidth(pWin)
                                         - GetSystemMetrics(SM_XVIRTUALSCREEN)),
                                  (HIWORD(lParam) - wBorderWidth(pWin)
                                   - GetSystemMetrics(SM_YVIRTUALSCREEN)));
        }
        return 0;

    case WM_SHOWWINDOW:
#if CYGMULTIWINDOW_DEBUG || TRUE
        winDebug("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
                 (unsigned int) GetTickCount());
#endif
        /* Bail out if the window is being hidden */
        if (!wParam)
            return 0;

        if (!pScreenInfo->fInternalWM)  //XXXX
            return 0;

        winMWExtWMUpdateWindowDecoration(pRLWinPriv, pScreenInfo);

        if (winIsInternalWMRunning(pScreenInfo)) {
#if CYGMULTIWINDOW_DEBUG || TRUE
            winDebug("\tMapWindow\n");
#endif
            /* Tell X to map the window */
            MapWindow(pWin, wClient(pWin));

            if (!pRLWinPriv->pFrame->win->overrideRedirect)
                /* Bring the Windows window to the foreground */
                SetForegroundWindow(hwnd);

            /* Setup the Window Manager message */
            wmMsg.msg = WM_WM_MAP;
            wmMsg.iWidth = pRLWinPriv->pFrame->width;
            wmMsg.iHeight = pRLWinPriv->pFrame->height;

            /* Tell our Window Manager thread to map the window */
            if (fWMMsgInitialized)
                winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
        }
        break;

    case WM_SIZING:
        /* Need to legalize the size according to WM_NORMAL_HINTS */
        /* for applications like xterm */
        return ValidateSizing(hwnd, pWin, wParam, lParam);

    case WM_WINDOWPOSCHANGED:
    {
        pWinPos = (LPWINDOWPOS) lParam;
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
        winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
                 (pWinPos->flags & SWP_DRAWFRAME) ? "SWP_DRAWFRAME " : "",
                 (pWinPos->flags & SWP_FRAMECHANGED) ? "SWP_FRAMECHANGED " : "",
                 (pWinPos->flags & SWP_HIDEWINDOW) ? "SWP_HIDEWINDOW " : "",
                 (pWinPos->flags & SWP_NOACTIVATE) ? "SWP_NOACTIVATE " : "",
                 (pWinPos->flags & SWP_NOCOPYBITS) ? "SWP_NOCOPYBITS " : "",
                 (pWinPos->flags & SWP_NOMOVE) ? "SWP_NOMOVE " : "",
                 (pWinPos->
                  flags & SWP_NOOWNERZORDER) ? "SWP_NOOWNERZORDER " : "",
                 (pWinPos->flags & SWP_NOSIZE) ? "SWP_NOSIZE " : "",
                 (pWinPos->flags & SWP_NOREDRAW) ? "SWP_NOREDRAW " : "",
                 (pWinPos->
                  flags & SWP_NOSENDCHANGING) ? "SWP_NOSENDCHANGING " : "",
                 (pWinPos->flags & SWP_NOZORDER) ? "SWP_NOZORDER " : "",
                 (pWinPos->flags & SWP_SHOWWINDOW) ? "SWP_SHOWWINDOW " : "");
        winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow ? "Yes" : "No"));
        winDebug("\textend: (%d, %d, %d, %d)\n",
                 pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);

#endif
        if (pWinPos->flags & SWP_HIDEWINDOW)
            break;

        /* Reorder if window z order was changed */
        if ((pScreenPriv != NULL)
            && !(pWinPos->flags & SWP_NOZORDER)
            && !(pWinPos->flags & SWP_SHOWWINDOW)
            && winIsInternalWMRunning(pScreenInfo)) {
#if CYGMULTIWINDOW_DEBUG
            winDebug("\twindow z order was changed\n");
#endif
            if (pWinPos->hwndInsertAfter == HWND_TOP
                || pWinPos->hwndInsertAfter == HWND_TOPMOST
                || pWinPos->hwndInsertAfter == HWND_NOTOPMOST) {
#if CYGMULTIWINDOW_DEBUG
                winDebug("\traise to top\n");
#endif
                /* Raise the window to the top in Z order */
                wmMsg.msg = WM_WM_RAISE;
                if (fWMMsgInitialized)
                    winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
            }
#if 1
            else if (pWinPos->hwndInsertAfter == HWND_BOTTOM) {
            }
            else {
                /* Check if this window is top of X windows. */
                HWND hWndAbove = NULL;
                DWORD dwCurrentProcessID = GetCurrentProcessId();
                DWORD dwWindowProcessID = 0;

                for (hWndAbove = pWinPos->hwndInsertAfter;
                     hWndAbove != NULL;
                     hWndAbove = GetNextWindow(hWndAbove, GW_HWNDPREV)) {
                    /* Ignore other XWin process's window */
                    GetWindowThreadProcessId(hWndAbove, &dwWindowProcessID);

                    if ((dwWindowProcessID == dwCurrentProcessID)
                        && GetProp(hWndAbove, WIN_WINDOW_PROP)
                        && !IsWindowVisible(hWndAbove)
                        && !IsIconic(hWndAbove))        /* ignore minimized windows */
                        break;
                }
                /* If this is top of X windows in Windows stack,
                   raise it in X stack. */
                if (hWndAbove == NULL) {
#if CYGMULTIWINDOW_DEBUG
                    winDebug("\traise to top\n");
#endif
                    /* Raise the window to the top in Z order */
                    wmMsg.msg = WM_WM_RAISE;
                    if (fWMMsgInitialized)
                        winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
                }
            }
#endif
        }

        if (!(pWinPos->flags & SWP_NOSIZE)) {
            if (IsIconic(hwnd)) {
#if CYGMULTIWINDOW_DEBUG
                winDebug("\tIconic -> MINIMIZED\n");
#endif
                if (winIsInternalWMRunning(pScreenInfo)) {
                    /* Raise the window to the top in Z order */
                    wmMsg.msg = WM_WM_LOWER;
                    if (fWMMsgInitialized)
                        winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
                }
                winWindowsWMSendEvent(WindowsWMControllerNotify,
                                      WindowsWMControllerNotifyMask,
                                      1,
                                      WindowsWMMinimizeWindow,
                                      pWin->drawable.id, 0, 0, 0, 0);
            }
            else if (IsZoomed(hwnd)) {
#if CYGMULTIWINDOW_DEBUG
                winDebug("\tZoomed -> MAXIMIZED\n");
#endif
                winWindowsWMSendEvent(WindowsWMControllerNotify,
                                      WindowsWMControllerNotifyMask,
                                      1,
                                      WindowsWMMaximizeWindow,
                                      pWin->drawable.id, 0, 0, 0, 0);
            }
            else {
#if CYGMULTIWINDOW_DEBUG
                winDebug("\tnone -> RESTORED\n");
#endif
                winWindowsWMSendEvent(WindowsWMControllerNotify,
                                      WindowsWMControllerNotifyMask,
                                      1,
                                      WindowsWMRestoreWindow,
                                      pWin->drawable.id, 0, 0, 0, 0);
            }
        }
        if (!g_fNoConfigureWindow) {

            if (!pRLWinPriv->fMovingOrSizing
                /*&& (pWinPos->flags & SWP_SHOWWINDOW) */ ) {
                GetClientRect(hwnd, &rcClient);
                MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT) &rcClient, 2);

                if (!(pWinPos->flags & SWP_NOMOVE)
                    && !(pWinPos->flags & SWP_NOSIZE)) {
#if CYGMULTIWINDOW_DEBUG
                    winDebug("\tmove & resize\n");
#endif
                    if (winIsInternalWMRunning(pScreenInfo))
                        winAdjustXWindow(pWin, hwnd);

                    winMWExtWMMoveResizeXWindow(pWin,
                                                rcClient.left -
                                                wBorderWidth(pWin)
                                                -
                                                GetSystemMetrics
                                                (SM_XVIRTUALSCREEN),
                                                rcClient.top -
                                                wBorderWidth(pWin)
                                                -
                                                GetSystemMetrics
                                                (SM_YVIRTUALSCREEN),
                                                rcClient.right - rcClient.left -
                                                wBorderWidth(pWin) * 2,
                                                rcClient.bottom - rcClient.top -
                                                wBorderWidth(pWin) * 2);
                }
                else if (!(pWinPos->flags & SWP_NOMOVE)) {
#if CYGMULTIWINDOW_DEBUG
                    winDebug("\tmove\n");
#endif
                    if (winIsInternalWMRunning(pScreenInfo))
                        winAdjustXWindow(pWin, hwnd);

                    winMWExtWMMoveResizeXWindow(pWin,
                                                rcClient.left -
                                                wBorderWidth(pWin)
                                                -
                                                GetSystemMetrics
                                                (SM_XVIRTUALSCREEN),
                                                rcClient.top -
                                                wBorderWidth(pWin)
                                                -
                                                GetSystemMetrics
                                                (SM_YVIRTUALSCREEN),
                                                rcClient.right - rcClient.left -
                                                wBorderWidth(pWin) * 2,
                                                rcClient.bottom - rcClient.top -
                                                wBorderWidth(pWin) * 2);
                }
                else if (!(pWinPos->flags & SWP_NOMOVE)) {
#if CYGMULTIWINDOW_DEBUG
                    winDebug("\tmove\n");
#endif
                    if (winIsInternalWMRunning(pScreenInfo))
                        winAdjustXWindow(pWin, hwnd);

                    winMWExtWMMoveXWindow(pWin,
                                          rcClient.left - wBorderWidth(pWin)
                                          - GetSystemMetrics(SM_XVIRTUALSCREEN),
                                          rcClient.top - wBorderWidth(pWin)
                                          -
                                          GetSystemMetrics(SM_YVIRTUALSCREEN));
                }
                else if (!(pWinPos->flags & SWP_NOSIZE)) {
#if CYGMULTIWINDOW_DEBUG
                    winDebug("\tresize\n");
#endif
                    if (winIsInternalWMRunning(pScreenInfo))
                        winAdjustXWindow(pWin, hwnd);

                    winMWExtWMResizeXWindow(pWin,
                                            rcClient.right - rcClient.left
                                            - wBorderWidth(pWin) * 2,
                                            rcClient.bottom - rcClient.top
                                            - wBorderWidth(pWin) * 2);
                }
            }
        }
    }
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
#endif
        return 0;

    case WM_SIZE:
        /* see dix/window.c */
        /* FIXME: Maximize/Restore? */
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
                 (unsigned int) GetTickCount());
#endif
#if CYGMULTIWINDOW_DEBUG
        winDebug("\t(%d, %d) %d\n", (short) LOWORD(lParam),
                 (short) HIWORD(lParam), g_fNoConfigureWindow);
#endif
        if (g_fNoConfigureWindow)
            break;

        /* Branch on type of resizing occurring */
        switch (wParam) {
        case SIZE_MINIMIZED:
#if CYGMULTIWINDOW_DEBUG
            winDebug("\tSIZE_MINIMIZED\n");
#endif
            if (winIsInternalWMRunning(pScreenInfo)) {
                /* Raise the window to the top in Z order */
                wmMsg.msg = WM_WM_LOWER;
                if (fWMMsgInitialized)
                    winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
            }
            winWindowsWMSendEvent(WindowsWMControllerNotify,
                                  WindowsWMControllerNotifyMask,
                                  1,
                                  WindowsWMMinimizeWindow,
                                  pWin->drawable.id,
                                  0, 0, LOWORD(lParam), HIWORD(lParam));
            break;

        case SIZE_RESTORED:
#if CYGMULTIWINDOW_DEBUG
            winDebug("\tSIZE_RESTORED\n");
#endif
            winWindowsWMSendEvent(WindowsWMControllerNotify,
                                  WindowsWMControllerNotifyMask,
                                  1,
                                  WindowsWMRestoreWindow,
                                  pWin->drawable.id,
                                  0, 0, LOWORD(lParam), HIWORD(lParam));
            break;

        case SIZE_MAXIMIZED:
#if CYGMULTIWINDOW_DEBUG
            winDebug("\tSIZE_MAXIMIZED\n");
#endif
            winWindowsWMSendEvent(WindowsWMControllerNotify,
                                  WindowsWMControllerNotifyMask,
                                  1,
                                  WindowsWMMaximizeWindow,
                                  pWin->drawable.id,
                                  0, 0, LOWORD(lParam), HIWORD(lParam));
            break;
        }

        /* Perform the resize and notify the X client */
        if (!pRLWinPriv->fMovingOrSizing) {
            if (winIsInternalWMRunning(pScreenInfo))
                winAdjustXWindow(pWin, hwnd);

            winMWExtWMResizeXWindow(pWin, (short) LOWORD(lParam)
                                    - wBorderWidth(pWin) * 2,
                                    (short) HIWORD(lParam)
                                    - wBorderWidth(pWin) * 2);
        }
        break;

    case WM_ACTIVATEAPP:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
                 (unsigned int) GetTickCount());
#endif
        if (wParam) {
            if (winIsInternalWMRunning(pScreenInfo)) {
            }
            else {
            }
            winWindowsWMSendEvent(WindowsWMActivationNotify,
                                  WindowsWMActivationNotifyMask,
                                  1,
                                  WindowsWMIsActive,
                                  pWin->drawable.id, 0, 0, 0, 0);
        }
        else {
            winWindowsWMSendEvent(WindowsWMActivationNotify,
                                  WindowsWMActivationNotifyMask,
                                  1,
                                  WindowsWMIsInactive,
                                  pWin->drawable.id, 0, 0, 0, 0);
        }
        break;

    case WM_SETCURSOR:
        if (LOWORD(lParam) == HTCLIENT) {
            if (!g_fSoftwareCursor)
                SetCursor(pScreenPriv->cursor.handle);
            return TRUE;
        }
        break;

    case WM_ENTERSIZEMOVE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
                 (unsigned int) GetTickCount());
#endif
        pRLWinPriv->fMovingOrSizing = TRUE;
        break;

    case WM_EXITSIZEMOVE:
#if CYGMULTIWINDOW_DEBUG
        winDebug("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
                 (unsigned int) GetTickCount());
#endif
        pRLWinPriv->fMovingOrSizing = FALSE;

        GetClientRect(hwnd, &rcClient);

        MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT) &rcClient, 2);

        if (winIsInternalWMRunning(pScreenInfo))
            winAdjustXWindow(pWin, hwnd);

        winMWExtWMMoveResizeXWindow(pWin, rcClient.left - wBorderWidth(pWin)
                                    - GetSystemMetrics(SM_XVIRTUALSCREEN),
                                    rcClient.top - wBorderWidth(pWin)
                                    - GetSystemMetrics(SM_YVIRTUALSCREEN),
                                    rcClient.right - rcClient.left
                                    - wBorderWidth(pWin) * 2,
                                    rcClient.bottom - rcClient.top
                                    - wBorderWidth(pWin) * 2);
        break;

    case WM_MANAGE:
        ErrorF("winMWExtWMWindowProc - WM_MANAGE\n");
        break;

    case WM_UNMANAGE:
        ErrorF("winMWExtWMWindowProc - WM_UNMANAGE\n");
        break;

    default:
        break;
    }

    return DefWindowProc(hwnd, message, wParam, lParam);
}
sis3316_flash::sis3316_flash(const TGWindow *p, UInt_t w, UInt_t h, Bool_t *b) : TGMainFrame(p, w, h)
{
	// use hierarchical cleaning
	SetCleanup(kDeepCleanup);
	if(b){
		fBSetup = b;
		*fBSetup = kTRUE;
	}
	// main window icon and general setup
	SetWindowName("SIS3316 - Flash Programmer");
	SetIconPixmap("sis1.png");

	fClient->GetColorByName("green", this->green);
	fClient->GetColorByName("red", this->red);
	reboot_prevent_flag = 0;

	// vertical frame
	fVert1 = new TGVerticalFrame(this, GetDefaultWidth(), GetDefaultHeight());
	AddFrame(fVert1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));


	// VME FPGA Programming section
	fGrpVME = new TGGroupFrame(fVert1, "VME FPGA Programming");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpVME, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));
	
	fLblVMEImg = new TGLabel(fGrpVME, "VME FPGA Image");
	fGrpVME->AddFrame(fLblVMEImg, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5));
	
	fHor1 = new TGHorizontalFrame(fGrpVME);
	fGrpVME->AddFrame(fHor1, new TGLayoutHints(kLHintsExpandX));

	fVMEImgPath = new TGTextEntry(fHor1, "test VME Image.bin");
	fHor1->AddFrame(fVMEImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fVMEImgPath->SetWidth(240);
	
	fButVMEBrowse = new TGTextButton(fHor1, "...", BTN_VME_BROWSE);
	fButVMEBrowse->ChangeOptions(fButVMEBrowse->GetOptions() | kFixedWidth);
	fButVMEBrowse->SetWidth(50);
	fButVMEBrowse->Associate(this);
	fHor1->AddFrame(fButVMEBrowse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5));

	fButVMEProg = new TGTextButton(fGrpVME, "Program VME FPGA", BTN_VME_PROG);
	fButVMEProg->Associate(this);
	fGrpVME->AddFrame(fButVMEProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15));



	// ADC FPGA Programming section
	fGrpADC = new TGGroupFrame(fVert1, "ADC FPGA Programming");
	//fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 10, 5));
	fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));
	
	// ADC1
	fLblADC1Img = new TGLabel(fGrpADC, "ADC FPGA Image");
	fGrpADC->AddFrame(fLblADC1Img, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5));
	
	fHorADC1 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC1, new TGLayoutHints(kLHintsExpandX));

	fADC1ImgPath = new TGTextEntry(fHorADC1, "test ADC Image.bin");
	fHorADC1->AddFrame(fADC1ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC1ImgPath->SetWidth(240);
	
	fButADC1Browse = new TGTextButton(fHorADC1, "...", BTN_ADC1_BROWSE);
	fButADC1Browse->ChangeOptions(fButADC1Browse->GetOptions() | kFixedWidth);
	fButADC1Browse->SetWidth(50);
	fButADC1Browse->Associate(this);
	fHorADC1->AddFrame(fButADC1Browse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5));

	fButADCProg = new TGTextButton(fGrpADC, "Program ADC FPGAs", BTN_ADC_PROG);
	fGrpADC->AddFrame(fButADCProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15));
	fButADCProg->Associate(this);

#ifdef NOT_IMPLEMENTED	
	// ADC2
	fLblADC2Img = new TGLabel(fGrpADC, "ADC2 FPGA Image");
	fGrpADC->AddFrame(fLblADC2Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));

	fHorADC2 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC2, new TGLayoutHints(kLHintsExpandX));

	fADC2ImgPath = new TGTextEntry(fHorADC2, "test ADC2 Image.bin");
	fHorADC2->AddFrame(fADC2ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC2ImgPath->SetWidth(187);

	fButADC2Browse = new TGTextButton(fHorADC2, "...", BTN_ADC2_BROWSE);
	fButADC2Browse->ChangeOptions(fButADC2Browse->GetOptions() | kFixedWidth);
	fButADC2Browse->SetWidth(50);
	fButADC2Browse->Associate(this);
	fHorADC2->AddFrame(fButADC2Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	
	// ADC3
	fLblADC3Img = new TGLabel(fGrpADC, "ADC3 FPGA Image");
	fGrpADC->AddFrame(fLblADC3Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));

	fHorADC3 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC3, new TGLayoutHints(kLHintsExpandX));

	fADC3ImgPath = new TGTextEntry(fHorADC3, "test ADC2 Image.bin");
	fHorADC3->AddFrame(fADC3ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC3ImgPath->SetWidth(187);

	fButADC3Browse = new TGTextButton(fHorADC3, "...", BTN_ADC3_BROWSE);
	fButADC3Browse->ChangeOptions(fButADC3Browse->GetOptions() | kFixedWidth);
	fButADC3Browse->SetWidth(50);
	fButADC3Browse->Associate(this);
	fHorADC3->AddFrame(fButADC3Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	
	// ADC4
	fLblADC4Img = new TGLabel(fGrpADC, "ADC4 FPGA Image");
	fGrpADC->AddFrame(fLblADC4Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));

	fHorADC4 = new TGHorizontalFrame(fGrpADC);
	fGrpADC->AddFrame(fHorADC4, new TGLayoutHints(kLHintsExpandX));

	fADC4ImgPath = new TGTextEntry(fHorADC4, "test ADC4 Image.bin");
	fHorADC4->AddFrame(fADC4ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	fADC4ImgPath->SetWidth(187);

	fButADC4Browse = new TGTextButton(fHorADC4, "...", BTN_ADC4_BROWSE);
	fButADC4Browse->ChangeOptions(fButADC4Browse->GetOptions() | kFixedWidth);
	fButADC4Browse->SetWidth(50);
	fButADC4Browse->Associate(this);
	fHorADC4->AddFrame(fButADC4Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
	

	fChkADCImgSelect = new TGCheckButton(fGrpADC, "ADC FPGAs have unique images");
	fChkADCImgSelect->SetState(kButtonDown)   ; // is ON !
	fChkADCImgSelect->SetEnabled(kFALSE); //
	//fChkADCImgSelect->Associate(this);
	fGrpADC->AddFrame(fChkADCImgSelect);

#endif	
	//fGrpProgram = new TGGroupFrame(fVert1, "Programming");
	//fVert1->AddFrame(fGrpProgram, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 10, 0, 0));

	fGrpBarProg = new TGGroupFrame(fVert1, "Programming progress");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpBarProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));


	fBar_prog = new TGHProgressBar(fGrpBarProg);
	fBar_prog->ShowPosition(kTRUE, kTRUE);
	fBar_prog->SetBarColor("blue");
	fBar_prog->SetForegroundColor(0x000000);
	fGrpBarProg->AddFrame(fBar_prog, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 10)); // hints, left, right, top, bottom


	fGrpBarVerify = new TGGroupFrame(fVert1, "Verifying progress");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpBarVerify, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));

	fBar_verify = new TGHProgressBar(fGrpBarVerify);
	fBar_verify->ShowPosition(kTRUE, kTRUE);
	fBar_verify->SetBarColor("blue");
	fBar_verify->SetForegroundColor(0x000000);
	fGrpBarVerify->AddFrame(fBar_verify, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 20)); // hints, left, right, top, bottom

	fGrpReboot = new TGGroupFrame(fVert1, "Reboot");  // hints, left, right, top, bottom
	fVert1->AddFrame(fGrpReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5));

	fButReboot = new TGTextButton(fGrpReboot, "Reboot SIS3316 FPGAs", BTN_REBOOT);
	fButReboot->Associate(this);
	fButReboot->ChangeBackground(this->green);
	fGrpReboot->AddFrame(fButReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15));



	fLabel_reboot_note = new TGLabel(fGrpReboot,"Note: the watchdog has to be enabled -> SW80-7 ON ");
	fLabel_reboot_note->SetTextJustify(kTextLeft + kTextCenterX );
	fLabel_reboot_note->SetMargins(0,0,0,0);
	fLabel_reboot_note->SetWrapLength(-1);
	fGrpReboot->AddFrame(fLabel_reboot_note, new TGLayoutHints(kLHintsExpandX,2,2,15,2));



	
	// draw everything
	SetWMSizeHints(w, h, w, h, 1, 1);
	Resize(GetDefaultSize());   // resize to default size
	MapSubwindows();
	// initially hidden
#ifdef NOT_IMPLEMENTED	
	fGrpADC->HideFrame(fHorADC2);
	fGrpADC->HideFrame(fHorADC3);
	fGrpADC->HideFrame(fHorADC4);
	fGrpADC->HideFrame(fLblADC2Img);
	fGrpADC->HideFrame(fLblADC3Img);
	fGrpADC->HideFrame(fLblADC4Img);
#endif
	MapWindow();
 
}
Exemple #11
0
KVFileDialog::KVFileDialog(const TGWindow *p, const TGWindow *main,
                           EKVFileDialogMode dlg_type, TGFileInfo *file_info) :
   TGTransientFrame(p, main, 10, 10, kVerticalFrame)
{
   // Create a file selection dialog. Depending on the dlg_type it can be
   // used for opening or saving a file or selecting a directory.

   fDlgMode=dlg_type;
   SetCleanup(kDeepCleanup);
   Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()");
   DontCallClose();

   int i;

   if (!p && !main) {
      MakeZombie();
      return;
   }
   if (!file_info) {
      Error("KVFileDialog", "file_info argument not set");
      fFileInfo = &gInfo;
      if (fFileInfo->fIniDir) {
         delete [] fFileInfo->fIniDir;
         fFileInfo->fIniDir = 0;
      }
      if (fFileInfo->fFilename) {
         delete [] fFileInfo->fFilename;
         fFileInfo->fFilename = 0;
      }
      fFileInfo->fFileTypeIdx = 0;
   } else
      fFileInfo = file_info;

   if (!fFileInfo->fFileTypes)
      fFileInfo->fFileTypes = gDefTypes;

   if (!fFileInfo->fIniDir)
      fFileInfo->fIniDir = StrDup(".");

   TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10);
   
   //--- top toolbar elements
   TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave)
                                                  ? "S&ave in:" : "&Look in:"));
   fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB);
   fTreeLB->Associate(this);

   fPcdup = fClient->GetPicture("tb_uplevel.xpm");
   fPnewf = fClient->GetPicture("tb_newfolder.xpm");
   fPlist = fClient->GetPicture("tb_list.xpm");
   fPdetails = fClient->GetPicture("tb_details.xpm");

   if (!(fPcdup && fPnewf && fPlist && fPdetails))
      Error("KVFileDialog", "missing toolbar pixmap(s).\n");

   fCdup    = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP);
   fNewf    = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER);
   fList    = new TGPictureButton(fHtop, fPlist, kIDF_LIST);
   fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS);

   fCdup->SetStyle(gClient->GetStyle());
   fNewf->SetStyle(gClient->GetStyle());
   fList->SetStyle(gClient->GetStyle());
   fDetails->SetStyle(gClient->GetStyle());

   fCdup->SetToolTipText("Up One Level");
   fNewf->SetToolTipText("Create New Folder");
   fList->SetToolTipText("List");
   fDetails->SetToolTipText("Details");

   fCdup->Associate(this);
   fNewf->Associate(this);
   fList->Associate(this);
   fDetails->Associate(this);

   fList->AllowStayDown(kTRUE);
   fDetails->AllowStayDown(kTRUE);

   fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());

   fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2));
   fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2));

   if (dlg_type == kKVFDSave) {
      fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB);
      fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected");
   } else {
      fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB);
      fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed");
      fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)");
   }
   fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
   fCheckB->SetOn(fFileInfo->fMultipleSelection);
   AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));

   //--- file view

   fFv = new TGListView(this, 400, 161);

   fFc = new TGFileContainer(fFv->GetViewPort(),
                             10, 10, kHorizontalFrame, fgWhitePixel);
   fFc->Associate(this);

   fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
   fFv->SetContainer(fFc);
   fFv->SetViewMode(kLVList);
   fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time

   TGTextButton** buttons = fFv->GetHeaderButtons();
   if (buttons) {
      buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)");
      buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)");
      buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)");
      buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)");
      buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)");
      buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)");
   }

   fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]);
   fFc->Sort(kSortByName);
   fFc->ChangeDirectory(fFileInfo->fIniDir);
   fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
   fTreeLB->Update(fFc->GetDirectory());

   fList->SetState(kButtonEngaged);

   AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1));

   if (dlg_type == kKVFDOpen) {
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)");
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()");
   }
   
   //--- file name and types

   TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10);

   TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10);

   TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:"));
   fTbfname = new TGTextBuffer(1034);
   fName = new TGTextEntry(fHfname, fTbfname);
   fName->Resize(230, fName->GetDefaultHeight());
   fName->Associate(this);

   fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:"));
   fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB);
   fTypes->Associate(this);
   fTypes->Resize(230, fName->GetDefaultHeight());

   TString s;
   for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
      s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]);
      fTypes->AddEntry(s.Data(), i);
   }
   fTypes->Select(fFileInfo->fFileTypeIdx);

   // Show all items in combobox without scrollbar
   //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize();
   //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight);

   if (fFileInfo->fFilename && fFileInfo->fFilename[0])
      fTbfname->AddText(0, fFileInfo->fFilename);
   else
      fTbfname->Clear();

   fTypes->GetListBox()->Resize(230, 120);
   fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   //--- Open/Save and Cancel buttons

   TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);

   fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave)
                                                 ? "&Save" : "&Open"), kIDF_OK);
   fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL);

   fOk->Associate(this);
   fCancel->Associate(this);

   fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
   fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));

   UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20;
   fVbf->Resize(width + 20, fVbf->GetDefaultHeight());

   fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));

   AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
   SetEditDisabled(kEditDisable);

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   Resize(size);

   //---- position relative to the parent's window

   CenterOnParent();

   //---- make the message box non-resizable

   SetWMSize(size.fWidth, size.fHeight);
   SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1);

   const char *wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type==kKVFDOpen) ? "Open" : "Choose directory...");
   SetWindowName(wname);
   SetIconName(wname);
   SetClassHints("FileDialog", "FileDialog");

   SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
                              kMWMDecorMinimize | kMWMDecorMenu,
               kMWMFuncAll |  kMWMFuncResize    | kMWMFuncMaximize |
                              kMWMFuncMinimize,
               kMWMInputModeless);

   MapWindow();
   fFc->DisplayDirectory();
   fClient->WaitFor(this);
}
Exemple #12
0
//______________________________________________________________________________
Bool_t ArgusWindow::Start()
{
   // Start Argus Window
   fWatchAll.Start(false);
   ROMEPrint::Debug("ArgusWindow::Start()\n");

   // Create status bar
   Int_t parts[2] = {70, 30};
   fStatusBar = new TGStatusBar(this, 50, 10, kHorizontalFrame);
   fStatusBar->SetParts(parts, sizeof(parts) / sizeof(Int_t));
   fProgress = new TGHProgressBar(fStatusBar->GetBarPart(1), TGProgressBar::kStandard, 20);
   fProgress->SetPosition(0);
   fStatusBar->GetBarPart(1)->AddFrame(fProgress, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 10, 10));
   if (fStatusBarSwitch) {
      this->AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 0, 0, 2, 0));
   }

   // Create horizontal frame which holds menu bar
   TGHorizontalFrame *hMenuFrame = new TGHorizontalFrame(this, 0, 0);
   AddFrame(hMenuFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
   {
      // Create menubar
      fMenuBar = new TGMenuBar(hMenuFrame, 1, 1, kHorizontalFrame);
      hMenuFrame->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
      {
         // Create popup menu
         fMenuFile = new TGPopupMenu(fClient->GetRoot());
         fMenuFile->Associate(this);
         fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));

         if (fTabWindow) {
            fMenuFile->AddEntry("New Window", M_FILE_NEW_WINDOW);
            if (gROME->GetNumberOfNetFolders()>0) {
               TGPopupMenu *fMenuNetFolder = new TGPopupMenu(fClient->GetRoot());
               if (AddMenuNetFolder(fMenuNetFolder)) {
                  fMenuFile->AddPopup("&Connect NetFolder", fMenuNetFolder);
                  fMenuNetFolder->Associate(this);
               }
            }
//            fMenuFile->AddEntry("Start C&ontroller", M_FILE_CONTROLLER);
            fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
         } else {
            fMenuFile->AddEntry("C&lose", M_FILE_EXIT);
         }
      }
   }

   {
      // separator
      TGHorizontal3DLine *hline = new TGHorizontal3DLine(this);
      AddFrame(hline, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX));
   }

   // Horizontal frame which holds the main canvas
   TGHorizontalFrame *hFrame = new TGHorizontalFrame(this);
   AddFrame(hFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY));

   // Vertical frame which holds the info frame and listtree
   TGVerticalFrame *vFrame = new TGVerticalFrame(hFrame);
   hFrame->AddFrame(vFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 1));
   {

      // now analyzer controller is dockable
      if (fTabWindow && !gROME->IsStandAloneARGUS()) {
         fController = new ArgusAnalyzerController(vFrame, -1, fControllerNetFolder);
         fController->Associate(this);
         vFrame->AddFrame(fController, new TGLayoutHints (kLHintsTop | kLHintsLeft));
      }

      if (!gROME->IsStandAloneARGUS()) {
         // run#
         TGHorizontalFrame *runFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(runFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fRunLabel   = new TGLabel(runFrame, "Run : ");
         fRunLabel->SetTextJustify(kTextLeft | kTextCenterY);
         runFrame->AddFrame(fRunLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fRunNumber   = new TGLabel(runFrame, "0");
         fRunNumber->SetTextJustify(kTextRight | kTextCenterY);
         runFrame->AddFrame(fRunNumber, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));

         // evnet#
         TGHorizontalFrame *eventFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(eventFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fEventLabel   = new TGLabel(eventFrame, "Event : ");
         fEventLabel->SetTextJustify(kTextLeft | kTextCenterY);
         eventFrame->AddFrame(fEventLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fEventNumber   = new TGLabel(eventFrame, "0");
         fEventNumber->SetTextJustify(kTextLeft | kTextCenterY);
         eventFrame->AddFrame(fEventNumber, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));

         // Year/Mon/Day
         TGHorizontalFrame *YearMonDayFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(YearMonDayFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fYearMonDayLabel = new TGLabel(YearMonDayFrame, "Date : ");
         fYearMonDayLabel->SetTextJustify(kTextLeft | kTextCenterY);
         YearMonDayFrame->AddFrame(fYearMonDayLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fYearMonDay = new TGLabel(YearMonDayFrame, "1970-Jan-01");
         fYearMonDay->SetTextJustify(kTextLeft | kTextCenterY);
         YearMonDayFrame->AddFrame(fYearMonDay, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));

         // Hour/Min/Sec
         TGHorizontalFrame *HourMinSecFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(HourMinSecFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fHourMinSecLabel = new TGLabel(HourMinSecFrame, "Time : ");
         fHourMinSecLabel->SetTextJustify(kTextLeft | kTextCenterY);
         HourMinSecFrame->AddFrame(fHourMinSecLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fHourMinSec = new TGLabel(HourMinSecFrame, "00:00:00");
         fHourMinSec->SetTextJustify(kTextLeft | kTextCenterY);
         HourMinSecFrame->AddFrame(fHourMinSec, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));
      }

      // Vertical frame which holds users info frame
      fUserInfoFrame = new TGVerticalFrame(vFrame);
      vFrame->AddFrame(fUserInfoFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0));

//         fControllerDock = new TGDockableFrame(vFrame, 0, kVerticalFrame);
//         vFrame->AddFrame(fControllerDock, new TGLayoutHints(kLHintsTop | kLHintsLeft));
//         fControllerDock->EnableUndock(kTRUE);
//         fControllerDock->EnableHide(kTRUE);
//         fControllerDock->Associate(this);

      if (fListTreeView && fTabWindow) {
         // Create ListTree
         TGCanvas *canvas = new TGCanvas(vFrame, 120, 400);
         vFrame->AddFrame(canvas, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY));
         fListTree = new TGListTree(canvas, kHorizontalFrame);
         fListTree->Connect("Clicked(TGListTreeItem*,Int_t)", "ArgusWindow", this, "OnClick(TGListTreeItem*,Int_t)");
         fListTree->Connect("DoubleClicked(TGListTreeItem*,Int_t)", "ArgusWindow", this, "OnDoubleClick(TGListTreeItem*,Int_t)");
         fListTree->Associate(this);
      }

      // Create the main frame
      const UInt_t width  = static_cast<UInt_t>(640 * GetWindowScale());
      const UInt_t height = static_cast<UInt_t>(480 * GetWindowScale());
      if (!fListTreeView && fTabWindow) {
         fTab = new TGTab(hFrame, width, height);
         fTab->Associate(this);
         hFrame->AddFrame(fTab, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
      } else {
         fMainFrame = new ROMECompositeFrame(hFrame, width, height);
         hFrame->AddFrame(fMainFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY));
      }
   }

   ROMEPrint::Debug("Creating Tabs\n");
   CheckActiveFlags();
   if (!CreateTabs()) {
      fWatchAll.Stop();
      return kFALSE;
   }
   ROMEPrint::Debug("Tabs Created\n");

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   ArgusTab   *tab;
   Int_t       lastTabIndex = -1;
   Int_t       iTab;
   const Int_t nTabs = fTabObjects->GetEntriesFast();
   if (fListTreeView) {
      ArgusTab   *lastTab = 0;
      TGDimension framesize(0,0);

      // first, hide all the tabs
      for (iTab = 0; iTab < nTabs; iTab++) {
         tab = GetTabObjectAt(iTab);
         fMainFrame->HideFrame(tab);
      }

      // show all the tabs one by one to get the maximum window size
      size = GetDefaultSize();
      for (iTab = nTabs-1; iTab >=0; iTab--) {
         tab = GetTabObjectAt(iTab);
         if (tab->IsSwitch() && fNumberOfChildren[iTab]<=0) {
            fMainFrame->HideFrame(lastTab);
            fMainFrame->ShowFrame(tab);

            framesize = GetDefaultSize();
            if (size.fWidth < framesize.fWidth) {
               size.fWidth = framesize.fWidth;
            }
            if (size.fHeight < framesize.fHeight) {
               size.fHeight = framesize.fHeight;
            }

            if (fTabWindow) { // we don't have listtrees for sub-windows
               fListTree->HighlightItem(fListTreeItem[iTab]);
            }
            lastTab = tab;
            lastTabIndex = iTab;
         }
      }
   } else {
      for (iTab = nTabs-1; iTab >=0; iTab--) {
         tab = GetTabObjectAt(iTab);
         if (tab->IsSwitch() && fNumberOfChildren[iTab]<=0) {
            fCurrentTabID = tab->GetID();
            lastTabIndex = iTab;
         }
      }
   }

   Resize(size);
   fInitialWidth  = size.fWidth;
   fInitialHeight = size.fHeight;

   // Adjust size of the sub window so that the main frame has the
   // same size as the parent's. This is not done if the parent window
   // is tab-view, because the size of the main frame is not trivial.
   if (!fTabWindow) {
      if (gROME->GetWindow()->IsListTreeView()) {
         TGDimension size1 = gROME->GetWindow()->GetInitialSize();
         TGDimension size3 = gROME->GetWindow()->GetUserInfoFrame()->GetSize();
         TGDimension size4 = GetUserInfoFrame()->GetSize();

         // Height shall be the same as the parent, but width might be
         // different because of different width of info frame.
         Resize(size1.fWidth - size3.fWidth + size4.fWidth, size1.fHeight);
      }
   }

   gSystem->Sleep(500);
   MapWindow();

   while (!IsMapped()) {
      gSystem->Sleep(20);
   }

   if (!gROME->IsStandAloneARGUS()) {
      // hide run# and event# if argus controller is shown/docked
      if (fController && (!fController->IsHidden() || !fController->IsUndocked())) {
         ((TGCompositeFrame*)(fRunNumber->GetParent()->GetParent()))->HideFrame((TGFrame*)(fRunNumber->GetParent()));
         ((TGCompositeFrame*)(fEventNumber->GetParent()->GetParent()))->HideFrame((TGFrame*)(fEventNumber->GetParent()));
      }
   }

   TriggerTabSelected(lastTabIndex);

   gSystem->Sleep(500);

   ROMEPrint::Debug("End of ArgusWindow::Start()\n");
   fWatchAll.Stop();
   return kTRUE;
}
Exemple #13
0
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
  TGMainFrame(p, w, h)
{
   // Create horizontal splitter
   TGVerticalFrame *fVf = new TGVerticalFrame(this, 10, 10);

   TGHorizontalFrame *fH1 = new TGHorizontalFrame(fVf, 10, 50, kFixedHeight);
   TGHorizontalFrame *fH2 = new TGHorizontalFrame(fVf, 10, 10);
   TGCompositeFrame *fFtop = new TGCompositeFrame(fH1, 10, 10, kSunkenFrame);
   TGCompositeFrame *fFbottom = new TGCompositeFrame(fH2, 10, 10, kSunkenFrame);

   TGLabel *fLtop = new TGLabel(fFtop, "Top Frame");
   TGLabel *fLbottom = new TGLabel(fFbottom, "Bottom Frame");

   fFtop->AddFrame(fLtop, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                            3, 0, 0, 0));
   fFbottom->AddFrame(fLbottom, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                                  3, 0, 0, 0));

   fH1->AddFrame(fFtop, new TGLayoutHints(kLHintsTop | kLHintsExpandY | 
                                          kLHintsExpandX, 0, 0, 1, 2));
   fH2->AddFrame(fFbottom, new TGLayoutHints(kLHintsTop | kLHintsExpandY | 
                                             kLHintsExpandX, 0, 0, 1, 2));

   fH1->Resize(fFtop->GetDefaultWidth(), fH1->GetDefaultHeight()+20);
   fH2->Resize(fFbottom->GetDefaultWidth(), fH2->GetDefaultHeight()+20);
   fVf->AddFrame(fH1, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   TGHSplitter *hsplitter = new TGHSplitter(fVf,2,2);
   hsplitter->SetFrame(fH1, kTRUE);
   fVf->AddFrame(hsplitter, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   fVf->AddFrame(fH2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));   
   
   // button frame
   TGVerticalFrame *hframe = new TGVerticalFrame(this, 10, 10);
   TGCompositeFrame *cframe2 = new TGCompositeFrame(hframe, 170, 50, 
                                             kHorizontalFrame | kFixedWidth);
   TGTextButton *save = new TGTextButton(cframe2, "&Save");
   cframe2->AddFrame(save, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             3, 2, 2, 2));
   save->Connect("Clicked()", "MyMainFrame", this, "DoSave()");
   save->SetToolTipText("Click on the button to save the application as C++ macro");
   
   TGTextButton *exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");
   cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             2, 0, 2, 2));
   hframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
   
   AddFrame(fVf, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY));
   AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
   
   // What to clean up in dtor
   SetCleanup(kDeepCleanup);
     
   // Set a name to the main frame   
   SetWindowName("Horizontal Splitter");
   SetWMSizeHints(300, 250, 600, 600, 0, 0);
   MapSubwindows();
   Resize(GetDefaultSize());
   MapWindow();
}