weld color picker

Change-Id: I487b9a0cc13b2b60a0f1e28667773b5d3b5c66cc
Reviewed-on: https://gerrit.libreoffice.org/51001
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-03-08 12:17:56 +00:00
parent e0e307675c
commit cf4b65c75c
19 changed files with 802 additions and 549 deletions

View File

@@ -231,8 +231,6 @@ bool FpComparison::ignore(FunctionDecl* function)
|| dc.Function("ApplySpecialItem").Class("TitleItemConverter").Namespace("wrapper").Namespace("chart").GlobalNamespace()
|| dc.Function("ApplySpecialItem").Class("TextLabelItemConverter").Namespace("wrapper").Namespace("chart").GlobalNamespace()
|| dc.Function("operate").Class("OOp_COMPARE").Namespace("file").Namespace("connectivity").GlobalNamespace()
|| dc.Function("SetValues").Class("ColorFieldControl").Namespace("cui").GlobalNamespace()
|| dc.Function("SetValue").Class("ColorSliderControl").Namespace("cui").GlobalNamespace()
|| dc.Function("Write").Class("ORTFImportExport").Namespace("dbaui").GlobalNamespace()
|| dc.Function("appendRow").Class("ORTFImportExport").Namespace("dbaui").GlobalNamespace()
|| dc.Function("WriteCell").Class("OHTMLImportExport").Namespace("dbaui").GlobalNamespace()

View File

@@ -63,7 +63,6 @@
#define RID_SVXBMP_FILEOPEN "res/fileopen.png"
#define RID_SVXBMP_TARGET "res/target.png"
#define RID_SVXBMP_NEWDOC "res/newdoc.png"
#define RID_SVXBMP_COLORSLIDER "res/colorslider.png"
#define RID_SVXBMP_COLLAPSEDNODE "res/sx18002.png"
#define RID_SVXBMP_EXPANDEDNODE "res/sx18003.png"

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.2 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkAdjustment" id="adjustment1">
<object class="GtkAdjustment" id="adjustmentblue">
<property name="upper">255</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<object class="GtkAdjustment" id="adjustmentbright">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentcyan">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentgreen">
<property name="upper">255</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmenthue">
<property name="upper">360</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<object class="GtkAdjustment" id="adjustmentkey">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentmag">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentred">
<property name="upper">255</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentsat">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentyellow">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
@@ -26,6 +60,8 @@
<property name="title" translatable="yes" context="colorpickerdialog|ColorPicker">Pick a Color</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -115,7 +151,7 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<child>
<object class="cuilo-ColorPreviewControl" id="preview">
<object class="GtkDrawingArea" id="preview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -127,8 +163,7 @@
</packing>
</child>
<child>
<object class="cuilo-ColorPreviewControl" id="previous">
<property name="visible">True</property>
<object class="GtkDrawingArea" id="previous">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
</object>
@@ -145,9 +180,10 @@
</packing>
</child>
<child>
<object class="cuilo-ColorFieldControl" id="colorField:border">
<object class="GtkDrawingArea" id="colorField">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
@@ -157,9 +193,10 @@
</packing>
</child>
<child>
<object class="cuilo-ColorSliderControl" id="colorSlider:border">
<object class="GtkDrawingArea" id="colorSlider">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
<property name="vexpand">True</property>
</object>
<packing>
@@ -172,7 +209,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_name">res/colorsliderright.png</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -184,7 +221,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_name">res/colorsliderleft.png</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -248,9 +285,8 @@
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">greenRadiobutton</property>
<property name="group">hueRadiobutton</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -267,7 +303,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">redRadiobutton</property>
<property name="group">hueRadiobutton</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -284,7 +320,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">redRadiobutton</property>
<property name="group">hueRadiobutton</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -292,11 +328,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="redSpinbutton:0">
<object class="GtkSpinButton" id="redSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment1</property>
<property name="adjustment">adjustmentred</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -304,11 +340,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="greenSpinbutton:0">
<object class="GtkSpinButton" id="greenSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment1</property>
<property name="adjustment">adjustmentgreen</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -316,11 +352,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="blueSpinbutton:0">
<object class="GtkSpinButton" id="blueSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment1</property>
<property name="adjustment">adjustmentblue</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -331,10 +367,10 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="colorpickerdialog|label2">Hex _#:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">hexEntry</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -342,7 +378,7 @@
</packing>
</child>
<child>
<object class="svxcorelo-HexColorControl" id="hexEntry">
<object class="GtkEntry" id="hexEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
@@ -408,7 +444,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">redRadiobutton</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -425,7 +460,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">redRadiobutton</property>
<property name="group">hueRadiobutton</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -442,7 +477,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">redRadiobutton</property>
<property name="group">hueRadiobutton</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -450,11 +485,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="hueSpinbutton">
<object class="GtkSpinButton" id="hueSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment2</property>
<property name="adjustment">adjustmenthue</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -462,11 +497,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="satSpinbutton:%">
<object class="GtkSpinButton" id="satSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment3</property>
<property name="adjustment">adjustmentsat</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -474,11 +509,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="brightSpinbutton:%">
<object class="GtkSpinButton" id="brightSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment3</property>
<property name="adjustment">adjustmentbright</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -533,10 +568,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="colorpickerdialog|label5">_Cyan:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">cyanSpinbutton:%</property>
<property name="mnemonic_widget">cyanSpinbutton</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -548,10 +583,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="colorpickerdialog|label6">_Magenta:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">magSpinbutton:%</property>
<property name="mnemonic_widget">magSpinbutton</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -563,10 +598,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="colorpickerdialog|label7">_Yellow:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">yellowSpinbutton:%</property>
<property name="mnemonic_widget">yellowSpinbutton</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -578,10 +613,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="colorpickerdialog|label8">_Key:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">keySpinbutton:%</property>
<property name="mnemonic_widget">keySpinbutton</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -589,11 +624,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="cyanSpinbutton:%">
<object class="GtkSpinButton" id="cyanSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment3</property>
<property name="adjustment">adjustmentcyan</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -601,11 +636,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="magSpinbutton:%">
<object class="GtkSpinButton" id="magSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment3</property>
<property name="adjustment">adjustmentmag</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -613,11 +648,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="yellowSpinbutton:%">
<object class="GtkSpinButton" id="yellowSpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment3</property>
<property name="adjustment">adjustmentyellow</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -625,11 +660,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="keySpinbutton:%">
<object class="GtkSpinButton" id="keySpinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment3</property>
<property name="adjustment">adjustmentkey</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -678,6 +713,9 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>

