KiCad PCB EDA Suite
bitmap_toggle.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) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
5  * @author Jon Evans <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef _BITMAP_TOGGLE_H
26 #define _BITMAP_TOGGLE_H
27 
28 #include <wx/statbmp.h>
29 #include <wx/panel.h>
30 
31 #include <gal/color4d.h>
32 
33 class wxStaticBitmap;
34 
35 wxDECLARE_EVENT( TOGGLE_CHANGED, wxCommandEvent );
36 
43 class BITMAP_TOGGLE : public wxPanel
44 {
45 public:
47 
48  BITMAP_TOGGLE( wxWindow* aParent, wxWindowID aId, const wxBitmap& aCheckedBitmap,
49  const wxBitmap& aUncheckedBitmap, bool aChecked = false );
50 
52  void SetValue( bool aValue );
53 
55  bool GetValue() const { return m_checked; }
56 
61  void SetWindowID( wxWindowID aId )
62  {
63  SetId( aId );
64  m_bitmap->SetId( aId );
65  }
66 
67 private:
68  bool m_checked;
69 
70  wxStaticBitmap* m_bitmap;
72  wxBitmap m_checked_bitmap;
73 
74  wxLongLong m_debounce; // Timestamp for debouncing events
75 };
76 
77 #endif
wxDECLARE_EVENT(TOGGLE_CHANGED, wxCommandEvent)
void SetValue(bool aValue)
Read the checkbox state.
A checkbox control except with custom bitmaps for the checked and unchecked states.
Definition: bitmap_toggle.h:43
void SetWindowID(wxWindowID aId)
Updates the window ID of this control and its children.
Definition: bitmap_toggle.h:61
wxLongLong m_debounce
Definition: bitmap_toggle.h:74
wxStaticBitmap * m_bitmap
Definition: bitmap_toggle.h:70
wxBitmap m_checked_bitmap
Definition: bitmap_toggle.h:72
wxBitmap m_unchecked_bitmap
Definition: bitmap_toggle.h:71
bool GetValue() const
Definition: bitmap_toggle.h:55