summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-23 14:15:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-28 17:53:27 +0200
commitd78da37b5250cbc94c553e4ee2d542a35e3eb293 (patch)
treed62f6dba4d9bc262edc1e2e6e9b7571cad2de1f7 /include
parent3341435d7916c209c7613d594f78059ba112495b (diff)
weld ScTabBgColorDlg
Change-Id: I864382bc55dead850c13faae9958fb660fd4f156 Reviewed-on: https://gerrit.libreoffice.org/54920 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/svtools/valueset.hxx201
-rw-r--r--include/svx/SvxColorValueSet.hxx13
-rw-r--r--include/vcl/customweld.hxx19
-rw-r--r--include/vcl/layout.hxx24
-rw-r--r--include/vcl/weld.hxx16
5 files changed, 269 insertions, 4 deletions
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index 000e00268874..5530adf33da8 100644
--- a/include/svtools/valueset.hxx
+++ b/include/svtools/valueset.hxx
@@ -25,6 +25,7 @@
#include <vcl/ctrl.hxx>
#include <vcl/virdev.hxx>
#include <vcl/timer.hxx>
+#include <vcl/customweld.hxx>
#include <memory>
#include <vector>
@@ -36,6 +37,7 @@ class DataChangedEvent;
class ScrollBar;
struct ValueSetItem;
+struct SvtValueSetItem;
class ValueSetAcc;
class ValueItemAcc;
@@ -178,6 +180,7 @@ to be set (before Show) with SetStyle().
*************************************************************************/
typedef std::vector<ValueSetItem*> ValueItemList;
+typedef std::vector<SvtValueSetItem*> SvtValueItemList;
#define WB_ITEMBORDER (WinBits(0x00010000))
#define WB_DOUBLEBORDER (WinBits(0x00020000))
@@ -405,6 +408,204 @@ public:
void SetEdgeBlending(bool bNew);
};
+class SVT_DLLPUBLIC SvtValueSet : public weld::CustomWidgetController
+{
+private:
+
+ ScopedVclPtr<VirtualDevice> maVirDev;
+ css::uno::Reference<css::accessibility::XAccessible> mxAccessible;
+ SvtValueItemList mItemList;
+ std::unique_ptr<SvtValueSetItem> mpNoneItem;
+ tools::Rectangle maNoneItemRect;
+ tools::Rectangle maItemListRect;
+ long mnItemWidth;
+ long mnItemHeight;
+ long mnTextOffset;
+ long mnVisLines;
+ long mnLines;
+ long mnUserItemWidth;
+ long mnUserItemHeight;
+ sal_uInt16 mnSelItemId;
+ sal_uInt16 mnHighItemId;
+ sal_uInt16 mnCols;
+ sal_uInt16 mnCurCol;
+ sal_uInt16 mnUserCols;
+ sal_uInt16 mnUserVisLines;
+ sal_uInt16 mnFirstLine;
+ sal_uInt16 mnSpacing;
+ DrawFrameStyle mnFrameStyle;
+ Color maColor;
+ OUString maText;
+ WinBits mnStyle;
+ Link<SvtValueSet*,void> maDoubleClickHdl;
+ Link<SvtValueSet*,void> maSelectHdl;
+ Link<SvtValueSet*,void> maHighlightHdl;
+
+ bool mbFormat : 1;
+ bool mbNoSelection : 1;
+ bool mbBlackSel : 1;
+ bool mbDoubleSel : 1;
+ bool mbScroll : 1;
+ bool mbFullMode : 1;
+ bool mbEdgeBlending : 1;
+ bool mbHasVisibleItems : 1;
+
+ friend class SvtValueSetAcc;
+ friend class SvtValueItemAcc;
+
+ SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
+
+ SVT_DLLPRIVATE void ImplInitScrollBar();
+ SVT_DLLPRIVATE void ImplDeleteItems();
+ SVT_DLLPRIVATE void ImplFormatItem(vcl::RenderContext const & rRenderContext, SvtValueSetItem* pItem, tools::Rectangle aRect);
+ SVT_DLLPRIVATE void ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rStr);
+ SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel);
+ SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext);
+ SVT_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext);
+ SVT_DLLPRIVATE bool ImplScroll( const Point& rPos );
+ SVT_DLLPRIVATE size_t ImplGetItem( const Point& rPoint ) const;
+ SVT_DLLPRIVATE SvtValueSetItem* ImplGetItem( size_t nPos );
+ SVT_DLLPRIVATE SvtValueSetItem* ImplGetFirstItem();
+ SVT_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const;
+ SVT_DLLPRIVATE void ImplInsertItem( SvtValueSetItem *const pItem, const size_t nPos );
+ SVT_DLLPRIVATE tools::Rectangle ImplGetItemRect( size_t nPos ) const;
+ SVT_DLLPRIVATE void ImplFireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue );
+ SVT_DLLPRIVATE bool ImplHasAccessibleListeners();
+ DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar*, void );
+
+ SvtValueSet (const SvtValueSet &) = delete;
+ SvtValueSet & operator= (const SvtValueSet &) = delete;
+
+protected:
+ virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
+
+public:
+ SvtValueSet();
+ virtual ~SvtValueSet() override;
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
+ virtual bool KeyInput( const KeyEvent& rKEvt ) override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+ virtual void GetFocus() override;
+ virtual void LoseFocus() override;
+ virtual void Resize() override;
+ virtual void StyleUpdated() override;
+ virtual OUString RequestHelp(tools::Rectangle& rHelpRect) override;
+
+ virtual void Select();
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+
+ OUString GetText() const { return maText; }
+ void SetText(const OUString& rText) { maText = rText; }
+ void SetStyle(WinBits nStyle) { mnStyle = nStyle; }
+ WinBits GetStyle() const { return mnStyle; }
+
+ /// Insert @rImage item.
+ void InsertItem(sal_uInt16 nItemId, const Image& rImage);
+ /// Insert @rImage item with @rStr as either a legend or tooltip depending on @bShowLegend.
+ void InsertItem(sal_uInt16 nItemId, const Image& rImage,
+ const OUString& rStr, size_t nPos = VALUESET_APPEND, bool bShowLegend = false);
+ /// Insert an @rColor item with @rStr tooltip.
+ void InsertItem(sal_uInt16 nItemId, const Color& rColor,
+ const OUString& rStr);
+ /// Insert an User Drawn item.
+ void InsertItem(sal_uInt16 nItemId, size_t nPos = VALUESET_APPEND);
+ /// Insert an User Drawn item with @rStr tooltip.
+ void InsertItem(sal_uInt16 nItemId, const OUString& rStr, size_t nPos);
+ void RemoveItem(sal_uInt16 nItemId);
+
+ void Clear();
+
+ size_t GetItemCount() const;
+ size_t GetItemPos( sal_uInt16 nItemId ) const;
+ sal_uInt16 GetItemId( size_t nPos ) const;
+ sal_uInt16 GetItemId( const Point& rPos ) const;
+ tools::Rectangle GetItemRect( sal_uInt16 nItemId ) const;
+ void EnableFullItemMode( bool bFullMode );
+
+ void SetColCount( sal_uInt16 nNewCols = 1 );
+ sal_uInt16 GetColCount() const
+ {
+ return mnUserCols;
+ }
+ void SetLineCount( sal_uInt16 nNewLines = 0 );
+ sal_uInt16 GetLineCount() const
+ {
+ return mnUserVisLines;
+ }
+ void SetItemWidth( long nItemWidth );
+ void SetItemHeight( long nLineHeight );
+ Size GetLargestItemSize();
+ void RecalculateItemSizes();
+
+ void SelectItem( sal_uInt16 nItemId );
+ sal_uInt16 GetSelectedItemId() const
+ {
+ return mnSelItemId;
+ }
+ size_t GetSelectItemPos() const
+ {
+ return GetItemPos( mnSelItemId );
+ }
+ bool IsItemSelected( sal_uInt16 nItemId ) const
+ {
+ return !mbNoSelection && (nItemId == mnSelItemId);
+ }
+ void SetNoSelection();
+ bool IsNoSelection() const
+ {
+ return mbNoSelection;
+ }
+
+ void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
+ Image GetItemImage( sal_uInt16 nItemId ) const;
+ void SetItemColor( sal_uInt16 nItemId, const Color& rColor );
+ Color GetItemColor( sal_uInt16 nItemId ) const;
+ void SetItemData( sal_uInt16 nItemId, void* pData );
+ void* GetItemData( sal_uInt16 nItemId ) const;
+ void SetItemText( sal_uInt16 nItemId, const OUString& rStr );
+ OUString GetItemText( sal_uInt16 nItemId ) const;
+ void SetColor( const Color& rColor );
+ void SetColor()
+ {
+ SetColor(COL_TRANSPARENT);
+ }
+ bool IsColor() const
+ {
+ return maColor.GetTransparency() == 0;
+ }
+
+ void SetExtraSpacing( sal_uInt16 nNewSpacing );
+
+ void Format(vcl::RenderContext const & rRenderContext);
+ void SetFormat();
+
+ Size CalcWindowSizePixel(const Size& rItemSize,
+ sal_uInt16 nCalcCols = 0,
+ sal_uInt16 nCalcLines = 0) const;
+ Size CalcItemSizePixel(const Size& rSize) const;
+
+ void SetSelectHdl(const Link<SvtValueSet*,void>& rLink)
+ {
+ maSelectHdl = rLink;
+ }
+ void SetDoubleClickHdl(const Link<SvtValueSet*,void>& rLink)
+ {
+ maDoubleClickHdl = rLink;
+ }
+
+ void SetHighlightHdl(const Link<SvtValueSet*,void>& rLink);
+
+ bool GetEdgeBlending() const
+ {
+ return mbEdgeBlending;
+ }
+ void SetEdgeBlending(bool bNew);
+};
+
+
#endif // INCLUDED_SVTOOLS_VALUESET_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx
index 1e6d6a615c79..32026c351814 100644
--- a/include/svx/SvxColorValueSet.hxx
+++ b/include/svx/SvxColorValueSet.hxx
@@ -42,6 +42,19 @@ public:
Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
};
+class SVX_DLLPUBLIC ColorValueSet : public SvtValueSet
+{
+public:
+ ColorValueSet();
+
+ virtual void Resize() override;
+
+ void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1);
+ void addEntriesForColorSet(const std::set<Color>& rColorSet, const OUString& rNamePrefix);
+ Size layoutAllVisible(sal_uInt32 nEntryCount);
+ Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
+};
+
#endif // INCLUDED_SVX_SVXCOLORVALUESET_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx
index 274db81bd781..2395bc5e45f6 100644
--- a/include/vcl/customweld.hxx
+++ b/include/vcl/customweld.hxx
@@ -21,6 +21,10 @@ private:
weld::DrawingArea* m_pDrawingArea;
public:
+ virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible()
+ {
+ return css::uno::Reference<css::accessibility::XAccessible>();
+ }
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) = 0;
virtual void Resize() {}
virtual void MouseButtonDown(const MouseEvent&) {}
@@ -30,17 +34,15 @@ public:
virtual void LoseFocus() {}
virtual void StyleUpdated() { Invalidate(); }
virtual bool KeyInput(const KeyEvent&) { return false; }
- virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible()
- {
- return css::uno::Reference<css::accessibility::XAccessible>();
- }
virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); }
virtual FactoryFunction GetUITestFactory() const { return nullptr; }
+ virtual OUString RequestHelp(tools::Rectangle&) { return OUString(); }
Size const& GetOutputSizePixel() const { return m_aSize; }
void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; }
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; }
weld::DrawingArea* GetDrawingArea() const { return m_pDrawingArea; }
void Invalidate() { m_pDrawingArea->queue_draw(); }
+ static bool IsUpdateMode() { return true; }
void Invalidate(const tools::Rectangle& rRect)
{
m_pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(),
@@ -51,13 +53,21 @@ public:
void GrabFocus() { m_pDrawingArea->grab_focus(); }
bool HasFocus() const { return m_pDrawingArea->has_focus(); }
bool IsVisible() const { return m_pDrawingArea->get_visible(); }
+ bool IsReallyVisible() const { return m_pDrawingArea->is_visible(); }
bool IsEnabled() const { return m_pDrawingArea->get_sensitive(); }
+ int GetTextHeight() const { return m_pDrawingArea->get_text_height(); }
+ OUString GetAccessibleName() const { return m_pDrawingArea->get_accessible_name(); }
void grab_add() { m_pDrawingArea->grab_add(); }
void grab_remove() { m_pDrawingArea->grab_remove(); }
void set_size_request(int nWidth, int nHeight)
{
m_pDrawingArea->set_size_request(nWidth, nHeight);
}
+ void queue_resize() { m_pDrawingArea->queue_resize(); }
+ CustomWidgetController()
+ : m_pDrawingArea(nullptr)
+ {
+ }
virtual ~CustomWidgetController();
};
@@ -77,6 +87,7 @@ private:
DECL_LINK(DoKeyPress, const KeyEvent&, bool);
DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle);
DECL_LINK(DoStyleUpdated, weld::Widget&, void);
+ DECL_LINK(DoRequestHelp, tools::Rectangle&, OUString);
public:
CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 6423d12488b9..d2fefe01f875 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -14,6 +14,7 @@
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
+#include <vcl/help.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/split.hxx>
#include <vcl/svapp.hxx>
@@ -627,6 +628,7 @@ private:
Link<const KeyEvent&, bool> m_aKeyPressHdl;
Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
Link<VclDrawingArea&, void> m_aStyleUpdatedHdl;
+ Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
{
@@ -677,6 +679,24 @@ private:
Invalidate();
}
}
+ virtual void RequestHelp(const HelpEvent& rHelpEvent) override
+ {
+ if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))
+ {
+ Point aPos(rHelpEvent.GetMousePosPixel());
+ tools::Rectangle aHelpArea(aPos.X(), aPos.Y());
+ OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea);
+ if (sHelpTip.isEmpty())
+ return;
+ Point aPt = OutputToScreenPixel(aHelpArea.TopLeft());
+ aHelpArea.SetLeft(aPt.X());
+ aHelpArea.SetTop(aPt.Y());
+ aPt = OutputToScreenPixel(aHelpArea.BottomRight());
+ aHelpArea.SetRight(aPt.X());
+ aHelpArea.SetBottom(aPt.Y());
+ Help::ShowQuickHelp(this, aHelpArea, sHelpTip);
+ }
+ }
virtual FactoryFunction GetUITestFactory() const override
{
if (m_pFactoryFunction)
@@ -732,6 +752,10 @@ public:
{
m_aStyleUpdatedHdl = rLink;
}
+ void SetQueryTooltipHdl(const Link<tools::Rectangle&, OUString>& rLink)
+ {
+ m_aQueryTooltipHdl = rLink;
+ }
};
//Get first window of a pTopLevel window as
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index ace717371fdd..963a7e509ebf 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -79,6 +79,8 @@ public:
virtual void set_accessible_name(const OUString& rName) = 0;
virtual OUString get_accessible_name() const = 0;
+ virtual void set_tooltip_text(const OUString& rTip) = 0;
+
virtual void connect_focus_in(const Link<Widget&, void>& rLink)
{
assert(!m_aFocusInHdl.IsSet());
@@ -94,6 +96,9 @@ public:
virtual void grab_add() = 0;
virtual void grab_remove() = 0;
+ //true for rtl, false otherwise
+ virtual bool get_direction() const = 0;
+
virtual Container* weld_parent() const = 0;
virtual ~Widget() {}
@@ -790,6 +795,12 @@ protected:
Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
Link<Widget&, void> m_aStyleUpdatedHdl;
Link<Widget&, tools::Rectangle> m_aGetFocusRectHdl;
+ Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
+
+ OUString signal_query_tooltip(tools::Rectangle& rHelpArea)
+ {
+ return m_aQueryTooltipHdl.Call(rHelpArea);
+ }
public:
void connect_draw(const Link<draw_args, void>& rLink) { m_aDrawHdl = rLink; }
@@ -813,8 +824,13 @@ public:
{
m_aGetFocusRectHdl = rLink;
}
+ void connect_query_tooltip(const Link<tools::Rectangle&, OUString>& rLink)
+ {
+ m_aQueryTooltipHdl = rLink;
+ }
virtual void queue_draw() = 0;
virtual void queue_draw_area(int x, int y, int width, int height) = 0;
+ virtual void queue_resize() = 0;
virtual a11yref get_accessible_parent() = 0;
virtual a11yrelationset get_accessible_relation_set() = 0;
};