View File

@@ -281,15 +281,6 @@
<glade-widget-class title="Graphic Preview" name="cuilo-GraphicPreviewWindow"
generic-name="Graphic Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Color Field Control" name="cuilo-ColorFieldControl"
generic-name="Color Field Control" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Color Slider Control" name="cuilo-ColorSliderControl"
generic-name="Color Slider Control" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Color Preview Control" name="cuilo-ColorPreviewControl"
generic-name="Color Preview Control" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Html Attribute Preview" name="sduilo-SdHtmlAttrPreview"
generic-name="Html Attribute Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>

View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

View File

@@ -26,6 +26,7 @@
#include <vcl/edit.hxx>
#include <vcl/svapp.hxx>
#include <vcl/builderfactory.hxx>
#include <vcl/weld.hxx>
#include <sot/exchange.hxx>
#include <sax/tools/converter.hxx>
#include <svx/svxdllapi.h>
@@ -46,6 +47,25 @@ private:
static bool ImplProcessKeyInput( const KeyEvent& rKEv );
};
namespace weld {
class SVX_DLLPUBLIC HexColorControl
{
private:
std::unique_ptr<weld::Entry> m_xEntry;
DECL_LINK(ImplProcessInputHdl, OUString&, bool);
public:
HexColorControl(weld::Entry* pEdit);
void connect_changed(const Link<Entry&, void>& rLink) { m_xEntry->connect_changed(rLink); }
void SetColor( ::Color nColor );
::Color GetColor();
};
}
#endif // INCLUDED_SVX_HEXCOLOR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -613,14 +613,39 @@ public:
class VCL_DLLPUBLIC VclDrawingArea : public vcl::Window
{
private:
Link<vcl::RenderContext&, void> m_aPaintHdl;
Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void> m_aPaintHdl;
Link<const Size&, void> m_aResizeHdl;
Link<const Point&, void> m_aMousePressHdl;
Link<const Point&, void> m_aMouseMotionHdl;
Link<const Point&, void> m_aMouseReleaseHdl;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
{
m_aPaintHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(rRenderContext, rRect));
}
virtual void Resize() override
{
m_aResizeHdl.Call(GetOutputSizePixel());
}
virtual void MouseMove(const MouseEvent& rMEvt) override
{
m_aMouseMotionHdl.Call(rMEvt.GetPosPixel());
}
virtual void MouseButtonDown(const MouseEvent& rMEvt) override
{
m_aMousePressHdl.Call(rMEvt.GetPosPixel());
}
virtual void MouseButtonUp(const MouseEvent& rMEvt) override
{
m_aMouseReleaseHdl.Call(rMEvt.GetPosPixel());
}
public:
VclDrawingArea(vcl::Window *pParent, WinBits nStyle)
: vcl::Window(pParent, nStyle)
{
}
void SetPaintHdl(const Link<vcl::RenderContext&, void>& rLink)
void SetPaintHdl(const Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>& rLink)
{
m_aPaintHdl = rLink;
}
@@ -628,13 +653,17 @@ public:
{
m_aResizeHdl = rLink;
}
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override
void SetMousePressHdl(const Link<const Point&, void>& rLink)
{
m_aPaintHdl.Call(rRenderContext);
m_aMousePressHdl = rLink;
}
virtual void Resize() override
void SetMouseMoveHdl(const Link<const Point&, void>& rLink)
{
m_aResizeHdl.Call(GetOutputSizePixel());
m_aMouseMotionHdl = rLink;
}
void SetMouseReleaseHdl(const Link<const Point&, void>& rLink)
{
m_aMouseReleaseHdl = rLink;
}
};

