2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 07:34:22 +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 07:34:22 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:34:22 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:34:22 +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 07:34:22 +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 07:34:22 +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 10:55:12 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_vcl.hxx"
|
2007-06-27 19:08:01 +00:00
|
|
|
#include <vcl/morebtn.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-01-06 12:23:15 +00:00
|
|
|
#include <tools/rc.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-12-01 12:14:46 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2006-06-19 18:18:29 +00:00
|
|
|
DECLARE_LIST( ImplMoreWindowList, Window* )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-02-25 12:11:09 +00:00
|
|
|
struct ImplMoreButtonData
|
|
|
|
{
|
|
|
|
ImplMoreWindowList *mpItemList;
|
|
|
|
XubString maMoreText;
|
|
|
|
XubString maLessText;
|
|
|
|
};
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void MoreButton::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
2005-02-25 12:11:09 +00:00
|
|
|
mpMBData = new ImplMoreButtonData;
|
2000-09-18 16:07:07 +00:00
|
|
|
mnDelta = 0;
|
|
|
|
meUnit = MAP_PIXEL;
|
|
|
|
mbState = FALSE;
|
|
|
|
|
2005-02-25 12:11:09 +00:00
|
|
|
mpMBData->mpItemList = NULL;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
PushButton::ImplInit( pParent, nStyle );
|
|
|
|
|
2005-02-25 12:11:09 +00:00
|
|
|
mpMBData->maMoreText = Button::GetStandardText( BUTTON_MORE );
|
|
|
|
mpMBData->maLessText = Button::GetStandardText( BUTTON_LESS );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SetHelpText( Button::GetStandardHelpText( BUTTON_MORE ) );
|
2005-02-25 12:11:09 +00:00
|
|
|
|
|
|
|
ShowState();
|
|
|
|
|
|
|
|
SetSymbolAlign( SYMBOLALIGN_RIGHT );
|
|
|
|
ImplSetSmallSymbol( TRUE );
|
|
|
|
|
|
|
|
if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
|
|
|
|
{
|
|
|
|
nStyle |= WB_CENTER;
|
|
|
|
SetStyle( nStyle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void MoreButton::ShowState()
|
|
|
|
{
|
|
|
|
if ( mbState )
|
|
|
|
{
|
|
|
|
SetSymbol( SYMBOL_PAGEUP );
|
|
|
|
SetText( mpMBData->maLessText );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetSymbol( SYMBOL_PAGEDOWN );
|
|
|
|
SetText( mpMBData->maMoreText );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
MoreButton::MoreButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
PushButton( WINDOW_MOREBUTTON )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
MoreButton::MoreButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
PushButton( WINDOW_MOREBUTTON )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_MOREBUTTON );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void MoreButton::ImplLoadRes( const ResId& rResId )
|
|
|
|
{
|
|
|
|
PushButton::ImplLoadRes( rResId );
|
|
|
|
|
2005-01-03 16:40:26 +00:00
|
|
|
ULONG nObjMask = ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nObjMask & RSC_MOREBUTTON_STATE )
|
|
|
|
{
|
|
|
|
// Nicht Methode rufen, da Dialog nicht umgeschaltet werden soll
|
|
|
|
mbState = (BOOL)ReadShortRes();
|
2005-02-25 12:11:09 +00:00
|
|
|
// SetText( GetText() );
|
|
|
|
ShowState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
if ( nObjMask & RSC_MOREBUTTON_MAPUNIT )
|
2005-01-03 16:40:26 +00:00
|
|
|
meUnit = (MapUnit)ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nObjMask & RSC_MOREBUTTON_DELTA )
|
|
|
|
// Groesse fuer Erweitern des Dialogs
|
|
|
|
mnDelta = ReadShortRes();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
MoreButton::~MoreButton()
|
|
|
|
{
|
2005-02-25 12:11:09 +00:00
|
|
|
if ( mpMBData->mpItemList )
|
|
|
|
delete mpMBData->mpItemList;
|
|
|
|
delete mpMBData;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void MoreButton::Click()
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
Size aSize( pParent->GetSizePixel() );
|
2005-02-25 12:11:09 +00:00
|
|
|
Window* pWindow = (mpMBData->mpItemList) ? mpMBData->mpItemList->First() : NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
long nDeltaPixel = LogicToPixel( Size( 0, mnDelta ), meUnit ).Height();
|
|
|
|
|
|
|
|
// Status aendern
|
|
|
|
mbState = !mbState;
|
2005-02-25 12:11:09 +00:00
|
|
|
ShowState();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Hier den Click-Handler rufen, damit vorher die Controls initialisiert
|
|
|
|
// werden koennen
|
|
|
|
PushButton::Click();
|
|
|
|
|
|
|
|
// Je nach Status die Fenster updaten
|
|
|
|
if ( mbState )
|
|
|
|
{
|
|
|
|
// Fenster anzeigen
|
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
pWindow->Show();
|
2005-02-25 12:11:09 +00:00
|
|
|
pWindow = mpMBData->mpItemList->Next();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dialogbox anpassen
|
|
|
|
Point aPos( pParent->GetPosPixel() );
|
|
|
|
Rectangle aDeskRect( pParent->ImplGetFrameWindow()->GetDesktopRectPixel() );
|
|
|
|
|
|
|
|
aSize.Height() += nDeltaPixel;
|
|
|
|
if ( (aPos.Y()+aSize.Height()) > aDeskRect.Bottom() )
|
|
|
|
{
|
|
|
|
aPos.Y() = aDeskRect.Bottom()-aSize.Height();
|
|
|
|
|
|
|
|
if ( aPos.Y() < aDeskRect.Top() )
|
|
|
|
aPos.Y() = aDeskRect.Top();
|
|
|
|
|
|
|
|
pParent->SetPosSizePixel( aPos, aSize );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pParent->SetSizePixel( aSize );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Dialogbox anpassen
|
|
|
|
aSize.Height() -= nDeltaPixel;
|
|
|
|
pParent->SetSizePixel( aSize );
|
|
|
|
|
|
|
|
// Fenster nicht mehr anzeigen
|
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
pWindow->Hide();
|
2005-02-25 12:11:09 +00:00
|
|
|
pWindow = mpMBData->mpItemList->Next();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void MoreButton::AddWindow( Window* pWindow )
|
|
|
|
{
|
2005-02-25 12:11:09 +00:00
|
|
|
if ( !mpMBData->mpItemList )
|
|
|
|
mpMBData->mpItemList = new ImplMoreWindowList( 1024, 16, 16 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-02-25 12:11:09 +00:00
|
|
|
mpMBData->mpItemList->Insert( pWindow, LIST_APPEND );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( mbState )
|
|
|
|
pWindow->Show();
|
|
|
|
else
|
|
|
|
pWindow->Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void MoreButton::RemoveWindow( Window* pWindow )
|
|
|
|
{
|
2005-02-25 12:11:09 +00:00
|
|
|
if ( mpMBData->mpItemList )
|
|
|
|
mpMBData->mpItemList->Remove( pWindow );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void MoreButton::SetText( const XubString& rText )
|
|
|
|
{
|
2005-02-25 12:11:09 +00:00
|
|
|
PushButton::SetText( rText );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
XubString MoreButton::GetText() const
|
|
|
|
{
|
2005-02-25 12:11:09 +00:00
|
|
|
return PushButton::GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void MoreButton::SetMoreText( const XubString& rText )
|
|
|
|
{
|
|
|
|
if ( mpMBData )
|
|
|
|
mpMBData->maMoreText = rText;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !mbState )
|
2005-02-25 12:11:09 +00:00
|
|
|
SetText( rText );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
XubString MoreButton::GetMoreText() const
|
|
|
|
{
|
|
|
|
if ( mpMBData )
|
|
|
|
return mpMBData->maMoreText;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2005-02-25 12:11:09 +00:00
|
|
|
return PushButton::GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void MoreButton::SetLessText( const XubString& rText )
|
|
|
|
{
|
|
|
|
if ( mpMBData )
|
|
|
|
mpMBData->maLessText = rText;
|
|
|
|
|
|
|
|
if ( mbState )
|
|
|
|
SetText( rText );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-02-25 12:11:09 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
XubString MoreButton::GetLessText() const
|
|
|
|
{
|
|
|
|
if ( mpMBData )
|
|
|
|
return mpMBData->maLessText;
|
|
|
|
else
|
|
|
|
return PushButton::GetText();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2005-02-25 12:11:09 +00:00
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|