KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_package.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PANEL_PACKAGE_H_
22#define PANEL_PACKAGE_H_
23
24#include <functional>
25
26#include "panel_package_base.h"
27#include "pcm.h"
28
31{
33 wxBitmap* bitmap;
35 bool pinned;
36 wxString repository_id;
40 PACKAGE_VIEW_DATA( const PCM_PACKAGE aPackage ) :
41 package( std::move( aPackage ) ), bitmap( nullptr ), state( PPS_INSTALLED ),
42 pinned( false ){};
44 package( std::move( aEntry.package ) ), bitmap( nullptr )
45 {
50 pinned = aEntry.pinned;
51 }
52};
53
54
56using ActionCallback = std::function<void( const PACKAGE_VIEW_DATA& aData,
57 PCM_PACKAGE_ACTION aAction, const wxString& aVersion )>;
58
59using PinCallback = std::function<void( const wxString& aPackageId, const PCM_PACKAGE_STATE aState,
60 const bool aPinned )>;
61
62
64{
65public:
66 PANEL_PACKAGE( wxWindow* parent, const ActionCallback& aCallback,
67 const PinCallback& aPinCallback, const PACKAGE_VIEW_DATA& aData );
68
70 void SetSelectCallback( const std::function<void()>& aCallback );
71
73 void SetSelected( bool aSelected );
74
75 void OnButtonClicked( wxCommandEvent& event ) override;
76
78 void SetState( PCM_PACKAGE_STATE aState, bool aPinned );
79
81 void OnClick( wxMouseEvent& event ) override;
82
83 void OnUninstallClick( wxCommandEvent& event );
84
85 void OnPinVersionClick( wxCommandEvent& event );
86
87 void OnSize( wxSizeEvent& event ) override;
88
90 wxString GetPreferredVersion() const;
91
92 const PACKAGE_VIEW_DATA& GetPackageData() const { return m_data; };
93
94private:
95 void OnPaint( wxPaintEvent& event ) override;
96
97private:
99 wxMenuItem* m_actionMenuItem;
100 std::function<void()> m_selectCallback;
101 bool m_selected = false;
106};
107
108
109#endif // PANEL_PACKAGE_H_
Class PANEL_PACKAGE_BASE.
void OnClick(wxMouseEvent &event) override
void OnUninstallClick(wxCommandEvent &event)
wxMenuItem * m_actionMenuItem
Definition: panel_package.h:99
void OnPinVersionClick(wxCommandEvent &event)
const PACKAGE_VIEW_DATA & GetPackageData() const
Definition: panel_package.h:92
void OnPaint(wxPaintEvent &event) override
void SetSelected(bool aSelected)
void OnButtonClicked(wxCommandEvent &event) override
Changes state of the (un)install button.
const ActionCallback & m_actionCallback
const PinCallback & m_pinCallback
wxMenuItem * m_pinVersionMenuItem
Definition: panel_package.h:98
PACKAGE_VIEW_DATA m_data
void SetState(PCM_PACKAGE_STATE aState, bool aPinned)
Called when anywhere on the panel is clicked (except install button)
void OnSize(wxSizeEvent &event) override
Get preferred version. If criteria are not met, return wxEmptyString.
std::function< void()> m_selectCallback
void SetSelectCallback(const std::function< void()> &aCallback)
Marks panel as selected.
wxString GetPreferredVersion() const
STL namespace.
std::function< void(const wxString &aPackageId, const PCM_PACKAGE_STATE aState, const bool aPinned)> PinCallback
Definition: panel_package.h:60
std::function< void(const PACKAGE_VIEW_DATA &aData, PCM_PACKAGE_ACTION aAction, const wxString &aVersion)> ActionCallback
Definition: panel_package.h:57
PCM_PACKAGE_STATE
Definition: pcm.h:58
@ PPS_INSTALLED
Definition: pcm.h:61
PCM_PACKAGE_ACTION
Definition: pcm.h:71
< Collection of data relevant to the package display panel Callback for (un)install button
Definition: panel_package.h:31
wxString update_version
Definition: panel_package.h:39
wxString repository_id
Definition: panel_package.h:36
wxString current_version
Definition: panel_package.h:38
const PCM_PACKAGE package
Definition: panel_package.h:32
wxString repository_name
Definition: panel_package.h:37
PACKAGE_VIEW_DATA(const PCM_INSTALLATION_ENTRY &aEntry)
Definition: panel_package.h:43
wxBitmap * bitmap
Definition: panel_package.h:33
PCM_PACKAGE_STATE state
Definition: panel_package.h:34
PACKAGE_VIEW_DATA(const PCM_PACKAGE aPackage)
Definition: panel_package.h:40
Definition: pcm_data.h:139
wxString repository_name
Definition: pcm_data.h:143
wxString repository_id
Definition: pcm_data.h:142
wxString current_version
Definition: pcm_data.h:141
bool pinned
Definition: pcm_data.h:145
Repository reference to a resource.
Definition: pcm_data.h:96