View File

@@ -54,6 +54,9 @@ public:
virtual void set_grid_top_attach(int nAttach) = 0;
virtual int get_grid_top_attach() const = 0;
virtual void set_margin_top(int nMargin) = 0;
virtual void set_margin_bottom(int nMargin) = 0;
virtual Container* weld_parent() const = 0;
virtual ~Widget() {}
@@ -307,6 +310,7 @@ public:
virtual void set_text(const OUString& rText) = 0;
virtual OUString get_text() const = 0;
virtual void set_width_chars(int nChars) = 0;
virtual void set_max_length(int nChars) = 0;
virtual void select_region(int nStartPos, int nEndPos) = 0;
virtual void set_position(int nCursorPos) = 0;
@@ -493,14 +497,27 @@ public:
class VCL_DLLPUBLIC DrawingArea : virtual public Widget
{
public:
typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> draw_args;
protected:
Link<vcl::RenderContext&, void> m_aDrawHdl;
Link<draw_args, void> m_aDrawHdl;
Link<const Size&, void> m_aSizeAllocateHdl;
Link<const Point&, void> m_aMousePressHdl;
Link<const Point&, void> m_aMouseMotionHdl;
Link<const Point&, void> m_aMouseReleaseHdl;
public:
void connect_draw(const Link<vcl::RenderContext&, void>& rLink) { m_aDrawHdl = rLink; }
void connect_draw(const Link<draw_args, void>& rLink) { m_aDrawHdl = rLink; }
void connect_size_allocate(const Link<const Size&, void>& rLink) { m_aSizeAllocateHdl = rLink; }
void connect_mouse_press(const Link<const Point&, void>& rLink) { m_aMousePressHdl = rLink; }
void connect_mouse_move(const Link<const Point&, void>& rLink) { m_aMouseMotionHdl = rLink; }
void connect_mouse_release(const Link<const Point&, void>& rLink)
{
m_aMouseReleaseHdl = rLink;
}
virtual void queue_draw() = 0;
virtual void queue_draw_area(int x, int y, int width, int height) = 0;
};
class VCL_DLLPUBLIC Builder

