2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-04-20 15:55:51 +02:00
|
|
|
#include "svx/fontlb.hxx"
|
2012-12-06 11:54:45 +00:00
|
|
|
#include <vcl/builder.hxx>
|
2002-07-23 09:52:55 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2012-11-16 16:14:53 -05:00
|
|
|
#include "svtools/treelistentry.hxx"
|
2012-11-29 20:39:48 -05:00
|
|
|
#include "svtools/viewdataentry.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-24 10:45:38 +00:00
|
|
|
SvLBoxFontString::SvLBoxFontString()
|
|
|
|
: SvLBoxString()
|
|
|
|
, mbUseColor(false)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxFontString::SvLBoxFontString(
|
2013-07-10 10:20:24 +01:00
|
|
|
SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& rString,
|
2014-09-16 10:09:58 +02:00
|
|
|
const vcl::Font& rFont, const Color* pColor ) :
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxString( pEntry, nFlags, rString ),
|
|
|
|
maFont( rFont ),
|
|
|
|
mbUseColor( pColor != NULL )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-07-15 21:59:04 +01:00
|
|
|
SetText( rString );
|
2002-07-23 09:52:55 +00:00
|
|
|
if( pColor )
|
|
|
|
maFont.SetColor( *pColor );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvLBoxFontString::~SvLBoxFontString()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SvLBoxItem* SvLBoxFontString::Create() const
|
|
|
|
{
|
|
|
|
return new SvLBoxFontString;
|
|
|
|
}
|
|
|
|
|
2012-11-29 14:17:48 -05:00
|
|
|
void SvLBoxFontString::Paint(
|
|
|
|
const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-09-16 10:09:58 +02:00
|
|
|
vcl::Font aOldFont( rDev.GetFont() );
|
|
|
|
vcl::Font aNewFont( maFont );
|
2012-11-29 14:17:48 -05:00
|
|
|
bool bSel = pView->IsSelected();
|
2002-07-23 09:52:55 +00:00
|
|
|
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 );
|
2012-11-29 14:17:48 -05:00
|
|
|
SvLBoxString::Paint(rPos, rDev, pView, pEntry);
|
2002-07-23 09:52:55 +00:00
|
|
|
rDev.SetFont( aOldFont );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2012-10-18 16:28:20 +02:00
|
|
|
void SvLBoxFontString::InitViewData( SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-09-16 10:09:58 +02:00
|
|
|
vcl::Font aOldFont( pView->GetFont() );
|
2012-10-11 22:18:53 -04:00
|
|
|
pView->Control::SetFont( maFont );
|
2002-07-23 09:52:55 +00:00
|
|
|
SvLBoxString::InitViewData( pView, pEntry, pViewData);
|
2012-10-11 22:18:53 -04:00
|
|
|
pView->Control::SetFont( aOldFont );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-25 20:51:35 +01:00
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SvxFontListBox::SvxFontListBox(vcl::Window* pParent, WinBits nStyle)
|
2012-12-06 11:54:45 +00:00
|
|
|
: SvTabListBox(pParent, nStyle)
|
|
|
|
, maStdFont(GetFont())
|
2014-03-31 21:10:46 +01:00
|
|
|
, mpEntryColor(NULL)
|
2012-12-06 11:54:45 +00:00
|
|
|
, mbUseFont(false)
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
maStdFont.SetTransparent(true);
|
2012-12-06 11:54:45 +00:00
|
|
|
maEntryFont = maStdFont;
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSvxFontListBox(vcl::Window *pParent, VclBuilder::stringmap &rMap)
|
2012-12-06 11:54:45 +00:00
|
|
|
{
|
2013-04-25 20:56:56 +01:00
|
|
|
WinBits nWinStyle = WB_TABSTOP;
|
|
|
|
OString sBorder = VclBuilder::extractCustomProperty(rMap);
|
|
|
|
if (!sBorder.isEmpty())
|
|
|
|
nWinStyle |= WB_BORDER;
|
|
|
|
return new SvxFontListBox(pParent, nWinStyle);
|
2012-12-06 11:54:45 +00:00
|
|
|
}
|
|
|
|
|
2014-09-16 10:09:58 +02:00
|
|
|
void SvxFontListBox::InsertFontEntry( const OUString& rString, const vcl::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
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
void SvxFontListBox::SelectEntryPos( sal_uLong nPos, bool bSelect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = GetEntry( nPos );
|
2002-07-23 09:52:55 +00:00
|
|
|
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
|
|
|
{
|
2014-03-24 15:42:28 +02:00
|
|
|
SelectAll( false, 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
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pSvLBoxEntry = FirstSelected();
|
2014-03-01 03:13:28 +01:00
|
|
|
return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : TREELIST_ENTRY_NOTFOUND;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
void SvxFontListBox::InitEntry(
|
2012-10-25 11:26:43 +01:00
|
|
|
SvTreeListEntry* pEntry, const OUString& rEntryText,
|
2006-12-20 13:11:23 +00:00
|
|
|
const Image& rCollImg, const Image& rExpImg,
|
2012-10-25 11:26:43 +01:00
|
|
|
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 ) );
|
2012-11-29 19:02:37 -05:00
|
|
|
pEntry->AddItem( new SvLBoxContextBmp(pEntry, 0, rCollImg, rExpImg, true) );
|
2002-07-23 09:52:55 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-02-25 20:51:35 +01:00
|
|
|
|
2002-07-23 09:52:55 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|