summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
Diffstat (limited to 'svtools')
-rw-r--r--svtools/UIConfig_svt.mk1
-rw-r--r--svtools/inc/borderline.hrc41
-rw-r--r--svtools/source/control/ctrlbox.cxx298
-rw-r--r--svtools/source/control/valueset.cxx140
-rw-r--r--svtools/uiconfig/ui/linewindow.ui54
5 files changed, 532 insertions, 2 deletions
diff --git a/svtools/UIConfig_svt.mk b/svtools/UIConfig_svt.mk
index bceaebe0f0db..5887d1645165 100644
--- a/svtools/UIConfig_svt.mk
+++ b/svtools/UIConfig_svt.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svt,\
svtools/uiconfig/ui/graphicexport \
svtools/uiconfig/ui/inputbox \
svtools/uiconfig/ui/javadisableddialog \
+ svtools/uiconfig/ui/linewindow \
svtools/uiconfig/ui/placeedit \
svtools/uiconfig/ui/printersetupdialog \
svtools/uiconfig/ui/querydeletedialog \
diff --git a/svtools/inc/borderline.hrc b/svtools/inc/borderline.hrc
new file mode 100644
index 000000000000..07e4f1cf79c1
--- /dev/null
+++ b/svtools/inc/borderline.hrc
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#ifndef INCLUDED_CUI_INC_BORDERLINE_HRC
+#define INCLUDED_CUI_INC_BORDERLINE_HRC
+
+#include <editeng/borderline.hxx>
+
+#define NC_(Context, String) (Context "\004" u8##String)
+
+const std::pair<const char*, SvxBorderLineStyle> RID_SVXSTR_BORDERLINE[] =
+{
+ { NC_("RID_SVXSTR_BORDERLINE", "None"), SvxBorderLineStyle::NONE },
+ { NC_("RID_SVXSTR_BORDERLINE", "Solid"), SvxBorderLineStyle::SOLID },
+ { NC_("RID_SVXSTR_BORDERLINE", "Dotted"), SvxBorderLineStyle::DOTTED },
+ { NC_("RID_SVXSTR_BORDERLINE", "Dashed"), SvxBorderLineStyle::DASHED },
+ { NC_("RID_SVXSTR_BORDERLINE", "Double"), SvxBorderLineStyle::DOUBLE },
+ { NC_("RID_SVXSTR_BORDERLINE", "Thin Thick, Small Gap"), SvxBorderLineStyle::THINTHICK_SMALLGAP },
+ { NC_("RID_SVXSTR_BORDERLINE", "Thin Thick, Medium Gap"), SvxBorderLineStyle::THINTHICK_MEDIUMGAP },
+ { NC_("RID_SVXSTR_BORDERLINE", "Thin Thick, Large Gap"), SvxBorderLineStyle::THINTHICK_LARGEGAP },
+ { NC_("RID_SVXSTR_BORDERLINE", "Thick Thin, Small Gap"), SvxBorderLineStyle::THICKTHIN_SMALLGAP },
+ { NC_("RID_SVXSTR_BORDERLINE", "Thick Thin, Medium Gap"), SvxBorderLineStyle::THICKTHIN_MEDIUMGAP },
+ { NC_("RID_SVXSTR_BORDERLINE", "Thick Thin, Large Gap"), SvxBorderLineStyle::THICKTHIN_LARGEGAP },
+ { NC_("RID_SVXSTR_BORDERLINE", "Embossed"), SvxBorderLineStyle::EMBOSSED },
+ { NC_("RID_SVXSTR_BORDERLINE", "Engraved"), SvxBorderLineStyle::ENGRAVED },
+ { NC_("RID_SVXSTR_BORDERLINE", "Outset"), SvxBorderLineStyle::OUTSET },
+ { NC_("RID_SVXSTR_BORDERLINE", "Inset"), SvxBorderLineStyle::INSET },
+ { NC_("RID_SVXSTR_BORDERLINE", "Fine Dashed"), SvxBorderLineStyle::FINE_DASHED },
+ { NC_("RID_SVXSTR_BORDERLINE", "Double Thin"), SvxBorderLineStyle::DOUBLE_THIN },
+ { NC_("RID_SVXSTR_BORDERLINE", "Dash Dot"), SvxBorderLineStyle::DASH_DOT },
+ { NC_("RID_SVXSTR_BORDERLINE", "Dash Dot Dot"), SvxBorderLineStyle::DASH_DOT_DOT }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 386597541494..3e3f2d9a7df2 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -22,6 +22,7 @@
#include <i18nutil/unicode.hxx>
#include <tools/stream.hxx>
#include <vcl/builderfactory.hxx>
+#include <vcl/customweld.hxx>
#include <vcl/svapp.hxx>
#include <vcl/field.hxx>
#include <vcl/settings.hxx>
@@ -38,6 +39,7 @@
#include <svtools/ctrlbox.hxx>
#include <svtools/ctrltool.hxx>
#include <svtools/borderhelper.hxx>
+#include <svtools/valueset.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/fontcapabilities.hxx>
@@ -49,6 +51,8 @@
#include <rtl/bootstrap.hxx>
+#include <borderline.hrc>
+
#include <stdio.h>
#define IMGOUTERTEXTSPACE 5
@@ -1575,4 +1579,298 @@ sal_Int64 FontSizeBox::GetValueFromStringUnit(const OUString& rStr, FieldUnit eO
return MetricBox::GetValueFromStringUnit( rStr, eOutUnit );
}
+SvxBorderLineStyle SvtLineListBox::GetSelectEntryStyle() const
+{
+ if (m_xLineSet->IsNoSelection())
+ return SvxBorderLineStyle::NONE;
+ auto nId = m_xLineSet->GetSelectedItemId();
+ return static_cast<SvxBorderLineStyle>(nId - 1);
+}
+
+void SvtLineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance,
+ Color aColor1, Color aColor2, Color aColorDist,
+ SvxBorderLineStyle nStyle, BitmapEx& rBmp )
+{
+ Size aSize(m_xControl->get_approximate_digit_width() * 15, m_xControl->get_text_height());
+
+ // SourceUnit to Twips
+ if ( eSourceUnit == FUNIT_POINT )
+ {
+ nLine1 /= 5;
+ nLine2 /= 5;
+ nDistance /= 5;
+ }
+
+ // Paint the lines
+ aSize = aVirDev->PixelToLogic( aSize );
+ long nPix = aVirDev->PixelToLogic( Size( 0, 1 ) ).Height();
+ sal_uInt32 n1 = nLine1;
+ sal_uInt32 n2 = nLine2;
+ long nDist = nDistance;
+ n1 += nPix-1;
+ n1 -= n1%nPix;
+ if ( n2 )
+ {
+ nDist += nPix-1;
+ nDist -= nDist%nPix;
+ n2 += nPix-1;
+ n2 -= n2%nPix;
+ }
+ long nVirHeight = n1+nDist+n2;
+ if ( nVirHeight > aSize.Height() )
+ aSize.setHeight( nVirHeight );
+ // negative width should not be drawn
+ if ( aSize.Width() <= 0 )
+ return;
+
+ Size aVirSize = aVirDev->LogicToPixel( aSize );
+ if ( aVirDev->GetOutputSizePixel() != aVirSize )
+ aVirDev->SetOutputSizePixel( aVirSize );
+ aVirDev->SetFillColor( aColorDist );
+ aVirDev->DrawRect( tools::Rectangle( Point(), aSize ) );
+
+ aVirDev->SetFillColor( aColor1 );
+
+ double y1 = double( n1 ) / 2;
+ svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle );
+
+ if ( n2 )
+ {
+ double y2 = n1 + nDist + double( n2 ) / 2;
+ aVirDev->SetFillColor( aColor2 );
+ svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, SvxBorderLineStyle::SOLID );
+ }
+ rBmp = aVirDev->GetBitmapEx( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
+}
+
+namespace
+{
+ OUString GetLineStyleName(SvxBorderLineStyle eStyle)
+ {
+ OUString sRet;
+ for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(RID_SVXSTR_BORDERLINE); ++i)
+ {
+ if (eStyle == RID_SVXSTR_BORDERLINE[i].second)
+ {
+ sRet = SvtResId(RID_SVXSTR_BORDERLINE[i].first);
+ break;
+ }
+ }
+ return sRet;
+ }
+}
+
+SvtLineListBox::SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl)
+ : m_xControl(std::move(pControl))
+ , m_xBuilder(Application::CreateBuilder(m_xControl.get(), "svt/ui/linewindow.ui"))
+ , m_xTopLevel(m_xBuilder->weld_widget("line_popup_window"))
+ , m_xNoneButton(m_xBuilder->weld_button("none_line_button"))
+ , m_xLineSet(new SvtValueSet(nullptr))
+ , m_xLineSetWin(new weld::CustomWeld(*m_xBuilder, "lineset", *m_xLineSet))
+ , m_nWidth( 5 )
+ , aVirDev(VclPtr<VirtualDevice>::Create())
+ , aColor(COL_BLACK)
+ , maPaintCol(COL_BLACK)
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ m_xLineSet->SetStyle(WinBits(WB_FLATVALUESET | WB_NO_DIRECTSELECT | WB_TABSTOP));
+ m_xLineSet->SetItemHeight(rStyleSettings.GetListBoxPreviewDefaultPixelSize().Height() + 1);
+ m_xLineSet->SetColCount(1);
+ m_xLineSet->SetSelectHdl(LINK(this, SvtLineListBox, ValueSelectHdl));
+
+ m_xNoneButton->connect_clicked(LINK(this, SvtLineListBox, NoneHdl));
+
+ m_xTopLevel->connect_focus_in(LINK(this, SvtLineListBox, FocusHdl));
+ m_xControl->set_popover(m_xTopLevel.get());
+ m_xControl->set_label(GetLineStyleName(SvxBorderLineStyle::NONE));
+ // lock to this text height
+ m_xControl->set_size_request(-1, m_xControl->get_preferred_size().Height());
+
+ eSourceUnit = FUNIT_POINT;
+
+ aVirDev->SetLineColor();
+ aVirDev->SetMapMode(MapMode(MapUnit::MapTwip));
+
+ UpdatePaintLineColor();
+}
+
+IMPL_LINK_NOARG(SvtLineListBox, FocusHdl, weld::Widget&, void)
+{
+ if (GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
+ m_xNoneButton->grab_focus();
+ else
+ m_xLineSet->GrabFocus();
+}
+
+IMPL_LINK_NOARG(SvtLineListBox, NoneHdl, weld::Button&, void)
+{
+ SelectEntry(SvxBorderLineStyle::NONE);
+ ValueSelectHdl(nullptr);
+}
+
+SvtLineListBox::~SvtLineListBox()
+{
+}
+
+sal_Int32 SvtLineListBox::GetStylePos( sal_Int32 nListPos )
+{
+ sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
+ --nListPos;
+
+ sal_Int32 n = 0;
+ size_t i = 0;
+ size_t nCount = m_vLineList.size();
+ while ( nPos == LISTBOX_ENTRY_NOTFOUND && i < nCount )
+ {
+ if ( nListPos == n )
+ nPos = static_cast<sal_Int32>(i);
+ n++;
+ i++;
+ }
+
+ return nPos;
+}
+
+void SvtLineListBox::SelectEntry(SvxBorderLineStyle nStyle)
+{
+ if (nStyle == SvxBorderLineStyle::NONE)
+ {
+ m_xLineSet->SetNoSelection();
+ m_xNoneButton->set_has_default(true);
+ }
+ else
+ {
+ m_xLineSet->SelectItem(static_cast<sal_Int16>(nStyle) + 1);
+ m_xNoneButton->set_has_default(false);
+ }
+ UpdatePreview();
+}
+
+void SvtLineListBox::InsertEntry(
+ const BorderWidthImpl& rWidthImpl, SvxBorderLineStyle nStyle, long nMinWidth,
+ ColorFunc pColor1Fn, ColorFunc pColor2Fn, ColorDistFunc pColorDistFn )
+{
+ m_vLineList.emplace_back(new ImpLineListData(
+ rWidthImpl, nStyle, nMinWidth, pColor1Fn, pColor2Fn, pColorDistFn));
+}
+
+void SvtLineListBox::UpdatePaintLineColor()
+{
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ Color aNewCol(rSettings.GetWindowColor().IsDark() ? rSettings.GetLabelTextColor() : aColor);
+
+ bool bRet = aNewCol != maPaintCol;
+
+ if( bRet )
+ maPaintCol = aNewCol;
+}
+
+void SvtLineListBox::UpdateEntries()
+{
+ UpdatePaintLineColor( );
+
+ SvxBorderLineStyle eSelected = GetSelectEntryStyle();
+
+ // Remove the old entries
+ m_xLineSet->Clear();
+
+ // Add the new entries based on the defined width
+
+ sal_uInt16 n = 0;
+ sal_uInt16 nCount = m_vLineList.size( );
+ while ( n < nCount )
+ {
+ auto& pData = m_vLineList[ n ];
+ BitmapEx aBmp;
+ ImpGetLine( pData->GetLine1ForWidth( m_nWidth ),
+ pData->GetLine2ForWidth( m_nWidth ),
+ pData->GetDistForWidth( m_nWidth ),
+ GetColorLine1(m_xLineSet->GetItemCount()),
+ GetColorLine2(m_xLineSet->GetItemCount()),
+ GetColorDist(m_xLineSet->GetItemCount()),
+ pData->GetStyle(), aBmp );
+ sal_Int16 nItemId = static_cast<sal_Int16>(pData->GetStyle()) + 1;
+ m_xLineSet->InsertItem(nItemId, Image(aBmp), GetLineStyleName(pData->GetStyle()));
+ if (pData->GetStyle() == eSelected)
+ m_xLineSet->SelectItem(nItemId);
+ n++;
+ }
+
+ m_xLineSet->SetOptimalSize();
+}
+
+Color SvtLineListBox::GetColorLine1( sal_Int32 nPos )
+{
+ sal_Int32 nStyle = GetStylePos( nPos );
+ if (nStyle == LISTBOX_ENTRY_NOTFOUND)
+ return GetPaintColor( );
+ auto& pData = m_vLineList[ nStyle ];
+ return pData->GetColorLine1( GetColor( ) );
+}
+
+Color SvtLineListBox::GetColorLine2( sal_Int32 nPos )
+{
+ sal_Int32 nStyle = GetStylePos(nPos);
+ if (nStyle == LISTBOX_ENTRY_NOTFOUND)
+ return GetPaintColor( );
+ auto& pData = m_vLineList[ nStyle ];
+ return pData->GetColorLine2( GetColor( ) );
+}
+
+Color SvtLineListBox::GetColorDist( sal_Int32 nPos )
+{
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ Color rResult = rSettings.GetFieldColor();
+
+ sal_Int32 nStyle = GetStylePos( nPos );
+ if (nStyle == LISTBOX_ENTRY_NOTFOUND)
+ return rResult;
+ auto& pData = m_vLineList[ nStyle ];
+ return pData->GetColorDist( GetColor( ), rResult );
+}
+
+IMPL_LINK_NOARG(SvtLineListBox, StyleUpdated, weld::Widget&, void)
+{
+ UpdateEntries();
+}
+
+IMPL_LINK_NOARG(SvtLineListBox, ValueSelectHdl, SvtValueSet*, void)
+{
+ maSelectHdl.Call(*this);
+ UpdatePreview();
+ if (m_xControl->get_active())
+ m_xControl->set_active(false);
+}
+
+void SvtLineListBox::UpdatePreview()
+{
+ SvxBorderLineStyle eStyle = GetSelectEntryStyle();
+ for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(RID_SVXSTR_BORDERLINE); ++i)
+ {
+ if (eStyle == RID_SVXSTR_BORDERLINE[i].second)
+ {
+ m_xControl->set_label(SvtResId(RID_SVXSTR_BORDERLINE[i].first));
+ break;
+ }
+ }
+
+ if (eStyle == SvxBorderLineStyle::NONE)
+ {
+ m_xControl->set_image(nullptr);
+ m_xControl->set_label(GetLineStyleName(SvxBorderLineStyle::NONE));
+ }
+ else
+ {
+ Image aImage(m_xLineSet->GetItemImage(m_xLineSet->GetSelectedItemId()));
+ m_xControl->set_label("");
+ const auto nPos = (aVirDev->GetOutputSizePixel().Height() - aImage.GetSizePixel().Height()) / 2;
+ aVirDev->Push(PushFlags::MAPMODE);
+ aVirDev->SetMapMode(MapMode(MapUnit::MapPixel));
+ aVirDev->Erase();
+ aVirDev->DrawImage(Point(0, nPos), aImage);
+ aVirDev->Pop();
+ m_xControl->set_image(aVirDev.get());
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index e45cf996137c..e39650e61377 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -2279,9 +2279,11 @@ void ValueSet::SetEdgeBlending(bool bNew)
SvtValueSet::SvtValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow)
: maVirDev( VclPtr<VirtualDevice>::Create())
, mxScrolledWindow(std::move(pScrolledWindow))
+ , mnHighItemId(0)
, maColor(COL_TRANSPARENT)
, mnStyle(0)
, mbFormat(true)
+ , mbHighlight(false)
{
maVirDev->SetBackground(Application::GetSettings().GetStyleSettings().GetFaceColor());
@@ -2303,6 +2305,7 @@ SvtValueSet::SvtValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow)
mnSpacing = 0;
mnFrameStyle = DrawFrameStyle::NONE;
mbNoSelection = true;
+ mbDrawSelection = true;
mbBlackSel = false;
mbDoubleSel = false;
mbScroll = false;
@@ -2653,6 +2656,25 @@ bool SvtValueSet::KeyInput( const KeyEvent& rKeyEvent )
return true;
}
+void SvtValueSet::ImplTracking(const Point& rPos)
+{
+ SvtValueSetItem* pItem = ImplGetItem( ImplGetItem( rPos ) );
+ if ( pItem )
+ {
+ if( GetStyle() & WB_MENUSTYLEVALUESET || GetStyle() & WB_FLATVALUESET )
+ mbHighlight = true;
+
+ ImplHighlightItem( pItem->mnId );
+ }
+ else
+ {
+ if( GetStyle() & WB_MENUSTYLEVALUESET || GetStyle() & WB_FLATVALUESET )
+ mbHighlight = true;
+
+ ImplHighlightItem( mnSelItemId, false );
+ }
+}
+
void SvtValueSet::MouseButtonDown( const MouseEvent& rMouseEvent )
{
if ( rMouseEvent.IsLeft() )
@@ -2677,6 +2699,14 @@ void SvtValueSet::MouseButtonDown( const MouseEvent& rMouseEvent )
CustomWidgetController::MouseButtonDown( rMouseEvent );
}
+void SvtValueSet::MouseMove(const MouseEvent& rMouseEvent)
+{
+ // because of SelectionMode
+ if ((GetStyle() & WB_MENUSTYLEVALUESET) || (GetStyle() & WB_FLATVALUESET))
+ ImplTracking(rMouseEvent.GetPosPixel());
+ CustomWidgetController::MouseMove(rMouseEvent);
+}
+
void SvtValueSet::RemoveItem( sal_uInt16 nItemId )
{
size_t nPos = GetItemPos( nItemId );
@@ -2780,6 +2810,23 @@ tools::Rectangle SvtValueSet::ImplGetItemRect( size_t nPos ) const
return tools::Rectangle( Point(x, y), Size(mnItemWidth, mnItemHeight) );
}
+void SvtValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection )
+{
+ if ( mnHighItemId == nItemId )
+ return;
+
+ // remember the old item to delete the previous selection
+ mnHighItemId = nItemId;
+
+ // don't draw the selection if nothing is selected
+ if ( !bIsSelection && mbNoSelection )
+ mbDrawSelection = false;
+
+ // remove the old selection and draw the new one
+ Invalidate();
+ mbDrawSelection = true;
+}
+
void SvtValueSet::ImplDraw(vcl::RenderContext& rRenderContext)
{
if (mbFormat)
@@ -2916,6 +2963,7 @@ void SvtValueSet::SelectItem( sal_uInt16 nItemId )
void SvtValueSet::SetNoSelection()
{
mbNoSelection = true;
+ mbHighlight = false;
if (IsReallyVisible() && IsUpdateMode())
Invalidate();
@@ -3260,13 +3308,19 @@ void SvtValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext)
return;
const bool bFocus = HasFocus();
- if (!bFocus && mbNoSelection)
+ const bool bDrawSel = !((mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight));
+
+ if (!bFocus && !bDrawSel)
{
ImplDrawItemText(rRenderContext, OUString());
return;
}
- ImplDrawSelect(rRenderContext, mnSelItemId, bFocus, !mbNoSelection);
+ ImplDrawSelect(rRenderContext, mnSelItemId, bFocus, bDrawSel);
+ if (mbHighlight)
+ {
+ ImplDrawSelect(rRenderContext, mnHighItemId, bFocus, bDrawSel);
+ }
}
void SvtValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel )
@@ -3568,6 +3622,26 @@ void SvtValueSet::SetColCount( sal_uInt16 nNewCols )
}
}
+void SvtValueSet::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
+{
+ size_t nPos = GetItemPos( nItemId );
+
+ if ( nPos == VALUESET_ITEM_NOTFOUND )
+ return;
+
+ SvtValueSetItem* pItem = mItemList[nPos];
+ pItem->meType = VALUESETITEM_IMAGE;
+ pItem->maImage = rImage;
+
+ if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
+ {
+ const tools::Rectangle aRect = ImplGetItemRect(nPos);
+ Invalidate(aRect);
+ }
+ else
+ mbFormat = true;
+}
+
Color SvtValueSet::GetItemColor( sal_uInt16 nItemId ) const
{
size_t nPos = GetItemPos( nItemId );
@@ -3661,6 +3735,14 @@ void SvtValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage,
ImplInsertItem( pItem, nPos );
}
+void SvtValueSet::InsertItem( sal_uInt16 nItemId, size_t nPos )
+{
+ SvtValueSetItem* pItem = new SvtValueSetItem( *this );
+ pItem->mnId = nItemId;
+ pItem->meType = VALUESETITEM_USERDRAW;
+ ImplInsertItem( pItem, nPos );
+}
+
void SvtValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor,
const OUString& rText )
{
@@ -3830,6 +3912,9 @@ void SvtValueSet::SetItemText(sal_uInt16 nItemId, const OUString& rText)
{
sal_uInt16 nTempId = mnSelItemId;
+ if (mbHighlight)
+ nTempId = mnHighItemId;
+
if (nTempId == nItemId)
Invalidate();
}
@@ -3842,4 +3927,55 @@ void SvtValueSet::SetItemText(sal_uInt16 nItemId, const OUString& rText)
}
}
+Size SvtValueSet::GetLargestItemSize()
+{
+ Size aLargestItem;
+
+ for (SvtValueSetItem* pItem : mItemList)
+ {
+ if (!pItem->mbVisible)
+ continue;
+
+ if (pItem->meType != VALUESETITEM_IMAGE &&
+ pItem->meType != VALUESETITEM_IMAGE_AND_TEXT)
+ {
+ // handle determining an optimal size for this case
+ continue;
+ }
+
+ Size aSize = pItem->maImage.GetSizePixel();
+ if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT)
+ {
+ aSize.AdjustHeight(3 * NAME_LINE_HEIGHT +
+ maVirDev->GetTextHeight() );
+ aSize.setWidth( std::max(aSize.Width(),
+ maVirDev->GetTextWidth(pItem->maText) + NAME_OFFSET) );
+ }
+
+ aLargestItem.setWidth( std::max(aLargestItem.Width(), aSize.Width()) );
+ aLargestItem.setHeight( std::max(aLargestItem.Height(), aSize.Height()) );
+ }
+
+ return aLargestItem;
+}
+
+void SvtValueSet::SetOptimalSize()
+{
+ Size aLargestSize(GetLargestItemSize());
+ aLargestSize.setWidth(std::max(aLargestSize.Width(), mnUserItemWidth));
+ aLargestSize.setHeight(std::max(aLargestSize.Height(), mnUserItemHeight));
+ Size aPrefSize(CalcWindowSizePixel(aLargestSize));
+ GetDrawingArea()->set_size_request(aPrefSize.Width(), aPrefSize.Height());
+}
+
+Image SvtValueSet::GetItemImage(sal_uInt16 nItemId) const
+{
+ size_t nPos = GetItemPos( nItemId );
+
+ if ( nPos != VALUESET_ITEM_NOTFOUND )
+ return mItemList[nPos]->maImage;
+ else
+ return Image();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/uiconfig/ui/linewindow.ui b/svtools/uiconfig/ui/linewindow.ui
new file mode 100644
index 000000000000..e438cf8b4a96
--- /dev/null
+++ b/svtools/uiconfig/ui/linewindow.ui
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="svx">
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkPopover" id="line_popup_window">
+ <property name="can_focus">False</property>
+ <property name="border_width">4</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkButton" id="none_line_button">
+ <property name="label" translatable="yes" context="colorwindow|none_color_button">None</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="no_show_all">True</property>
+ <property name="image">none_icon</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="lineset">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkImage" id="none_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">cmd/sc_square_unfilled.png</property>
+ </object>
+</interface>