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 #pragma once
21 
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
25 
26 #include <config_options.h>
27 #include <vcl/dllapi.h>
28 #include <vcl/ctrl.hxx>
29 #include <vcl/toolkit/imgctrl.hxx>
30 #include <memory>
31 
32 class Bitmap;
33 
34 namespace vcl
35 {
36 
37 struct RoadmapTypes
38 {
39 public:
40     typedef sal_Int16 ItemId;
41     typedef sal_Int32 ItemIndex;
42 };
43 
44 class HyperLabel;
45 class RoadmapImpl;
46 class RoadmapItem;
47 
48 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) ORoadmap final : public Control, public RoadmapTypes
49 {
50 public:
51     ORoadmap( vcl::Window* _pParent, WinBits _nWinStyle );
52     virtual ~ORoadmap( ) override;
53     virtual void dispose() override;
54 
55     void            SetRoadmapBitmap( const BitmapEx& maBitmap );
56 
57     void            EnableRoadmapItem( ItemId _nItemId, bool _bEnable );
58 
59     void            ChangeRoadmapItemLabel( ItemId _nID, const OUString& sLabel );
60     void            ChangeRoadmapItemID( ItemId _nID, ItemId NewID  );
61 
62     void            SetRoadmapInteractive( bool _bInteractive );
63     bool            IsRoadmapInteractive() const;
64 
65     void            SetRoadmapComplete( bool _bComplete );
66     bool            IsRoadmapComplete() const;
67 
68     ItemIndex       GetItemCount() const;
69     ItemId          GetItemID( ItemIndex _nIndex ) const;
70 
71     void            InsertRoadmapItem( ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled );
72     void            ReplaceRoadmapItem( ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled );
73     void            DeleteRoadmapItem( ItemIndex _nIndex );
74 
75     ItemId          GetCurrentRoadmapItemID() const;
76     bool            SelectRoadmapItemByID(ItemId nItemID, bool bGrabFocus = true);
77 
78     void            SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl );
79     Link<LinkParamNone*,void> const & GetItemSelectHdl( ) const;
80     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
81     virtual void    GetFocus() override;
82     virtual void    ApplySettings( vcl::RenderContext& rRenderContext ) override;
83 
84 private:
85     bool            PreNotify( NotifyEvent& rNEvt ) override;
86 
87     /// called when an item has been selected by any means
88     void            Select();
89 
90     DECL_LINK(ImplClickHdl, HyperLabel*, void);
91 
92     RoadmapItem*         GetByIndex( ItemIndex _nItemIndex );
93     const RoadmapItem*   GetByIndex( ItemIndex _nItemIndex ) const;
94 
95     RoadmapItem*         GetByID( ItemId _nID  );
96     const RoadmapItem*   GetByID( ItemId _nID  ) const;
97     RoadmapItem*         GetPreviousHyperLabel( ItemIndex Index);
98 
99     void                 DrawHeadline(vcl::RenderContext& rRenderContext);
100     void                 DeselectOldRoadmapItems();
101     ItemId               GetNextAvailableItemId( ItemIndex NewIndex );
102     ItemId               GetPreviousAvailableItemId( ItemIndex NewIndex );
103     RoadmapItem*         GetByPointer(vcl::Window const * pWindow);
104     RoadmapItem*         InsertHyperLabel( ItemIndex Index, const OUString& _aStr, ItemId RMID, bool _bEnabled, bool _bIncomplete  );
105     void                 UpdatefollowingHyperLabels( ItemIndex Index );
106 
107     // Window overridables
108     void            Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect) override;
109     void            implInit(vcl::RenderContext& rRenderContext);
110 
111     std::unique_ptr<RoadmapImpl>    m_pImpl;
112 };
113 
114 }   // namespace vcl
115 
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
117