summaryrefslogtreecommitdiff
path: root/include/vcl/toolkit
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-03-27 21:13:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-04-06 21:26:42 +0200
commit85528c15cf9ad125acd347733ca788acda299c2f (patch)
tree3141c509b801b20bc2c2c8466daec3a735ecf68e /include/vcl/toolkit
parenta4f747e9cd70bc25994040e7812680c2c8356c08 (diff)
move MetricField, MetricBox and MetricFormatter to be toolkit only
Change-Id: I80d3f5896f4e3b985ab1563a0a8306e5ff7183ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91337 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/vcl/toolkit')
-rw-r--r--include/vcl/toolkit/field.hxx100
1 files changed, 100 insertions, 0 deletions
diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx
index 47156bc8c388..f0b0a8b3521a 100644
--- a/include/vcl/toolkit/field.hxx
+++ b/include/vcl/toolkit/field.hxx
@@ -25,8 +25,108 @@
#endif
#include <config_options.h>
+#include <vcl/combobox.hxx>
#include <vcl/field.hxx>
+class VCL_DLLPUBLIC MetricFormatter : public NumericFormatter
+{
+public:
+ virtual ~MetricFormatter() override;
+
+ virtual void Reformat() override;
+
+ virtual void SetUnit( FieldUnit meUnit );
+ FieldUnit GetUnit() const { return meUnit; }
+ void SetCustomUnitText( const OUString& rStr );
+ const OUString& GetCustomUnitText() const { return maCustomUnitText; }
+
+ using NumericFormatter::SetMax;
+ void SetMax( sal_Int64 nNewMax, FieldUnit eInUnit );
+ using NumericFormatter::GetMax;
+ sal_Int64 GetMax( FieldUnit eOutUnit ) const;
+ using NumericFormatter::SetMin;
+ void SetMin( sal_Int64 nNewMin, FieldUnit eInUnit );
+ using NumericFormatter::GetMin;
+ sal_Int64 GetMin( FieldUnit eOutUnit ) const;
+
+ void SetValue( sal_Int64 nNewValue, FieldUnit eInUnit );
+ virtual void SetValue( sal_Int64 nValue ) override;
+ using NumericFormatter::SetUserValue;
+ void SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit );
+ using NumericFormatter::GetValue;
+ sal_Int64 GetValue( FieldUnit eOutUnit ) const;
+ virtual OUString CreateFieldText( sal_Int64 nValue ) const override;
+ sal_Int64 GetCorrectedValue( FieldUnit eOutUnit ) const;
+
+protected:
+ FieldUnit meUnit;
+
+ MetricFormatter(Edit* pEdit);
+
+ SAL_DLLPRIVATE void ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr );
+
+ virtual sal_Int64 GetValueFromString(const OUString& rStr) const override;
+ sal_Int64 GetValueFromStringUnit(const OUString& rStr, FieldUnit eOutUnit) const;
+
+private:
+ OUString maCustomUnitText;
+};
+
+class VCL_DLLPUBLIC MetricField : public SpinField, public MetricFormatter
+{
+public:
+ explicit MetricField( vcl::Window* pParent, WinBits nWinStyle );
+
+ virtual bool PreNotify( NotifyEvent& rNEvt ) override;
+ virtual bool EventNotify( NotifyEvent& rNEvt ) override;
+ virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
+
+ virtual Size CalcMinimumSize() const override;
+
+ virtual void Modify() override;
+
+ virtual void Up() override;
+ virtual void Down() override;
+ virtual void First() override;
+ virtual void Last() override;
+
+ virtual void SetUnit( FieldUnit meUnit ) override;
+
+ void SetFirst( sal_Int64 nNewFirst, FieldUnit eInUnit );
+ sal_Int64 GetFirst( FieldUnit eOutUnit ) const;
+ void SetLast( sal_Int64 nNewLast, FieldUnit eInUnit );
+ sal_Int64 GetLast( FieldUnit eOutUnit ) const;
+
+ virtual bool set_property(const OString &rKey, const OUString &rValue) override;
+ virtual void dispose() override;
+
+ virtual boost::property_tree::ptree DumpAsPropertyTree() override;
+};
+
+class VCL_DLLPUBLIC MetricBox : public ComboBox, public MetricFormatter
+{
+public:
+ explicit MetricBox( vcl::Window* pParent, WinBits nWinStyle );
+
+ virtual bool PreNotify( NotifyEvent& rNEvt ) override;
+ virtual bool EventNotify( NotifyEvent& rNEvt ) override;
+ virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
+
+ virtual Size CalcMinimumSize() const override;
+
+ virtual void Modify() override;
+
+ virtual void ReformatAll() override;
+
+ void InsertValue( sal_Int64 nValue, FieldUnit eInUnit = FieldUnit::NONE,
+ sal_Int32 nPos = COMBOBOX_APPEND );
+
+ // Needed, because GetValue() with nPos hide these functions
+ using MetricFormatter::GetValue;
+
+ virtual void dispose() override;
+};
+
class UNLESS_MERGELIBS(VCL_DLLPUBLIC) CurrencyFormatter : public NumericFormatter
{
protected: