LibreOffice Module vcl (master) 1
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at .
18 */
20#pragma once
23#error "don't use this in new code"
26#include <vcl/ctrl.hxx>
27#include <vcl/textfilter.hxx>
29#include <memory>
31#include <rtl/ustrbuf.hxx>
32#include <o3tl/deleter.hxx>
33#include <vcl/dllapi.h>
34#include <vcl/dndhelp.hxx>
35#include <vcl/vclptr.hxx>
36#include <com/sun/star/uno/Reference.h>
38namespace com::sun::star::i18n {
39 class XBreakIterator;
40 class XExtendedInputSequenceChecker;
42namespace weld {
43 class Widget;
46class PopupMenu;
47class VclBuilder;
48struct DDInfo;
49struct Impl_IMEInfos;
53class Timer;
60 std::unique_ptr<DDInfo, o3tl::default_delete<DDInfo>> mpDDInfo;
61 std::unique_ptr<Impl_IMEInfos> mpIMEInfos;
62 OUStringBuffer maText;
64 OUString maSaveValue;
65 OUString maUndoText;
68 sal_uInt16 mnAlign;
69 sal_Int32 mnMaxTextLen;
70 sal_Int32 mnWidthInChars;
71 sal_Int32 mnMaxWidthChars;
84 std::unique_ptr<VclBuilder> mpUIBuilder;
86 css::uno::Reference<css::i18n::XBreakIterator> mxBreakIterator;
87 css::uno::Reference<css::i18n::XExtendedInputSequenceChecker> mxISC;
89 SAL_DLLPRIVATE bool ImplTruncateToMaxLen( OUString&, sal_Int32 nSelectionLen ) const;
90 SAL_DLLPRIVATE void ImplInitEditData();
91 SAL_DLLPRIVATE OUString ImplGetText() const;
92 SAL_DLLPRIVATE void ImplRepaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle);
93 SAL_DLLPRIVATE void ImplInvalidateOrRepaint();
94 SAL_DLLPRIVATE void ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode );
95 SAL_DLLPRIVATE void ImplSetText( const OUString& rStr, const Selection* pNewSelection );
96 SAL_DLLPRIVATE void ImplInsertText( const OUString& rStr, const Selection* pNewSelection = nullptr, bool bIsUserInput = false );
97 SAL_DLLPRIVATE static OUString ImplGetValidString( const OUString& rString );
98 SAL_DLLPRIVATE void ImplClearBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle, tools::Long nXStart, tools::Long nXEnd);
99 SAL_DLLPRIVATE void ImplPaintBorder(vcl::RenderContext const & rRenderContext);
100 SAL_DLLPRIVATE void ImplShowCursor( bool bOnlyIfVisible = true );
101 SAL_DLLPRIVATE void ImplAlign();
102 SAL_DLLPRIVATE void ImplAlignAndPaint();
103 SAL_DLLPRIVATE sal_Int32 ImplGetCharPos( const Point& rWindowPos ) const;
104 SAL_DLLPRIVATE void ImplSetCursorPos( sal_Int32 nChar, bool bSelect );
105 SAL_DLLPRIVATE void ImplShowDDCursor();
106 SAL_DLLPRIVATE void ImplHideDDCursor();
107 SAL_DLLPRIVATE bool ImplHandleKeyEvent( const KeyEvent& rKEvt );
108 SAL_DLLPRIVATE void ImplCopyToSelectionClipboard();
109 SAL_DLLPRIVATE void ImplCopy(css::uno::Reference<css::datatransfer::clipboard::XClipboard> const & rxClipboard);
110 SAL_DLLPRIVATE void ImplPaste(css::uno::Reference<css::datatransfer::clipboard::XClipboard> const & rxClipboard);
111 SAL_DLLPRIVATE tools::Long ImplGetTextYPosition() const;
112 SAL_DLLPRIVATE css::uno::Reference<css::i18n::XExtendedInputSequenceChecker> const& ImplGetInputSequenceChecker();
113 SAL_DLLPRIVATE css::uno::Reference<css::i18n::XBreakIterator> const& ImplGetBreakIterator();
114 SAL_DLLPRIVATE void filterText();
118 using Window::ImplInit;
119 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
120 SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
121 SAL_DLLPRIVATE void ImplSetSelection( const Selection& rSelection, bool bPaint = true );
122 SAL_DLLPRIVATE ControlType ImplGetNativeControlType() const;
123 SAL_DLLPRIVATE tools::Long ImplGetExtraXOffset() const;
124 SAL_DLLPRIVATE tools::Long ImplGetExtraYOffset() const;
125 static SAL_DLLPRIVATE void ImplInvalidateOutermostBorder( vcl::Window* pWin );
127 css::uno::Reference<css::datatransfer::dnd::XDragSourceListener > mxDnDListener;
129 // DragAndDropClient
133 virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent& dge) override;
134 virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent& dsde) override;
135 virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde) override;
136 virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee) override;
137 virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent& dte) override;
138 virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent& dtde) override;
141 Edit(WindowType nType);
142 virtual void FillLayoutData() const override;
143 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
145 // public because needed in button.cxx
146 SAL_DLLPRIVATE bool ImplUseNativeBorder(vcl::RenderContext const & rRenderContext, WinBits nStyle) const;
148 Edit( vcl::Window* pParent, WinBits nStyle = WB_BORDER );
149 virtual ~Edit() override;
150 virtual void dispose() override;
152 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
153 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
154 virtual void KeyInput( const KeyEvent& rKEvt ) override;
155 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
156 virtual void Resize() override;
157 virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
158 virtual void GetFocus() override;
159 virtual void LoseFocus() override;
160 virtual void Tracking( const TrackingEvent& rTEvt ) override;
161 virtual void Command( const CommandEvent& rCEvt ) override;
162 virtual void StateChanged( StateChangedType nType ) override;
163 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
164 virtual bool PreNotify(NotifyEvent& rNEvt) override;
166 virtual void Modify();
168 static bool IsCharInput( const KeyEvent& rKEvt );
170 virtual void SetModifyFlag();
172 void SetEchoChar( sal_Unicode c );
173 sal_Unicode GetEchoChar() const { return mcEchoChar; }
175 virtual void SetReadOnly( bool bReadOnly = true );
176 virtual bool IsReadOnly() const { return mbReadOnly; }
178 void SetInsertMode( bool bInsert );
179 bool IsInsertMode() const;
181 virtual void SetMaxTextLen( sal_Int32 nMaxLen );
182 virtual sal_Int32 GetMaxTextLen() const { return mnMaxTextLen; }
184 void SetWidthInChars(sal_Int32 nWidthInChars);
185 sal_Int32 GetWidthInChars() const { return mnWidthInChars; }
187 void setMaxWidthChars(sal_Int32 nWidth);
189 virtual void SetSelection( const Selection& rSelection );
190 virtual const Selection& GetSelection() const;
192 virtual void ReplaceSelected( const OUString& rStr );
193 virtual void DeleteSelected();
194 virtual OUString GetSelected() const;
196 virtual void Cut();
197 virtual void Copy();
198 virtual void Paste();
199 void Undo();
201 virtual void SetText( const OUString& rStr ) override;
202 virtual void SetText( const OUString& rStr, const Selection& rNewSelection );
203 virtual OUString GetText() const override;
205 void SetCursorAtLast();
207 void SetPlaceholderText( const OUString& rStr );
209 void SaveValue() { maSaveValue = GetText(); }
210 const OUString& GetSavedValue() const { return maSaveValue; }
212 virtual void SetModifyHdl( const Link<Edit&,void>& rLink ) { maModifyHdl = rLink; }
213 virtual const Link<Edit&,void>& GetModifyHdl() const { return maModifyHdl; }
215 void SetActivateHdl(const Link<Edit&,bool>& rLink) { maActivateHdl = rLink; }
217 void SetSubEdit( Edit* pEdit );
218 Edit* GetSubEdit() const { return mpSubEdit; }
220 void SetAutocompleteHdl( const Link<Edit&,void>& rLink ) { maAutocompleteHdl = rLink; }
221 const Link<Edit&,void>& GetAutocompleteHdl() const { return maAutocompleteHdl; }
223 virtual Size CalcMinimumSize() const;
224 virtual Size CalcMinimumSizeForText(const OUString &rString) const;
225 virtual Size GetOptimalSize() const override;
226 virtual Size CalcSize(sal_Int32 nChars) const;
227 sal_Int32 GetMaxVisChars() const;
229 // shows a warning box saying "text too long, truncated"
230 static void ShowTruncationWarning(weld::Widget* pParent);
232 VclPtr<PopupMenu> CreatePopupMenu();
234 virtual OUString GetSurroundingText() const override;
235 virtual Selection GetSurroundingTextSelection() const override;
236 virtual bool DeleteSurroundingText(const Selection& rSelection) override;
237 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
239 void SetTextFilter(TextFilter* pFilter) { mpFilterText = pFilter; }
241 virtual FactoryFunction GetUITestFactory() const override;
243 void SetForceControlBackground(bool b) { mbForceControlBackground = b; }
245 bool IsPassword() const { return mbPassword; }
247 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
250/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
Definition: ctrl.hxx:82
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:414
virtual void FillLayoutData() const
Definition: ctrl.cxx:81
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:257
virtual void Resize() override
Definition: ctrl.cxx:75
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:96
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:370
void ImplInitSettings()
Definition: ctrl.cxx:424
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:59
Definition: edit.hxx:56
Link< Edit &, bool > maActivateHdl
Definition: edit.hxx:83
sal_Int32 mnMaxTextLen
Definition: edit.hxx:69
sal_Int32 mnWidthInChars
Definition: edit.hxx:70
sal_Int32 mnMaxWidthChars
Definition: edit.hxx:71
bool mbInsertMode
Definition: edit.hxx:75
bool mbReadOnly
Definition: edit.hxx:74
std::unique_ptr< DDInfo, o3tl::default_delete< DDInfo > > mpDDInfo
Definition: edit.hxx:60
OUStringBuffer maText
Definition: edit.hxx:62
void SetTextFilter(TextFilter *pFilter)
Definition: edit.hxx:239
VclPtr< Edit > mpSubEdit
Definition: edit.hxx:58
virtual const Link< Edit &, void > & GetModifyHdl() const
Definition: edit.hxx:213
bool mbActivePopup
Definition: edit.hxx:78
sal_uInt16 mnAlign
Definition: edit.hxx:68
bool mbClickedInSelection
Definition: edit.hxx:76
css::uno::Reference< css::i18n::XExtendedInputSequenceChecker > mxISC
Definition: edit.hxx:87
virtual sal_Int32 GetMaxTextLen() const
Definition: edit.hxx:182
bool mbInternModified
Definition: edit.hxx:73
bool IsPassword() const
Definition: edit.hxx:245
OUString maSaveValue
Definition: edit.hxx:64
std::unique_ptr< Impl_IMEInfos > mpIMEInfos
Definition: edit.hxx:61
Selection maSelection
Definition: edit.hxx:67
const OUString & GetSavedValue() const
Definition: edit.hxx:210
css::uno::Reference< css::i18n::XBreakIterator > mxBreakIterator
Definition: edit.hxx:86
bool mbForceControlBackground
Definition: edit.hxx:79
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener
Definition: edit.hxx:127
void SetActivateHdl(const Link< Edit &, bool > &rLink)
Definition: edit.hxx:215
Edit * GetSubEdit() const
Definition: edit.hxx:218
OUString maPlaceholderText
Definition: edit.hxx:63
void SaveValue()
Definition: edit.hxx:209
Link< Edit &, void > maAutocompleteHdl
Definition: edit.hxx:82
bool mbPassword
Definition: edit.hxx:80
void SetAutocompleteHdl(const Link< Edit &, void > &rLink)
Definition: edit.hxx:220
virtual void SetModifyHdl(const Link< Edit &, void > &rLink)
Definition: edit.hxx:212
TextFilter * mpFilterText
Definition: edit.hxx:59
bool mbIsSubEdit
Definition: edit.hxx:77
std::unique_ptr< VclBuilder > mpUIBuilder
Definition: edit.hxx:84
virtual bool IsReadOnly() const
Definition: edit.hxx:176
const Link< Edit &, void > & GetAutocompleteHdl() const
Definition: edit.hxx:221
sal_Int32 GetWidthInChars() const
Definition: edit.hxx:185
sal_Unicode mcEchoChar
Definition: edit.hxx:72
void SetForceControlBackground(bool b)
Definition: edit.hxx:243
OUString maUndoText
Definition: edit.hxx:65
tools::Long mnXOffset
Definition: edit.hxx:66
sal_Unicode GetEchoChar() const
Definition: edit.hxx:173
Link< Edit &, void > maModifyHdl
Definition: edit.hxx:81
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:171
Definition: timer.hxx:27
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar,...
Definition: builder.hxx:69
virtual void GetFocus()
Definition: window.cxx:1845
virtual Selection GetSurroundingTextSelection() const
Definition: window.cxx:3783
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1936
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1927
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:420
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:427
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1809
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1020
virtual OUString GetSurroundingText() const
Definition: window.cxx:3778
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
virtual bool DeleteSurroundingText(const Selection &rSelection)
Definition: window.cxx:3812
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: window.cxx:3365
virtual void Draw(::OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags)
Definition: window.cxx:1833
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1483
virtual void LoseFocus()
Definition: window.cxx:1859
virtual OUString GetText() const
Definition: window.cxx:3062
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:942
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3942
virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde)
Definition: dndhelp.cxx:42
virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde)
Definition: dndhelp.cxx:38
virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee)
Definition: dndhelp.cxx:46
virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde)
Definition: dndhelp.cxx:54
virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge)
Definition: dndhelp.cxx:34
virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent &dte)
Definition: dndhelp.cxx:50
Link< ColorFieldControl &, void > maModifyHdl
Definition: dllapi.h:29
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
long Long
Definition: edit.cxx:94
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
Definition: window.hxx:291
sal_Int64 WinBits
Definition: wintypes.hxx:109
Definition: wintypes.hxx:27
WinBits const WB_BORDER
Definition: wintypes.hxx:115