void XToolBar::Attach(void) { frame->frameWin->AddFrameControl(this); WinSetParent(winhandle, frame->frame, TRUE); WinSetOwner(winhandle, frame->frame); LONG x = borderSize, y = borderSize; XRect rect; int width = 0, height = 0; if (style & TB_RIGHT || style & TB_LEFT) { for (int i = 0; i < clients; i++) { clientArray[i]->clientWin->GetSize(&rect); if (clientArray[i]->group) x = borderSize; if (x + clientArray[i]->xOffset + rect.GetWidth() > width) width = x + clientArray[i]->xOffset + rect.GetWidth() + borderSize; x += clientArray[i]->xOffset + rect.GetWidth(); } cx = width; } else { int yy = 0; for (int i = 0; i < clients; i++) { char className[10]; WinQueryClassName(clientArray[i]->clientWin->GetHandle(), 10, (PCH) className); className[0] = ' '; if (atol(className) == 2) { if (yy < borderSize * 2 + 25) yy = borderSize * 2 + 25; } else { clientArray[i]->clientWin->GetSize(&rect); if (yy < rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset) yy = rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset; } } cy = yy; } cutWindow = NULL; XRect rect2; frame->GetSize(&rect2); rect2.SetHeight(rect2.GetHeight() - 1); frame->SetSize(&rect2); }
/* * _NewWindow - create a new window */ unsigned _NewWindow( char *name, ... ) { LPWDATA w; MENUITEM menus; HWND hwnd,frame,temp; char str[80]; int x1,x2,y1,y2; ULONG style; RECTL rcl; va_list al; _GetWindowNameAndCoords( name, str, &x1, &x2, &y1, &y2 ); style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_VERTSCROLL; frame = WinCreateStdWindow( _MainWindow, WS_VISIBLE | WS_CLIPSIBLINGS, &style, _ClassName, str, 0, NULL, 0, &hwnd ); if( frame == 0 ) return( FALSE ); WinSetOwner( hwnd, _MainWindow ); va_start( al, name ); w = _AnotherWindowData( hwnd, al ); w->frame = frame; w->text_color = CLR_WHITE; w->background_color = CLR_BLACK; WinSendMsg( frame, WM_SETICON, MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 ); WinSetWindowBits( WinWindowFromID( w->frame, FID_VERTSCROLL ), QWL_STYLE, SBS_AUTOTRACK, SBS_AUTOTRACK ); _CreateFont( w ); _PositionScrollThumb( w ); WinQueryWindowRect( _MainWindow, &rcl ); WinSetWindowPos( frame, HWND_TOP, x1*w->xchar, (rcl.yTop - rcl.yBottom)-y1*w->ychar-y2*w->ychar, x2*w->xchar, y2*w->ychar, SWP_SIZE | SWP_MOVE | SWP_ZORDER ); menus.iPosition = _MainWindowData->window_count - 1; menus.afStyle = MIS_TEXT; menus.afAttribute = 0; menus.id = DID_WIND_STDIO + w->handles[0]; menus.hwndSubMenu = NULL; menus.hItem = 0; if ( MIT_ERROR == (BOOL)WinSendMsg( menuHandle, ( ULONG )MM_INSERTITEM, MPFROMP( &menus ), MPFROMP( str ) ) ) abort(); temp = WinWindowFromID( frame, FID_SYSMENU ); WinSendMsg( temp, MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, TRUE), MPFROMP((PSZ)&menus) ); WinSendMsg( menus.hwndSubMenu, MM_DELETEITEM, MPFROM2SHORT( SC_CLOSE, TRUE ), 0 ); WinUpdateWindow( hwnd ); WinSetFocus( HWND_DESKTOP, hwnd ); return( TRUE ); } /* _NewWindow */
void ToolBarParent::DoMove(void) { if (init) return; else init = TRUE; XRect rect1, rect3; toolBar->frame->GetSize(&rect1); GetSize(&rect3); if (rect3.GetX() > rect1.GetX() + 50 && rect3.GetX() < rect1.GetX() + rect1.GetWidth() - 50 && (rect3.GetY() + rect3.GetHeight()) < rect1.GetY() + rect1.GetHeight() && (rect3.GetY() + rect3.GetHeight()) > rect1.GetY() + rect1.GetHeight() - 50) { WinSetOwner(frame, NULLHANDLE); toolBar->style = TB_TOP; toolBar->Attach(); clientWindow = NULL; delete this; } else if (rect3.GetX() > rect1.GetX() + 50 && rect3.GetX() < rect1.GetX() + rect1.GetWidth() - 50 && rect3.GetY() + rect3.GetHeight() > rect1.GetY() && rect3.GetY() + rect3.GetHeight() < rect1.GetY() + 50) { WinSetOwner(frame, NULLHANDLE); toolBar->style = TB_BOTTOM; toolBar->Attach(); clientWindow = NULL; delete this; } else if (rect3.GetX() > rect1.GetX() && rect3.GetX() < rect1.GetX() + 50 && rect3.GetY() > rect1.GetY() && rect3.GetY() < rect1.GetY() + rect1.GetHeight()) { WinSetOwner(frame, NULLHANDLE); toolBar->style = TB_LEFT; toolBar->Attach(); clientWindow = NULL; delete this; } else if (rect3.GetX() < rect1.GetX() + rect1.GetWidth() && rect3.GetX() > rect1.GetX() + rect1.GetWidth() - 50 && rect3.GetY() > rect1.GetY() && rect3.GetY() < rect1.GetY() + rect1.GetHeight()) { WinSetOwner(frame, NULLHANDLE); toolBar->style = TB_RIGHT; toolBar->Attach(); clientWindow = NULL; delete this; } init = FALSE; }
ToolBarParent :: ToolBarParent(const XResource * r, const XRect& rec, XToolBar * t):XFrameWindow(r, "", FRM_TITLEBAR | FRM_BORDER | FRM_SYSMENU | WIN_VISIBLE, rec) { t->cutWindow = this; init = TRUE; toolBar = t; WinSetParent(t->GetHandle(), frameWin->GetHandle(), TRUE); WinSetOwner(frame, t->frame->frame); SetClient(t); /****************************** ULONG Frame_style = WinQueryWindowULong( frame, QWL_STYLE ); Frame_style = ( Frame_style & ~FS_BORDER ) | FS_SIZEBORDER; WinSetWindowULong( frame, QWL_STYLE, Frame_style ); WinSendMsg( frame, WM_UPDATEFRAME, MPFROMP( FCF_BORDER ), 0 ); ********************************/ Activate(); SetText(t->title); init = FALSE; }
OWindow& OWindow::setOwner(const HWND handle) { owner = handle; WinSetOwner(hwnd, owner); return(*this); }
HWND os2FrameWindow::CreateFrameWindow(nsWindow* aParent, HWND aParentWnd, const nsIntRect& aRect, nsWindowType aWindowType, nsBorderStyle aBorderStyle) { // Create a frame window with a MozillaWindowClass window as its client. HWND hClient; uint32_t fcfFlags = GetFCFlags(aWindowType, aBorderStyle); mFrameWnd = WinCreateStdWindow(HWND_DESKTOP, 0, (ULONG*)&fcfFlags, kWindowClassName, "Title", WS_CLIPCHILDREN, NULLHANDLE, 0, &hClient); if (!mFrameWnd) { return 0; } // Hide from the Window List until shown. SetWindowListVisibility(false); // This prevents a modal dialog from being covered by its disabled parent. if (aParentWnd != HWND_DESKTOP) { WinSetOwner(mFrameWnd, aParentWnd); } // Get the frame control HWNDs for use by fullscreen mode. mTitleBar = WinWindowFromID(mFrameWnd, FID_TITLEBAR); mSysMenu = WinWindowFromID(mFrameWnd, FID_SYSMENU); mMinMax = WinWindowFromID(mFrameWnd, FID_MINMAX); // Calc the size of a frame needed to contain a client area of the // specified width & height. Without this, eWindowType_dialog windows // will be truncated (toplevel windows will still display correctly). RECTL rcl = {0, 0, aRect.width, aRect.height}; WinCalcFrameRect(mFrameWnd, &rcl, FALSE); mFrameBounds = nsIntRect(aRect.x, aRect.y, rcl.xRight-rcl.xLeft, rcl.yTop-rcl.yBottom); // Move & resize the frame. int32_t pmY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - mFrameBounds.y - mFrameBounds.height; WinSetWindowPos(mFrameWnd, 0, mFrameBounds.x, pmY, mFrameBounds.width, mFrameBounds.height, SWP_SIZE | SWP_MOVE); // Store the client's bounds. For windows with resizable borders, // the width includes the width of the frame controls (minmax, etc.). SWP swp; WinQueryWindowPos(hClient, &swp); mOwner->SetBounds(nsIntRect(swp.x, mFrameBounds.height - swp.y - swp.cy, swp.cx, swp.cy)); // Subclass the frame. mPrevFrameProc = WinSubclassWindow(mFrameWnd, fnwpFrame); WinSetWindowPtr(mFrameWnd, QWL_USER, this); DEBUGFOCUS(Create os2FrameWindow); return hClient; }
~ToolBarParent() { WinSetOwner(frame, HWND_DESKTOP); }
// Called in the PM thread. void nsFrameWindow::RealDoCreate( HWND hwndP, nsWindow *aParent, const nsIntRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, nsWidgetInitData *aInitData, HWND hwndO) { nsIntRect rect = aRect; if( aParent) // Offset rect by position of owner { nsIntRect clientRect; aParent->GetBounds(rect); aParent->GetClientBounds(clientRect); rect.x += aRect.x + clientRect.x; rect.y += aRect.y + clientRect.y; rect.width = aRect.width; rect.height = aRect.height; hwndP = aParent->GetMainWindow(); rect.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - (rect.y + rect.height); } else // Use original rect, no owner window { rect = aRect; rect.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - (aRect.y + aRect.height); } #if DEBUG_sobotka printf("\nIn nsFrameWindow::RealDoCreate:\n"); printf(" hwndP = %lu\n", hwndP); printf(" aParent = 0x%lx\n", &aParent); printf(" aRect = %ld, %ld, %ld, %ld\n", aRect.x, aRect.y, aRect.height, aRect.width); #endif ULONG fcfFlags = GetFCFlags(); ULONG style = WindowStyle(); if( aInitData) { if( aInitData->clipChildren) style |= WS_CLIPCHILDREN; #if 0 // // Windows has a slightly different idea of what the implications are // of a window having or not having the CLIPSIBLINGS style. // All 'canvas' components we create must have clipsiblings, or // strange things happen & performance actually degrades. // else style &= ~WS_CLIPCHILDREN; #endif if( aInitData->clipSiblings) style |= WS_CLIPSIBLINGS; else style &= ~WS_CLIPSIBLINGS; } #ifdef DEBUG_FOCUS mWindowIdentifier = currentWindowIdentifier; currentWindowIdentifier++; if (aInitData && (aInitData->mWindowType == eWindowType_toplevel)) DEBUGFOCUS(Create Frame Window); else DEBUGFOCUS(Create Window); #endif mFrameWnd = WinCreateStdWindow( HWND_DESKTOP, 0, &fcfFlags, WindowClass(), "Title", style, NULLHANDLE, 0, &mWnd); /* Because WinCreateStdWindow doesn't take an owner, we have to set it */ if (hwndP) WinSetOwner(mFrameWnd, hwndP); /* Set some HWNDs and style into properties for fullscreen mode */ HWND hwndTitleBar = WinWindowFromID(mFrameWnd, FID_TITLEBAR); WinSetProperty(mFrameWnd, "hwndTitleBar", (PVOID)hwndTitleBar, 0); HWND hwndSysMenu = WinWindowFromID(mFrameWnd, FID_SYSMENU); WinSetProperty(mFrameWnd, "hwndSysMenu", (PVOID)hwndSysMenu, 0); HWND hwndMinMax = WinWindowFromID(mFrameWnd, FID_MINMAX); WinSetProperty(mFrameWnd, "hwndMinMax", (PVOID)hwndMinMax, 0); SetWindowListVisibility( PR_FALSE); // Hide from Window List until shown NS_ASSERTION( mFrameWnd, "Couldn't create frame"); // Frames have a minimum height based on the pieces they are created with, // such as titlebar, menubar, frame borders, etc. We need this minimum // height so we can correctly set the frame position (coordinate flipping). nsIntRect frameRect = rect; long minheight; if ( fcfFlags & FCF_SIZEBORDER) { minheight = 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER); } else if ( fcfFlags & FCF_DLGBORDER) { minheight = 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYDLGFRAME); } else { minheight = 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER); } if ( fcfFlags & FCF_TITLEBAR) { minheight += WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR); } if ( frameRect.height < minheight) { frameRect.height = minheight; } // Set up parent data - don't addref to avoid circularity mParent = nsnull; // Make sure we have a device context from somewhere if( aContext) { mContext = aContext; NS_ADDREF(mContext); } else { nsresult rc; static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); rc = CallCreateInstance(kDeviceContextCID, &mContext); if( NS_SUCCEEDED(rc)) mContext->Init(this); #ifdef DEBUG else printf( "Couldn't find DC instance for nsWindow\n"); #endif } // Record bounds. This is XP, the rect of the entire main window in // parent space. Returned by GetBounds(). // NB: We haven't subclassed yet, so callbacks to change mBounds won't // have happened! mBounds = frameRect; mBounds.height = frameRect.height; // Record passed in things mEventCallback = aHandleEventFunction; if( mParent) mParent->AddChild( this); // call the event callback to notify about creation DispatchStandardEvent( NS_CREATE ); SubclassWindow(TRUE); PostCreateWidget(); // Subclass frame fnwpDefFrame = WinSubclassWindow( mFrameWnd, fnwpFrame); WinSetWindowPtr( mFrameWnd, QWL_USER, this); WinSetWindowPos(mFrameWnd, 0, frameRect.x, frameRect.y, frameRect.width, frameRect.height, SWP_SIZE | SWP_MOVE); }