BOOL CDockManager::Dock(DM_POS nPos) { if (nPos == DMP_UNDOCKED) return UnDock(); // check if no change if (IsDocked() && m_nDockPos == nPos) return TRUE; BOOL bDocked = IsDocked(); m_nDockPos = nPos; CRect rDock; ScGetCWnd()->GetWindowRect(rDock); // save window pos if not currently docked if (!bDocked) m_rUndocked = rDock; // and restore previous width/height if (nPos == DMP_BELOW) { int nHeight = GetDockedHeight(IsMaximized()); if (nHeight != -1) { rDock.bottom = rDock.top + nHeight; CAutoFlag af(m_bResizeUpdate, FALSE); CAutoFlag af2(m_bSizeUpdate, FALSE); MoveWindow(ScGetCWnd(), rDock); } } else { int nWidth = GetDockedWidth(IsMaximized()); if (nWidth != -1) { rDock.right = rDock.left + nWidth; CAutoFlag af(m_bResizeUpdate, FALSE); CAutoFlag af2(m_bSizeUpdate, FALSE); MoveWindow(ScGetCWnd(), rDock); } } // also restore main window pos if maximized if (IsMaximized()) OnMaximize(); else { UpdateDockWindowPos(); FitDockWindowToWorkArea(); // make sure it's visible } return TRUE; }
// // Handle toolbar resizing // void ToolBar::OnLeftDown( wxMouseEvent & event ) { // Go ahead and set the event to propagate event.Skip(); // Don't do anything if we're not docked if( !IsDocked() ) { return; } // Can we be resized? if( IsResizable() ) { wxPoint pos = event.GetPosition(); wxRect rect = GetRect(); // Adjust to size of resize grabber rect.x = rect.width - RWIDTH; rect.y = 0; rect.width = RWIDTH; // Is left click within resize grabber? if( rect.Contains( pos ) ) { // Retrieve the mouse position mResizeStart = ClientToScreen( pos ); // We want all of the mouse events CaptureMouse(); } } }
// // Handle toolbar resizing // void ToolBar::OnLeftDown( wxMouseEvent & event ) { // Go ahead and set the event to propagate event.Skip(); // Don't do anything if we're not docked if( !IsDocked() ) { return; } // Can we be resized? if( IsResizable() ) { wxPoint pos = event.GetPosition(); // Is left click within resize grabber? if( IsResizeGrabberHit( pos ) ) { // Retrieve the mouse position mResizeStart = ClientToScreen( pos ); // We want all of the mouse events CaptureMouse(); } } }
bool UFlareSpacecraftNavigationSystem::DockAt(AFlareSpacecraft* TargetStation) { FLOGV("UFlareSpacecraftNavigationSystem::DockAt : '%s' docking at '%s'", *Spacecraft->GetParent()->GetImmatriculation().ToString(), *TargetStation->GetParent()->GetImmatriculation().ToString()); FFlareDockingInfo DockingInfo = TargetStation->GetDockingSystem()->RequestDock(Spacecraft, Spacecraft->GetActorLocation()); // Docking granted if (DockingInfo.Granted) { if (IsDocked()) { FLOG("UFlareSpacecraftNavigationSystem::DockAt : leaving current dock"); Undock(); } FLOG("UFlareSpacecraftNavigationSystem::DockAt : access granted"); PushCommandDock(DockingInfo); return true; } // Failed else { FLOG("UFlareSpacecraftNavigationSystem::DockAt : docking denied"); return false; } }
void CDockManager::OnMaximize() { ASSERT (IsMaximized()); BOOL bDockVisible = ::IsWindowVisible(ScGetHwnd()); CRect rMain = GetWorkArea(); if (bDockVisible && IsDocked()) { CRect rDock; ::GetWindowRect(ScGetHwnd(), rDock); switch (m_nDockPos) { case DMP_LEFT: if (m_nWidthDockedMax == -1) rMain.left += min(rDock.Width(), rMain.Width() / 2); else rMain.left += m_nWidthDockedMax; break; case DMP_RIGHT: if (m_nWidthDockedMax == -1) rMain.right -= min(rDock.Width(), rMain.Width() / 2); else rMain.right -= m_nWidthDockedMax; break; case DMP_BELOW: if (m_nHeightDockedMax == -1) rMain.bottom -= min(rDock.Height(), rMain.Height() / 2); else rMain.bottom -= m_nHeightDockedMax; break; default: ASSERT(0); return; } } MoveWindow(GetCWnd(), rMain); if (bDockVisible && IsDocked()) UpdateDockWindowPos(); }
void WxBrowser::SetParentCaption() { wxWindow* parent = GetParent(); if( IsDocked() ) { parent = parent->GetParent(); } parent->SetLabel( GetLocalizedCaption() ); }
/** * Saves the window state for this dockable window */ void WxBrowser::SaveWindowState(void) { FString LocKey = GetLocalizationKey(); // Write out the current docking state GConfig->SetBool(TEXT("Docking"),*(LocKey + TEXT("_Docked")), IsDocked(),GEditorUserSettingsIni); // And now whether it's visible or not GConfig->SetBool(TEXT("Docking"),*(LocKey + TEXT("_Visible")), bIsVisible,GEditorUserSettingsIni); }
CRect CDockManager::GetUnDockedRect() const { if (IsDocked()) return m_rUndocked; // else CRect rect; ::GetWindowRect(ScGetHwnd(), rect); return rect; }
AFlareSpacecraft* UFlareSpacecraftNavigationSystem::GetDockStation() { if (IsDocked()) { for (int32 SpacecraftIndex = 0; SpacecraftIndex < Spacecraft->GetGame()->GetActiveSector()->GetSpacecrafts().Num(); SpacecraftIndex++) { AFlareSpacecraft* Station = Spacecraft->GetGame()->GetActiveSector()->GetSpacecrafts()[SpacecraftIndex]; if (Station && Station->GetParent()->GetImmatriculation() == Data->DockedTo) { return Station; } } } return NULL; }
bool UFlareSpacecraftNavigationSystem::Undock() { // Try undocking if (IsDocked()) { FLOGV("UFlareSpacecraftNavigationSystem::Undock : '%s' undocking from '%s'", *Spacecraft->GetParent()->GetImmatriculation().ToString(), *Data->DockedTo.ToString()); // Detach from station if(DockConstraint) { DockConstraint->BreakConstraint(); DockConstraint->DestroyComponent(); DockConstraint = NULL; } AFlareSpacecraft* DockStation = GetDockStation(); DockStation->GetDockingSystem()->ReleaseDock(Spacecraft, Data->DockedAt); // Update data SetStatus(EFlareShipStatus::SS_AutoPilot); Data->DockedTo = NAME_None; Data->DockedAt = -1; // Update Angular acceleration rate : when it's docked the mass is the ship mass + the station mass Spacecraft->SetRCSDescription(Spacecraft->GetRCSDescription()); Spacecraft->OnUndocked(DockStation); // Leave PushCommandLocation(Spacecraft->GetRootComponent()->GetComponentTransform().TransformPositionNoScale(5000 * FVector(-1, 0, 0))); FLOG("UFlareSpacecraftNavigationSystem::Undock : successful"); // Hack for bug #195: for ue4 to reweld all. Spacecraft->Airframe->SetSimulatePhysics(false); Spacecraft->Airframe->SetSimulatePhysics(true); return true; } // Failed else { FLOGV("UFlareSpacecraftNavigationSystem::Undock : '%s' is not docked", *Spacecraft->GetParent()->GetImmatriculation().ToString()); return false; } }
// // Show or hide the toolbar // bool ToolBar::Expose( bool show ) { bool was = mVisible; mVisible = show; if( IsDocked() ) { Show( show ); } else { GetParent()->Show( show ); } return was; }
void ToolBar::ReCreateButtons() { // SetSizer(NULL) detaches mHSizer and deletes it. // Do not use Detach() here, as that attempts to detach mHSizer from itself! SetSizer( NULL ); // Get rid of any children we may have DestroyChildren(); // Create the main sizer wxBoxSizer *ms = new wxBoxSizer( wxHORIZONTAL ); // Create the grabber and add it to the main sizer mGrabber = new Grabber( this, mType ); ms->Add( mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1 ); // Use a box sizer for laying out controls mHSizer = new wxBoxSizer( wxHORIZONTAL ); ms->Add( mHSizer, 1, wxEXPAND ); // (Re)Establish dock state SetDocked( IsDocked(), false ); // Go add all the rest of the gadgets Populate(); // Add some space for the resize border if( IsResizable() ) { mSpacer = ms->Add( RWIDTH, 1 ); } // Set the sizer and do initial layout SetSizerAndFit( ms ); Layout(); // Recalculate the height to be a multiple of toolbarSingle #define tbs ( toolbarSingle + toolbarGap ) wxSize sz = GetSize(); sz.y = ( ( ( sz.y + tbs ) / tbs ) * tbs ) - 1; #undef tbs // Set the true AND minimum sizes and do final layout SetBestFittingSize(sz); Layout(); }
void CDockManager::OnRestore() { ASSERT (!IsMaximized()); BOOL bDockVisible = ::IsWindowVisible(ScGetHwnd()); if (bDockVisible && IsDocked()) { CRect rDock; GetWindowRect(rDock); switch (m_nDockPos) { case DMP_LEFT: if (m_nWidthDocked != -1) { rDock.right = rDock.left; rDock.left -= m_nWidthDocked; } break; case DMP_RIGHT: if (m_nWidthDocked != -1) { rDock.left = rDock.right; rDock.right += m_nWidthDocked; } break; case DMP_BELOW: if (m_nHeightDocked != -1) { rDock.top = rDock.bottom; rDock.bottom += m_nHeightDocked; } break; default: ASSERT(0); return; } MoveWindow(ScGetCWnd(), rDock); } }
BOOL CDockManager::UnDock() { if (!IsDocked()) return TRUE; m_nLastDockPos = m_nDockPos; m_nDockPos = DMP_UNDOCKED; // restore window pos ScGetCWnd()->MoveWindow(m_rUndocked); // also restore main window pos if maximized if (IsMaximized()) OnMaximize(); else FitDockWindowToWorkArea(); // make sure it's visible return TRUE; }
//******************************************************************************* BOOL CBCGPBaseTabbedBar::RemoveControlBar (CWnd* pBar) { ASSERT_VALID (this); ASSERT_VALID (pBar); ASSERT_VALID (m_pTabWnd); int nTabNumber = m_pTabWnd->GetTabFromHwnd (pBar->GetSafeHwnd ()); if (nTabNumber < 0 || nTabNumber >= m_pTabWnd->GetTabsNum ()) { return FALSE; } m_pTabWnd->RemoveTab (nTabNumber); if (m_pTabWnd->GetTabsNum () == 0) { if (AllowDestroyEmptyTabbedBar ()) { if (IsDocked ()) { UnDockControlBar (); } else { CBCGPMiniFrameWnd* pMiniFrame = GetParentMiniFrame (); pMiniFrame->RemoveControlBar (this); } DestroyWindow (); return FALSE; } else { m_pTabWnd->ShowWindow (SW_HIDE); } } return TRUE; }
//********************************************************************************** CToolPalette::EDisplayOptions CToolPalette::GetToolbarDisplayOptions() const { int x = 0; bool bHorizontal = (GetCurrentAlignment() & CBRS_ORIENT_HORZ) != 0; if (!bHorizontal) { CString title; GetWindowText (title); if (!title.IsEmpty ()) { x |= eDisplayTitle; } if (IsDocked ()) { x |= eDisplayBorder; } } return (EDisplayOptions)x; }
/** * This function is called when the window has been selected from within the ctrl + tab dialog. */ void WxBrowser::OnSelected() { wxWindow* Parent = GetParent(); if(IsDocked()) { wxNotebook* Notebook = (wxNotebook*)Parent; if(!Notebook->GetParent()->IsShown()) { Notebook->GetParent()->Show(); } for(INT PageIndex = 0; PageIndex < (INT)Notebook->GetPageCount(); ++PageIndex) { if(Notebook->GetPage(PageIndex) == this) { // If the page is visible but does not have focus then give it the focus if(Notebook->GetSelection() == PageIndex) { this->SetFocus(); } else { Notebook->SetSelection(PageIndex); } } } } else { if(!Parent->IsShown()) { Parent->Show(); } Parent->Raise(); } }
// // Show or hide the toolbar // bool ToolBar::Expose( bool show ) { bool was = mVisible; SetVisible( show ); if( IsDocked() ) { Show( show ); } else { wxWindow * pParent = GetParent(); if( !IsPositioned() && show ){ SetPositioned(); pParent->CentreOnParent(); pParent->Move( pParent->GetPosition() + wxSize( mType*10, mType*10 )); } pParent->Show( show ); } return was; }
CSize CDockManager::GetMinMaximizedSize() { CSize sizeMin = GetWorkArea().Size(); if (IsDocked() && ::IsWindowVisible(ScGetHwnd())) { switch (m_nDockPos) { case DMP_LEFT: case DMP_RIGHT: sizeMin.cx = MINMAXSIZE; break; case DMP_BELOW: sizeMin.cy = MINMAXSIZE; break; default: ASSERT(0); } } return sizeMin; }
// // This draws the background of a toolbar // void ToolBar::OnPaint( wxPaintEvent & event ) { wxPaintDC dc( (wxWindow *) event.GetEventObject() ); // Start with a clean background // // Under GTK, clearing will cause the background to be white and // rather than setting a background color, just bypass the clear. #if !defined(__WXGTK__) dc.Clear(); #endif // Go repaint the rest Repaint( &dc ); if( IsResizable() && IsDocked() ) { wxSize sz = GetSize(); AColor::Dark( &dc, false ); dc.DrawLine( sz.x - 4, 0, sz.x - 4, sz.y ); dc.DrawLine( sz.x - 1, 0, sz.x - 1, sz.y ); } }
// // This draws the background of a toolbar // void ToolBar::OnPaint( wxPaintEvent & event ) { wxPaintDC dc( (wxWindow *) event.GetEventObject() ); // Start with a clean background // // Under GTK, clearing will cause the background to be white and // rather than setting a background color, just bypass the clear. #if !defined(__WXGTK__) dc.Clear(); #endif // EXPERIMENTAL_THEMING is set to not apply the gradient // on wxMAC builds. on wxMAC we have the AQUA_THEME. #ifdef USE_AQUA_THEME Repaint( &dc ); #else #ifdef EXPERIMENTAL_THEMING wxImage * mpBackGradient = &theTheme.Image( bmpRecoloredUpLarge ); if( mpBackGradient != NULL ) { wxSize imSz( mpBackGradient->GetWidth(), mpBackGradient->GetHeight() ); wxSize sz = GetSize(); int y; for(y=0;y<sz.y;y++) { int yPix = ((float)y * imSz.y - 0.0001f)/(sz.y-1); wxColour col( mpBackGradient->GetRed( 0, yPix), mpBackGradient->GetGreen( 0, yPix), mpBackGradient->GetBlue( 0, yPix)); // Set background colour so that controls placed on this // toolbar such as radio buttons will draw reasonably. // It's a little tacky setting the background colour // here, but we can't do it in the constructor as the gradient // may not be available yet. // Better than this would be to set the colour when the image // is loaded. // We use the colour at the half way point as a suitable 'average'. if( y==(sz.y/2) ) { SetBackgroundColour( col ); } wxPen Pen( col ); dc.SetPen(Pen ); dc.DrawLine( 0, y, sz.x, y ); } } #endif #endif if( IsResizable() && IsDocked() ) { wxSize sz = GetSize(); AColor::Dark( &dc, false ); dc.DrawLine( sz.x - 4, 0, sz.x - 4, sz.y ); dc.DrawLine( sz.x - 1, 0, sz.x - 1, sz.y ); } }
void CDockManager::UpdateMainWindowPos() { ASSERT (IsDocked()); if (!IsDocked()) return; CRect rMain, rDock; GetWindowRect(rMain); ::GetWindowRect(ScGetHwnd(), rDock); // if the main window is maximized then shrink/enlarge // the window if (IsMaximized()) { rMain = GetWorkArea(); switch (m_nDockPos) { case DMP_LEFT: rMain.left = rDock.right; break; case DMP_RIGHT: rMain.right = rDock.left; break; case DMP_BELOW: rMain.bottom = rDock.top; break; default: ASSERT(0); return; } } // else just move the main window else { switch (m_nDockPos) { case DMP_LEFT: rMain.top = rDock.top; rMain.bottom = rDock.bottom; rMain.right = rDock.right + rMain.Width(); rMain.left = rDock.right; break; case DMP_RIGHT: rMain.top = rDock.top; rMain.bottom = rDock.bottom; rMain.left = rDock.left - rMain.Width(); rMain.right = rDock.left; break; case DMP_BELOW: rMain.left = rDock.left; rMain.right = rDock.right; rMain.top = rDock.top - rMain.Height(); rMain.bottom = rDock.top; break; default: ASSERT(0); return; } } MoveWindow(GetCWnd(), rMain); }
void CDockManager::UpdateDockWindowPos() { ASSERT (IsDocked()); if (!IsDocked()) return; CRect rMain, rDock; GetWindowRect(rMain); ::GetWindowRect(ScGetHwnd(), rDock); if (IsMaximized()) { CRect rWorkArea = GetWorkArea(); switch (m_nDockPos) { case DMP_LEFT: rDock.top = rMain.top; rDock.bottom = rMain.bottom; rDock.left = rWorkArea.left; rDock.right = rMain.left; break; case DMP_RIGHT: rDock.top = rMain.top; rDock.bottom = rMain.bottom; rDock.right = rWorkArea.right; rDock.left = rMain.right; break; case DMP_BELOW: rDock.left = rMain.left; rDock.right = rMain.right; rDock.bottom = rWorkArea.bottom; rDock.top = rMain.bottom; break; default: ASSERT(0); return; } } else // not maximized { switch (m_nDockPos) { case DMP_LEFT: rDock.top = rMain.top; rDock.bottom = rMain.bottom; rDock.left = rMain.left - rDock.Width(); rDock.right = rMain.left; break; case DMP_RIGHT: rDock.top = rMain.top; rDock.bottom = rMain.bottom; rDock.right = rMain.right + rDock.Width(); rDock.left = rMain.right; break; case DMP_BELOW: rDock.left = rMain.left; rDock.right = rMain.right; rDock.bottom = rMain.bottom + rDock.Height(); rDock.top = rMain.bottom; break; default: ASSERT(0); return; } } MoveWindow(ScGetCWnd(), rDock); }
void UFlareSpacecraftNavigationSystem::TickSystem(float DeltaSeconds) { UpdateCOM(); // Manual pilot if (IsManualPilot() && Spacecraft->GetParent()->GetDamageSystem()->IsAlive()) { LinearTargetVelocity = Spacecraft->GetStateManager()->GetLinearTargetVelocity(); AngularTargetVelocity = Spacecraft->GetStateManager()->GetAngularTargetVelocity(); UseOrbitalBoost = Spacecraft->GetStateManager()->IsUseOrbitalBoost(); if (Spacecraft->GetStateManager()->IsWantFire()) { Spacecraft->GetWeaponsSystem()->StartFire(); } else { Spacecraft->GetWeaponsSystem()->StopFire(); } } // Autopilot else if (IsAutoPilot()) { FFlareShipCommandData CurrentCommand; if (CommandData.Peek(CurrentCommand)) { if (CurrentCommand.Type == EFlareCommandDataType::CDT_Location) { if (UpdateLinearAttitudeAuto(DeltaSeconds, CurrentCommand.LocationTarget, FVector::ZeroVector, (CurrentCommand.PreciseApproach ? LinearMaxDockingVelocity : LinearMaxVelocity), 1.0)) { ClearCurrentCommand(); } } else if (CurrentCommand.Type == EFlareCommandDataType::CDT_BrakeLocation) { UpdateLinearBraking(DeltaSeconds, CurrentCommand.VelocityTarget); } else if (CurrentCommand.Type == EFlareCommandDataType::CDT_Rotation) { UpdateAngularAttitudeAuto(DeltaSeconds); } else if (CurrentCommand.Type == EFlareCommandDataType::CDT_BrakeRotation) { UpdateAngularBraking(DeltaSeconds); } else if (CurrentCommand.Type == EFlareCommandDataType::CDT_Dock) { DockingAutopilot(Cast<AFlareSpacecraft>(CurrentCommand.ActionTarget), CurrentCommand.ActionTargetParam, DeltaSeconds); } } // TODO Autopilot anticollision system } // Physics if (!IsDocked()) { // TODO enable physic when docked but attach the ship to the station PhysicSubTick(DeltaSeconds); } }
void ToolBar::OnMotion( wxMouseEvent & event ) { // Go ahead and set the event to propagate event.Skip(); // Don't do anything if we're not docked if( !IsDocked() ) { return; } // Retrieve the mouse position wxPoint pos = ClientToScreen( event.GetPosition() ); if( !HasCapture() ) { if( IsResizable() ) { wxPoint pos = event.GetPosition(); wxRect rect = GetRect(); // Adjust to size of resize grabber rect.x = rect.width - RWIDTH; rect.y = 0; rect.width = RWIDTH; // Is left click within resize grabber? if( rect.Contains( pos ) ) { SetCursor( wxCURSOR_SIZEWE ); } else { SetCursor( wxCURSOR_ARROW ); } } } else if( event.Dragging() ) { wxRect r = GetRect(); wxSize msz = GetMinSize(); wxSize psz = GetParent()->GetClientSize(); // Adjust the size by the difference between the // last mouse and current mouse positions. r.width += ( pos.x - mResizeStart.x ); // Constrain if( r.width < msz.x ) { // Don't allow resizing to go too small r.width = msz.x; } else if( r.GetRight() > psz.x - 3 ) { // Don't allow resizing to go too large // // The 3 magic pixels are because I'm too chicken to change the // calculations in ToolDock::LayoutToolBars() even though I'm // the one that set them up. :-) r.SetRight( psz.x - 3 ); } else { // Remember for next go round mResizeStart = pos; } // Resize the bar SetSize( r.GetSize() ); // Tell everyone we've changed sizes Updated(); // Refresh our world GetParent()->Refresh(); GetParent()->Update(); } }
LRESULT CDockManager::WindowProc(HWND /*hRealWnd*/, UINT msg, WPARAM wp, LPARAM lp) { if (!IsDocked()) return Default(); switch (msg) { case WM_MOVE: { LRESULT lr = Default(); if (m_bResizeUpdate) UpdateDockWindowPos(); return lr; } break; case WM_SIZE: { LRESULT lr = Default(); if (m_bResizeUpdate) UpdateDockWindowPos(); return lr; } break; case WM_SYSCOMMAND: if (wp == SC_MAXIMIZE || wp == SC_RESTORE) { CAutoFlag af(m_bResizeUpdate, FALSE); LRESULT lr = Default(); if (wp == SC_MAXIMIZE) OnMaximize(); else OnRestore(); return lr; } break; case WM_NCLBUTTONDBLCLK: if (wp == HTCAPTION) { CAutoFlag af(m_bResizeUpdate, FALSE); BOOL bIsZoomed = IsMaximized(); LRESULT lr = Default(); if (!bIsZoomed) OnMaximize(); else OnRestore(); return lr; } break; case WM_NCLBUTTONDOWN: // if this is in the caption and the main window in maxed // then eat if (wp == HTCAPTION && IsMaximized()) { // activate the window first SendMessage(WM_ACTIVATE, WA_CLICKACTIVE, NULL); return 0; } break; case WM_GETMINMAXINFO: { // if the main window is zoomed then don't restrict how far // the docked window can be resized LRESULT lr = Default(); // save off our last min size LPMINMAXINFO pMMI = (LPMINMAXINFO)lp; m_sizeMainMin = pMMI->ptMinTrackSize; OnMinMaxInfo(pMMI, TRUE); return lr; } } return Default(); }
void DeviceToolBar::RepositionCombos() { int w, h, dockw, dockh; float ratioUnused; bool constrained = true; wxWindow *window; wxSize desiredInput, desiredOutput, desiredHost, desiredChannels; float hostRatio, outputRatio, inputRatio, channelsRatio; // if the toolbar is docked then the width we should use is the project width. // as the toolbar's with can extend past this. GetClientSize(&w, &h); // FIXME: Note that there's some bug in here, in that even if the prefs show the toolbar // docked, on initialization, this call to IsDocked() returns false. if (IsDocked()) { // If the toolbar is docked its width can be larger than what is actually viewable // So take the min. We don't need to worry about having another toolbar to the left off us // because if we are larger than the dock size we always get our own row. // and if smaller then we don't use the dock size (because we take the min). window = GetDock(); window->GetClientSize(&dockw, &dockh); if (dockw < w) w = dockw; } // subtract the main grabber on the left and the resizer as well w -= grabberWidth + GetResizeGrabberWidth(); if (w <= 0) return; // set up initial sizes and ratios hostRatio = kHostWidthRatio; inputRatio = kInputWidthRatio; outputRatio = kOutputWidthRatio; channelsRatio = kChannelsWidthRatio; desiredHost = mHost->GetBestSize(); desiredInput = mInput->GetBestSize(); desiredOutput = mOutput->GetBestSize(); desiredChannels = mInputChannels->GetBestSize(); // wxGtk has larger comboboxes than the other platforms. For DeviceToolBar this will cause // the height to be double because of the discrete grid layout. So we shrink it to prevent this. #ifdef __WXGTK__ desiredHost.SetHeight(desiredHost.GetHeight() -4); desiredInput.SetHeight(desiredHost.GetHeight()); desiredOutput.SetHeight(desiredHost.GetHeight()); desiredChannels.SetHeight(desiredHost.GetHeight()); #endif ratioUnused = 0.995f - (kHostWidthRatio + kInputWidthRatio + kOutputWidthRatio + kChannelsWidthRatio); int i = 0; // limit the amount of times we solve contraints to 5 while (constrained && ratioUnused > 0.01f && i < 5) { i++; constrained = RepositionCombo(mHost, w, desiredHost, hostRatio, ratioUnused, 0, true); constrained |= RepositionCombo(mInput, w, desiredInput, inputRatio, ratioUnused, mRecordBitmap->GetWidth(), true); constrained |= RepositionCombo(mOutput, w, desiredOutput, outputRatio, ratioUnused, mPlayBitmap->GetWidth(), true); constrained |= RepositionCombo(mInputChannels, w, desiredChannels, channelsRatio, ratioUnused, 0, true); } Update(); }
LRESULT CDockManager::ScWindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_MOVE: if (IsDocked()) { LRESULT lr = ScDefault(hRealWnd); if (m_bResizeUpdate) UpdateMainWindowPos(); return lr; } break; case WM_SIZE: if (IsDocked()) { LRESULT lr = ScDefault(hRealWnd); if (m_bResizeUpdate) UpdateMainWindowPos(); // save dock width if (m_bSizeUpdate && ::IsWindowVisible(ScGetHwnd())) { CRect rDock; ::GetWindowRect(ScGetHwnd(), rDock); if (IsMaximized()) { if (m_nDockPos == DMP_BELOW) m_nHeightDockedMax = rDock.Height(); else m_nWidthDockedMax = rDock.Width(); } else { if (m_nDockPos == DMP_BELOW) m_nHeightDocked = rDock.Height(); else m_nWidthDocked = rDock.Width(); } } return lr; } break; case WM_SYSCOMMAND: if (IsDocked()) { switch (wp) { // hide system menu case SC_KEYMENU: case SC_MOUSEMENU: return 0; // don't allow docked window to be minimized or maximized directly // instead, send the message to the main window case SC_MAXIMIZE: case SC_MINIMIZE: return SendMessage(msg, wp, lp); // if the dock window is being closed and the main window is maximized // then readjust the main window rect case SC_CLOSE: if (IsMaximized()) { LRESULT lr = ScDefault(hRealWnd); OnMaximize(); return lr; } break; } } break; case WM_NCRBUTTONDOWN: // if this is in the caption then eat it if (IsDocked() && wp == HTCAPTION) { // activate the window first ScSendMessage(WM_ACTIVATE, WA_CLICKACTIVE, NULL); return 0; } break; case WM_NCLBUTTONDOWN: // if this is in the caption and the main window in maxed // then eat if (IsDocked() && wp == HTCAPTION && IsMaximized()) { // activate the window first ScSendMessage(WM_ACTIVATE, WA_CLICKACTIVE, NULL); return 0; } break; case WM_NCLBUTTONDBLCLK: if (wp == HTCAPTION) { // toggle the docked state if (IsDocked()) UnDock(); else Dock(m_nLastDockPos); // and eat the message return 0; } break; case WM_NCHITTEST: if (IsDocked()) { UINT nHitTest = ScDefault(hRealWnd); // if the main window is _not_ unmaximized then don't let the // docked window be resized on it's docked edge // because its not intuitive and causes no end of trouble :) if (!IsMaximized()) { switch (m_nDockPos) { case DMP_LEFT: if (nHitTest == HTRIGHT || nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT) nHitTest = HTCLIENT; break; case DMP_RIGHT: if (nHitTest == HTLEFT || nHitTest == HTTOPLEFT || nHitTest == HTBOTTOMLEFT) nHitTest = HTCLIENT; break; case DMP_BELOW: if (nHitTest == HTTOP || nHitTest == HTTOPLEFT || nHitTest == HTTOPRIGHT) nHitTest = HTCLIENT; break; default: ASSERT(0); break; } } // else main window is maximized so _only_ let it be resized on its // docked edge and resize the main window afterwards else { switch (m_nDockPos) { case DMP_LEFT: if (nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT || nHitTest == HTLEFT || nHitTest == HTTOPLEFT || nHitTest == HTBOTTOMLEFT || nHitTest == HTTOP || nHitTest == HTBOTTOM) { nHitTest = HTCLIENT; } break; case DMP_RIGHT: if (nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT || nHitTest == HTRIGHT || nHitTest == HTTOPLEFT || nHitTest == HTBOTTOMLEFT || nHitTest == HTTOP || nHitTest == HTBOTTOM) { nHitTest = HTCLIENT; } break; case DMP_BELOW: if (nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT || nHitTest == HTRIGHT || nHitTest == HTTOPLEFT || nHitTest == HTBOTTOMLEFT || nHitTest == HTLEFT || nHitTest == HTBOTTOM) { nHitTest = HTCLIENT; } break; default: ASSERT(0); break; } } return nHitTest; } break; case WM_GETMINMAXINFO: if (IsDocked()) { LRESULT lr = ScDefault(hRealWnd); // save off our last min size LPMINMAXINFO pMMI = (LPMINMAXINFO)lp; m_sizeDockMin = pMMI->ptMinTrackSize; OnMinMaxInfo(pMMI, FALSE); return lr; } case WM_WINDOWPOSCHANGED: // if the dock window is being shown/hidden and the main window is maximized // then adjust the main window rect if (IsDocked() && IsMaximized()) { LPWINDOWPOS lpwp = (LPWINDOWPOS)lp; BOOL bVisible = ::IsWindowVisible(hRealWnd); BOOL bWantHide = (lpwp->flags & SWP_HIDEWINDOW); //BOOL bWantShow = (lpwp->flags & SWP_SHOWWINDOW); if (bVisible && bWantHide) // special case { CAutoFlag af(m_bResizeUpdate, FALSE); LRESULT lr = ScDefault(hRealWnd); CRect rMain = GetWorkArea(); MoveWindow(GetCWnd(), rMain); return lr; } else //if (!bVisible && bWantShow) { LRESULT lr = ScDefault(hRealWnd); OnMaximize(); return lr; } } break; } return ScDefault(hRealWnd); }