View File

@@ -105,9 +105,9 @@ void SfxPreviewWin_Impl::ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFil
}
}
IMPL_LINK(SfxPreviewWin_Impl, DoPaint, vcl::RenderContext&, rRenderContext, void)
IMPL_LINK(SfxPreviewWin_Impl, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
{
ImpPaint(rRenderContext, xMetaFile.get());
ImpPaint(aPayload.first, xMetaFile.get());
}
IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void)
@@ -193,6 +193,7 @@ IMPL_LINK( SfxNewFileDialog, RegionSelect, weld::TreeView&, rBox, void )
m_xTemplateLb->append(m_aTemplates.GetName(nRegion, i));
m_xTemplateLb->thaw();
m_xTemplateLb->select(0);
TemplateSelect(*m_xTemplateLb);
}
IMPL_LINK_NOARG(SfxNewFileDialog, Expand, weld::Expander&, void)

View File

@@ -32,7 +32,7 @@ protected:
public:
SfxPreviewWin_Impl(weld::DrawingArea* pArea);
void SetObjectShell( SfxObjectShell const * pObj );
DECL_LINK(DoPaint, vcl::RenderContext&, void);
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
void queue_draw() { m_xDrawingArea->queue_draw(); }
void show() { m_xDrawingArea->show(); }

View File

