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 #ifndef INCLUDED_SD_SOURCE_UI_DLG_REMOTEDIALOGCLIENTBOX_HXX
21 #define INCLUDED_SD_SOURCE_UI_DLG_REMOTEDIALOGCLIENTBOX_HXX
23 #include <rtl/ustring.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/field.hxx>
32 #define SMALL_ICON_SIZE 16
34 #define ICON_HEIGHT 42
36 #define ICON_OFFSET 72
37 #define RIGHT_ICON_OFFSET 5
38 #define SPACE_BETWEEN 3
40 // struct ClientBoxEntry
41 struct ClientBoxEntry
;
44 typedef std::shared_ptr
<ClientBoxEntry
> TClientBoxEntry
;
49 std::shared_ptr
<ClientInfo
> m_pClientInfo
;
51 explicit ClientBoxEntry(const std::shared_ptr
<ClientInfo
>& pClientInfo
);
56 // class ExtensionBox_Impl
58 class ClientBox
: public Control
60 bool m_bHasScrollBar
: 1;
61 bool m_bHasActive
: 1;
62 bool m_bNeedsRecalc
: 1;
63 bool m_bAdjustActive
: 1;
64 //Must be guarded together with m_vEntries to ensure a valid index at all times.
65 //Use m_entriesMutex as guard.
71 VclPtr
<NumericBox
> m_aPinBox
;
72 VclPtr
<PushButton
> m_aDeauthoriseButton
;
73 ::tools::Rectangle m_sPinTextRect
;
75 VclPtr
<ScrollBar
> m_aScrollBar
;
77 //This mutex is used for synchronizing access to m_vEntries.
78 //Currently it is used to synchronize adding, removing entries and
79 //functions like getItemName, getItemDescription, etc. to prevent
80 //that m_vEntries is accessed at an invalid index.
81 //ToDo: There are many more places where m_vEntries is read and which may
82 //fail. For example the Paint method is probable called from the main thread
83 //while new entries are added / removed in a separate thread.
84 mutable ::osl::Mutex m_entriesMutex
;
85 std::vector
< TClientBoxEntry
> m_vEntries
;
87 void CalcActiveHeight();
88 long GetTotalHeight() const;
89 void SetupScrollBar();
90 void DrawRow(vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
& rRect
, const TClientBoxEntry
& rEntry
);
91 bool HandleCursorKey( sal_uInt16 nKeyCode
);
93 DECL_LINK( ScrollHdl
, ScrollBar
*, void );
94 DECL_LINK( DeauthoriseHdl
, Button
*, void );
97 ClientBox( vcl::Window
* pParent
, WinBits nStyle
);
98 virtual ~ClientBox() override
;
99 virtual void dispose() override
;
101 void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
102 void Paint( vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
&rPaintRect
) override
;
103 void Resize() override
;
104 Size
GetOptimalSize() const override
;
105 bool EventNotify( NotifyEvent
& rNEvt
) override
;
107 TClientBoxEntry
const & GetEntryData( long nPos
) { return m_vEntries
[ nPos
]; }
108 long GetActiveEntryIndex();
109 ::tools::Rectangle
GetEntryRect( const long nPos
) const;
110 long PointToPos( const Point
& rPos
);
111 void DoScroll( long nDelta
);
114 void selectEntry( const long nPos
);
115 void addEntry(const std::shared_ptr
<ClientInfo
>& pClientInfo
);
119 void populateEntries();
122 } // end namespace sd
124 #endif // INCLUDED_SD_SOURCE_UI_DLG_REMOTEDIALOGCLIENTBOX_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */