[Libreoffice-commits] .: 2 commits - svx/inc svx/source vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Nov 26 12:26:59 PST 2012
svx/inc/tbunosearchcontrollers.hxx | 4 --
svx/source/tbxctrls/tbunosearchcontrollers.cxx | 36 ++----------------------
vcl/inc/vcl/edit.hxx | 4 ++
vcl/source/control/edit.cxx | 37 +++++++++++++++++++++++--
4 files changed, 42 insertions(+), 39 deletions(-)
New commits:
commit 52252bb529a41979aa4f11d529ae555401ae8563
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Mon Nov 26 23:28:57 2012 +0400
findbar: use new SetPlaceholderText method
Change-Id: I2e9b825110ed2e83c053b2084c4e6c868d1e9d9f
diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx
index 8fb7d33..88291a8 100644
--- a/svx/inc/tbunosearchcontrollers.hxx
+++ b/svx/inc/tbunosearchcontrollers.hxx
@@ -60,10 +60,8 @@ public:
css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
virtual ~FindTextFieldControl();
- virtual void Modify();
virtual long PreNotify( NotifyEvent& rNEvt );
- void InitControls_Impl();
void Remember_Impl(const String& rStr);
void SetTextToSelected_Impl();
@@ -71,8 +69,6 @@ private:
css::uno::Reference< css::frame::XFrame > m_xFrame;
css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager;
- sal_Bool m_bToClearTextField;
-
};
class SearchToolbarControllersManager
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index acbb95e..3ea241d 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -81,24 +81,16 @@ FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle,
css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager) :
ComboBox( pParent, nStyle ),
m_xFrame(xFrame),
- m_xServiceManager(xServiceManager),
- m_bToClearTextField(sal_True)
+ m_xServiceManager(xServiceManager)
{
- InitControls_Impl();
+ SetPlaceholderText(SVX_RESSTR(RID_SVXSTR_FINDBAR_FIND));
+ EnableAutocomplete(sal_True, sal_True);
}
FindTextFieldControl::~FindTextFieldControl()
{
}
-void FindTextFieldControl::InitControls_Impl()
-{
- SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) );
- SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor());
-
- EnableAutocomplete(sal_True, sal_True);
-}
-
void FindTextFieldControl::Remember_Impl(const String& rStr)
{
sal_uInt16 nCount = GetEntryCount();
@@ -137,17 +129,9 @@ void FindTextFieldControl::SetTextToSelected_Impl()
if ( aString.getLength() != 0 )
{
SetText( aString );
- m_bToClearTextField = sal_False;
}
}
-void FindTextFieldControl::Modify()
-{
- ComboBox::Modify();
-
- SetControlForeground( GetSettings().GetStyleSettings().GetWindowTextColor() );
-}
-
long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt )
{
long nRet= ComboBox::PreNotify( rNEvt );
@@ -208,22 +192,8 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt )
}
case EVENT_GETFOCUS:
- if ( m_bToClearTextField )
- {
- SetText( OUString() );
- m_bToClearTextField = sal_False;
- }
SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
break;
-
- case EVENT_LOSEFOCUS:
- if ( GetText().Len() == 0 )
- {
- SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) );
- SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor());
- m_bToClearTextField = sal_True;
- }
- break;
}
return nRet;
commit 37c4a408ebd2895ca06e6a22c54591494e9ec52c
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Mon Nov 26 23:26:17 2012 +0400
vcl: Edit: add placeholder text feature, import it from .ui
Change-Id: I65d305b07dba5ddd80a108d5ef1b36f75eb67243
diff --git a/vcl/inc/vcl/edit.hxx b/vcl/inc/vcl/edit.hxx
index e2b9186..3ad29cf 100644
--- a/vcl/inc/vcl/edit.hxx
+++ b/vcl/inc/vcl/edit.hxx
@@ -62,6 +62,7 @@ private:
DDInfo* mpDDInfo;
Impl_IMEInfos* mpIMEInfos;
XubString maText;
+ OUString maPlaceholderText;
XubString maSaveValue;
XubString maUndoText;
XubString maRedoText;
@@ -209,6 +210,9 @@ public:
virtual void SetText( const XubString& rStr, const Selection& rNewSelection );
virtual XubString GetText() const;
+ virtual void SetPlaceholderText( const OUString& rStr );
+ virtual OUString GetPlaceholderText() const;
+
void SaveValue() { maSaveValue = GetText(); }
const XubString& GetSavedValue() const { return maSaveValue; }
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 0c1ae90..a82a465 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -238,6 +238,8 @@ bool Edit::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
nBits |= WB_PASSWORD;
SetStyle(nBits);
}
+ else if (rKey == "placeholder-text")
+ SetPlaceholderText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
else
return Control::set_property(rKey, rValue);
return true;
@@ -255,6 +257,7 @@ void Edit::take_properties(Window &rOther)
Edit &rOtherEdit = static_cast<Edit&>(rOther);
maText = rOtherEdit.maText;
+ maPlaceholderText = rOtherEdit.maPlaceholderText;
maSaveValue = rOtherEdit.maSaveValue;
maUndoText = rOtherEdit.maUndoText;
maRedoText = rOtherEdit.maRedoText;
@@ -601,10 +604,12 @@ void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout )
ImplClearBackground( 0, GetOutputSizePixel().Width() );
+ bool bPaintPlaceholderText = aText.Len() == 0 && !maPlaceholderText.isEmpty();
+
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if ( IsEnabled() )
ImplInitSettings( sal_False, sal_True, sal_False );
- else
+ if ( !IsEnabled() || bPaintPlaceholderText )
SetTextColor( rStyleSettings.GetDisableColor() );
// Set background color of the normal text
@@ -630,7 +635,11 @@ void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout )
long nPos = nStart ? pDX[2*nStart] : 0;
aPos.X() = nPos + mnXOffset + ImplGetExtraOffset();
- if ( !bDrawSelection && !mpIMEInfos )
+ if ( bPaintPlaceholderText )
+ {
+ DrawText( aPos, maPlaceholderText );
+ }
+ else if ( !bDrawSelection && !mpIMEInfos )
{
DrawText( aPos, aText, nStart, nEnd - nStart );
}
@@ -2863,6 +2872,30 @@ XubString Edit::GetText() const
// -----------------------------------------------------------------------
+void Edit::SetPlaceholderText( const OUString& rStr )
+{
+ if ( mpSubEdit )
+ mpSubEdit->SetPlaceholderText( rStr );
+ else if ( maPlaceholderText != rStr )
+ {
+ maPlaceholderText = rStr;
+ if ( GetText().Len() == 0 )
+ Invalidate();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+OUString Edit::GetPlaceholderText() const
+{
+ if ( mpSubEdit )
+ return mpSubEdit->GetPlaceholderText();
+
+ return maPlaceholderText;
+}
+
+// -----------------------------------------------------------------------
+
void Edit::SetModifyFlag()
{
if ( mpSubEdit )
More information about the Libreoffice-commits
mailing list