LibreOffice Module sc (master) 1
tabbgcolordlg.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#undef SC_DLLIMPLEMENTATION
21
22#include <tabbgcolordlg.hxx>
23
24#include <tools/color.hxx>
25#include <vcl/event.hxx>
26
27#include <officecfg/Office/Common.hxx>
28
29ScTabBgColorDlg::ScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle,
30 const OUString& rTabBgColorNoColorText, const Color& rDefaultColor)
31 : GenericDialogController(pParent, "modules/scalc/ui/tabcolordialog.ui", "TabColorDialog")
32 , m_aTabBgColor(rDefaultColor)
33 , m_xSelectPalette(m_xBuilder->weld_combo_box("paletteselector"))
34 , m_xTabBgColorSet(new ScTabBgColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin", true)))
35 , m_xTabBgColorSetWin(new weld::CustomWeld(*m_xBuilder, "colorset", *m_xTabBgColorSet))
36 , m_xBtnOk(m_xBuilder->weld_button("ok"))
37{
38 m_xTabBgColorSet->SetDialog(this);
40
41 m_xDialog->set_title(rTitle);
42
44 m_xTabBgColorSet->SetStyle(nBits);
45 m_xTabBgColorSet->SetText(rTabBgColorNoColorText);
46
47 const sal_uInt32 nColCount = SvxColorValueSet::getColumnCount();
48 const sal_uInt32 nRowCount(10);
50 Size aSize(m_xTabBgColorSet->CalcWindowSizePixel(Size(nLength, nLength), nColCount, nRowCount));
51 m_xTabBgColorSetWin->set_size_request(aSize.Width() + 8, aSize.Height() + 8);
52
54
55 m_xSelectPalette->connect_changed(LINK(this, ScTabBgColorDlg, SelectPaletteLBHdl));
56 m_xTabBgColorSet->SetDoubleClickHdl(LINK(this, ScTabBgColorDlg, TabBgColorDblClickHdl_Impl));
57 m_xBtnOk->connect_clicked(LINK(this, ScTabBgColorDlg, TabBgColorOKHdl_Impl));
58}
59
61{
62}
63
65{
66 rColor = m_aTabBgColor;
67}
68
70{
71 m_xSelectPalette->clear();
72 std::vector<OUString> aPaletteList = m_aPaletteManager.GetPaletteList();
73 for (auto const& palette : aPaletteList)
74 {
75 m_xSelectPalette->append_text(palette);
76 }
77 OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
78 m_xSelectPalette->set_active_text(aPaletteName);
79 if (m_xSelectPalette->get_active() != -1)
80 {
81 SelectPaletteLBHdl(*m_xSelectPalette);
82 }
83}
84
86{
87 m_xTabBgColorSet->Clear();
88 sal_Int32 nPos = m_xSelectPalette->get_active();
89 m_aPaletteManager.SetPalette( nPos );
90 m_aPaletteManager.ReloadColorSet(*m_xTabBgColorSet);
91 m_xTabBgColorSet->Resize();
92 m_xTabBgColorSet->SelectItem(0);
93}
94
95// Handler, called when color selection is changed
96IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, ValueSet*, void)
97{
98 sal_uInt16 nItemId = m_xTabBgColorSet->GetSelectedItemId();
99 Color aColor = nItemId ? ( m_xTabBgColorSet->GetItemColor( nItemId ) ) : COL_AUTO;
100 m_aTabBgColor = aColor;
101 m_xDialog->response(RET_OK);
102}
103
104// Handler, called when the OK button is pushed
105IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl, weld::Button&, void)
106{
107 sal_uInt16 nItemId = m_xTabBgColorSet->GetSelectedItemId();
108 Color aColor = nItemId ? ( m_xTabBgColorSet->GetItemColor( nItemId ) ) : COL_AUTO;
109 m_aTabBgColor = aColor;
110 m_xDialog->response(RET_OK);
111}
112
113ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet(std::unique_ptr<weld::ScrolledWindow> pWindow)
114 : SvxColorValueSet(std::move(pWindow))
115 , m_pTabBgColorDlg(nullptr)
116{
117}
118
120{
121}
122
124{
125 switch ( rKEvt.GetKeyCode().GetCode() )
126 {
127 case KEY_SPACE:
128 case KEY_RETURN:
129 {
130 sal_uInt16 nItemId = GetSelectedItemId();
131 const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : COL_AUTO;
132 m_pTabBgColorDlg->m_aTabBgColor = aColor;
133 m_pTabBgColorDlg->response(RET_OK);
134 return true;
135 }
136 break;
137 }
138 return SvxColorValueSet::KeyInput(rKEvt);
139}
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
const vcl::KeyCode & GetKeyCode() const
std::vector< OUString > GetPaletteList()
virtual bool KeyInput(const KeyEvent &rKEvt) override
ScTabBgColorValueSet(std::unique_ptr< weld::ScrolledWindow > pWindow)
std::unique_ptr< weld::ComboBox > m_xSelectPalette
PaletteManager m_aPaletteManager
std::unique_ptr< weld::Button > m_xBtnOk
std::unique_ptr< weld::CustomWeld > m_xTabBgColorSetWin
void GetSelectedColor(Color &rColor) const
virtual ~ScTabBgColorDlg() override
std::unique_ptr< ScTabBgColorValueSet > m_xTabBgColorSet
ScTabBgColorDlg(weld::Window *pParent, const OUString &rTitle, const OUString &rTabBgColorNoColorText, const Color &rDefaultColor)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static sal_uInt32 getColumnCount()
static sal_uInt32 getEntryEdgeLength()
sal_uInt16 GetCode() const
std::shared_ptr< weld::Dialog > m_xDialog
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_SPACE
sal_uInt16 nPos
IMPL_LINK_NOARG(ScTabBgColorDlg, SelectPaletteLBHdl, weld::ComboBox &, void)
#define WB_ITEMBORDER
#define WB_NONEFIELD
#define WB_NAMEFIELD
#define WB_NO_DIRECTSELECT
RET_OK
sal_Int64 WinBits
WinBits const WB_3DLOOK
sal_Int32 nLength