Files
libreoffice/vcl/source/window/dockwin.cxx
Michael Meeks 44cfc7cb65 re-base on ALv2 code. Includes (at least) relevant parts of:
linecap: Reintegrating finished LineCap feature
    Patch contributed by Regina Henschel
    http://svn.apache.org/viewvc?view=revision&revision=1232507

    Patches contributed by Sven Jacobi
    impress212: #i81610# fixed animation export
    http://svn.apache.org/viewvc?view=revision&revision=1167620
    impress212: drawinglayer gbuild environment changes
    http://svn.apache.org/viewvc?view=revision&revision=1167627
    http://svn.apache.org/viewvc?view=revision&revision=1167628
    impress212: DffPropSet -> minor code improvements, removing table
    http://svn.apache.org/viewvc?view=revision&revision=1167634
    impress212: #158494# fixed excel import (text rotation)
    http://svn.apache.org/viewvc?view=revision&revision=1167638

    Patches contributed by Armin Le Grand
    Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement
    http://svn.apache.org/viewvc?view=revision&revision=1220836
    #118728# changed indentifying definitions for Svg file detection
    http://svn.apache.org/viewvc?view=revision&revision=1229961
    #118838# LineGeometry creation for complicated cases optimized to
	create single Polygons
    http://svn.apache.org/viewvc?view=revision&revision=1236232
    #119176# corrected file type detection for SVG for svg files
	without xml header
    http://svn.apache.org/viewvc?view=revision&revision=1309445
    #118728# Extended Svg file detection
    http://svn.apache.org/viewvc?view=revision&revision=1230531
    #118529# solve break converters and convert commands for OLEs and images
    http://svn.apache.org/viewvc?view=revision&revision=1186168
    svg: added WaE changes from branch svgreplacement to trunc
    http://svn.apache.org/viewvc?view=revision&revision=1222974
    svg: corrected missing member initialization
    http://svn.apache.org/viewvc?view=revision&revision=1226134
    fix for #118525#: Using primitives for chart sub-geometry visualisation
    http://svn.apache.org/viewvc?view=revision&revision=1226879
    #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert
	metafiles to bitmapEx ...
    http://svn.apache.org/viewvc?view=revision&revision=1293316
    fix for #118525#: removed no longer used variable maOriginalMapMode, one
    more exception eliminated
    http://svn.apache.org/viewvc?view=revision&revision=1227097
    #16758# Added buffering to the VDev usages of the VclProcessor2D derivates...
    http://svn.apache.org/viewvc?view=revision&revision=1229521
    #116758# Secured VDev buffer device to Vcl deinit
    http://svn.apache.org/viewvc?view=revision&revision=1230574
    #116758# added remembering allocated VDevs for VDevBuffer to be able to also
    delete these when vcl goes down; it should never happen, but You never know
    http://svn.apache.org/viewvc?view=revision&revision=1230927
    #118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive
	representation instead of TransparencePrimitive2D
    http://svn.apache.org/viewvc?view=revision&revision=1231198
    #118822# secured 3D geometry creation (slices) by subdividing the 2D
    source polyPolygon early
    http://svn.apache.org/viewvc?view=revision&revision=1234749
    #118829# enhanced Svg gradient quality, obstacles avoided
    http://svn.apache.org/viewvc?view=revision&revision=1235361
    #118834# Unified usage of TextBreakupHelper as single tooling class
    for i18n text primitive breakup
    http://svn.apache.org/viewvc?view=revision&revision=1236110
    #118853# added square pixel size limit to conversion of
    TransparencePrimitive2D to Metafile action
    http://svn.apache.org/viewvc?view=revision&revision=1237656
    #118824# coreccted mirroring and boundrect when the graphicmanager
    is used for bitmap output
    http://svn.apache.org/viewvc?view=revision&revision=1240097
    #115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for
    various optimization scenarios
    http://svn.apache.org/viewvc?view=revision&revision=1241434
    #118783# Corrected errors in ID strings, corrected Svg line/fill export,
    corrected polygon close state
    http://svn.apache.org/viewvc?view=revision&revision=1232006
    #118796# corrected null-pointer usage in SVG text exporter
    http://svn.apache.org/viewvc?view=revision&revision=1240262
    #118729# Use GraphicStreamUrl and GraphicUrl to allow multi image
    import with linked graphics, too
    http://svn.apache.org/viewvc?view=revision&revision=1229962
    #118898# corrected error in GDIMetaFile::GetBoundRect in handling
    MetaFloatTransparentAction
    http://svn.apache.org/viewvc?view=revision&revision=1293349
    #118855# Corrected handling of possibly created empty clipRegions
    after PolyPolygon clipping
    http://svn.apache.org/viewvc?view=revision&revision=1237725
	#115962# Better (but not yet optimal, see comments in task) handling
	of MetaFloatTransparentAction in PDF export
	http://svn.apache.org/viewvc?view=revision&revision=1241078
    IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ...
    http://svn.apache.org/viewvc?view=revision&revision=1200879
    118779# Added svg content streaming in/out to ImpGraphic stream operators
    http://svn.apache.org/viewvc?view=revision&revision=1231908
    linecap: correctons for WaE and mac drawing
    http://svn.apache.org/viewvc?view=revision&revision=1232793
    svg: uses current system Dpi for Svg replacement image creation
    http://svn.apache.org/viewvc?view=revision&revision=1233948

    Patches contributed by Mathias Bauer (and others)
    gnumake4 work variously
    http://svn.apache.org/viewvc?view=revision&revision=1394326
    http://svn.apache.org/viewvc?view=revision&revision=1396797
    http://svn.apache.org/viewvc?view=revision&revision=1397315
    http://svn.apache.org/viewvc?view=revision&revision=1394326
    Remove duplicate header includes.
    cws mba34issues01: #i117720#: convert assertion into warning
    http://svn.apache.org/viewvc?view=revision&revision=1172352
    118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand.
    http://svn.apache.org/viewvc?view=revision&revision=1182166
    cws mba34issues01: #i117714#: remove assertion
    http://svn.apache.org/viewvc?view=revision&revision=1172357

    Patch contributed by Jurgen Schmidt
    add some additional checks to ensure proper reading operations
    http://svn.apache.org/viewvc?view=revision&revision=1209022
    mostly prefer our stream / bounds checking work.

    Patches contributed by Herbert Duerr
    #i118816# add clarifying comment regarding Font::*Color*() methods
    http://svn.apache.org/viewvc?view=revision&revision=1233833
    extend macro->string handling for empty strings
    http://svn.apache.org/viewvc?view=revision&revision=1175801
    avoid magic constants for SALCOLOR_NONE
    http://svn.apache.org/viewvc?view=revision&revision=1177543
    initialize slant properly in ImplFontMetricData constructor (author=iorsh)
    http://svn.apache.org/viewvc?view=revision&revision=1177551
    #i118675# make check for extension updates more stable
    http://svn.apache.org/viewvc?view=revision&revision=1214797
    #a118617# remove VBasicEventListener.dll binary
    There are no known users depending on its CLSID
    http://svn.apache.org/viewvc?view=revision&revision=1203697

    Patches contributed by Ariel Constenla-Haile
    Fix build breaker on Linux/gcc
    http://svn.apache.org/viewvc?view=revision&revision=1221104
    Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG
    http://svn.apache.org/viewvc?view=revision&revision=1215559

    Patches contributed by Oliver-Rainer Wittmann
    sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider
    instances of <SwFlyDrawObj>
    http://svn.apache.org/viewvc?view=revision&revision=1172120
    sw34bf06: #i117783# - Writer's implementation of XPagePrintable -
    apply print settings to new printing routines
    http://svn.apache.org/viewvc?view=revision&revision=1172115

    gnumake4 work variously from Hans-Joachim Lankenau
    http://svn.apache.org/viewvc?view=revision&revision=1397315
    http://svn.apache.org/viewvc?view=revision&revision=1396797
    http://svn.apache.org/viewvc?view=revision&revision=1396782
    http://svn.apache.org/viewvc?view=revision&revision=1394707
    plus some amount of re-splitting of legacy headers.

    Patch contributed by Pavel Janik
    WaE: Remove unused variables.
    http://svn.apache.org/viewvc?view=revision&revision=1230697

    Patches contributed by Takashi Ono
    mingwport35: i#117795: MinGW port fix for vcl2gnumake
    http://svn.apache.org/viewvc?view=revision&revision=1172091
    mingwport35: i#117795: MinGW port fix for vcl2gnumake
    http://svn.apache.org/viewvc?view=revision&revision=1172091

    Patch contributed by Christian Lippka
    impress212: #i98044# re enable Text menu for outline and title shapes
    http://svn.apache.org/viewvc?view=revision&revision=1167639

    Patch contributed by Andre Fischer
    118674: Made category B code optional and disabled by default.
    http://svn.apache.org/viewvc?view=revision&revision=1215131
    118881: Ignore empty paragraphs after bullets.
    http://svn.apache.org/viewvc?view=revision&revision=1296205

    Patches contributed by Philipp Lohmann
    ooo340fixes: #i117780# use rtl allocator
    http://svn.apache.org/viewvc?view=revision&revision=1172087
    ooo34gsl02: #i117807# fix an off by one error (index actually
    inside the pfb section header)
    http://svn.apache.org/viewvc?view=revision&revision=1167576

