summaryrefslogtreecommitdiff
path: root/sc/source/ui/sidebar
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-04 20:47:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-05 11:08:05 +0100
commit3845bded94ea1b933d545efce3cd2e5b0a75a2f6 (patch)
tree726745a6dbd441f990d3fecbdbe2b5486919837f /sc/source/ui/sidebar
parent7618302b9c15580c1e00af042c586837f6f0bb0f (diff)
convert line style to .ui format
andd... 1) adjust the UserDraw so the units are not truncated 2) fix focus so keyboard works inside the popup 3) merge CellLineStylePopup and CellLineStyleControl Change-Id: I51f05dd990c0a35b5b7515876362d3fbd908167f
Diffstat (limited to 'sc/source/ui/sidebar')
-rw-r--r--sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx5
-rw-r--r--sc/source/ui/sidebar/CellAppearancePropertyPanel.hrc4
-rw-r--r--sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx29
-rw-r--r--sc/source/ui/sidebar/CellAppearancePropertyPanel.src29
-rw-r--r--sc/source/ui/sidebar/CellLineStyleControl.cxx53
-rw-r--r--sc/source/ui/sidebar/CellLineStyleControl.hxx17
-rw-r--r--sc/source/ui/sidebar/CellLineStyleValueSet.cxx23
-rw-r--r--sc/source/ui/sidebar/CellLineStyleValueSet.hxx3
8 files changed, 47 insertions, 116 deletions
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
index 84c07426973f..0915adde4eb0 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
@@ -171,10 +171,9 @@ IMPL_LINK(CellAppearancePropertyPanel, TbxLineStyleSelectHdl, ToolBox*, pToolBox
if (aCommand == UNO_LINESTYLE)
{
if (!mxCellLineStylePopup)
- mxCellLineStylePopup = VclPtr<CellLineStylePopup>::Create(pToolBox, GetBindings()->GetDispatcher());
+ mxCellLineStylePopup = VclPtr<CellLineStylePopup>::Create(GetBindings()->GetDispatcher());
mxCellLineStylePopup->SetLineStyleSelect(mnOut, mnIn, mnDis);
- mxCellLineStylePopup->StartPopupMode(pToolBox, FloatWinPopupFlags::Down |
- FloatWinPopupFlags::NoAppFocusClose);
+ mxCellLineStylePopup->StartPopupMode(pToolBox, FloatWinPopupFlags::GrabFocus);
}
}
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hrc b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hrc
index 439bb588bac6..aece5133095e 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hrc
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hrc
@@ -17,10 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-//line style page
-#define VS_STYLE 1
-#define PB_OPTIONS 2
-
//line border page
#define TB_BORDER1 1
#define TB_BORDER2 2
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx
index d7d36ec78ddd..612a059801f4 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx
@@ -24,12 +24,10 @@
#include <svx/sidebar/PanelLayout.hxx>
#include <vcl/floatwin.hxx>
#include "CellBorderStyleControl.hxx"
-#include "CellLineStyleControl.hxx"
#include <memory>
class FixedText;
namespace sc { namespace sidebar {
- class CellLineStyleControl;
class CellBorderUpdater;
}}
class ToolBox;
@@ -58,30 +56,7 @@ public:
}
};
-class CellLineStylePopup : public FloatingWindow
-{
- VclPtr<CellLineStyleControl> m_xControl;
-public:
- CellLineStylePopup(vcl::Window* pParent, SfxDispatcher* pDispatcher)
- : FloatingWindow(pParent, WB_BORDER | WB_SYSTEMWINDOW)
- , m_xControl(VclPtr<CellLineStyleControl>::Create(this, pDispatcher))
- {
- SetSizePixel(m_xControl->GetOutputSizePixel());
- }
- void SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis)
- {
- m_xControl->SetLineStyleSelect(out, in, dis);
- }
- virtual ~CellLineStylePopup() override
- {
- disposeOnce();
- }
- virtual void dispose() override
- {
- m_xControl.disposeAndClear();
- FloatingWindow::dispose();
- }
-};
+class CellLineStylePopup;
class CellAppearancePropertyPanel
: public PanelLayout,
@@ -89,7 +64,7 @@ class CellAppearancePropertyPanel
public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
{
private:
- friend class CellLineStyleControl;
+ friend class CellLineStylePopup;
friend class CellBorderStyleControl;
public:
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.src b/sc/source/ui/sidebar/CellAppearancePropertyPanel.src
index 63619994f809..7682c1a0313e 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.src
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.src
@@ -65,35 +65,6 @@ Image IMG_LINE_STYLE9
ImageBitmap = Bitmap{File = "sidebar/CellBorderLineStyle_750.png";};
};
-// cell line style popup
-
-Control RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE
-{
- OutputSize = TRUE;
- DialogControl = TRUE;
- Border = FALSE;
-
- Size = MAP_APPFONT(
- POPUPPANEL_MARGIN_SMALL * 2 + POPUP_BORDER_WIDTH + 80,
- 13 + POPUP_BORDER_HEIGHT + POPUPPANEL_MARGIN_SMALL * 2 + POPUPPANEL_MARGIN_LARGE + 12*9);
-
- Control VS_STYLE
- {
- Hide = TRUE ;
- Pos = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL + OFFSET_X , POPUPPANEL_MARGIN_SMALL + OFFSET_Y );
- Size = MAP_APPFONT ( 80 , 12 * 9);
- TabStop = TRUE ;
- Text [ en-US ] = "Line Style";
- };
- PushButton PB_OPTIONS
- {
- Pos = MAP_APPFONT ( POPUPPANEL_MARGIN_LARGE + OFFSET_X , POPUPPANEL_MARGIN_SMALL * 2 + OFFSET_Y + 12 * 9);
- Size = MAP_APPFONT ( 75 , 12 );
- TabStop = TRUE;
- Text [ en-US ] = "~More Options...";
- };
-};
-
// cell border style popup
Control RID_POPUPPANEL_APPEARANCE_CELL_BORDERSTYLE
diff --git a/sc/source/ui/sidebar/CellLineStyleControl.cxx b/sc/source/ui/sidebar/CellLineStyleControl.cxx
index e9e68a335a32..7f497497b789 100644
--- a/sc/source/ui/sidebar/CellLineStyleControl.cxx
+++ b/sc/source/ui/sidebar/CellLineStyleControl.cxx
@@ -33,35 +33,30 @@
namespace sc { namespace sidebar {
-CellLineStyleControl::CellLineStyleControl(FloatingWindow* pParent, SfxDispatcher* pDispatcher)
-: Control(pParent, ScResId(RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE)),
- mpDispatcher(pDispatcher),
- mxFloatParent(pParent),
- maPushButtonMoreOptions(VclPtr<PushButton>::Create(this, ScResId(PB_OPTIONS))),
- maCellLineStyleValueSet(VclPtr<sc::sidebar::CellLineStyleValueSet>::Create(this, ScResId(VS_STYLE))),
- mbVSfocus(true)
+CellLineStylePopup::CellLineStylePopup(SfxDispatcher* pDispatcher)
+ : FloatingWindow(SfxGetpApp()->GetTopWindow(), "FloatingLineStyle", "modules/scalc/ui/floatinglinestyle.ui")
+ , mpDispatcher(pDispatcher)
+ , maCellLineStyleValueSet(VclPtr<sc::sidebar::CellLineStyleValueSet>::Create(get<vcl::Window>("box")))
{
+ get(maPushButtonMoreOptions, "more");
Initialize();
- FreeResource();
}
-CellLineStyleControl::~CellLineStyleControl()
+CellLineStylePopup::~CellLineStylePopup()
{
disposeOnce();
}
-void CellLineStyleControl::dispose()
+void CellLineStylePopup::dispose()
{
- maPushButtonMoreOptions.disposeAndClear();
+ maPushButtonMoreOptions.clear();
maCellLineStyleValueSet.disposeAndClear();
- mxFloatParent.clear();
- Control::dispose();
+ FloatingWindow::dispose();
}
-void CellLineStyleControl::Initialize()
+void CellLineStylePopup::Initialize()
{
- //maPushButtonMoreOptions->SetIcoPosX(2);
- Link<Button*,void> aLink = LINK(this, CellLineStyleControl, PBClickHdl);
+ Link<Button*,void> aLink = LINK(this, CellLineStylePopup, PBClickHdl);
maPushButtonMoreOptions->SetClickHdl(aLink);
maCellLineStyleValueSet->SetStyle(maCellLineStyleValueSet->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT);
@@ -90,20 +85,12 @@ void CellLineStyleControl::Initialize()
}
SetAllNoSel();
- maCellLineStyleValueSet->SetSelectHdl(LINK(this, CellLineStyleControl, VSSelectHdl));
+ maCellLineStyleValueSet->SetSelectHdl(LINK(this, CellLineStylePopup, VSSelectHdl));
maCellLineStyleValueSet->StartSelection();
maCellLineStyleValueSet->Show();
}
-void CellLineStyleControl::GetFocus()
-{
- if (!mbVSfocus && maPushButtonMoreOptions)
- maPushButtonMoreOptions->GrabFocus();
- else if (maCellLineStyleValueSet)
- maCellLineStyleValueSet->GrabFocus();
-}
-
-void CellLineStyleControl::SetAllNoSel()
+void CellLineStylePopup::SetAllNoSel()
{
maCellLineStyleValueSet->SelectItem(0);
maCellLineStyleValueSet->SetNoSelection();
@@ -113,7 +100,7 @@ void CellLineStyleControl::SetAllNoSel()
maCellLineStyleValueSet->StartSelection();
}
-IMPL_LINK(CellLineStyleControl, VSSelectHdl, ValueSet*, pControl, void)
+IMPL_LINK(CellLineStylePopup, VSSelectHdl, ValueSet*, pControl, void)
{
if(pControl == maCellLineStyleValueSet.get())
{
@@ -181,23 +168,23 @@ IMPL_LINK(CellLineStyleControl, VSSelectHdl, ValueSet*, pControl, void)
mpDispatcher->ExecuteList(
SID_FRAME_LINESTYLE, SfxCallMode::RECORD, { &aLineItem });
SetAllNoSel();
- mxFloatParent->EndPopupMode();
+ EndPopupMode();
}
}
-IMPL_LINK(CellLineStyleControl, PBClickHdl, Button *, pPBtn, void)
+IMPL_LINK(CellLineStylePopup, PBClickHdl, Button *, pPBtn, void)
{
if (pPBtn == maPushButtonMoreOptions.get())
{
mpDispatcher->Execute(SID_CELL_FORMAT_BORDER, SfxCallMode::ASYNCHRON);
- mxFloatParent->EndPopupMode();
+ EndPopupMode();
}
}
-void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis)
+void CellLineStylePopup::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis)
{
+ maCellLineStyleValueSet->GrabFocus();
SetAllNoSel();
- mbVSfocus = true;
//FIXME: fully for new border line possibilities
@@ -240,7 +227,7 @@ void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal
else
{
maCellLineStyleValueSet->SetSelItem(0);
- mbVSfocus = false;
+ maPushButtonMoreOptions->GrabFocus();
}
maCellLineStyleValueSet->SetFormat();
maCellLineStyleValueSet->Invalidate();
diff --git a/sc/source/ui/sidebar/CellLineStyleControl.hxx b/sc/source/ui/sidebar/CellLineStyleControl.hxx
index 93548495d4d6..ea5f090d1c02 100644
--- a/sc/source/ui/sidebar/CellLineStyleControl.hxx
+++ b/sc/source/ui/sidebar/CellLineStyleControl.hxx
@@ -20,6 +20,7 @@
#define INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLECONTROL_HXX
#include <vcl/button.hxx>
+#include <vcl/floatwin.hxx>
#include "CellLineStyleValueSet.hxx"
class SfxDispatcher;
@@ -27,30 +28,26 @@ class SfxDispatcher;
namespace sc { namespace sidebar {
class CellAppearancePropertyPanel;
-class CellLineStyleControl : public Control
+
+class CellLineStylePopup : public FloatingWindow
{
-private:
SfxDispatcher* mpDispatcher;
- VclPtr<FloatingWindow> mxFloatParent;
VclPtr<PushButton> maPushButtonMoreOptions;
VclPtr<CellLineStyleValueSet> maCellLineStyleValueSet;
OUString maStr[CELL_LINE_STYLE_ENTRIES];
- bool mbVSfocus : 1;
-
void Initialize();
void SetAllNoSel();
DECL_LINK(VSSelectHdl, ValueSet*, void);
DECL_LINK(PBClickHdl, Button*, void);
-public:
- CellLineStyleControl(FloatingWindow* pParent, SfxDispatcher* pDispatcher);
- virtual ~CellLineStyleControl() override;
- virtual void dispose() override;
- void GetFocus() override;
+public:
+ CellLineStylePopup(SfxDispatcher* pDispatcher);
void SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis);
+ virtual ~CellLineStylePopup() override;
+ virtual void dispose() override;
};
} } // end of namespace svx::sidebar
diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx
index ec05c9168667..9c3d25a9ede4 100644
--- a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx
+++ b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx
@@ -23,10 +23,10 @@
namespace sc { namespace sidebar {
-CellLineStyleValueSet::CellLineStyleValueSet( vcl::Window* pParent, const ResId& rResId)
-: ValueSet( pParent, rResId ),
- pVDev(nullptr),
- nSelItem(0)
+CellLineStyleValueSet::CellLineStyleValueSet(vcl::Window* pParent)
+ : ValueSet(pParent, WB_TABSTOP)
+ , pVDev(nullptr)
+ , nSelItem(0)
{
SetColCount();
SetLineCount( 9);
@@ -43,6 +43,11 @@ void CellLineStyleValueSet::dispose()
ValueSet::dispose();
}
+Size CellLineStyleValueSet::GetOptimalSize() const
+{
+ return LogicToPixel(Size(80, 12 * 9), MAP_APPFONT);
+}
+
void CellLineStyleValueSet::SetUnit(const OUString* str)
{
for (int i = 0; i < CELL_LINE_STYLE_ENTRIES; ++i)
@@ -85,9 +90,6 @@ void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
aSize.Height() = nRectHeight*3/5;
aFont.SetFontSize( aSize );
- long nTLX = aBLPos.X() + 5, nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
- long nTRX = aBLPos.X() + nRectWidth * 7 / 9 - 15, nTRY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
-
if( nSelItem == nItemId )
{
Color aBackColor(50,107,197);
@@ -104,13 +106,16 @@ void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
}
//draw text
- if(nSelItem == nItemId )
+ if (nSelItem == nItemId )
aFont.SetColor(COL_WHITE);
else
aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
pDev->SetFont(aFont);
- Point aStart(aBLPos.X() + nRectWidth * 7 / 9 - 5 , aBLPos.Y() + nRectHeight/6);
+ long nTextWidth = pDev->GetTextWidth(maStrUnit[nItemId - 1]);
+ long nTLX = aBLPos.X() + 5, nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
+ long nTRX = aBLPos.X() + nRectWidth - nTextWidth - 15, nTRY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
+ Point aStart(aBLPos.X() + nRectWidth - nTextWidth - 5 , aBLPos.Y() + nRectHeight/6);
pDev->DrawText(aStart, maStrUnit[nItemId - 1]); //can't set DrawTextFlags::EndEllipsis here, or the text will disappear
//draw line
diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.hxx b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx
index 6ab6e7569e52..3e87b310dda7 100644
--- a/sc/source/ui/sidebar/CellLineStyleValueSet.hxx
+++ b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx
@@ -33,12 +33,13 @@ private:
sal_uInt16 nSelItem;
OUString maStrUnit[CELL_LINE_STYLE_ENTRIES];
public:
- CellLineStyleValueSet( vcl::Window* pParent, const ResId& rResId);
+ CellLineStyleValueSet(vcl::Window* pParent);
virtual ~CellLineStyleValueSet() override;
virtual void dispose() override;
void SetUnit(const OUString* str);
void SetSelItem(sal_uInt16 nSel);
+ virtual Size GetOptimalSize() const override;
virtual void UserDraw( const UserDrawEvent& rUDEvt ) override;
};