Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
5f2f8343
Kaydet (Commit)
5f2f8343
authored
Agu 17, 2015
tarafından
Szymon Kłos
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Edit control with autocompletion
Change-Id: Id3aefbffa6b36b475ca78856c9e103cef433f88c
üst
fb82388b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
0 deletions
+150
-0
autocmpledit.hxx
include/svtools/autocmpledit.hxx
+39
-0
Library_svt.mk
svtools/Library_svt.mk
+1
-0
autocmpledit.cxx
svtools/source/control/autocmpledit.cxx
+110
-0
No files found.
include/svtools/autocmpledit.hxx
0 → 100644
Dosyayı görüntüle @
5f2f8343
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SVTOOLS_AUTOCMPLEDIT_HXX
#define INCLUDED_SVTOOLS_AUTOCMPLEDIT_HXX
#include <svtools/svtdllapi.h>
#include <vcl/edit.hxx>
#include <vector>
class
SVT_DLLPUBLIC
AutocompleteEdit
:
public
Edit
{
private
:
std
::
vector
<
OUString
>
m_aEntries
;
std
::
vector
<
OUString
>
m_aMatching
;
std
::
vector
<
OUString
>::
size_type
m_nCurrent
;
void
AutoCompleteHandler
(
Edit
*
);
bool
Match
(
const
OUString
&
rText
);
bool
PreNotify
(
NotifyEvent
&
rNEvt
);
public
:
AutocompleteEdit
(
vcl
::
Window
*
pParent
);
void
AddEntry
(
const
OUString
&
rEntry
);
void
ClearEntries
();
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
svtools/Library_svt.mk
Dosyayı görüntüle @
5f2f8343
...
...
@@ -107,6 +107,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/contnr/viewdataentry \
svtools/source/control/accessibleruler \
svtools/source/control/asynclink \
svtools/source/control/autocmpledit \
svtools/source/control/breadcrumb \
svtools/source/control/calendar \
svtools/source/control/collatorres \
...
...
svtools/source/control/autocmpledit.cxx
0 → 100644
Dosyayı görüntüle @
5f2f8343
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <svtools/autocmpledit.hxx>
#include <vcl/svapp.hxx>
AutocompleteEdit
::
AutocompleteEdit
(
vcl
::
Window
*
pParent
)
:
Edit
(
pParent
)
,
m_nCurrent
(
0
)
{
SignalConnectAutocomplete
(
nullptr
,
[
this
]
(
Edit
*
const
pEdit
)
{
this
->
AutoCompleteHandler
(
pEdit
);
}
);
}
void
AutocompleteEdit
::
AddEntry
(
const
OUString
&
rEntry
)
{
m_aEntries
.
push_back
(
rEntry
);
}
void
AutocompleteEdit
::
ClearEntries
()
{
m_aEntries
.
clear
();
m_aMatching
.
clear
();
}
void
AutocompleteEdit
::
AutoCompleteHandler
(
Edit
*
)
{
if
(
GetAutocompleteAction
()
!=
AUTOCOMPLETE_KEYINPUT
)
return
;
if
(
Application
::
AnyInput
(
VclInputFlags
::
KEYBOARD
)
)
return
;
OUString
aCurText
=
GetText
();
Selection
aSelection
(
GetSelection
()
);
if
(
aSelection
.
Max
()
!=
aCurText
.
getLength
()
)
return
;
sal_uInt16
nLen
=
(
sal_uInt16
)
aSelection
.
Min
();
aCurText
=
aCurText
.
copy
(
0
,
nLen
);
if
(
!
aCurText
.
isEmpty
()
)
{
if
(
m_aEntries
.
size
()
)
{
if
(
Match
(
aCurText
)
)
{
m_nCurrent
=
0
;
SetText
(
m_aMatching
[
0
]
);
sal_uInt16
nNewLen
=
m_aMatching
[
0
].
getLength
();
Selection
aSel
(
nLen
,
nNewLen
);
SetSelection
(
aSel
);
}
}
}
}
bool
AutocompleteEdit
::
Match
(
const
OUString
&
rText
)
{
bool
bRet
=
false
;
m_aMatching
.
clear
();
for
(
std
::
vector
<
OUString
>::
size_type
i
=
0
;
i
<
m_aEntries
.
size
();
++
i
)
{
if
(
m_aEntries
[
i
].
startsWith
(
rText
)
)
{
m_aMatching
.
push_back
(
m_aEntries
[
i
]
);
bRet
=
true
;
}
}
return
bRet
;
}
bool
AutocompleteEdit
::
PreNotify
(
NotifyEvent
&
rNEvt
)
{
if
(
rNEvt
.
GetType
()
==
MouseNotifyEvent
::
KEYINPUT
)
{
const
KeyEvent
&
rEvent
=
*
rNEvt
.
GetKeyEvent
();
const
vcl
::
KeyCode
&
rKey
=
rEvent
.
GetKeyCode
();
vcl
::
KeyCode
aCode
(
rKey
.
GetCode
()
);
if
(
(
aCode
==
KEY_UP
||
aCode
==
KEY_DOWN
)
&&
!
rKey
.
IsMod2
()
)
{
Selection
aSelection
(
GetSelection
()
);
sal_uInt16
nLen
=
(
sal_uInt16
)
aSelection
.
Min
();
if
(
m_aMatching
.
size
()
&&
(
(
aCode
==
KEY_DOWN
&&
m_nCurrent
+
1
<
m_aMatching
.
size
()
)
||
(
aCode
==
KEY_UP
&&
m_nCurrent
>
0
)
)
)
{
SetText
(
m_aMatching
[
aCode
==
KEY_DOWN
?
++
m_nCurrent
:
--
m_nCurrent
]
);
SetSelection
(
Selection
(
nLen
,
GetText
().
getLength
()
)
);
return
true
;
}
}
}
return
Edit
::
PreNotify
(
rNEvt
);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment