Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
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 http://mozilla.org/MPL/2.0/.
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 http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVTOOLS_SIMPTABL_HXX
21 : #define INCLUDED_SVTOOLS_SIMPTABL_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <svtools/headbar.hxx>
25 : #include <svtools/svtabbx.hxx>
26 : #include <unotools/intlwrapper.hxx>
27 :
28 : class SvSimpleTable;
29 : class SVT_DLLPUBLIC SvSimpleTableContainer : public Control
30 : {
31 : private:
32 : VclPtr<SvSimpleTable> m_pTable;
33 :
34 : protected:
35 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
36 :
37 : public:
38 : SvSimpleTableContainer( vcl::Window* pParent, WinBits nBits = WB_BORDER );
39 : virtual ~SvSimpleTableContainer();
40 : virtual void dispose() SAL_OVERRIDE;
41 :
42 : void SetTable(SvSimpleTable* pTable);
43 :
44 : virtual void Resize() SAL_OVERRIDE;
45 :
46 : virtual void GetFocus() SAL_OVERRIDE;
47 : };
48 :
49 : class SVT_DLLPUBLIC SvSimpleTable : public SvHeaderTabListBox
50 : {
51 : private:
52 : SvSimpleTableContainer& m_rParentTableContainer;
53 :
54 : Link<> aHeaderBarClickLink;
55 : Link<> aHeaderBarDblClickLink;
56 : Link<> aCommandLink;
57 : CommandEvent aCEvt;
58 : VclPtr<HeaderBar> aHeaderBar;
59 : long nOldPos;
60 : sal_uInt16 nHeaderItemId;
61 : bool bPaintFlag;
62 : bool bSortDirection;
63 : sal_uInt16 nSortCol;
64 :
65 : const CollatorWrapper aCollator;
66 :
67 : DECL_LINK( StartDragHdl, HeaderBar* );
68 : DECL_LINK( DragHdl, HeaderBar* );
69 : DECL_LINK( EndDragHdl, HeaderBar* );
70 : DECL_LINK( HeaderBarClick, HeaderBar* );
71 : DECL_LINK( HeaderBarDblClick, HeaderBar* );
72 : DECL_LINK( CompareHdl, SvSortData* );
73 :
74 : protected:
75 :
76 : virtual void NotifyScrolled() SAL_OVERRIDE;
77 :
78 : virtual void SetTabs() SAL_OVERRIDE;
79 : virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
80 :
81 : virtual void HBarClick();
82 : void HBarDblClick();
83 : void HBarStartDrag();
84 : void HBarDrag();
85 : void HBarEndDrag();
86 :
87 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
88 :
89 : virtual sal_Int32 ColCompare(SvTreeListEntry*,SvTreeListEntry*);
90 : public:
91 :
92 : SvSimpleTable(SvSimpleTableContainer& rParent, WinBits nBits = WB_BORDER);
93 : virtual ~SvSimpleTable();
94 : virtual void dispose() SAL_OVERRIDE;
95 :
96 : void UpdateViewSize();
97 :
98 : void InsertHeaderEntry(const OUString& rText,
99 : sal_uInt16 nCol=HEADERBAR_APPEND,
100 : HeaderBarItemBits nBits = HeaderBarItemBits::STDSTYLE);
101 :
102 : void SetTabs(const long* pTabs, MapUnit = MAP_APPFONT);
103 :
104 : void ClearHeader();
105 :
106 : void ShowTable();
107 : void HideTable();
108 : bool IsVisible() const;
109 :
110 : void EnableTable();
111 : void DisableTable();
112 : bool IsEnabled() const;
113 :
114 : sal_uInt16 GetSelectedCol();
115 : void SortByCol(sal_uInt16, bool bDir=true);
116 0 : bool GetSortDirection(){ return bSortDirection;}
117 0 : sal_uInt16 GetSortedCol(){ return nSortCol;}
118 : SvLBoxItem* GetEntryAtPos( SvTreeListEntry* pEntry, sal_uInt16 nPos ) const;
119 :
120 0 : CommandEvent GetCommandEvent()const { return aCEvt;}
121 0 : inline bool IsFocusOnCellEnabled() const { return IsCellFocusEnabled(); }
122 :
123 0 : void SetCommandHdl( const Link<>& rLink ) { aCommandLink = rLink; }
124 : const Link<>& GetCommandHdl() const { return aCommandLink; }
125 :
126 0 : void SetHeaderBarClickHdl( const Link<>& rLink ) { aHeaderBarClickLink = rLink; }
127 : const Link<>& GetHeaderBarClickHdl() const { return aHeaderBarClickLink; }
128 :
129 : void SetHeaderBarDblClickHdl( const Link<>& rLink ) { aHeaderBarDblClickLink = rLink; }
130 : const Link<>& GetHeaderBarDblClickHdl() const { return aHeaderBarDblClickLink; }
131 :
132 : void SetHeaderBarHelpId(const OString& rHelpId) { aHeaderBar->SetHelpId(rHelpId); }
133 :
134 0 : HeaderBar& GetTheHeaderBar() { return *aHeaderBar.get(); }
135 : };
136 :
137 :
138 : #endif // INCLUDED_SVTOOLS_SIMPTABL_HXX
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|