2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 08:07:02 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 08:07:02 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 08:07:02 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 08:07:02 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 08:07:02 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 08:07:02 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 11:16:48 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_vcl.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
|
|
|
#ifndef _SV_RC_H
|
2004-01-06 13:06:29 +00:00
|
|
|
#include <tools/rc.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2007-06-27 19:29:22 +00:00
|
|
|
#include <vcl/svdata.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2007-07-24 09:20:10 +00:00
|
|
|
#include <vcl/window.h>
|
2007-06-27 19:29:22 +00:00
|
|
|
#include <vcl/event.hxx>
|
2007-07-24 09:20:10 +00:00
|
|
|
#include <vcl/brdwin.hxx>
|
2007-06-27 19:29:22 +00:00
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#include <vcl/button.hxx>
|
|
|
|
#include <vcl/mnemonic.hxx>
|
|
|
|
#include <vcl/dialog.hxx>
|
|
|
|
#include <vcl/decoview.hxx>
|
2001-02-14 17:11:46 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifdef DBG_UTIL
|
2007-06-27 19:29:22 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
2007-06-27 19:29:22 +00:00
|
|
|
#include <vcl/unowrap.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-12-01 12:37:35 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
|
|
|
|
static ByteString ImplGetDialogText( Dialog* pDialog )
|
|
|
|
{
|
|
|
|
ByteString aErrorStr( pDialog->GetText(), RTL_TEXTENCODING_UTF8 );
|
|
|
|
if ( (pDialog->GetType() == WINDOW_MESSBOX) ||
|
|
|
|
(pDialog->GetType() == WINDOW_INFOBOX) ||
|
|
|
|
(pDialog->GetType() == WINDOW_WARNINGBOX) ||
|
|
|
|
(pDialog->GetType() == WINDOW_ERRORBOX) ||
|
|
|
|
(pDialog->GetType() == WINDOW_QUERYBOX) )
|
|
|
|
{
|
|
|
|
aErrorStr += ", ";
|
|
|
|
aErrorStr += ByteString( ((MessBox*)pDialog)->GetMessText(), RTL_TEXTENCODING_UTF8 );
|
|
|
|
}
|
|
|
|
return aErrorStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
static sal_Bool ImplIsMnemonicCtrl( Window* pWindow )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-03-27 16:59:30 +00:00
|
|
|
if( ! pWindow->GetSettings().GetStyleSettings().GetAutoMnemonic() )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2003-03-27 16:59:30 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( (pWindow->GetType() == WINDOW_RADIOBUTTON) ||
|
|
|
|
(pWindow->GetType() == WINDOW_CHECKBOX) ||
|
|
|
|
(pWindow->GetType() == WINDOW_TRISTATEBOX) ||
|
|
|
|
(pWindow->GetType() == WINDOW_PUSHBUTTON) )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( pWindow->GetType() == WINDOW_FIXEDTEXT )
|
|
|
|
{
|
|
|
|
if ( pWindow->GetStyle() & (WB_INFO | WB_NOLABEL) )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
Window* pNextWindow = pWindow->GetWindow( WINDOW_NEXT );
|
|
|
|
if ( !pNextWindow )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
pNextWindow = pNextWindow->GetWindow( WINDOW_CLIENT );
|
|
|
|
if ( !(pNextWindow->GetStyle() & WB_TABSTOP) ||
|
|
|
|
(pNextWindow->GetType() == WINDOW_FIXEDTEXT) ||
|
|
|
|
(pNextWindow->GetType() == WINDOW_GROUPBOX) ||
|
|
|
|
(pNextWindow->GetType() == WINDOW_RADIOBUTTON) ||
|
|
|
|
(pNextWindow->GetType() == WINDOW_CHECKBOX) ||
|
|
|
|
(pNextWindow->GetType() == WINDOW_TRISTATEBOX) ||
|
|
|
|
(pNextWindow->GetType() == WINDOW_PUSHBUTTON) )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ImplWindowAutoMnemonic( Window* pWindow )
|
|
|
|
{
|
2002-05-16 10:22:20 +00:00
|
|
|
MnemonicGenerator aMnemonicGenerator;
|
2000-09-18 16:07:07 +00:00
|
|
|
Window* pGetChild;
|
|
|
|
Window* pChild;
|
|
|
|
|
|
|
|
// Die schon vergebenen Mnemonics registieren
|
|
|
|
pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
|
|
|
|
while ( pGetChild )
|
|
|
|
{
|
|
|
|
pChild = pGetChild->ImplGetWindow();
|
|
|
|
aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
|
|
|
|
pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bei TabPages auch noch die Controls vom Dialog beruecksichtigen
|
|
|
|
if ( pWindow->GetType() == WINDOW_TABPAGE )
|
|
|
|
{
|
|
|
|
Window* pParent = pWindow->GetParent();
|
|
|
|
if ( pParent->GetType() == WINDOW_TABCONTROL )
|
|
|
|
pParent = pParent->GetParent();
|
|
|
|
|
|
|
|
if ( (pParent->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
|
|
|
|
{
|
2003-03-27 16:59:30 +00:00
|
|
|
pGetChild = pParent->GetWindow( WINDOW_FIRSTCHILD );
|
2000-09-18 16:07:07 +00:00
|
|
|
while ( pGetChild )
|
|
|
|
{
|
|
|
|
pChild = pGetChild->ImplGetWindow();
|
|
|
|
aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
|
|
|
|
pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Die Mnemonics an die Controls vergeben, die noch keinen haben
|
|
|
|
pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
|
|
|
|
while ( pGetChild )
|
|
|
|
{
|
|
|
|
pChild = pGetChild->ImplGetWindow();
|
|
|
|
if ( ImplIsMnemonicCtrl( pChild ) )
|
|
|
|
{
|
|
|
|
XubString aText = pChild->GetText();
|
|
|
|
if ( aMnemonicGenerator.CreateMnemonic( aText ) )
|
|
|
|
pChild->SetText( aText );
|
|
|
|
}
|
|
|
|
|
|
|
|
pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
static PushButton* ImplGetDefaultButton( Dialog* pDialog )
|
|
|
|
{
|
|
|
|
Window* pChild = pDialog->GetWindow( WINDOW_FIRSTCHILD );
|
|
|
|
while ( pChild )
|
|
|
|
{
|
|
|
|
if ( pChild->ImplIsPushButton() )
|
|
|
|
{
|
|
|
|
PushButton* pPushButton = (PushButton*)pChild;
|
|
|
|
if ( pPushButton->ImplIsDefButton() )
|
|
|
|
return pPushButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
pChild = pChild->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static PushButton* ImplGetOKButton( Dialog* pDialog )
|
|
|
|
{
|
|
|
|
Window* pChild = pDialog->GetWindow( WINDOW_FIRSTCHILD );
|
|
|
|
while ( pChild )
|
|
|
|
{
|
|
|
|
if ( pChild->GetType() == WINDOW_OKBUTTON )
|
|
|
|
return (PushButton*)pChild;
|
|
|
|
|
|
|
|
pChild = pChild->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static PushButton* ImplGetCancelButton( Dialog* pDialog )
|
|
|
|
{
|
|
|
|
Window* pChild = pDialog->GetWindow( WINDOW_FIRSTCHILD );
|
|
|
|
while ( pChild )
|
|
|
|
{
|
|
|
|
if ( pChild->GetType() == WINDOW_CANCELBUTTON )
|
|
|
|
return (PushButton*)pChild;
|
|
|
|
|
|
|
|
pChild = pChild->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void ImplMouseAutoPos( Dialog* pDialog )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uIntPtr nMouseOptions = pDialog->GetSettings().GetMouseSettings().GetOptions();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nMouseOptions & MOUSE_OPTION_AUTOCENTERPOS )
|
|
|
|
{
|
|
|
|
Size aSize = pDialog->GetOutputSizePixel();
|
|
|
|
pDialog->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
|
|
|
|
}
|
|
|
|
else if ( nMouseOptions & MOUSE_OPTION_AUTODEFBTNPOS )
|
|
|
|
{
|
|
|
|
Window* pWindow = ImplGetDefaultButton( pDialog );
|
|
|
|
if ( !pWindow )
|
|
|
|
pWindow = ImplGetOKButton( pDialog );
|
|
|
|
if ( !pWindow )
|
|
|
|
pWindow = ImplGetCancelButton( pDialog );
|
|
|
|
if ( !pWindow )
|
|
|
|
pWindow = pDialog;
|
|
|
|
Size aSize = pWindow->GetOutputSizePixel();
|
|
|
|
pWindow->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2006-11-22 09:40:03 +00:00
|
|
|
struct DialogImpl
|
|
|
|
{
|
|
|
|
long mnResult;
|
|
|
|
bool mbStartedModal;
|
|
|
|
Link maEndDialogHdl;
|
|
|
|
|
|
|
|
DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2006-06-19 18:36:16 +00:00
|
|
|
void Dialog::ImplInitDialogData()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
mpWindowImpl->mbDialog = sal_True;
|
2006-11-22 09:40:03 +00:00
|
|
|
mpDialogParent = NULL;
|
|
|
|
mpPrevExecuteDlg = NULL;
|
2010-09-29 15:46:40 +08:00
|
|
|
mbInExecute = sal_False;
|
|
|
|
mbOldSaveBack = sal_False;
|
|
|
|
mbInClose = sal_False;
|
|
|
|
mbModalMode = sal_False;
|
2006-11-22 09:40:03 +00:00
|
|
|
mnMousePositioned = 0;
|
|
|
|
mpDialogImpl = new DialogImpl;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 nSysWinMode = Application::GetSystemWindowMode();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !(nStyle & WB_NODIALOGCONTROL) )
|
|
|
|
nStyle |= WB_DIALOGCONTROL;
|
|
|
|
nStyle |= WB_ROLLABLE;
|
|
|
|
|
2000-12-01 15:34:15 +00:00
|
|
|
// Now, all Dialogs are per default system windows !!!
|
|
|
|
nStyle |= WB_SYSTEMWINDOW;
|
|
|
|
|
2002-05-16 10:22:20 +00:00
|
|
|
|
2003-11-05 13:28:59 +00:00
|
|
|
// parent is NULL: get the default Dialog parent
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pParent )
|
|
|
|
{
|
|
|
|
pParent = Application::GetDefDialogParent();
|
|
|
|
if ( !pParent && !(nStyle & WB_SYSTEMWINDOW) )
|
2004-01-06 13:06:29 +00:00
|
|
|
pParent = ImplGetSVData()->maWinData.mpAppWin;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// If Parent is disabled, then we search for a modal dialog
|
|
|
|
// in this frame
|
2007-11-26 14:13:56 +00:00
|
|
|
if ( pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
|
|
|
|
while ( pExeDlg )
|
|
|
|
{
|
|
|
|
// Nur wenn er sichtbar und enabled ist
|
2010-09-29 15:46:40 +08:00
|
|
|
if ( pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild( pExeDlg, sal_True ) &&
|
2000-09-18 16:07:07 +00:00
|
|
|
pExeDlg->IsReallyVisible() &&
|
2007-11-26 14:13:56 +00:00
|
|
|
pExeDlg->IsEnabled() && pExeDlg->IsInputEnabled() && !pExeDlg->IsInModalMode() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pParent = pExeDlg;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pExeDlg = pExeDlg->mpPrevExecuteDlg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-05 13:28:59 +00:00
|
|
|
// DIALOG_NO_PARENT: explicitly don't have a parent for this Dialog
|
|
|
|
else if( pParent == DIALOG_NO_PARENT )
|
|
|
|
pParent = NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-01 15:34:15 +00:00
|
|
|
/*
|
|
|
|
// Now, all Dialogs are per default system windows !!!
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pParent && !(nSysWinMode & SYSTEMWINDOW_MODE_NOAUTOMODE) )
|
|
|
|
{
|
2005-01-13 17:02:52 +00:00
|
|
|
if ( !pParent->mpWindowImpl->mpFrameWindow->IsVisible() )
|
2000-09-18 16:07:07 +00:00
|
|
|
pParent = NULL;
|
|
|
|
else
|
|
|
|
{
|
2005-01-13 17:02:52 +00:00
|
|
|
if ( pParent->mpWindowImpl->mpFrameWindow->IsDialog() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-01-13 17:02:52 +00:00
|
|
|
Size aOutSize = pParent->mpWindowImpl->mpFrameWindow->GetOutputSizePixel();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( (aOutSize.Width() < 210) ||(aOutSize.Height() < 160) )
|
|
|
|
nStyle |= WB_SYSTEMWINDOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-12-01 15:34:15 +00:00
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !pParent || (nStyle & WB_SYSTEMWINDOW) ||
|
2005-01-13 17:02:52 +00:00
|
|
|
(pParent->mpWindowImpl->mpFrameData->mbNeedSysWindow && !(nSysWinMode & SYSTEMWINDOW_MODE_NOAUTOMODE)) ||
|
2000-09-18 16:07:07 +00:00
|
|
|
(nSysWinMode & SYSTEMWINDOW_MODE_DIALOG) )
|
|
|
|
{
|
2001-11-01 13:49:00 +00:00
|
|
|
// create window with a small border ?
|
2001-11-07 07:33:55 +00:00
|
|
|
if ( (nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
|
|
|
|
SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
|
2005-01-13 17:02:52 +00:00
|
|
|
pBorderWin->mpWindowImpl->mpClientWindow = this;
|
|
|
|
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
|
|
|
|
mpWindowImpl->mpBorderWindow = pBorderWin;
|
|
|
|
mpWindowImpl->mpRealParent = pParent;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
mpWindowImpl->mbFrame = sal_True;
|
|
|
|
mpWindowImpl->mbOverlapWin = sal_True;
|
2009-04-01 11:54:14 +00:00
|
|
|
SystemWindow::ImplInit( pParent, (nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_CLOSEABLE | WB_STANDALONE)) | WB_CLOSEABLE, NULL );
|
2001-11-01 13:49:00 +00:00
|
|
|
// Now set all style bits
|
2005-01-13 17:02:52 +00:00
|
|
|
mpWindowImpl->mnStyle = nStyle;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
|
|
|
|
SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
|
2005-01-13 17:02:52 +00:00
|
|
|
pBorderWin->mpWindowImpl->mpClientWindow = this;
|
|
|
|
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
|
|
|
|
mpWindowImpl->mpBorderWindow = pBorderWin;
|
|
|
|
mpWindowImpl->mpRealParent = pParent;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
|
|
|
|
|
|
|
|
ImplInitSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::ImplInitSettings()
|
|
|
|
{
|
2007-07-05 07:41:12 +00:00
|
|
|
// user override
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
2007-07-05 07:41:12 +00:00
|
|
|
// NWF background
|
|
|
|
else if( IsNativeControlSupported( CTRL_WINDOW_BACKGROUND, PART_BACKGROUND_DIALOG ) )
|
|
|
|
{
|
|
|
|
mpWindowImpl->mnNativeBackground = PART_BACKGROUND_DIALOG;
|
2010-09-29 15:46:40 +08:00
|
|
|
EnableChildTransparentMode( sal_True );
|
2007-07-05 07:41:12 +00:00
|
|
|
}
|
|
|
|
// fallback to settings color
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
SetBackground( GetSettings().GetStyleSettings().GetDialogColor() );
|
2007-07-05 07:41:12 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::ImplCenterDialog()
|
|
|
|
{
|
|
|
|
Rectangle aDeskRect = ImplGetFrameWindow()->GetDesktopRectPixel();
|
|
|
|
Point aDeskPos = aDeskRect.TopLeft();
|
|
|
|
Size aDeskSize = aDeskRect.GetSize();
|
|
|
|
Size aWinSize = GetSizePixel();
|
2001-10-24 07:57:18 +00:00
|
|
|
Window *pWindow = this;
|
2005-01-13 17:02:52 +00:00
|
|
|
while ( pWindow->mpWindowImpl->mpBorderWindow )
|
|
|
|
pWindow = pWindow->mpWindowImpl->mpBorderWindow;
|
2000-09-18 16:07:07 +00:00
|
|
|
Point aWinPos( ((aDeskSize.Width() - aWinSize.Width()) / 2) + aDeskPos.X(),
|
|
|
|
((aDeskSize.Height() - aWinSize.Height()) / 2) + aDeskPos.Y() );
|
|
|
|
|
|
|
|
// Pruefen, ob Dialogbox ausserhalb des Desks liegt
|
|
|
|
if ( (aWinPos.X() + aWinSize.Width()) > (aDeskPos.X()+aDeskSize.Width()) )
|
|
|
|
aWinPos.X() = aDeskPos.X()+aDeskSize.Width() - aWinSize.Width();
|
|
|
|
if ( (aWinPos.Y()+aWinSize.Height()) > (aDeskPos.Y()+aDeskSize.Height()) )
|
|
|
|
aWinPos.Y() = aDeskPos.Y()+aDeskSize.Height() - aWinSize.Height();
|
|
|
|
// Linke Ecke bevorzugen, da Titelbar oben ist
|
|
|
|
if ( aWinPos.X() < aDeskPos.X() )
|
|
|
|
aWinPos.X() = aDeskPos.X();
|
|
|
|
if ( aWinPos.Y() < aDeskPos.Y() )
|
|
|
|
aWinPos.Y() = aDeskPos.Y();
|
|
|
|
|
2001-10-24 07:57:18 +00:00
|
|
|
//SetPosPixel( aWinPos );
|
|
|
|
SetPosPixel( pWindow->ScreenToOutputPixel( aWinPos ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Dialog::Dialog( WindowType nType ) :
|
|
|
|
SystemWindow( nType )
|
|
|
|
{
|
2006-06-19 18:36:16 +00:00
|
|
|
ImplInitDialogData();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Dialog::Dialog( Window* pParent, WinBits nStyle ) :
|
|
|
|
SystemWindow( WINDOW_DIALOG )
|
|
|
|
{
|
2006-06-19 18:36:16 +00:00
|
|
|
ImplInitDialogData();
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Dialog::Dialog( Window* pParent, const ResId& rResId ) :
|
|
|
|
SystemWindow( WINDOW_DIALOG )
|
|
|
|
{
|
2006-06-19 18:36:16 +00:00
|
|
|
ImplInitDialogData();
|
2000-09-18 16:07:07 +00:00
|
|
|
rResId.SetRT( RSC_DIALOG );
|
|
|
|
ImplInit( pParent, ImplInitRes( rResId ) );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-11-22 09:40:03 +00:00
|
|
|
Dialog::~Dialog()
|
|
|
|
{
|
|
|
|
delete mpDialogImpl;
|
|
|
|
mpDialogImpl = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-10-30 17:11:35 +01:00
|
|
|
IMPL_LINK( Dialog, ImplAsyncCloseHdl, void*, EMPTYARG )
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
long Dialog::Notify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
// Zuerst Basisklasse rufen wegen TabSteuerung
|
|
|
|
long nRet = SystemWindow::Notify( rNEvt );
|
|
|
|
if ( !nRet )
|
|
|
|
{
|
|
|
|
if ( rNEvt.GetType() == EVENT_KEYINPUT )
|
|
|
|
{
|
|
|
|
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
|
|
|
|
KeyCode aKeyCode = pKEvt->GetKeyCode();
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 nKeyCode = aKeyCode.GetCode();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( (nKeyCode == KEY_ESCAPE) &&
|
|
|
|
((GetStyle() & WB_CLOSEABLE) || ImplGetCancelButton( this ) || ImplGetOKButton( this )) )
|
|
|
|
{
|
2009-10-30 17:11:35 +01:00
|
|
|
// #i89505# for the benefit of slightly mentally challenged implementations
|
|
|
|
// like e.g. SfxModelessDialog which destroy themselves inside Close()
|
|
|
|
// post this Close asynchronous so we can leave our key handler before
|
|
|
|
// we get destroyed
|
|
|
|
PostUserEvent( LINK( this, Dialog, ImplAsyncCloseHdl ), this );
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-26 12:58:10 +00:00
|
|
|
else if ( rNEvt.GetType() == EVENT_GETFOCUS )
|
|
|
|
{
|
|
|
|
// make sure the dialog is still modal
|
|
|
|
// changing focus between application frames may
|
|
|
|
// have re-enabled input for our parent
|
2007-10-15 15:27:13 +00:00
|
|
|
if( mbInExecute && mbModalMode )
|
2002-06-26 12:58:10 +00:00
|
|
|
{
|
|
|
|
// do not change modal counter (pSVData->maAppData.mnModalDialog)
|
2010-09-29 15:46:40 +08:00
|
|
|
SetModalInputMode( sal_False );
|
|
|
|
SetModalInputMode( sal_True );
|
2002-10-21 13:03:17 +00:00
|
|
|
|
|
|
|
// #93022# def-button might have changed after show
|
|
|
|
if( !mnMousePositioned )
|
|
|
|
{
|
|
|
|
mnMousePositioned = 1;
|
|
|
|
ImplMouseAutoPos( this );
|
|
|
|
}
|
|
|
|
|
2002-06-26 12:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
SystemWindow::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( nType == STATE_CHANGE_INITSHOW )
|
|
|
|
{
|
2003-03-27 16:59:30 +00:00
|
|
|
if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplWindowAutoMnemonic( this );
|
|
|
|
|
2005-01-13 17:02:52 +00:00
|
|
|
//if ( IsDefaultPos() && !mpWindowImpl->mbFrame )
|
2002-12-05 08:11:33 +00:00
|
|
|
// ImplCenterDialog();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !HasChildPathFocus() || HasFocus() )
|
|
|
|
GrabFocusToFirstControl();
|
|
|
|
if ( !(GetStyle() & WB_CLOSEABLE) )
|
|
|
|
{
|
|
|
|
if ( ImplGetCancelButton( this ) || ImplGetOKButton( this ) )
|
|
|
|
{
|
|
|
|
if ( ImplGetBorderWindow() )
|
|
|
|
((ImplBorderWindow*)ImplGetBorderWindow())->SetCloser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImplMouseAutoPos( this );
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
SystemWindow::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_Bool Dialog::Close()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-11-27 08:52:58 +00:00
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
|
|
|
ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
|
|
|
|
if ( aDelData.IsDelete() )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2001-11-27 08:52:58 +00:00
|
|
|
ImplRemoveDel( &aDelData );
|
|
|
|
|
2005-01-13 17:02:52 +00:00
|
|
|
if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
mbInClose = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !(GetStyle() & WB_CLOSEABLE) )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_Bool bRet = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplAddDel( &aDelData );
|
|
|
|
PushButton* pButton = ImplGetCancelButton( this );
|
|
|
|
if ( pButton )
|
|
|
|
pButton->Click();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pButton = ImplGetOKButton( this );
|
|
|
|
if ( pButton )
|
|
|
|
pButton->Click();
|
2001-08-07 10:54:21 +00:00
|
|
|
else
|
2010-09-29 15:46:40 +08:00
|
|
|
bRet = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
if ( aDelData.IsDelete() )
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplRemoveDel( &aDelData );
|
2001-08-07 10:54:21 +00:00
|
|
|
return bRet;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( IsInExecute() )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
EndDialog( sal_False );
|
|
|
|
mbInClose = sal_False;
|
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
mbInClose = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
return SystemWindow::Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_Bool Dialog::ImplStartExecuteModal()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( mbInExecute )
|
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
2006-11-22 09:40:03 +00:00
|
|
|
ByteString aErrorStr( "Dialog::StartExecuteModal() is called in Dialog::StartExecuteModal(): " );
|
2000-09-18 16:07:07 +00:00
|
|
|
aErrorStr += ImplGetDialogText( this );
|
|
|
|
DBG_ERROR( aErrorStr.GetBuffer() );
|
|
|
|
#endif
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( Application::IsDialogCancelEnabled() )
|
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
2006-11-22 09:40:03 +00:00
|
|
|
ByteString aErrorStr( "Dialog::StartExecuteModal() is called in a none UI application: " );
|
2000-09-18 16:07:07 +00:00
|
|
|
aErrorStr += ImplGetDialogText( this );
|
|
|
|
DBG_ERROR( aErrorStr.GetBuffer() );
|
|
|
|
#endif
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent )
|
|
|
|
{
|
|
|
|
pParent = pParent->ImplGetFirstOverlapWindow();
|
|
|
|
DBG_ASSERT( pParent->IsReallyVisible(),
|
2006-11-22 09:40:03 +00:00
|
|
|
"Dialog::StartExecuteModal() - Parent not visible" );
|
2001-12-10 12:36:20 +00:00
|
|
|
DBG_ASSERT( pParent->IsInputEnabled(),
|
2007-11-26 14:13:56 +00:00
|
|
|
"Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
|
|
|
|
DBG_ASSERT( ! pParent->IsInModalMode(),
|
|
|
|
"Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
|
|
|
|
// Dialoge, die sich in Execute befinden, miteinander verketten
|
|
|
|
mpPrevExecuteDlg = pSVData->maWinData.mpLastExecuteDlg;
|
|
|
|
pSVData->maWinData.mpLastExecuteDlg = this;
|
|
|
|
|
|
|
|
// Capture beenden, damit der Dialog bedient werden kann
|
|
|
|
if ( pSVData->maWinData.mpTrackWin )
|
|
|
|
pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
|
|
|
|
if ( pSVData->maWinData.mpCaptureWin )
|
|
|
|
pSVData->maWinData.mpCaptureWin->ReleaseMouse();
|
2010-09-29 15:46:40 +08:00
|
|
|
EnableInput( sal_True, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( GetParent() )
|
|
|
|
{
|
|
|
|
NotifyEvent aNEvt( EVENT_EXECUTEDIALOG, this );
|
|
|
|
GetParent()->Notify( aNEvt );
|
|
|
|
}
|
2010-09-29 15:46:40 +08:00
|
|
|
mbInExecute = sal_True;
|
|
|
|
SetModalInputMode( sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
mbOldSaveBack = IsSaveBackgroundEnabled();
|
|
|
|
EnableSaveBackground();
|
2008-04-04 10:02:17 +00:00
|
|
|
|
|
|
|
// FIXME: no layouting, workaround some clipping issues
|
|
|
|
ImplAdjustNWFSizes();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Show();
|
|
|
|
|
2006-11-22 09:40:03 +00:00
|
|
|
pSVData->maAppData.mnModalMode++;
|
2010-09-29 15:46:40 +08:00
|
|
|
return sal_True;
|
2006-11-22 09:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::ImplEndExecuteModal()
|
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
pSVData->maAppData.mnModalMode--;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
short Dialog::Execute()
|
|
|
|
{
|
|
|
|
if ( !ImplStartExecuteModal() )
|
|
|
|
return 0;
|
2002-10-21 13:03:17 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
2005-01-21 12:34:48 +00:00
|
|
|
|
2008-01-29 15:17:42 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
ImplDelData aParentDelData;
|
2005-01-21 12:34:48 +00:00
|
|
|
Window* pDialogParent = mpDialogParent;
|
|
|
|
if( pDialogParent )
|
|
|
|
pDialogParent->ImplAddDel( &aParentDelData );
|
2008-01-29 15:17:42 +00:00
|
|
|
#endif
|
2006-11-22 09:40:03 +00:00
|
|
|
|
2008-01-29 15:17:42 +00:00
|
|
|
// Yield util EndDialog is called or dialog gets destroyed
|
|
|
|
// (the latter should not happen, but better safe than sorry
|
2000-09-18 16:07:07 +00:00
|
|
|
while ( !aDelData.IsDelete() && mbInExecute )
|
|
|
|
Application::Yield();
|
2006-11-22 09:40:03 +00:00
|
|
|
|
|
|
|
ImplEndExecuteModal();
|
|
|
|
|
2008-01-29 15:17:42 +00:00
|
|
|
#ifdef DBG_UTIL
|
2005-01-21 12:34:48 +00:00
|
|
|
if( pDialogParent )
|
|
|
|
{
|
|
|
|
if( ! aParentDelData.IsDelete() )
|
|
|
|
pDialogParent->ImplRemoveDel( &aParentDelData );
|
|
|
|
else
|
|
|
|
DBG_ERROR( "Dialog::Execute() - Parent of dialog destroyed in Execute()" );
|
|
|
|
}
|
2008-01-29 15:17:42 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !aDelData.IsDelete() )
|
|
|
|
ImplRemoveDel( &aDelData );
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "Dialog::Execute() - Dialog destroyed in Execute()" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-11-22 09:40:03 +00:00
|
|
|
long nRet = mpDialogImpl->mnResult;
|
|
|
|
mpDialogImpl->mnResult = -1;
|
2000-09-18 16:07:07 +00:00
|
|
|
return (short)nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-11-22 09:40:03 +00:00
|
|
|
// virtual
|
|
|
|
void Dialog::StartExecuteModal( const Link& rEndDialogHdl )
|
|
|
|
{
|
|
|
|
if ( !ImplStartExecuteModal() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mpDialogImpl->maEndDialogHdl = rEndDialogHdl;
|
|
|
|
mpDialogImpl->mbStartedModal = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_Bool Dialog::IsStartedModal() const
|
2006-11-22 09:40:03 +00:00
|
|
|
{
|
|
|
|
return mpDialogImpl->mbStartedModal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void Dialog::EndDialog( long nResult )
|
|
|
|
{
|
|
|
|
if ( mbInExecute )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
SetModalInputMode( sal_False );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Dialog aus der Kette der Dialoge die in Execute stehen entfernen
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
|
|
|
|
while ( pExeDlg )
|
|
|
|
{
|
|
|
|
if ( pExeDlg == this )
|
|
|
|
{
|
2002-12-10 15:50:31 +00:00
|
|
|
pSVData->maWinData.mpLastExecuteDlg = mpPrevExecuteDlg;
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
pExeDlg = pExeDlg->mpPrevExecuteDlg;
|
|
|
|
}
|
2002-12-10 15:50:31 +00:00
|
|
|
// set focus to previous modal dialogue if it is modal for
|
|
|
|
// the same frame parent (or NULL)
|
2002-11-07 17:45:37 +00:00
|
|
|
if( mpPrevExecuteDlg )
|
2002-12-10 15:50:31 +00:00
|
|
|
{
|
|
|
|
Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
|
|
|
|
Window* pPrevFrameParent = mpPrevExecuteDlg->ImplGetFrameWindow()->ImplGetParent();
|
|
|
|
if( ( !pFrameParent && !pPrevFrameParent ) ||
|
|
|
|
( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
mpPrevExecuteDlg->GrabFocus();
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
mpPrevExecuteDlg = NULL;
|
|
|
|
|
|
|
|
Hide();
|
|
|
|
EnableSaveBackground( mbOldSaveBack );
|
|
|
|
if ( GetParent() )
|
|
|
|
{
|
|
|
|
NotifyEvent aNEvt( EVENT_ENDEXECUTEDIALOG, this );
|
|
|
|
GetParent()->Notify( aNEvt );
|
|
|
|
}
|
2006-11-22 09:40:03 +00:00
|
|
|
|
|
|
|
mpDialogImpl->mnResult = nResult;
|
|
|
|
|
|
|
|
if ( mpDialogImpl->mbStartedModal )
|
|
|
|
{
|
|
|
|
ImplEndExecuteModal();
|
|
|
|
mpDialogImpl->maEndDialogHdl.Call( this );
|
|
|
|
|
|
|
|
mpDialogImpl->maEndDialogHdl = Link();
|
|
|
|
mpDialogImpl->mbStartedModal = false;
|
|
|
|
mpDialogImpl->mnResult = -1;
|
|
|
|
}
|
2010-09-29 15:46:40 +08:00
|
|
|
mbInExecute = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2006-11-22 09:40:03 +00:00
|
|
|
|
|
|
|
long Dialog::GetResult() const
|
|
|
|
{
|
|
|
|
return mpDialogImpl->mnResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2001-01-29 12:48:40 +00:00
|
|
|
|
2001-01-29 14:48:32 +00:00
|
|
|
void Dialog::EndAllDialogs( Window* pParent )
|
2001-01-29 12:48:40 +00:00
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
Dialog* pTempModDialog;
|
|
|
|
Dialog* pModDialog = pSVData->maWinData.mpLastExecuteDlg;
|
|
|
|
while ( pModDialog )
|
|
|
|
{
|
|
|
|
pTempModDialog = pModDialog->mpPrevExecuteDlg;
|
2010-09-29 15:46:40 +08:00
|
|
|
if( !pParent || ( pParent && pParent->IsWindowOrChild( pModDialog, sal_True ) ) )
|
2001-01-29 12:48:40 +00:00
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
pModDialog->EndDialog( sal_False );
|
2001-01-29 12:48:40 +00:00
|
|
|
pModDialog->PostUserEvent( Link() );
|
|
|
|
}
|
|
|
|
pModDialog = pTempModDialog;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
void Dialog::SetModalInputMode( sal_Bool bModal )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( bModal == mbModalMode )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
mbModalMode = bModal;
|
|
|
|
if ( bModal )
|
|
|
|
{
|
|
|
|
pSVData->maAppData.mnModalDialog++;
|
|
|
|
|
|
|
|
// Diable the prev Modal Dialog, because our dialog must close at first,
|
|
|
|
// before the other dialog can be closed (because the other dialog
|
|
|
|
// is on stack since our dialog returns)
|
2010-09-29 15:46:40 +08:00
|
|
|
if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, sal_True ) )
|
|
|
|
mpPrevExecuteDlg->EnableInput( sal_False, sal_True, sal_True, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 08:19:27 +00:00
|
|
|
// determine next overlap dialog parent
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent )
|
|
|
|
{
|
|
|
|
// #103716# dialogs should always be modal to the whole frame window
|
|
|
|
// #115933# disable the whole frame hierarchie, useful if our parent
|
|
|
|
// is a modeless dialog
|
2007-11-26 14:13:56 +00:00
|
|
|
mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
|
|
|
|
mpDialogParent->ImplIncModalCount();
|
2004-07-05 08:19:27 +00:00
|
|
|
}
|
2001-12-10 12:36:20 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSVData->maAppData.mnModalDialog--;
|
|
|
|
|
2002-11-07 17:45:37 +00:00
|
|
|
if ( mpDialogParent )
|
2004-07-05 08:19:27 +00:00
|
|
|
{
|
|
|
|
// #115933# re-enable the whole frame hierarchie again (see above)
|
|
|
|
// note that code in getfocus assures that we do not accidentally enable
|
|
|
|
// windows that were disabled before
|
2007-11-26 14:13:56 +00:00
|
|
|
mpDialogParent->ImplDecModalCount();
|
2004-07-05 08:19:27 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// Enable the prev Modal Dialog
|
2010-09-29 15:46:40 +08:00
|
|
|
if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, sal_True ) )
|
2002-11-07 17:45:37 +00:00
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
mpPrevExecuteDlg->EnableInput( sal_True, sal_True, sal_True, this );
|
2002-11-07 17:45:37 +00:00
|
|
|
// ensure continued modality of prev dialog
|
|
|
|
// do not change modality counter
|
2010-09-29 15:46:40 +08:00
|
|
|
mpPrevExecuteDlg->SetModalInputMode( sal_False );
|
|
|
|
mpPrevExecuteDlg->SetModalInputMode( sal_True );
|
2002-11-07 17:45:37 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
void Dialog::SetModalInputMode( sal_Bool bModal, sal_Bool bSubModalDialogs )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( bSubModalDialogs )
|
|
|
|
{
|
|
|
|
Window* pOverlap = ImplGetFirstOverlapWindow();
|
2005-01-13 17:02:52 +00:00
|
|
|
pOverlap = pOverlap->mpWindowImpl->mpFirstOverlap;
|
2000-09-18 16:07:07 +00:00
|
|
|
while ( pOverlap )
|
|
|
|
{
|
|
|
|
if ( pOverlap->IsDialog() )
|
2010-09-29 15:46:40 +08:00
|
|
|
((Dialog*)pOverlap)->SetModalInputMode( bModal, sal_True );
|
2005-01-13 17:02:52 +00:00
|
|
|
pOverlap = pOverlap->mpWindowImpl->mpNext;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetModalInputMode( bModal );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Dialog::GrabFocusToFirstControl()
|
|
|
|
{
|
|
|
|
Window* pFocusControl;
|
|
|
|
|
|
|
|
// Wenn Dialog den Focus hat, versuchen wr trotzdem
|
|
|
|
// ein Focus-Control zu finden
|
|
|
|
if ( HasFocus() )
|
|
|
|
pFocusControl = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Wenn schon ein Child-Fenster mal den Focus hatte,
|
|
|
|
// dann dieses bevorzugen
|
2005-01-13 17:02:52 +00:00
|
|
|
pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
|
2000-09-18 16:07:07 +00:00
|
|
|
// Control aus der Dialog-Steuerung suchen
|
|
|
|
if ( pFocusControl )
|
|
|
|
pFocusControl = ImplFindDlgCtrlWindow( pFocusControl );
|
|
|
|
}
|
|
|
|
// Kein Control hatte vorher den Focus, oder das Control
|
|
|
|
// befindet sich nicht in der Tab-Steuerung, dann das erste
|
|
|
|
// Control in der TabSteuerung den Focus geben
|
|
|
|
if ( !pFocusControl ||
|
|
|
|
!(pFocusControl->GetStyle() & WB_TABSTOP) ||
|
|
|
|
!pFocusControl->IsVisible() ||
|
|
|
|
!pFocusControl->IsEnabled() || !pFocusControl->IsInputEnabled() )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 n = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
pFocusControl = ImplGetDlgWindow( n, DLGWINDOW_FIRST );
|
|
|
|
}
|
|
|
|
if ( pFocusControl )
|
|
|
|
pFocusControl->ImplControlFocus( GETFOCUS_INIT );
|
|
|
|
}
|
|
|
|
|
2004-06-17 11:22:28 +00:00
|
|
|
void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
|
2001-06-05 12:52:42 +00:00
|
|
|
{
|
|
|
|
ImplBorderWindow aImplWin( (Window*)this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
|
|
|
|
// aImplWin.SetText( GetText() );
|
|
|
|
// aImplWin.SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
|
2010-09-29 15:46:40 +08:00
|
|
|
// aImplWin.SetDisplayActive( sal_True );
|
2001-06-05 12:52:42 +00:00
|
|
|
// aImplWin.InitView();
|
|
|
|
aImplWin.GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uIntPtr )
|
2001-02-14 17:11:46 +00:00
|
|
|
{
|
2001-02-19 11:43:04 +00:00
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
|
|
|
Size aSize = pDev->LogicToPixel( rSize );
|
|
|
|
|
2007-11-26 15:42:31 +00:00
|
|
|
Wallpaper aWallpaper = GetBackground();
|
|
|
|
if ( !aWallpaper.IsBitmap() )
|
|
|
|
ImplInitSettings();
|
2001-02-14 17:11:46 +00:00
|
|
|
|
2001-02-16 10:13:00 +00:00
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
pDev->SetLineColor();
|
|
|
|
|
2007-11-26 15:42:31 +00:00
|
|
|
if ( aWallpaper.IsBitmap() )
|
|
|
|
pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pDev->SetFillColor( aWallpaper.GetColor() );
|
|
|
|
pDev->DrawRect( Rectangle( aPos, aSize ) );
|
|
|
|
}
|
2001-02-16 10:13:00 +00:00
|
|
|
|
2007-06-20 09:38:21 +00:00
|
|
|
if (!( GetStyle() & WB_NOBORDER ))
|
|
|
|
{
|
|
|
|
ImplBorderWindow aImplWin( this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
|
|
|
|
aImplWin.SetText( GetText() );
|
|
|
|
aImplWin.SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
|
2010-09-29 15:46:40 +08:00
|
|
|
aImplWin.SetDisplayActive( sal_True );
|
2007-06-20 09:38:21 +00:00
|
|
|
aImplWin.InitView();
|
2001-02-16 10:13:00 +00:00
|
|
|
|
2007-06-20 09:38:21 +00:00
|
|
|
aImplWin.Draw( Rectangle( aPos, aSize ), pDev, aPos );
|
|
|
|
}
|
2001-02-14 17:11:46 +00:00
|
|
|
|
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
ModelessDialog::ModelessDialog( Window* pParent, WinBits nStyle ) :
|
|
|
|
Dialog( WINDOW_MODELESSDIALOG )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ModelessDialog::ModelessDialog( Window* pParent, const ResId& rResId ) :
|
|
|
|
Dialog( WINDOW_MODELESSDIALOG )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_MODELESSDIALOG );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
ModalDialog::ModalDialog( Window* pParent, WinBits nStyle ) :
|
|
|
|
Dialog( WINDOW_MODALDIALOG )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ModalDialog::ModalDialog( Window* pParent, const ResId& rResId ) :
|
|
|
|
Dialog( WINDOW_MODALDIALOG )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_MODALDIALOG );
|
|
|
|
ImplInit( pParent, ImplInitRes( rResId ) );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
}
|