1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "rtl/ustring.hxx"
21 #include "vcl/scrbar.hxx"
22 #include "vcl/fixed.hxx"
23 #include "vcl/dialog.hxx"
24 #include "vcl/field.hxx"
26 #include "svtools/extensionlistbox.hxx"
27 #include "cppuhelper/implbase1.hxx"
29 #include "com/sun/star/lang/Locale.hpp"
30 #include "com/sun/star/lang/XEventListener.hpp"
31 #include "com/sun/star/deployment/XPackage.hpp"
33 #include <boost/shared_ptr.hpp>
35 #include "RemoteServer.hxx"
36 #include "sdresid.hxx"
40 #define SMALL_ICON_SIZE 16
42 #define ICON_HEIGHT 42
44 #define ICON_OFFSET 72
45 #define RIGHT_ICON_OFFSET 5
46 #define SPACE_BETWEEN 3
47 //------------------------------------------------------------------------------
48 // struct ClientBoxEntry
49 //------------------------------------------------------------------------------
50 struct ClientBoxEntry
;
52 typedef ::boost::shared_ptr
< ClientBoxEntry
> TClientBoxEntry
;
57 ClientInfo
* m_pClientInfo
;
60 ClientBoxEntry( ClientInfo
* pClientInfo
);
65 //------------------------------------------------------------------------------
66 // class ExtensionBox_Impl
67 //------------------------------------------------------------------------------
71 //------------------------------------------------------------------------------
72 class ClientRemovedListener
: public ::cppu::WeakImplHelper1
< ::com::sun::star::lang::XEventListener
>
78 ClientRemovedListener( ClientBox
*pParent
) { m_pParent
= pParent
; }
79 ~ClientRemovedListener();
81 //===================================================================================
83 virtual void SAL_CALL
disposing( ::com::sun::star::lang::EventObject
const & evt
)
84 throw (::com::sun::star::uno::RuntimeException
);
88 //------------------------------------------------------------------------------
98 //Must be guarded together with m_vEntries to ensure a valid index at all times.
99 //Use m_entriesMutex as guard.
103 long m_nActiveHeight
;
108 NumericBox m_aPinBox
;
109 FixedText m_aPinDescription
;
111 ScrollBar
* m_pScrollBar
;
113 com::sun::star::uno::Reference
< ClientRemovedListener
> m_xRemoveListener
;
115 RemoteServer
*m_pServer
;
116 //This mutex is used for synchronizing access to m_vEntries.
117 //Currently it is used to synchronize adding, removing entries and
118 //functions like getItemName, getItemDescription, etc. to prevent
119 //that m_vEntries is accessed at an invalid index.
120 //ToDo: There are many more places where m_vEntries is read and which may
121 //fail. For example the Paint method is probable called from the main thread
122 //while new entries are added / removed in a separate thread.
123 mutable ::osl::Mutex m_entriesMutex
;
124 std::vector
< TClientBoxEntry
> m_vEntries
;
125 std::vector
< TClientBoxEntry
> m_vRemovedEntries
;
127 void CalcActiveHeight( const long nPos
);
128 long GetTotalHeight() const;
129 void SetupScrollBar();
130 void DrawRow( const Rectangle
& rRect
, const TClientBoxEntry pEntry
);
131 bool HandleTabKey( bool bReverse
);
132 bool HandleCursorKey( sal_uInt16 nKeyCode
);
133 void DeleteRemoved();
136 DECL_DLLPRIVATE_LINK( ScrollHdl
, ScrollBar
* );
138 //Index starts with 1.
139 //Throws an com::sun::star::lang::IllegalArgumentException, when the index is invalid.
140 void checkIndex(sal_Int32 pos
) const;
144 ClientBox( Dialog
* pParent
, RemoteServer
*pServer
,
145 const SdResId
& aId
);
148 void MouseButtonDown( const MouseEvent
& rMEvt
);
149 void Paint( const Rectangle
&rPaintRect
);
151 long Notify( NotifyEvent
& rNEvt
);
153 const Size
GetMinOutputSizePixel() const;
154 void SetExtraSize( long nSize
) { m_nExtraHeight
= nSize
; }
155 TClientBoxEntry
GetEntryData( long nPos
) { return m_vEntries
[ nPos
]; }
156 long GetActiveEntryIndex();
157 long GetEntryCount() { return (long) m_vEntries
.size(); }
158 Rectangle
GetEntryRect( const long nPos
) const;
159 bool HasActive() { return m_bHasActive
; }
160 long PointToPos( const Point
& rPos
);
161 void SetScrollHdl( const Link
& rLink
);
162 void DoScroll( long nDelta
);
163 void SetHyperlinkHdl( const Link
& rLink
){ m_aClickHdl
= rLink
; }
165 void RemoveUnlocked();
168 void selectEntry( const long nPos
);
169 long addEntry( ClientInfo
* pClientInfo
);
170 void updateEntry( const ClientInfo
* rPackageInfo
);
171 void removeEntry( const ClientInfo
* rPackageInfo
);
173 void prepareChecking();
178 RemoteServer
* getServer() const { return m_pServer
; }
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */