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
b387a3fe
Kaydet (Commit)
b387a3fe
authored
Mar 08, 2015
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
tabbar: use unique_ptr for buttons, sizer & clean-up
Change-Id: I4c479f0581e5fde7c3c2c21dcb2a88a2039e09ba
üst
b03a9ae9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
112 deletions
+109
-112
tabbar.hxx
include/svtools/tabbar.hxx
+3
-7
tabbar.cxx
svtools/source/control/tabbar.cxx
+106
-105
No files found.
include/svtools/tabbar.hxx
Dosyayı görüntüle @
b387a3fe
...
...
@@ -315,13 +315,9 @@ class SVT_DLLPUBLIC TabBar : public vcl::Window
friend
class
ImplTabSizer
;
private
:
std
::
unique_ptr
<
TabBar_Impl
>
mpImpl
;
ImplTabBarList
*
mpItemList
;
ImplTabButton
*
mpFirstBtn
;
ImplTabButton
*
mpPrevBtn
;
ImplTabButton
*
mpNextBtn
;
ImplTabButton
*
mpLastBtn
;
TabBar_Impl
*
mpImpl
;
TabBarEdit
*
mpEdit
;
OUString
maEditText
;
Color
maSelColor
;
Color
maSelTextColor
;
...
...
@@ -461,7 +457,7 @@ public:
void
EndEditMode
(
bool
bCancel
=
false
);
void
SetEditText
(
const
OUString
&
rText
)
{
maEditText
=
rText
;
}
const
OUString
&
GetEditText
()
const
{
return
maEditText
;
}
bool
IsInEditMode
()
const
{
return
(
mpEdit
!=
NULL
);
}
bool
IsInEditMode
()
const
;
bool
IsEditModeCanceled
()
const
{
return
mbEditCanceled
;
}
sal_uInt16
GetEditPageId
()
const
{
return
mnEditId
;
}
...
...
svtools/source/control/tabbar.cxx
Dosyayı görüntüle @
b387a3fe
...
...
@@ -352,17 +352,23 @@ IMPL_LINK_NOARG(TabBarEdit, ImplEndTimerHdl)
struct
TabBar_Impl
{
ImplTabSizer
*
mpSizer
;
::
svt
::
AccessibleFactoryAccess
maAccessibleFactory
;
std
::
unique_ptr
<
ImplTabSizer
>
mpSizer
;
std
::
unique_ptr
<
ImplTabButton
>
mpFirstButton
;
std
::
unique_ptr
<
ImplTabButton
>
mpPrevButton
;
std
::
unique_ptr
<
ImplTabButton
>
mpNextButton
;
std
::
unique_ptr
<
ImplTabButton
>
mpLastButton
;
std
::
unique_ptr
<
TabBarEdit
>
mpEdit
;
svt
::
AccessibleFactoryAccess
maAccessibleFactory
;
TabBar_Impl
()
:
mpSizer
(
NULL
)
{
}
~
TabBar_Impl
()
{
delete
mpSizer
;
}
:
mpSizer
(
)
,
mpFirstButton
()
,
mpPrevButton
()
,
mpNextButton
()
,
mpLastButton
()
,
mpEdit
()
{
}
};
...
...
@@ -373,13 +379,9 @@ const sal_uInt16 TabBar::INSERT_TAB_POS = ::std::numeric_limits<sal_uInt16>::max
void
TabBar
::
ImplInit
(
WinBits
nWinStyle
)
{
mpImpl
.
reset
(
new
TabBar_Impl
);
mpItemList
=
new
ImplTabBarList
;
mpFirstBtn
=
NULL
;
mpPrevBtn
=
NULL
;
mpNextBtn
=
NULL
;
mpLastBtn
=
NULL
;
mpImpl
=
new
TabBar_Impl
;
mpEdit
=
NULL
;
mnMaxPageWidth
=
0
;
mnCurMaxWidth
=
0
;
mnOffX
=
0
;
...
...
@@ -412,14 +414,14 @@ void TabBar::ImplInit( WinBits nWinStyle )
ImplInitControls
();
if
(
mpFirstBt
n
)
mp
FirstBt
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVET0HOME
));
if
(
mpPrevBt
n
)
mp
PrevBt
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVELEFT
));
if
(
mpNextBt
n
)
mp
NextBt
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVERIGHT
));
if
(
mpLastBt
n
)
mp
LastBt
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVETOEND
));
if
(
mpImpl
->
mpFirstButto
n
)
mp
Impl
->
mpFirstButto
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVET0HOME
));
if
(
mpImpl
->
mpPrevButto
n
)
mp
Impl
->
mpPrevButto
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVELEFT
));
if
(
mpImpl
->
mpNextButto
n
)
mp
Impl
->
mpNextButto
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVERIGHT
));
if
(
mpImpl
->
mpLastButto
n
)
mp
Impl
->
mpLastButto
n
->
SetAccessibleName
(
SVT_RESSTR
(
STR_TABBAR_PUSHBUTTON_MOVETOEND
));
SetSizePixel
(
Size
(
100
,
CalcWindowSizePixel
().
Height
()
)
);
ImplInitSettings
(
true
,
true
);
...
...
@@ -440,17 +442,6 @@ TabBar::~TabBar()
{
EndEditMode
(
true
);
// Controls loeschen
if
(
mpPrevBtn
)
delete
mpPrevBtn
;
if
(
mpNextBtn
)
delete
mpNextBtn
;
if
(
mpFirstBtn
)
delete
mpFirstBtn
;
if
(
mpLastBtn
)
delete
mpLastBtn
;
delete
mpImpl
;
for
(
size_t
i
=
0
,
n
=
mpItemList
->
size
();
i
<
n
;
++
i
)
{
delete
(
*
mpItemList
)[
i
];
}
...
...
@@ -689,63 +680,65 @@ void TabBar::ImplInitControls()
{
if
(
mnWinStyle
&
WB_SIZEABLE
)
{
if
(
!
mpImpl
->
mpSizer
)
mpImpl
->
mpSizer
=
new
ImplTabSizer
(
this
,
mnWinStyle
&
(
WB_DRAG
|
WB_3DLOOK
)
);
if
(
!
mpImpl
->
mpSizer
)
{
mpImpl
->
mpSizer
.
reset
(
new
ImplTabSizer
(
this
,
mnWinStyle
&
(
WB_DRAG
|
WB_3DLOOK
)));
}
mpImpl
->
mpSizer
->
Show
();
}
else
{
DELETEZ
(
mpImpl
->
mpSizer
);
mpImpl
->
mpSizer
.
reset
(
);
}
Link
aLink
=
LINK
(
this
,
TabBar
,
ImplClickHdl
);
if
(
mnWinStyle
&
(
WB_MINSCROLL
|
WB_SCROLL
)
)
{
if
(
!
mpPrevBtn
)
if
(
!
mpImpl
->
mpPrevButton
)
{
mp
PrevBtn
=
new
ImplTabButton
(
this
,
WB_REPEAT
);
mp
PrevBtn
->
SetClickHdl
(
aLink
);
mp
Impl
->
mpPrevButton
.
reset
(
new
ImplTabButton
(
this
,
WB_REPEAT
)
);
mp
Impl
->
mpPrevButton
->
SetClickHdl
(
aLink
);
}
mp
PrevBtn
->
SetSymbol
(
mbMirrored
?
SymbolType
::
NEXT
:
SymbolType
::
PREV
);
mp
PrevBt
n
->
Show
();
mp
Impl
->
mpPrevButton
->
SetSymbol
(
mbMirrored
?
SymbolType
::
NEXT
:
SymbolType
::
PREV
);
mp
Impl
->
mpPrevButto
n
->
Show
();
if
(
!
mpNextBtn
)
if
(
!
mpImpl
->
mpNextButton
)
{
mp
NextBtn
=
new
ImplTabButton
(
this
,
WB_REPEAT
);
mp
NextBtn
->
SetClickHdl
(
aLink
);
mp
Impl
->
mpNextButton
.
reset
(
new
ImplTabButton
(
this
,
WB_REPEAT
)
);
mp
Impl
->
mpNextButton
->
SetClickHdl
(
aLink
);
}
mp
NextBtn
->
SetSymbol
(
mbMirrored
?
SymbolType
::
PREV
:
SymbolType
::
NEXT
);
mp
NextBt
n
->
Show
();
mp
Impl
->
mpNextButton
->
SetSymbol
(
mbMirrored
?
SymbolType
::
PREV
:
SymbolType
::
NEXT
);
mp
Impl
->
mpNextButto
n
->
Show
();
}
else
{
DELETEZ
(
mpPrevBtn
);
DELETEZ
(
mpNextBtn
);
mpImpl
->
mpPrevButton
.
reset
(
);
mpImpl
->
mpNextButton
.
reset
(
);
}
if
(
mnWinStyle
&
WB_SCROLL
)
{
if
(
!
mpFirstBtn
)
if
(
!
mpImpl
->
mpFirstButton
)
{
mp
FirstBtn
=
new
ImplTabButton
(
this
);
mp
FirstBtn
->
SetClickHdl
(
aLink
);
mp
Impl
->
mpFirstButton
.
reset
(
new
ImplTabButton
(
this
)
);
mp
Impl
->
mpFirstButton
->
SetClickHdl
(
aLink
);
}
mp
FirstBtn
->
SetSymbol
(
mbMirrored
?
SymbolType
::
LAST
:
SymbolType
::
FIRST
);
mp
FirstBt
n
->
Show
();
mp
Impl
->
mpFirstButton
->
SetSymbol
(
mbMirrored
?
SymbolType
::
LAST
:
SymbolType
::
FIRST
);
mp
Impl
->
mpFirstButto
n
->
Show
();
if
(
!
mpLastBtn
)
if
(
!
mpImpl
->
mpLastButton
)
{
mp
LastBtn
=
new
ImplTabButton
(
this
);
mp
LastBtn
->
SetClickHdl
(
aLink
);
mp
Impl
->
mpLastButton
.
reset
(
new
ImplTabButton
(
this
)
);
mp
Impl
->
mpLastButton
->
SetClickHdl
(
aLink
);
}
mp
LastBtn
->
SetSymbol
(
mbMirrored
?
SymbolType
::
FIRST
:
SymbolType
::
LAST
);
mp
LastBt
n
->
Show
();
mp
Impl
->
mpLastButton
->
SetSymbol
(
mbMirrored
?
SymbolType
::
FIRST
:
SymbolType
::
LAST
);
mp
Impl
->
mpLastButto
n
->
Show
();
}
else
{
DELETEZ
(
mpFirstBtn
);
DELETEZ
(
mpLastBtn
);
mpImpl
->
mpFirstButton
.
reset
(
);
mpImpl
->
mpLastButton
.
reset
(
);
}
mbHasInsertTab
=
(
mnWinStyle
&
WB_INSERTTAB
);
...
...
@@ -760,16 +753,16 @@ void TabBar::ImplEnableControls()
// enable/disable buttons
bool
bEnableBtn
=
mbScrollAlwaysEnabled
||
mnFirstPos
>
0
;
if
(
mpFirstBtn
)
mp
FirstBtn
->
Enable
(
bEnableBtn
);
if
(
mpPrevBtn
)
mp
PrevBtn
->
Enable
(
bEnableBtn
);
if
(
mpImpl
->
mpFirstButton
)
mp
Impl
->
mpFirstButton
->
Enable
(
bEnableBtn
);
if
(
mpImpl
->
mpPrevButton
)
mp
Impl
->
mpPrevButton
->
Enable
(
bEnableBtn
);
bEnableBtn
=
mbScrollAlwaysEnabled
||
mnFirstPos
<
ImplGetLastFirstPos
();
if
(
mpNextBtn
)
mp
NextBtn
->
Enable
(
bEnableBtn
);
if
(
mpLastBtn
)
mp
LastBtn
->
Enable
(
bEnableBtn
);
if
(
mpImpl
->
mpNextButton
)
mp
Impl
->
mpNextButton
->
Enable
(
bEnableBtn
);
if
(
mpImpl
->
mpLastButton
)
mp
Impl
->
mpLastButton
->
Enable
(
bEnableBtn
);
}
void
TabBar
::
SetScrollAlwaysEnabled
(
bool
bScrollAlwaysEnabled
)
...
...
@@ -808,22 +801,22 @@ IMPL_LINK( TabBar, ImplClickHdl, ImplTabButton*, pBtn )
sal_uInt16
nNewPos
=
mnFirstPos
;
if
(
pBtn
==
mp
FirstBtn
||
(
pBtn
==
mpPrevBtn
&&
pBtn
->
isModKeyPressed
()))
if
(
pBtn
==
mp
Impl
->
mpFirstButton
.
get
()
||
(
pBtn
==
mpImpl
->
mpPrevButton
.
get
()
&&
pBtn
->
isModKeyPressed
()))
{
nNewPos
=
0
;
}
else
if
(
pBtn
==
mp
LastBtn
||
(
pBtn
==
mpNextBtn
&&
pBtn
->
isModKeyPressed
()))
else
if
(
pBtn
==
mp
Impl
->
mpLastButton
.
get
()
||
(
pBtn
==
mpImpl
->
mpNextButton
.
get
()
&&
pBtn
->
isModKeyPressed
()))
{
sal_uInt16
nCount
=
GetPageCount
();
if
(
nCount
)
nNewPos
=
nCount
-
1
;
}
else
if
(
pBtn
==
mp
PrevBtn
)
else
if
(
pBtn
==
mp
Impl
->
mpPrevButton
.
get
()
)
{
if
(
mnFirstPos
)
nNewPos
=
mnFirstPos
-
1
;
}
else
if
(
pBtn
==
mp
NextBtn
)
else
if
(
pBtn
==
mp
Impl
->
mpNextButton
.
get
()
)
{
sal_uInt16
nCount
=
GetPageCount
();
if
(
mnFirstPos
<
nCount
)
...
...
@@ -1418,27 +1411,27 @@ void TabBar::Resize()
nButtonWidth
+=
nButtonMargin
;
Size
aBtnSize
(
nHeight
,
nHeight
);
if
(
mpFirstBtn
)
if
(
mpImpl
->
mpFirstButton
)
{
mp
FirstBt
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
mp
Impl
->
mpFirstButto
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
nX
+=
nXDiff
;
nButtonWidth
+=
nHeight
;
}
if
(
mpPrevBtn
)
if
(
mpImpl
->
mpPrevButton
)
{
mp
PrevBt
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
mp
Impl
->
mpPrevButto
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
nX
+=
nXDiff
;
nButtonWidth
+=
nHeight
;
}
if
(
mpNextBtn
)
if
(
mpImpl
->
mpNextButton
)
{
mp
NextBt
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
mp
Impl
->
mpNextButto
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
nX
+=
nXDiff
;
nButtonWidth
+=
nHeight
;
}
if
(
mpLastBtn
)
if
(
mpImpl
->
mpLastButton
)
{
mp
LastBt
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
mp
Impl
->
mpLastButto
n
->
SetPosSizePixel
(
Point
(
nX
,
0
),
aBtnSize
);
nX
+=
nXDiff
;
nButtonWidth
+=
nHeight
;
}
...
...
@@ -1604,12 +1597,18 @@ void TabBar::StateChanged( StateChangedType nType )
else
if
(
nType
==
StateChangedType
::
MIRRORING
)
{
// reacts on calls of EnableRTL, have to mirror all child controls
if
(
mpFirstBtn
)
mpFirstBtn
->
EnableRTL
(
IsRTLEnabled
()
);
if
(
mpPrevBtn
)
mpPrevBtn
->
EnableRTL
(
IsRTLEnabled
()
);
if
(
mpNextBtn
)
mpNextBtn
->
EnableRTL
(
IsRTLEnabled
()
);
if
(
mpLastBtn
)
mpLastBtn
->
EnableRTL
(
IsRTLEnabled
()
);
if
(
mpImpl
->
mpSizer
)
mpImpl
->
mpSizer
->
EnableRTL
(
IsRTLEnabled
()
);
if
(
mpEdit
)
mpEdit
->
EnableRTL
(
IsRTLEnabled
()
);
if
(
mpImpl
->
mpFirstButton
)
mpImpl
->
mpFirstButton
->
EnableRTL
(
IsRTLEnabled
());
if
(
mpImpl
->
mpPrevButton
)
mpImpl
->
mpPrevButton
->
EnableRTL
(
IsRTLEnabled
());
if
(
mpImpl
->
mpNextButton
)
mpImpl
->
mpNextButton
->
EnableRTL
(
IsRTLEnabled
());
if
(
mpImpl
->
mpLastButton
)
mpImpl
->
mpLastButton
->
EnableRTL
(
IsRTLEnabled
());
if
(
mpImpl
->
mpSizer
)
mpImpl
->
mpSizer
->
EnableRTL
(
IsRTLEnabled
());
if
(
mpImpl
->
mpEdit
)
mpImpl
->
mpEdit
->
EnableRTL
(
IsRTLEnabled
());
}
}
...
...
@@ -2271,7 +2270,7 @@ bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const
bool
TabBar
::
StartEditMode
(
sal_uInt16
nPageId
)
{
sal_uInt16
nPos
=
GetPagePos
(
nPageId
);
if
(
mpEdit
||
(
nPos
==
PAGE_NOT_FOUND
)
||
(
mnLastOffX
<
8
)
)
if
(
mpImpl
->
mpEdit
||
(
nPos
==
PAGE_NOT_FOUND
)
||
(
mnLastOffX
<
8
)
)
return
false
;
mnEditId
=
nPageId
;
...
...
@@ -2281,7 +2280,7 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
ImplFormat
();
Update
();
mp
Edit
=
new
TabBarEdit
(
this
,
WB_CENTER
);
mp
Impl
->
mpEdit
.
reset
(
new
TabBarEdit
(
this
,
WB_CENTER
)
);
Rectangle
aRect
=
GetPageRect
(
mnEditId
);
long
nX
=
aRect
.
Left
();
long
nWidth
=
aRect
.
GetWidth
();
...
...
@@ -2294,8 +2293,8 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
nX
=
aRect
.
Left
();
nWidth
=
aRect
.
GetWidth
();
}
mp
Edit
->
SetText
(
GetPageText
(
mnEditId
)
);
mp
Edit
->
setPosSizePixel
(
nX
,
aRect
.
Top
()
+
mnOffY
+
1
,
nWidth
,
aRect
.
GetHeight
()
-
3
);
mp
Impl
->
mpEdit
->
SetText
(
GetPageText
(
mnEditId
)
);
mp
Impl
->
mpEdit
->
setPosSizePixel
(
nX
,
aRect
.
Top
()
+
mnOffY
+
1
,
nWidth
,
aRect
.
GetHeight
()
-
3
);
vcl
::
Font
aFont
=
GetPointFont
();
Color
aForegroundColor
;
Color
aBackgroundColor
;
...
...
@@ -2318,12 +2317,12 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
}
if
(
GetPageBits
(
mnEditId
)
&
TPB_SPECIAL
)
aForegroundColor
=
Color
(
COL_LIGHTBLUE
);
mp
Edit
->
SetControlFont
(
aFont
);
mp
Edit
->
SetControlForeground
(
aForegroundColor
);
mp
Edit
->
SetControlBackground
(
aBackgroundColor
);
mpEdit
->
GrabFocus
();
mp
Edit
->
SetSelection
(
Selection
(
0
,
mpEdit
->
GetText
().
getLength
()
)
);
mpEdit
->
Show
();
mp
Impl
->
mpEdit
->
SetControlFont
(
aFont
);
mp
Impl
->
mpEdit
->
SetControlForeground
(
aForegroundColor
);
mp
Impl
->
mpEdit
->
SetControlBackground
(
aBackgroundColor
);
mp
Impl
->
mp
Edit
->
GrabFocus
();
mp
Impl
->
mpEdit
->
SetSelection
(
Selection
(
0
,
mpImpl
->
mpEdit
->
GetText
().
getLength
())
);
mp
Impl
->
mp
Edit
->
Show
();
return
true
;
}
else
...
...
@@ -2333,17 +2332,20 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
}
}
bool
TabBar
::
IsInEditMode
()
const
{
return
mpImpl
->
mpEdit
.
get
()
!=
NULL
;
}
void
TabBar
::
EndEditMode
(
bool
bCancel
)
{
if
(
mpEdit
)
if
(
mpImpl
->
mpEdit
)
{
// call hdl
bool
bEnd
=
true
;
mbEditCanceled
=
bCancel
;
maEditText
=
mpEdit
->
GetText
();
mpEdit
->
SetPostEvent
();
maEditText
=
mp
Impl
->
mp
Edit
->
GetText
();
mp
Impl
->
mp
Edit
->
SetPostEvent
();
if
(
!
bCancel
)
{
TabBarAllowRenamingReturnCode
nAllowRenaming
=
AllowRenaming
();
...
...
@@ -2358,14 +2360,13 @@ void TabBar::EndEditMode( bool bCancel )
// renaming not allowed, than reset edit data
if
(
!
bEnd
)
{
mpEdit
->
ResetPostEvent
();
mpEdit
->
GrabFocus
();
mp
Impl
->
mp
Edit
->
ResetPostEvent
();
mp
Impl
->
mp
Edit
->
GrabFocus
();
}
else
{
// close edit and call end hdl
delete
mpEdit
;
mpEdit
=
NULL
;
mpImpl
->
mpEdit
.
reset
();
EndRenaming
();
mnEditId
=
0
;
}
...
...
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