@@ -126,4 +126,67 @@ bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv )
return false;
}
namespace weld {
HexColorControl::HexColorControl(weld::Entry* pEntry)
: m_xEntry(pEntry)
{
m_xEntry->set_max_length(6);
m_xEntry->set_width_chars(6);
m_xEntry->connect_insert_text(LINK(this, HexColorControl, ImplProcessInputHdl));
}
void HexColorControl::SetColor(Color nColor)
{
OUStringBuffer aBuffer;
sax::Converter::convertColor(aBuffer, nColor);
m_xEntry->set_text(aBuffer.makeStringAndClear().copy(1));
}
Color HexColorControl::GetColor()
{
sal_Int32 nColor = -1;
OUString aStr("#");
aStr += m_xEntry->get_text();
sal_Int32 nLen = aStr.getLength();
if (nLen < 7)
{
static const sal_Char* const pNullStr = "000000";
aStr += OUString::createFromAscii( &pNullStr[nLen-1] );
}
sax::Converter::convertColor(nColor, aStr);
#if 0
if (nColor == -1)
SetControlBackground(COL_RED);
else
SetControlBackground();
#endif
return Color(nColor);
}
IMPL_LINK(HexColorControl, ImplProcessInputHdl, OUString&, rTest, bool)
{
const sal_Unicode* pTest = rTest.getStr();
sal_Int32 nLen = rTest.getLength();
OUStringBuffer aFilter(nLen);
for (sal_Int32 i = 0; i < nLen; ++i)
{
if (rtl::isAsciiHexDigit(*pTest))
aFilter.append(*pTest);
++pTest;
}
rTest = aFilter.makeStringAndClear();
return true;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -842,8 +842,10 @@ void AutoFormatPreview::NotifyChange(const SwTableAutoFormat& rNewData)
mxDrawingArea->queue_draw();
}
IMPL_LINK(AutoFormatPreview, DoPaint, vcl::RenderContext&, rRenderContext, void)
IMPL_LINK(AutoFormatPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
{
vcl::RenderContext& rRenderContext = aPayload.first;
rRenderContext.Push(PushFlags::ALL);
DrawModeFlags nOldDrawMode = rRenderContext.GetDrawMode();

View File

@@ -67,7 +67,7 @@ private:
uno::Reference<i18n::XBreakIterator> m_xBreak;
void Init();
DECL_LINK(DoPaint, vcl::RenderContext&, void);
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
void CalcCellArray(bool bFitWidth);
void CalcLineMap();

View File

@@ -289,6 +289,16 @@ public:
return m_xWidget->get_grid_top_attach();
}
virtual void set_margin_top(int nMargin) override
{
m_xWidget->set_margin_top(nMargin);
}
virtual void set_margin_bottom(int nMargin) override
{
m_xWidget->set_margin_bottom(nMargin);
}
virtual weld::Container* weld_parent() const override;
virtual ~SalInstanceWidget() override
@@ -795,6 +805,11 @@ public:
m_xEntry->SetWidthInChars(nChars);
}
virtual void set_max_length(int nChars) override
{
m_xEntry->SetMaxTextLen(nChars);
}
virtual void select_region(int nStartPos, int nEndPos) override
{
m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
@@ -884,7 +899,6 @@ public:
m_xTreeView->SetNoSelection();
else
m_xTreeView->SelectEntryPos(pos);
m_xTreeView->Select();
}
virtual OUString get_selected() override
@@ -1122,8 +1136,12 @@ class SalInstanceDrawingArea : public SalInstanceWidget, public virtual weld::Dr
private:
VclPtr<VclDrawingArea> m_xDrawingArea;
DECL_LINK(PaintHdl, vcl::RenderContext&, void);
typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> target_and_area;
DECL_LINK(PaintHdl, target_and_area, void);
DECL_LINK(ResizeHdl, const Size&, void);
DECL_LINK(MousePressHdl, const Point&, void);
DECL_LINK(MouseMoveHdl, const Point&, void);
DECL_LINK(MouseReleaseHdl, const Point&, void);
public:
SalInstanceDrawingArea(VclDrawingArea* pDrawingArea, bool bTakeOwnership)
@@ -1132,6 +1150,9 @@ public:
{
m_xDrawingArea->SetPaintHdl(LINK(this, SalInstanceDrawingArea, PaintHdl));
m_xDrawingArea->SetResizeHdl(LINK(this, SalInstanceDrawingArea, ResizeHdl));
m_xDrawingArea->SetMousePressHdl(LINK(this, SalInstanceDrawingArea, MousePressHdl));
m_xDrawingArea->SetMouseMoveHdl(LINK(this, SalInstanceDrawingArea, MouseMoveHdl));
m_xDrawingArea->SetMouseReleaseHdl(LINK(this, SalInstanceDrawingArea, MouseReleaseHdl));
}
virtual void queue_draw() override
@@ -1139,16 +1160,21 @@ public:
m_xDrawingArea->Invalidate();
}
virtual void queue_draw_area(int x, int y, int width, int height) override
{
m_xDrawingArea->Invalidate(tools::Rectangle(Point(x, y), Size(width, height)));
}
virtual ~SalInstanceDrawingArea() override
{
m_xDrawingArea->SetResizeHdl(Link<const Size&, void>());
m_xDrawingArea->SetPaintHdl(Link<vcl::RenderContext&, void>());
m_xDrawingArea->SetPaintHdl(Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>());
}
};
IMPL_LINK(SalInstanceDrawingArea, PaintHdl, vcl::RenderContext&, rDevice, void)
IMPL_LINK(SalInstanceDrawingArea, PaintHdl, target_and_area, aPayload, void)
{
m_aDrawHdl.Call(rDevice);
m_aDrawHdl.Call(aPayload);
}
IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void)
@@ -1156,6 +1182,21 @@ IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void)
m_aSizeAllocateHdl.Call(rSize);
}
IMPL_LINK(SalInstanceDrawingArea, MousePressHdl, const Point&, rPos, void)
{
m_aMousePressHdl.Call(rPos);
}
IMPL_LINK(SalInstanceDrawingArea, MouseMoveHdl, const Point&, rPos, void)
{
m_aMouseMotionHdl.Call(rPos);
}
IMPL_LINK(SalInstanceDrawingArea, MouseReleaseHdl, const Point&, rPos, void)
{
m_aMouseReleaseHdl.Call(rPos);
}
//ComboBox and ListBox have the same apis, ComboBoxes in LibreOffice have an edit box and ListBoxes
//don't. This distinction isn't there in Gtk. Use a template to sort this problem out.
template <class vcl_type>

View File

@@ -1300,6 +1300,16 @@ public:
return nAttach;
}
virtual void set_margin_top(int nMargin) override
{
gtk_widget_set_margin_top(m_pWidget, nMargin);
}
virtual void set_margin_bottom(int nMargin) override
{
gtk_widget_set_margin_bottom(m_pWidget, nMargin);
}
virtual weld::Container* weld_parent() const override;
virtual OString get_buildable_name() const override
@@ -1336,6 +1346,14 @@ public:
if (m_bTakeOwnership)
gtk_widget_destroy(m_pWidget);
}
virtual void disable_notify_events()
{
}
virtual void enable_notify_events()
{
}
};
class GtkInstanceContainer : public GtkInstanceWidget, public virtual weld::Container
@@ -1851,7 +1869,9 @@ public:
virtual void set_active(bool active) override
{
disable_notify_events();
gtk_toggle_button_set_active(m_pToggleButton, active);
enable_notify_events();
}
virtual bool get_active() const override
@@ -1869,6 +1889,18 @@ public:
return gtk_toggle_button_get_inconsistent(m_pToggleButton);
}
virtual void disable_notify_events() override
{
g_signal_handler_block(m_pToggleButton, m_nSignalId);
GtkInstanceButton::disable_notify_events();
}
virtual void enable_notify_events() override
{
GtkInstanceButton::enable_notify_events();
g_signal_handler_unblock(m_pToggleButton, m_nSignalId);
}
virtual ~GtkInstanceToggleButton() override
{
g_signal_handler_disconnect(m_pToggleButton, m_nSignalId);
@@ -1939,7 +1971,9 @@ public:
virtual void set_text(const OUString& rText) override
{
disable_notify_events();
gtk_entry_set_text(m_pEntry, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr());
enable_notify_events();
}
virtual OUString get_text() const override
@@ -1951,7 +1985,16 @@ public:
virtual void set_width_chars(int nChars) override
{
disable_notify_events();
gtk_entry_set_width_chars(m_pEntry, nChars);
enable_notify_events();
}
virtual void set_max_length(int nChars) override
{
disable_notify_events();
gtk_entry_set_max_length(m_pEntry, nChars);
enable_notify_events();
}
virtual void select_region(int nStartPos, int nEndPos) override
@@ -1964,6 +2007,20 @@ public:
gtk_editable_set_position(GTK_EDITABLE(m_pEntry), nCursorPos);
}
virtual void disable_notify_events() override
{
g_signal_handler_block(m_pEntry, m_nInsertTextSignalId);
g_signal_handler_block(m_pEntry, m_nChangedSignalId);
GtkInstanceWidget::disable_notify_events();
}
virtual void enable_notify_events() override
{
GtkInstanceWidget::disable_notify_events();
g_signal_handler_unblock(m_pEntry, m_nChangedSignalId);
g_signal_handler_unblock(m_pEntry, m_nInsertTextSignalId);
}
virtual ~GtkInstanceEntry() override
{
g_signal_handler_disconnect(m_pEntry, m_nInsertTextSignalId);
@@ -2034,18 +2091,22 @@ public:
virtual void insert(const OUString& rText, int pos) override
{
disable_notify_events();
GtkTreeIter iter;
gtk_list_store_insert(m_pListStore, &iter, pos);
gtk_list_store_set(m_pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1);
enable_notify_events();
}
using GtkInstanceContainer::remove;
virtual void remove(int pos) override
{
disable_notify_events();
GtkTreeIter iter;
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &iter, nullptr, pos);
gtk_list_store_remove(m_pListStore, &iter);
enable_notify_events();
}
virtual int find(const OUString& rText) const override
@@ -2060,6 +2121,7 @@ public:
if (pos == before)
return;
disable_notify_events();
GtkTreeIter iter;
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &iter, nullptr, pos);
@@ -2067,16 +2129,21 @@ public:
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &position, nullptr, before);
gtk_list_store_move_before(m_pListStore, &iter, &position);
enable_notify_events();
}
virtual void set_top_entry(int pos) override
{
disable_notify_events();
move_before(pos, 0);
enable_notify_events();
}
virtual void clear() override
{
disable_notify_events();
gtk_list_store_clear(m_pListStore);
enable_notify_events();
}
virtual int n_children() const override
@@ -2087,6 +2154,7 @@ public:
virtual void select(int pos) override
{
assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen");
disable_notify_events();
if (pos != -1)
{
GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
@@ -2097,6 +2165,7 @@ public:
{
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(m_pTreeView));
}
enable_notify_events();
}
virtual OUString get_selected() override
@@ -2141,14 +2210,18 @@ public:
virtual void freeze() override
{
disable_notify_events();
g_object_ref(m_pListStore);
gtk_tree_view_set_model(m_pTreeView, nullptr);
enable_notify_events();
}
virtual void thaw() override
{
disable_notify_events();
gtk_tree_view_set_model(m_pTreeView, GTK_TREE_MODEL(m_pListStore));
g_object_unref(m_pListStore);
enable_notify_events();
}
virtual int get_height_rows(int nRows) const override
@@ -2175,6 +2248,20 @@ public:
gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
}
virtual void disable_notify_events() override
{
g_signal_handler_block(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId);
g_signal_handler_block(m_pTreeView, m_nRowActivatedSignalId);
GtkInstanceContainer::disable_notify_events();
}
virtual void enable_notify_events() override
{
GtkInstanceContainer::disable_notify_events();
g_signal_handler_unblock(m_pTreeView, m_nRowActivatedSignalId);
g_signal_handler_unblock(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId);
}
virtual ~GtkInstanceTreeView() override
{
g_signal_handler_disconnect(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId);
@@ -2228,12 +2315,16 @@ public:
virtual void set_value(int value) override
{
disable_notify_events();
gtk_spin_button_set_value(m_pButton, toGtk(value));
enable_notify_events();
}
virtual void set_range(int min, int max) override
{
disable_notify_events();
gtk_spin_button_set_range(m_pButton, toGtk(min), toGtk(max));
enable_notify_events();
}
virtual void get_range(int& min, int& max) const override
@@ -2246,7 +2337,9 @@ public:
virtual void set_increments(int step, int page) override
{
disable_notify_events();
gtk_spin_button_set_increments(m_pButton, toGtk(step), toGtk(page));
enable_notify_events();
}
virtual void get_increments(int& step, int& page) const override
@@ -2259,7 +2352,9 @@ public:
virtual void set_digits(unsigned int digits) override
{
disable_notify_events();
gtk_spin_button_set_digits(m_pButton, digits);
enable_notify_events();
}
virtual unsigned int get_digits() const override
@@ -2267,6 +2362,18 @@ public:
return gtk_spin_button_get_digits(m_pButton);
}
virtual void disable_notify_events() override
{
g_signal_handler_block(m_pButton, m_nValueChangedSignalId);
GtkInstanceEntry::disable_notify_events();
}
virtual void enable_notify_events() override
{
GtkInstanceEntry::disable_notify_events();
g_signal_handler_unblock(m_pButton, m_nValueChangedSignalId);
}
virtual ~GtkInstanceSpinButton() override
{
g_signal_handler_disconnect(m_pButton, m_nOutputSignalId);
@@ -2356,12 +2463,27 @@ private:
cairo_surface_t* m_pSurface;
gulong m_nDrawSignalId;
gulong m_nSizeAllocateSignalId;
gulong m_nButtonPressSignalId;
gulong m_nMotionSignalId;
gulong m_nButtonReleaseSignalId;
static gboolean signalDraw(GtkWidget*, cairo_t* cr, gpointer widget)
{
GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
pThis->signal_draw(cr);
return false;
}
void signal_draw(cairo_t* cr)
{
GdkRectangle rect;
if (!gdk_cairo_get_clip_rectangle(cr, &rect))
return;
tools::Rectangle aRect(Point(rect.x, rect.y), Size(rect.width, rect.height));
m_aDrawHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(*m_xDevice, aRect));
cairo_surface_mark_dirty(m_pSurface);
cairo_set_source_surface(cr, m_pSurface, 0, 0);
cairo_paint(cr);
}
static void signalSizeAllocate(GtkWidget*, GdkRectangle* allocation, gpointer widget)
{
GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
@@ -2384,22 +2506,52 @@ private:
#endif
m_aSizeAllocateHdl.Call(Size(nWidth, nHeight));
}
void signal_draw(cairo_t* cr)
static gboolean signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer widget)
{
m_aDrawHdl.Call(*m_xDevice);
cairo_surface_mark_dirty(m_pSurface);
cairo_set_source_surface(cr, m_pSurface, 0, 0);
cairo_paint(cr);
GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
return pThis->signal_button(pEvent);
}
bool signal_button(GdkEventButton* pEvent)
{
Point aEvent(pEvent->x, pEvent->y);
switch (pEvent->type)
{
case GDK_BUTTON_PRESS:
m_aMousePressHdl.Call(aEvent);
break;
case GDK_BUTTON_RELEASE:
m_aMouseReleaseHdl.Call(aEvent);
break;
default:
return false;
}
return true;
}
static gboolean signalMotion(GtkWidget*, GdkEventMotion* pEvent, gpointer widget)
{
GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
return pThis->signal_motion(pEvent);
}
bool signal_motion(GdkEventMotion* pEvent)
{
Point aEvent(pEvent->x, pEvent->y);
m_aMouseMotionHdl.Call(aEvent);
return true;
}
public:
GtkInstanceDrawingArea(GtkDrawingArea* pDrawingArea, bool bTakeOwnership)
: GtkInstanceWidget(GTK_WIDGET(pDrawingArea), bTakeOwnership)
, m_pDrawingArea(pDrawingArea)
, m_xDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT)
, m_pSurface(nullptr)
, m_nDrawSignalId(g_signal_connect(pDrawingArea, "draw", G_CALLBACK(signalDraw), this))
, m_nSizeAllocateSignalId(g_signal_connect(pDrawingArea, "size_allocate", G_CALLBACK(signalSizeAllocate), this))
, m_nDrawSignalId(g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(signalDraw), this))
, m_nSizeAllocateSignalId(g_signal_connect(m_pDrawingArea, "size_allocate", G_CALLBACK(signalSizeAllocate), this))
, m_nButtonPressSignalId(g_signal_connect(m_pDrawingArea, "button-press-event", G_CALLBACK(signalButton), this))
, m_nMotionSignalId(g_signal_connect(m_pDrawingArea, "motion-notify-event", G_CALLBACK(signalMotion), this))
, m_nButtonReleaseSignalId(g_signal_connect(m_pDrawingArea, "button-release-event", G_CALLBACK(signalButton), this))
{
}
@@ -2408,10 +2560,18 @@ public:
gtk_widget_queue_draw(GTK_WIDGET(m_pDrawingArea));
}
virtual void queue_draw_area(int x, int y, int width, int height) override
{
gtk_widget_queue_draw_area(GTK_WIDGET(m_pDrawingArea), x, y, width, height);
}
virtual ~GtkInstanceDrawingArea() override
{
if (m_pSurface)
cairo_surface_destroy(m_pSurface);
g_signal_handler_disconnect(m_pDrawingArea, m_nButtonPressSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nMotionSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nButtonReleaseSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nSizeAllocateSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nDrawSignalId);
}
@@ -2483,13 +2643,17 @@ public:
virtual void set_active_id(const OUString& rStr) override
{
disable_notify_events();
OString aId(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8));
gtk_combo_box_set_active_id(GTK_COMBO_BOX(m_pComboBoxText), aId.getStr());
enable_notify_events();
}
virtual void set_active(int pos) override
{
disable_notify_events();
gtk_combo_box_set_active(GTK_COMBO_BOX(m_pComboBoxText), pos);
enable_notify_events();
}
virtual OUString get_active_text() const override
@@ -2581,6 +2745,18 @@ public:
gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING);
}
virtual void disable_notify_events() override
{
g_signal_handler_block(m_pComboBoxText, m_nSignalId);
GtkInstanceContainer::disable_notify_events();
}
virtual void enable_notify_events() override
{
GtkInstanceContainer::disable_notify_events();
g_signal_handler_unblock(m_pComboBoxText, m_nSignalId);
}
virtual ~GtkInstanceComboBoxText() override
{
g_signal_handler_disconnect(m_pComboBoxText, m_nSignalId);