2010-10-12 15:53:47 +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-10 21:29:38 +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-10 21:29:38 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:29:38 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:29:38 +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-10 21:29:38 +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-10 21:29:38 +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
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2010-04-20 15:55:51 +02:00
|
|
|
#include "svx/fontlb.hxx"
|
2002-07-23 09:52:55 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
// ============================================================================
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_NAME( SvLBoxFontString );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxFontString::SvLBoxFontString() :
|
|
|
|
SvLBoxString()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_CTOR( SvLBoxFontString, 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxFontString::SvLBoxFontString(
|
|
|
|
SvLBoxEntry* pEntry, sal_uInt16 nFlags, const XubString& rString,
|
|
|
|
const Font& rFont, const Color* pColor ) :
|
|
|
|
SvLBoxString( pEntry, nFlags, rString ),
|
|
|
|
maFont( rFont ),
|
|
|
|
mbUseColor( pColor != NULL )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_CTOR( SvLBoxFontString, 0 );
|
|
|
|
SetText( pEntry, rString );
|
|
|
|
if( pColor )
|
|
|
|
maFont.SetColor( *pColor );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvLBoxFontString::~SvLBoxFontString()
|
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_DTOR( SvLBoxFontString, 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SvLBoxItem* SvLBoxFontString::Create() const
|
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_CHKTHIS( SvLBoxFontString, 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
return new SvLBoxFontString;
|
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvLBoxFontString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_CHKTHIS( SvLBoxFontString, 0 );
|
|
|
|
Font aOldFont( rDev.GetFont() );
|
|
|
|
Font aNewFont( maFont );
|
|
|
|
bool bSel = (nFlags & SVLISTENTRYFLAG_SELECTED) != 0;
|
|
|
|
if( !mbUseColor || bSel ) // selection always gets highlight color
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
|
|
|
|
aNewFont.SetColor( bSel ? rSett.GetHighlightTextColor() : rSett.GetFieldTextColor() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
rDev.SetFont( aNewFont );
|
|
|
|
SvLBoxString::Paint( rPos, rDev, nFlags, pEntry );
|
|
|
|
rDev.SetFont( aOldFont );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvLBoxFontString::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
DBG_CHKTHIS( SvLBoxFontString, 0 );
|
|
|
|
Font aOldFont( pView->GetFont() );
|
|
|
|
pView->SetFont( maFont );
|
|
|
|
SvLBoxString::InitViewData( pView, pEntry, pViewData);
|
|
|
|
pView->SetFont( aOldFont );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
SvxFontListBox::SvxFontListBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
SvTabListBox( pParent, rResId ),
|
|
|
|
maStdFont( GetFont() ),
|
|
|
|
mbUseFont( false )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-13 16:27:50 +01:00
|
|
|
maStdFont.SetTransparent( sal_True );
|
2002-07-23 09:52:55 +00:00
|
|
|
maEntryFont = maStdFont;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvxFontListBox::InsertFontEntry( const String& rString, const Font& rFont, const Color* pColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
mbUseFont = true; // InitEntry() will use maEntryFont
|
|
|
|
maEntryFont = rFont; // font to use in InitEntry() over InsertEntry()
|
|
|
|
mpEntryColor = pColor; // color to use in InitEntry() over InsertEntry()
|
|
|
|
InsertEntry( rString );
|
|
|
|
mbUseFont = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvxFontListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxEntry* pEntry = GetEntry( nPos );
|
|
|
|
if( pEntry )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
Select( pEntry, bSelect );
|
|
|
|
ShowEntry( pEntry );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvxFontListBox::SetNoSelection()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-13 16:27:50 +01:00
|
|
|
SelectAll( sal_False, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 16:27:50 +01:00
|
|
|
sal_uLong SvxFontListBox::GetSelectEntryPos() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxEntry* pSvLBoxEntry = FirstSelected();
|
2008-06-30 14:41:26 +00:00
|
|
|
return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : LIST_APPEND;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
XubString SvxFontListBox::GetSelectEntry() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
return GetEntryText( GetSelectEntryPos() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvxFontListBox::InitEntry(
|
|
|
|
SvLBoxEntry* pEntry, const XubString& rEntryText,
|
2006-12-20 13:11:23 +00:00
|
|
|
const Image& rCollImg, const Image& rExpImg,
|
|
|
|
SvLBoxButtonKind eButtonKind )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-23 09:52:55 +00:00
|
|
|
if( mbUseFont )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if( nTreeFlags & TREEFLAG_CHKBTN )
|
2006-12-20 13:11:23 +00:00
|
|
|
pEntry->AddItem( new SvLBoxButton( pEntry, eButtonKind, 0,
|
|
|
|
pCheckButtonData ) );
|
2002-07-23 09:52:55 +00:00
|
|
|
pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, rCollImg, rExpImg, SVLISTENTRYFLAG_EXPANDED ) );
|
|
|
|
pEntry->AddItem( new SvLBoxFontString( pEntry, 0, rEntryText, maEntryFont, mpEntryColor ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2006-12-20 13:11:23 +00:00
|
|
|
SvTreeListBox::InitEntry( pEntry, rEntryText, rCollImg, rExpImg,
|
|
|
|
eButtonKind );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
// ============================================================================
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|