various cleanups, related compilation fixes, warning cleanups, re-working
of obsolete stl template pieces to use boost instead, changed string
classes, re-adapt KDE about data, about dialog, fixing warnings,
and other fixes & improvements.
Disable svg import / render for about/ branding code-paths for now.
Restore full icon theme set.
Remove OS/2 conditionals and sources.
Remove conflicting gtk/full-screen monitors support.
Retain existing svg rasterizer files - temporarily disabled.
Standardize stringificaiton and fixup dllpostfix issues.
Rename SvgGradientHelper::== to equalTo to avoid overloading issues.
Use the flat GdiPlus API for LineCaps calls.
2012-11-06 11:58:16 +00:00

1058 lines
33 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <tools/time.hxx>
#include <tools/rc.h>
#include <vcl/event.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/dockwin.hxx>
#include <vcl/svapp.hxx>
#include <vcl/timer.hxx>
#include <vcl/unowrap.hxx>
#include <svdata.hxx>
#include <window.h>
#include <brdwin.hxx>
#include <salframe.hxx>
// =======================================================================
#define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
// =======================================================================
// -----------------------------------------------------------------------
class DockingWindow::ImplData
{
public:
ImplData();
~ImplData();
Window* mpParent;
Size maMaxOutSize;
};
DockingWindow::ImplData::ImplData()
{
mpParent = NULL;
maMaxOutSize = Size( SHRT_MAX, SHRT_MAX );
}
DockingWindow::ImplData::~ImplData()
{
}
// -----------------------------------------------------------------------
class ImplDockFloatWin : public FloatingWindow
{
private:
DockingWindow* mpDockWin;
sal_uLong mnLastTicks;
Timer maDockTimer;
Point maDockPos;
Rectangle maDockRect;
sal_Bool mbInMove;
sal_uLong mnLastUserEvent;
DECL_LINK(DockingHdl, void *);
DECL_LINK(DockTimerHdl, void *);
public:
ImplDockFloatWin( Window* pParent, WinBits nWinBits,
DockingWindow* pDockingWin );
~ImplDockFloatWin();
virtual void Move();
virtual void Resize();
virtual void TitleButtonClick( sal_uInt16 nButton );
virtual void Pin();
virtual void Roll();
virtual void PopupModeEnd();
virtual void Resizing( Size& rSize );
virtual sal_Bool Close();
sal_uLong GetLastTicks() const { return mnLastTicks; }
};
ImplDockFloatWin::ImplDockFloatWin( Window* pParent, WinBits nWinBits,
DockingWindow* pDockingWin ) :
FloatingWindow( pParent, nWinBits ),
mpDockWin( pDockingWin ),
mnLastTicks( Time::GetSystemTicks() ),
mbInMove( sal_False ),
mnLastUserEvent( 0 )
{
// Daten vom DockingWindow uebernehmen
if ( pDockingWin )
{
SetSettings( pDockingWin->GetSettings() );
Enable( pDockingWin->IsEnabled(), sal_False );
EnableInput( pDockingWin->IsInputEnabled(), sal_False );
AlwaysEnableInput( pDockingWin->IsAlwaysEnableInput(), sal_False );
EnableAlwaysOnTop( pDockingWin->IsAlwaysOnTopEnabled() );
SetActivateMode( pDockingWin->GetActivateMode() );
}
SetBackground();
maDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin, DockTimerHdl ) );
maDockTimer.SetTimeout( 50 );
}
// -----------------------------------------------------------------------
ImplDockFloatWin::~ImplDockFloatWin()
{
if( mnLastUserEvent )
Application::RemoveUserEvent( mnLastUserEvent );
}
// -----------------------------------------------------------------------
IMPL_LINK_NOARG(ImplDockFloatWin, DockTimerHdl)
{
DBG_ASSERT( mpDockWin->IsFloatingMode(), "docktimer called but not floating" );
maDockTimer.Stop();
PointerState aState = GetPointerState();
if( aState.mnState & KEY_MOD1 )
{
// i43499 CTRL disables docking now
mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking();
mpDockWin->EndDocking( maDockRect, sal_True );
if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
maDockTimer.Start();
}
else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
{
mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking();
mpDockWin->EndDocking( maDockRect, sal_False );
}
else
{
mpDockWin->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
maDockTimer.Start();
}
return 0;
}
IMPL_LINK_NOARG(ImplDockFloatWin, DockingHdl)
{
PointerState aState = mpDockWin->GetParent()->GetPointerState();
mnLastUserEvent = 0;
if( mpDockWin->IsDockable() &&
(Time::GetSystemTicks() - mnLastTicks > 500) &&
( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
!(aState.mnState & KEY_MOD1) ) // i43499 CTRL disables docking now
{
maDockPos = Point( mpDockWin->GetParent()->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) );
maDockPos = mpDockWin->GetParent()->OutputToScreenPixel( maDockPos ); // sfx expects screen coordinates
if( ! mpDockWin->IsDocking() )
mpDockWin->StartDocking();
maDockRect = Rectangle( maDockPos, mpDockWin->GetSizePixel() );
// mouse pos also in screen pixels
Point aMousePos = mpDockWin->GetParent()->OutputToScreenPixel( aState.maPos );
sal_Bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
if( ! bFloatMode )
{
mpDockWin->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_OBJECT | SHOWTRACK_WINDOW );
DockTimerHdl( this );
}
else
{
mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking();
maDockTimer.Stop();
mpDockWin->EndDocking( maDockRect, sal_True );
}
}
mbInMove = sal_False;
return 0;
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::Move()
{
if( mbInMove )
return;
mbInMove = sal_True;
FloatingWindow::Move();
mpDockWin->Move();
/*
* note: the window should only dock if
* the user releases all mouse buttons. The real problem here
* is that we don't get mouse events (at least not on X)
* if the mouse is on the decoration. So we have to start an
* awkward timer based process that polls the modifier/buttons
* to see whether they are in the right condition shortly after the
* last Move message.
*/
if( ! mnLastUserEvent )
mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin, DockingHdl ) );
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::Resize()
{
FloatingWindow::Resize();
Size aSize( GetSizePixel() );
mpDockWin->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), WINDOW_POSSIZE_POSSIZE );
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::TitleButtonClick( sal_uInt16 nButton )
{
FloatingWindow::TitleButtonClick( nButton );
mpDockWin->TitleButtonClick( nButton );
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::Pin()
{
FloatingWindow::Pin();
mpDockWin->Pin();
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::Roll()
{
FloatingWindow::Roll();
mpDockWin->Roll();
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::PopupModeEnd()
{
FloatingWindow::PopupModeEnd();
mpDockWin->PopupModeEnd();
}
// -----------------------------------------------------------------------
void ImplDockFloatWin::Resizing( Size& rSize )
{
FloatingWindow::Resizing( rSize );
mpDockWin->Resizing( rSize );
}
// -----------------------------------------------------------------------
sal_Bool ImplDockFloatWin::Close()
{
return mpDockWin->Close();
}
// =======================================================================
sal_Bool DockingWindow::ImplStartDocking( const Point& rPos )
{
if ( !mbDockable )
return sal_False;
maMouseOff = rPos;
maMouseStart = maMouseOff;
mbDocking = sal_True;
mbLastFloatMode = IsFloatingMode();
mbStartFloat = mbLastFloatMode;
// FloatingBorder berechnen
FloatingWindow* pWin;
if ( mpFloatWin )
pWin = mpFloatWin;
else
pWin = new ImplDockFloatWin( mpImplData->mpParent, mnFloatBits, NULL );
pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
if ( !mpFloatWin )
delete pWin;
Point aPos = ImplOutputToFrame( Point() );
Size aSize = Window::GetOutputSizePixel();
mnTrackX = aPos.X();
mnTrackY = aPos.Y();
mnTrackWidth = aSize.Width();
mnTrackHeight = aSize.Height();
if ( mbLastFloatMode )
{
maMouseOff.X() += mnDockLeft;
maMouseOff.Y() += mnDockTop;
mnTrackX -= mnDockLeft;
mnTrackY -= mnDockTop;
mnTrackWidth += mnDockLeft+mnDockRight;
mnTrackHeight += mnDockTop+mnDockBottom;
}
if ( GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_DOCKING &&
!( mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ) ) // no full drag when migrating to system window
mbDragFull = sal_True;
else
{
StartDocking();
mbDragFull = sal_False;
ImplUpdateAll();
ImplGetFrameWindow()->ImplUpdateAll();
}
StartTracking( STARTTRACK_KEYMOD );
return sal_True;
}
// =======================================================================
void DockingWindow::ImplInitDockingWindowData()
{
mpImplData = new ImplData;
mpWindowImpl->mbDockWin = sal_True;
mpFloatWin = NULL;
mbDockCanceled = sal_False;
mbDockPrevented = sal_False;
mbFloatPrevented = sal_False;
mbDocking = sal_False;
mbPined = sal_False;
mbRollUp = sal_False;
mbDockBtn = sal_False;
mbHideBtn = sal_False;
}
// -----------------------------------------------------------------------
void DockingWindow::ImplInit( Window* pParent, WinBits nStyle )
{
if ( !(nStyle & WB_NODIALOGCONTROL) )
nStyle |= WB_DIALOGCONTROL;
mpImplData->mpParent = pParent;
mbDockable = (nStyle & WB_DOCKABLE) != 0;
mnFloatBits = WB_BORDER | (nStyle & DOCKWIN_FLOATSTYLES);
nStyle &= ~(DOCKWIN_FLOATSTYLES | WB_BORDER);
if ( nStyle & WB_DOCKBORDER )
nStyle |= WB_BORDER;
Window::ImplInit( pParent, nStyle, NULL );
ImplInitSettings();
}
// -----------------------------------------------------------------------
void DockingWindow::ImplInitSettings()
{
// Hack, damit man auch DockingWindows ohne Hintergrund bauen kann
// und noch nicht alles umgestellt ist
if ( IsBackground() )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
Color aColor;
if ( IsControlBackground() )
aColor = GetControlBackground();
else if ( Window::GetStyle() & WB_3DLOOK )
aColor = rStyleSettings.GetFaceColor();
else
aColor = rStyleSettings.GetWindowColor();
SetBackground( aColor );
}
}
// -----------------------------------------------------------------------
void DockingWindow::ImplLoadRes( const ResId& rResId )
{
Window::ImplLoadRes( rResId );
sal_uLong nMask = ReadLongRes();
if ( (RSC_DOCKINGWINDOW_XYMAPMODE | RSC_DOCKINGWINDOW_X |
RSC_DOCKINGWINDOW_Y) & nMask )
{
// Groessenangabe aus der Resource verwenden
Point aPos;
MapUnit ePosMap = MAP_PIXEL;
if ( RSC_DOCKINGWINDOW_XYMAPMODE & nMask )
ePosMap = (MapUnit)ReadLongRes();
if ( RSC_DOCKINGWINDOW_X & nMask )
{
aPos.X() = ReadShortRes();
aPos.X() = ImplLogicUnitToPixelX( aPos.X(), ePosMap );
}
if ( RSC_DOCKINGWINDOW_Y & nMask )
{
aPos.Y() = ReadShortRes();
aPos.Y() = ImplLogicUnitToPixelY( aPos.Y(), ePosMap );
}
SetFloatingPos( aPos );
}
if ( nMask & RSC_DOCKINGWINDOW_FLOATING )
{
if ( (sal_Bool)ReadShortRes() )
SetFloatingMode( sal_True );
}
}
// -----------------------------------------------------------------------
DockingWindow::DockingWindow( WindowType nType ) :
Window( nType )
{
ImplInitDockingWindowData();
}
// -----------------------------------------------------------------------
DockingWindow::DockingWindow( Window* pParent, WinBits nStyle ) :
Window( WINDOW_DOCKINGWINDOW )
{
ImplInitDockingWindowData();
ImplInit( pParent, nStyle );
}
// -----------------------------------------------------------------------
DockingWindow::DockingWindow( Window* pParent, const ResId& rResId ) :
Window( WINDOW_DOCKINGWINDOW )
{
ImplInitDockingWindowData();
rResId.SetRT( RSC_DOCKINGWINDOW );
WinBits nStyle = ImplInitRes( rResId );
ImplInit( pParent, nStyle );
ImplLoadRes( rResId );
if ( !(nStyle & WB_HIDE) )
Show();
}
// -----------------------------------------------------------------------
DockingWindow::~DockingWindow()
{
if ( IsFloatingMode() )
{
Show( sal_False, SHOW_NOFOCUSCHANGE );
SetFloatingMode( sal_False );
}
delete mpImplData;
}
// -----------------------------------------------------------------------
void DockingWindow::Tracking( const TrackingEvent& rTEvt )
{
if( GetDockingManager()->IsDockable( this ) ) // new docking interface
return Window::Tracking( rTEvt );
if ( mbDocking )
{
if ( rTEvt.IsTrackingEnded() )
{
mbDocking = sal_False;
if ( mbDragFull )
{
// Bei Abbruch alten Zustand wieder herstellen
if ( rTEvt.IsTrackingCanceled() )
{
StartDocking();
Rectangle aRect( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) );
EndDocking( aRect, mbStartFloat );
}
}
else
{
HideTracking();
if ( rTEvt.IsTrackingCanceled() )
{
mbDockCanceled = sal_True;
EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
mbDockCanceled = sal_False;
}
else
EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
}
}
// Docking nur bei nicht synthetischen MouseEvents
else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
{
Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
Point aFrameMousePos = ImplOutputToFrame( aMousePos );
Size aFrameSize = mpWindowImpl->mpFrameWindow->GetOutputSizePixel();
if ( aFrameMousePos.X() < 0 )
aFrameMousePos.X() = 0;
if ( aFrameMousePos.Y() < 0 )
aFrameMousePos.Y() = 0;
if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
aFrameMousePos.X() = aFrameSize.Width()-1;
if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
aFrameMousePos.Y() = aFrameSize.Height()-1;
aMousePos = ImplFrameToOutput( aFrameMousePos );
aMousePos.X() -= maMouseOff.X();
aMousePos.Y() -= maMouseOff.Y();
Point aFramePos = ImplOutputToFrame( aMousePos );
Rectangle aTrackRect( aFramePos, Size( mnTrackWidth, mnTrackHeight ) );
Rectangle aCompRect = aTrackRect;
aFramePos.X() += maMouseOff.X();
aFramePos.Y() += maMouseOff.Y();
if ( mbDragFull )
StartDocking();
sal_Bool bFloatMode = Docking( aFramePos, aTrackRect );
mbDockPrevented = sal_False;
mbFloatPrevented = sal_False;
if ( mbLastFloatMode != bFloatMode )
{
if ( bFloatMode )
{
aTrackRect.Left() -= mnDockLeft;
aTrackRect.Top() -= mnDockTop;
aTrackRect.Right() += mnDockRight;
aTrackRect.Bottom() += mnDockBottom;
}
else
{
if ( aCompRect == aTrackRect )
{
aTrackRect.Left() += mnDockLeft;
aTrackRect.Top() += mnDockTop;
aTrackRect.Right() -= mnDockRight;
aTrackRect.Bottom() -= mnDockBottom;
}
}
mbLastFloatMode = bFloatMode;
}
if ( mbDragFull )
{
Point aPos;
Point aOldPos = OutputToScreenPixel( aPos );
EndDocking( aTrackRect, mbLastFloatMode );
// Wenn der Status bzw. die Position sich
// geaendert hat, dann neu ausgeben
if ( aOldPos != OutputToScreenPixel( aPos ) )
{
ImplUpdateAll();
ImplGetFrameWindow()->ImplUpdateAll();
}
// EndDocking( aTrackRect, mbLastFloatMode );
}
else
{
sal_uInt16 nTrackStyle;
if ( bFloatMode )
nTrackStyle = SHOWTRACK_BIG;
else
nTrackStyle = SHOWTRACK_OBJECT;
Rectangle aShowTrackRect = aTrackRect;
aShowTrackRect.SetPos( ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
ShowTracking( aShowTrackRect, nTrackStyle );
// Maus-Offset neu berechnen, da Rechteck veraendert werden
// konnte
maMouseOff.X() = aFramePos.X() - aTrackRect.Left();
maMouseOff.Y() = aFramePos.Y() - aTrackRect.Top();
}
mnTrackX = aTrackRect.Left();
mnTrackY = aTrackRect.Top();
mnTrackWidth = aTrackRect.GetWidth();
mnTrackHeight = aTrackRect.GetHeight();
}
}
}
// -----------------------------------------------------------------------
long DockingWindow::Notify( NotifyEvent& rNEvt )
{
if( GetDockingManager()->IsDockable( this ) ) // new docking interface
return Window::Notify( rNEvt );
if ( mbDockable )
{
if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
{
const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
if ( pMEvt->IsLeft() )
{
if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
{
SetFloatingMode( !IsFloatingMode() );
return sal_True;
}
else if ( pMEvt->GetClicks() == 1 )
{
// check if window is floating standalone (IsFloating())
// or only partially floating and still docked with one border
// ( !mpWindowImpl->mbFrame)
if( ! IsFloatingMode() || ! mpFloatWin->mpWindowImpl->mbFrame )
{
Point aPos = pMEvt->GetPosPixel();
Window* pWindow = rNEvt.GetWindow();
if ( pWindow != this )
{
aPos = pWindow->OutputToScreenPixel( aPos );
aPos = ScreenToOutputPixel( aPos );
}
ImplStartDocking( aPos );
}
return sal_True;
}
}
}
else if( rNEvt.GetType() == EVENT_KEYINPUT )
{
const KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
rKey.IsShift() && rKey.IsMod1() )
{
SetFloatingMode( !IsFloatingMode() );
return sal_True;
}
}
}
return Window::Notify( rNEvt );
}
// -----------------------------------------------------------------------
void DockingWindow::StartDocking()
{
mbDocking = sal_True;
}
// -----------------------------------------------------------------------
sal_Bool DockingWindow::Docking( const Point&, Rectangle& )
{
return IsFloatingMode();
}
// -----------------------------------------------------------------------
void DockingWindow::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
{
if ( !IsDockingCanceled() )
{
sal_Bool bShow = sal_False;
if ( bFloatMode != IsFloatingMode() )
{
Show( sal_False, SHOW_NOFOCUSCHANGE );
SetFloatingMode( bFloatMode );
bShow = sal_True;
if ( bFloatMode && mpFloatWin )
mpFloatWin->SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() );
}
if ( !bFloatMode )
{
Point aPos = rRect.TopLeft();
aPos = GetParent()->ScreenToOutputPixel( aPos );
Window::SetPosSizePixel( aPos, rRect.GetSize() );
}
if ( bShow )
Show();
}
mbDocking = sal_False;
}
// -----------------------------------------------------------------------
sal_Bool DockingWindow::PrepareToggleFloatingMode()
{
return sal_True;
}
// -----------------------------------------------------------------------
sal_Bool DockingWindow::Close()
{
ImplDelData aDelData;
ImplAddDel( &aDelData );
ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
if ( aDelData.IsDead() )
return sal_False;
ImplRemoveDel( &aDelData );
if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() )
return sal_False;
Show( sal_False, SHOW_NOFOCUSCHANGE );
return sal_True;
}
// -----------------------------------------------------------------------
void DockingWindow::ToggleFloatingMode()
{
}
// -----------------------------------------------------------------------
void DockingWindow::TitleButtonClick( sal_uInt16 )
{
}
// -----------------------------------------------------------------------
void DockingWindow::Pin()
{
}
// -----------------------------------------------------------------------
void DockingWindow::Roll()
{
}
// -----------------------------------------------------------------------
void DockingWindow::PopupModeEnd()
{
}
// -----------------------------------------------------------------------
void DockingWindow::Resizing( Size& )
{
}
// -----------------------------------------------------------------------
void DockingWindow::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
{
ImplInitSettings();
Invalidate();
}
Window::StateChanged( nType );
}
// -----------------------------------------------------------------------
void DockingWindow::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
{
ImplInitSettings();
Invalidate();
}
else
Window::DataChanged( rDCEvt );
}
// -----------------------------------------------------------------------
void DockingWindow::SetFloatingMode( sal_Bool bFloatMode )
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
pWrapper->SetFloatingMode( bFloatMode );
return;
}
if ( IsFloatingMode() != bFloatMode )
{
if ( PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed
{
sal_Bool bVisible = IsVisible();
if ( bFloatMode )
{
Show( sal_False, SHOW_NOFOCUSCHANGE );
maDockPos = Window::GetPosPixel();
Window* pRealParent = mpWindowImpl->mpRealParent;
mpOldBorderWin = mpWindowImpl->mpBorderWindow;
ImplDockFloatWin* pWin =
new ImplDockFloatWin(
mpImplData->mpParent,
mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits,
this );
mpFloatWin = pWin;
mpWindowImpl->mpBorderWindow = NULL;
mpWindowImpl->mnLeftBorder = 0;
mpWindowImpl->mnTopBorder = 0;
mpWindowImpl->mnRightBorder = 0;
mpWindowImpl->mnBottomBorder = 0;
// Falls Parent zerstoert wird, muessen wir auch vom
// BorderWindow den Parent umsetzen
if ( mpOldBorderWin )
mpOldBorderWin->SetParent( pWin );
SetParent( pWin );
SetPosPixel( Point() );
mpWindowImpl->mpBorderWindow = pWin;
pWin->mpWindowImpl->mpClientWindow = this;
mpWindowImpl->mpRealParent = pRealParent;
pWin->SetText( Window::GetText() );
pWin->SetOutputSizePixel( Window::GetSizePixel() );
pWin->SetPosPixel( maFloatPos );
// DockingDaten ans FloatingWindow weiterreichen
pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, mbDockBtn );
pWin->ShowTitleButton( TITLE_BUTTON_HIDE, mbHideBtn );
pWin->SetPin( mbPined );
if ( mbRollUp )
pWin->RollUp();
else
pWin->RollDown();
pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
pWin->SetMinOutputSizePixel( maMinOutSize );
pWin->SetMaxOutputSizePixel( mpImplData->maMaxOutSize );
ToggleFloatingMode();
if ( bVisible )
Show();
}
else
{
Show( sal_False, SHOW_NOFOCUSCHANGE );
// FloatingDaten wird im FloatingWindow speichern
maFloatPos = mpFloatWin->GetPosPixel();
mbDockBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING );
mbHideBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE );
mbPined = mpFloatWin->IsPined();
mbRollUp = mpFloatWin->IsRollUp();
maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
mpImplData->maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel();
Window* pRealParent = mpWindowImpl->mpRealParent;
mpWindowImpl->mpBorderWindow = NULL;
if ( mpOldBorderWin )
{
SetParent( mpOldBorderWin );
((ImplBorderWindow*)mpOldBorderWin)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
mpOldBorderWin->Resize();
}
mpWindowImpl->mpBorderWindow = mpOldBorderWin;
SetParent( pRealParent );
mpWindowImpl->mpRealParent = pRealParent;
delete static_cast<ImplDockFloatWin*>(mpFloatWin);
mpFloatWin = NULL;
SetPosPixel( maDockPos );
ToggleFloatingMode();
if ( bVisible )
Show();
}
}
}
}
// -----------------------------------------------------------------------
void DockingWindow::SetFloatStyle( WinBits nStyle )
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
pWrapper->SetFloatStyle( nStyle );
return;
}
mnFloatBits = nStyle;
}
// -----------------------------------------------------------------------
WinBits DockingWindow::GetFloatStyle() const
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
return pWrapper->GetFloatStyle();
}
return mnFloatBits;
}
// -----------------------------------------------------------------------
void DockingWindow::setPosSizePixel( long nX, long nY,
long nWidth, long nHeight,
sal_uInt16 nFlags )
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
if ( pWrapper->mpFloatWin )
pWrapper->mpFloatWin->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
else
Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
return;
}
if ( mpFloatWin )
mpFloatWin->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
else
Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
}
// -----------------------------------------------------------------------
Point DockingWindow::GetPosPixel() const
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
if ( pWrapper->mpFloatWin )
return pWrapper->mpFloatWin->GetPosPixel();
else
return Window::GetPosPixel();
}
if ( mpFloatWin )
return mpFloatWin->GetPosPixel();
else
return Window::GetPosPixel();
}
// -----------------------------------------------------------------------
Size DockingWindow::GetSizePixel() const
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
if ( pWrapper->mpFloatWin )
return pWrapper->mpFloatWin->GetSizePixel();
else
return Window::GetSizePixel();
}
if ( mpFloatWin )
return mpFloatWin->GetSizePixel();
else
return Window::GetSizePixel();
}
// -----------------------------------------------------------------------
void DockingWindow::SetOutputSizePixel( const Size& rNewSize )
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
if ( pWrapper->mpFloatWin )
pWrapper->mpFloatWin->SetOutputSizePixel( rNewSize );
else
Window::SetOutputSizePixel( rNewSize );
return;
}
if ( mpFloatWin )
mpFloatWin->SetOutputSizePixel( rNewSize );
else
Window::SetOutputSizePixel( rNewSize );
}
// -----------------------------------------------------------------------
Size DockingWindow::GetOutputSizePixel() const
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
if ( pWrapper->mpFloatWin )
return pWrapper->mpFloatWin->GetOutputSizePixel();
else
return Window::GetOutputSizePixel();
}
if ( mpFloatWin )
return mpFloatWin->GetOutputSizePixel();
else
return Window::GetOutputSizePixel();
}
Point DockingWindow::GetFloatingPos() const
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
{
if ( pWrapper->mpFloatWin )
{
WindowStateData aData;
aData.SetMask( WINDOWSTATE_MASK_POS );
pWrapper->mpFloatWin->GetWindowStateData( aData );
Point aPos( aData.GetX(), aData.GetY() );
aPos = pWrapper->mpFloatWin->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos );
return aPos;
}
else
return maFloatPos;
}
if ( mpFloatWin )
{
WindowStateData aData;
aData.SetMask( WINDOWSTATE_MASK_POS );
mpFloatWin->GetWindowStateData( aData );
Point aPos( aData.GetX(), aData.GetY() );
aPos = mpFloatWin->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos );
return aPos;
}
else
return maFloatPos;
}
sal_Bool DockingWindow::IsFloatingMode() const
{
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper )
return pWrapper->IsFloatingMode();
else
return (mpFloatWin != NULL);
}
void DockingWindow::SetMaxOutputSizePixel( const Size& rSize )
{
if ( mpFloatWin )
mpFloatWin->SetMaxOutputSizePixel( rSize );
mpImplData->maMaxOutSize = rSize;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */