Removed lots of code that was supposed to do scrolling in the about dialog. And removed unused includes and variables too. Also don't squeeze the Copyright text in a too small multiline edit. Compiled and run: looks a bit nicer than before and less code too.
There are still a few commented out lines where we need to remove Resource strings, that's beyond my head though. Included TODOs for that. Signed-off-by: Sebastian Spaeth <sebast...@sspaeth.de> --- All in all this is a net win (170 LOC less and some more comments), and easier too understand too IMHO. Not sure sfx2/inc/about.hxx | 25 +--- sfx2/source/dialog/about.cxx | 351 ++++++++++++------------------------------ 2 files changed, 101 insertions(+), 275 deletions(-) diff --git a/sfx2/inc/about.hxx b/sfx2/inc/about.hxx index 901807e..51de28a 100644 --- a/sfx2/inc/about.hxx +++ b/sfx2/inc/about.hxx @@ -31,57 +31,34 @@ #include <tools/resary.hxx> #include <vcl/button.hxx> -#include <vcl/accel.hxx> #include <svtools/svmedit.hxx> -#include <tools/list.hxx> -#include <svtools/stdctrl.hxx> #include "svtools/fixedhyper.hxx" #include <sfx2/basedlgs.hxx> // SfxModalDialog -DECLARE_LIST( AccelList, Accelerator* ) - // class AboutDialog ----------------------------------------------------- class AboutDialog : public SfxModalDialog { private: OKButton aOKButton; - Image aAppLogo; + Image aAppLogo; MultiLineEdit aVersionText; MultiLineEdit aCopyrightText; svt::FixedHyperlink aInfoLink; - ResStringArray aDeveloperAry; - String aDevVersionStr; - String aAccelStr; - String aVersionData; String aVersionTextStr; String aCopyrightTextStr; String aLinkStr; - AccelList aAccelList; - - AutoTimer aTimer; - long nOff; - long m_nDeltaWidth; - int m_nPendingScrolls; - - BOOL bNormal; - protected: virtual BOOL Close(); virtual void Paint( const Rectangle& ); public: AboutDialog( Window* pParent, const ResId& rId, const String& rVerStr ); - ~AboutDialog(); - DECL_LINK( TimerHdl, Timer * ); - DECL_LINK( AccelSelectHdl, Accelerator * ); DECL_LINK( HandleHyperlink, svt::FixedHyperlink * ); }; #endif // #ifndef _ABOUT_HXX - - diff --git a/sfx2/source/dialog/about.cxx b/sfx2/source/dialog/about.cxx index a6360e1..289b995 100644 --- a/sfx2/source/dialog/about.cxx +++ b/sfx2/source/dialog/about.cxx @@ -31,46 +31,44 @@ // include --------------------------------------------------------------- -#include <vcl/svapp.hxx> +//#include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> -#include <tools/stream.hxx> -#include <tools/urlobj.hxx> -#include <rtl/bootstrap.hxx> -#include <unotools/configmgr.hxx> -#include <unotools/bootstrap.hxx> +//#include <tools/stream.hxx> +//#include <tools/urlobj.hxx> +//#include <rtl/bootstrap.hxx> +//#include <unotools/bootstrap.hxx> #include <com/sun/star/uno/Any.h> #include <unotools/configmgr.hxx> -#include <vcl/svapp.hxx> -#include <vcl/graph.hxx> -#include <svtools/filter.hxx> - +//#include <vcl/svapp.hxx> +//#include <vcl/graph.hxx> +//#include <svtools/filter.hxx> +// #include "com/sun/star/system/SystemShellExecuteFlags.hpp" #include "com/sun/star/system/XSystemShellExecute.hpp" #include <comphelper/processfactory.hxx> #include "comphelper/anytostring.hxx" #include "cppuhelper/exc_hlp.hxx" -#include "cppuhelper/bootstrap.hxx" - -#include <sfx2/sfxuno.hxx> +//#include "cppuhelper/bootstrap.hxx" +// +//#include <sfx2/sfxuno.hxx> +//TODO:Clean up about.hxx too #include "about.hxx" -#include "sfxresid.hxx" -#include <sfx2/sfxdefs.hxx> +//#include "sfxresid.hxx" +//#include <sfx2/sfxdefs.hxx> #include <sfx2/app.hxx> - #include "dialog.hrc" using namespace ::com::sun::star; -// defines --------------------------------------------------------------- - -#define SCROLL_OFFSET 1 -#define SPACE_OFFSET 5 -#define SCROLL_TIMER 30 - -#define WELCOME_URL DEFINE_CONST_UNICODE( "http://www.openoffice.org/welcome/credits.html" ) +#define SPACE_OFFSET 10 +#define WELCOME_URL DEFINE_CONST_UNICODE( "http://www.openoffice.org/welcome/credits.html" ) -/** loads the application logo as used in the about dialog and impress slideshow pause screen */ +/** + * loads the application logo as used in the about dialog + * and impress slideshow pause screen + * @return Image() with the Application logo +*/ Image SfxApplication::GetApplicationLogo() { BitmapEx aBitmap; @@ -78,38 +76,42 @@ Image SfxApplication::GetApplicationLogo() return Image( aBitmap ); } +/** + * Class containing the Help menu about dialog +*/ AboutDialog::AboutDialog( Window* pParent, const ResId& rId, const String& rVerStr ) : SfxModalDialog ( pParent, rId ), - aOKButton ( this, ResId( ABOUT_BTN_OK, *rId.GetResMgr() ) ), aVersionText ( this, ResId( ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ), aCopyrightText ( this, ResId( ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ), aInfoLink ( this, ResId( ABOUT_FTXT_LINK, *rId.GetResMgr() ) ), - aDeveloperAry ( ResId( ABOUT_STR_DEVELOPER_ARY, *rId.GetResMgr() ) ), - aDevVersionStr ( rVerStr ), - aAccelStr ( ResId( ABOUT_STR_ACCEL, *rId.GetResMgr() ) ), + //TODO, remove from resources + //aDeveloperAry ( ResId( ABOUT_STR_DEVELOPER_ARY, *rId.GetResMgr() ) ), + //aDevVersionStr ( rVerStr ), + //TODO, remove from resources + //aAccelStr ( ResId( ABOUT_STR_ACCEL, *rId.GetResMgr() ) ), aVersionTextStr( ResId( ABOUT_STR_VERSION, *rId.GetResMgr() ) ), aCopyrightTextStr( ResId( ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) ), - aLinkStr ( ResId( ABOUT_STR_LINK, *rId.GetResMgr() ) ), - aTimer (), - nOff ( 0 ), - m_nDeltaWidth ( 0 ), - m_nPendingScrolls( 0 ), - bNormal ( TRUE ) + aLinkStr ( ResId( ABOUT_STR_LINK, *rId.GetResMgr() ) ) { - rtl::OUString sProduct; - utl::ConfigManager::GetDirectConfigProperty(utl::ConfigManager::PRODUCTNAME) >>= sProduct; + // Get name of the product into sProduct + //rtl::OUString sProduct; + //utl::ConfigManager::GetDirectConfigProperty(utl::ConfigManager::PRODUCTNAME) >>= sProduct; - // load image from module path + // load 'about' logo image from module path aAppLogo = SfxApplication::GetApplicationLogo(); - // Transparenter Font - Font aFont = GetFont(); - aFont.SetTransparent( TRUE ); - SetFont( aFont ); + // set correct system color for background and text + const StyleSettings& rSettings = GetSettings().GetStyleSettings(); + Color aWhiteCol( rSettings.GetWindowColor() ); + Wallpaper aWall( aWhiteCol ); + SetBackground( aWall ); + Font aNewFont( aCopyrightText.GetFont() ); + //aNewFont.SetTransparent( TRUE ); + Color aTextColor( rSettings.GetWindowTextColor() ); - // if necessary more info + // append more version info if necessary String sVersion = aVersionTextStr; sVersion.SearchAndReplaceAscii( "$(VER)", Application::GetDisplayName() ); sVersion += '\n'; @@ -119,186 +121,100 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId, const String& rVerS sVersion += '\n'; sVersion += aBuildString; #endif - aVersionText.SetText( sVersion ); - - // Initialisierung fuer Aufruf Entwickler - if ( aAccelStr.Len() && ByteString(U2S(aAccelStr)).IsAlphaAscii() ) - { - Accelerator *pAccel = 0, *pPrevAccel = 0, *pFirstAccel = 0; - aAccelStr.ToUpperAscii(); - - for ( USHORT i = 0; i < aAccelStr.Len(); ++i ) - { - pPrevAccel = pAccel; - pAccel = new Accelerator; - aAccelList.Insert( pAccel, LIST_APPEND ); - USHORT nKey = aAccelStr.GetChar(i) - 'A' + KEY_A; - pAccel->InsertItem( 1, KeyCode( nKey, KEY_MOD1 ) ); - if ( i > 0 ) - pPrevAccel->SetAccel( 1, pAccel ); - if ( i == 0 ) - pFirstAccel = pAccel; - } - pAccel->SetSelectHdl( LINK( this, AboutDialog, AccelSelectHdl ) ); - GetpApp()->InsertAccel( pFirstAccel ); - } - // set for background and text the correct system color - const StyleSettings& rSettings = GetSettings().GetStyleSettings(); - Color aWhiteCol( rSettings.GetWindowColor() ); - Wallpaper aWall( aWhiteCol ); - SetBackground( aWall ); - Font aNewFont( aCopyrightText.GetFont() ); - aNewFont.SetTransparent( TRUE ); + aVersionText.SetText( sVersion ); + aCopyrightText.SetText( aCopyrightTextStr ); aVersionText.SetFont( aNewFont ); - aCopyrightText.SetFont( aNewFont ); - aVersionText.SetBackground(); + aVersionText.SetControlForeground( aTextColor ); + + aCopyrightText.SetFont( aNewFont ); aCopyrightText.SetBackground(); + aCopyrightText.SetControlForeground( aTextColor ); + aInfoLink.SetURL( aLinkStr ); aInfoLink.SetBackground(); aInfoLink.SetClickHdl( LINK( this, AboutDialog, HandleHyperlink ) ); - Color aTextColor( rSettings.GetWindowTextColor() ); - aVersionText.SetControlForeground( aTextColor ); - aCopyrightText.SetControlForeground( aTextColor ); - - aCopyrightText.SetText( aCopyrightTextStr ); - // determine size and position of the dialog & elements - Size aAppLogoSiz = aAppLogo.GetSizePixel(); - Size aOutSiz = GetOutputSizePixel(); - aOutSiz.Width() = aAppLogoSiz.Width(); - - // analyze size of the aVersionText widget - // character size - Size a6Size = aVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT ); - // preferred Version widget size - Size aVTSize = aVersionText.CalcMinimumSize(); - long nY = aAppLogoSiz.Height() + ( a6Size.Height() * 2 ); - long nDlgMargin = a6Size.Width() * 3 ; - long nCtrlMargin = aVTSize.Height() + ( a6Size.Height() * 2 ); - long nTextWidth = aOutSiz.Width() - nDlgMargin; + Size aAppLogoSize = aAppLogo.GetSizePixel(); + Size aOutSize = GetOutputSizePixel(); + aOutSize.Width() = aAppLogoSize.Width(); + + // get actual size of the aVersionText widget + Size aVersionTextSize = aVersionText.LogicToPixel( Size( 6, 6 ), + MAP_APPFONT ); + // y of VersionText + long nY = aAppLogoSize.Height() + SPACE_OFFSET; + long nDlgHoriMargin = aVersionTextSize.Width() * 3 ; + long nTextWidth = aOutSize.Width() - nDlgHoriMargin; // finally set the aVersionText widget position and size + // preferred Version widget size + Size aVTSize = aVersionText.CalcMinimumSize(); Size aVTCopySize = aVTSize; - Point aVTCopyPnt; + Point aVTPnt; aVTCopySize.Width() = nTextWidth; - aVTCopyPnt.X() = ( aOutSiz.Width() - aVTCopySize.Width() ) / 2; - aVTCopyPnt.Y() = nY; - aVersionText.SetPosSizePixel( aVTCopyPnt, aVTCopySize ); - - nY += nCtrlMargin; + aVTPnt.X() = ( aOutSize.Width() - aVTCopySize.Width() ) / 2; + aVTPnt.Y() = nY; + aVersionText.SetPosSizePixel( aVTPnt, aVTCopySize ); - // OK-Button-Position (at the bottom and centered) - Size aOKSiz = aOKButton.GetSizePixel(); - Point aOKPnt = aOKButton.GetPosPixel(); - - // FixedHyperlink with more info link - Point aLinkPnt = aInfoLink.GetPosPixel(); - Size aLinkSize = aInfoLink.GetSizePixel(); + // jump to start of Copyright text + nY += aVTSize.Height() + aVersionTextSize.Height(); // Multiline edit with Copyright-Text - Point aCopyPnt = aCopyrightText.GetPosPixel(); - Size aCopySize = aCopyrightText.GetSizePixel(); - aCopySize.Width() = nTextWidth; - aCopySize.Height() = aOutSiz.Height() - nY - ( aOKSiz.Height() * 2 ) - 3*aLinkSize.Height() - nCtrlMargin; - - aCopyPnt.X() = ( aOutSiz.Width() - aCopySize.Width() ) / 2; - aCopyPnt.Y() = nY; - aCopyrightText.SetPosSizePixel( aCopyPnt, aCopySize ); - - nY += aCopySize.Height() + aLinkSize.Height(); + Size aCRSize = aCopyrightText.CalcMinimumSize(); + Point aCRPnt; + aCRSize.Width() = nTextWidth; + aCRSize.Height() = aOutSize.Height() - nY \ + - 2 * aOKButton.GetSizePixel().Height() \ + - aInfoLink.GetSizePixel().Height(); + aCRPnt.X() = ( aOutSize.Width() - aCRSize.Width() ) / 2; + aCRPnt.Y() = nY; + aCopyrightText.SetPosSizePixel( aCRPnt, aCRSize ); + // FixedHyperlink with more info link + Point aLinkPnt = aInfoLink.GetPosPixel(); + Size aLinkSize = aInfoLink.GetSizePixel(); + nY += aCRSize.Height() + aLinkSize.Height(); aLinkSize.Width() = aInfoLink.CalcMinimumSize().Width(); - aLinkPnt.X() = ( aOutSiz.Width() - aLinkSize.Width() ) / 2; + aLinkPnt.X() = ( aOutSize.Width() - aLinkSize.Width() ) / 2; aLinkPnt.Y() = nY; aInfoLink.SetPosSizePixel( aLinkPnt, aLinkSize ); - nY += aLinkSize.Height() + nCtrlMargin; + // OK-Button-Position (at the bottom and centered) + Size aOKSize = aOKButton.GetSizePixel(); + Point aOKPnt; - aOKPnt.X() = ( aOutSiz.Width() - aOKSiz.Width() ) / 2; - aOKPnt.Y() = nY; + aOKPnt.X() = ( aOutSize.Width() - aOKSize.Width() ) / 2; + aOKPnt.Y() = aOutSize.Height() - aOKSize.Height(); aOKButton.SetPosPixel( aOKPnt ); // Change the width of the dialog - SetOutputSizePixel( aOutSiz ); - - FreeResource(); - + SetOutputSizePixel( aOutSize ); // explizite Help-Id SetHelpId( SID_ABOUT ); + FreeResource(); } // ----------------------------------------------------------------------- - -AboutDialog::~AboutDialog() -{ - // L"oschen des Entwickleraufrufs - if ( aAccelList.Count() ) - { - GetpApp()->RemoveAccel( aAccelList.First() ); - Accelerator* pAccel = aAccelList.Last(); - - while ( pAccel ) - { - delete pAccel; - pAccel = aAccelList.Prev(); - } - } -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( AboutDialog, TimerHdl, Timer *, pTimer ) -{ - (void)pTimer; //unused - ++m_nPendingScrolls; - Invalidate( INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN ); - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( AboutDialog, AccelSelectHdl, Accelerator *, pAccelerator ) -{ -#ifdef YURI_DARIO - aCopyrightText.SetHelpText( DEFINE_CONST_UNICODE("Conoscere qualcuno ovunque egli sia, con cui comprendersi nonostante le distanze\n" - "e le differenze, puo' trasformare la terra in un giardino. baci Valeria") ); -#endif - - (void)pAccelerator; //unused - // init Timer - aTimer.SetTimeoutHdl( LINK( this, AboutDialog, TimerHdl ) ); - - // init scroll mode - nOff = GetOutputSizePixel().Height(); - MapMode aMapMode( MAP_PIXEL ); - SetMapMode( aMapMode ); - bNormal = FALSE; - - // start scroll Timer - aTimer.SetTimeout( SCROLL_TIMER ); - aTimer.Start(); - return 0; -} - -// ----------------------------------------------------------------------- - IMPL_LINK( AboutDialog, HandleHyperlink, svt::FixedHyperlink*, pHyperlink ) { rtl::OUString sURL=pHyperlink->GetURL(); rtl::OUString sTitle=GetText(); - if ( ! sURL.getLength() ) // Nothing to do, when the URL is empty - return 1; + // Nothing to do, when the URL is empty + if ( ! sURL.getLength() ) return 1; + try { uno::Reference< system::XSystemShellExecute > xSystemShellExecute( ::comphelper::getProcessServiceFactory()->createInstance( - DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") ), uno::UNO_QUERY_THROW ); - xSystemShellExecute->execute( sURL, rtl::OUString(), system::SystemShellExecuteFlags::DEFAULTS ); + DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") ), + uno::UNO_QUERY_THROW ); + xSystemShellExecute->execute( sURL, rtl::OUString(), + system::SystemShellExecuteFlags::DEFAULTS ); } catch ( uno::Exception& ) { @@ -317,8 +233,6 @@ IMPL_LINK( AboutDialog, HandleHyperlink, svt::FixedHyperlink*, pHyperlink ) BOOL AboutDialog::Close() { - // stop Timer and finish the dialog - aTimer.Stop(); EndDialog( RET_OK ); return( FALSE ); } @@ -328,73 +242,8 @@ BOOL AboutDialog::Close() void AboutDialog::Paint( const Rectangle& rRect ) { SetClipRegion( rRect ); - - if ( bNormal ) // not in scroll mode - { - Point aPos( m_nDeltaWidth / 2, 0 ); - DrawImage( aPos, aAppLogo ); - return; - } - - // scroll the content - const int nDeltaY = -SCROLL_OFFSET * m_nPendingScrolls; - if( !nDeltaY ) - return; - nOff += nDeltaY; - Scroll( 0, nDeltaY, SCROLL_NOERASE ); - m_nPendingScrolls = 0; - - // draw the credits text - const Font aOrigFont = GetFont(); - const int nFullWidth = GetOutputSizePixel().Width(); - - int nY = nOff; - const int nDevCnt = static_cast<int>( aDeveloperAry.Count() ); - for( int i = 0; i < nDevCnt; ++i ) - { - if( nY >= rRect.Bottom() ) - break; - - int nPos2 = nY + GetTextHeight() + 3; - if( nPos2 >= rRect.Top() + nDeltaY ) - { - const String aStr = aDeveloperAry.GetString(i); - const long nVal = aDeveloperAry.GetValue(i); - - if ( nVal ) - { - // emphasize the headers - Font aFont = aOrigFont; - aFont.SetWeight( (FontWeight)nVal ); - SetFont( aFont ); - nPos2 = nY + GetTextHeight() + 3; - } - - // clear text background - Rectangle aEraseRect( Point(0,nY), Size( nFullWidth, nPos2-nY)); - Erase( aEraseRect ); - - // draw centered text - const long nTextWidth = GetTextWidth( aStr ); - long nX = (nFullWidth - 5 - nTextWidth) / 2; - if( nX < 0 ) - nX = SPACE_OFFSET; - const Point aPnt( nX, nY ); - DrawText( aPnt, aStr ); - - // restore the font if needed - if( nVal ) - SetFont( aOrigFont ); - } - nY = nPos2; - } - - // close dialog if the whole text has been scrolled - if ( nY <= 0 ) - { - bNormal = TRUE; - Close(); - } + Point aPos( 0, 0 ); + DrawImage( aPos, aAppLogo ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- 1.7.1 _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice