KiCad PCB EDA Suite
split_button.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) 2020 Kicad Developers, see AUTHORS.txt for contributors.
5 * Copyright (C) 2016 Anil8735(https://stackoverflow.com/users/3659387/anil8753) from https://stackoverflow.com/a/37274011
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 __SPLIT_BUTTON_H__
26#define __SPLIT_BUTTON_H__
27
28#include <wx/bitmap.h>
29#include <wx/panel.h>
30
31class wxButton;
32class wxMenu;
33
34class SPLIT_BUTTON : public wxPanel
35{
36public:
37 SPLIT_BUTTON( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
38 const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize );
39
41
42 wxMenu* GetSplitButtonMenu();
43 void SetBitmap( const wxBitmap& aBmp );
44 void SetMinSize( const wxSize& aSize ) override;
45 void SetWidthPadding( int aPadding );
46 void SetLabel( const wxString& aLabel ) override;
47
48protected:
49 void OnKillFocus( wxFocusEvent& aEvent );
50 void OnMouseLeave( wxMouseEvent& aEvent );
51 void OnMouseEnter( wxMouseEvent& aEvent );
52 void OnLeftButtonUp( wxMouseEvent& aEvent );
53 void OnLeftButtonDown( wxMouseEvent& aEvent );
54 void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
55 void onThemeChanged( wxSysColourChangedEvent &aEvent );
56
57 bool Enable( bool aEnable = true ) override;
58
59private:
61 int m_stateMenu = 0;
62 bool m_bIsEnable = true;
63 const int m_arrowButtonWidth = 20;
65 bool m_bLButtonDown = false;
66 wxString m_label;
67 wxMenu* m_pMenu = nullptr;
68 wxBitmap m_bitmap;
70};
71
72#endif /*__SPLIT_BUTTON_H__*/
const int m_arrowButtonWidth
Definition: split_button.h:63
void SetLabel(const wxString &aLabel) override
wxString m_label
Definition: split_button.h:66
void onThemeChanged(wxSysColourChangedEvent &aEvent)
bool m_bLButtonDown
Definition: split_button.h:65
void OnLeftButtonUp(wxMouseEvent &aEvent)
wxBitmap m_bitmap
Definition: split_button.h:68
void OnKillFocus(wxFocusEvent &aEvent)
void OnMouseLeave(wxMouseEvent &aEvent)
void SetWidthPadding(int aPadding)
wxMenu * GetSplitButtonMenu()
wxMenu * m_pMenu
Definition: split_button.h:67
void OnLeftButtonDown(wxMouseEvent &aEvent)
void SetMinSize(const wxSize &aSize) override
bool Enable(bool aEnable=true) override
wxSize m_unadjustedMinSize
Definition: split_button.h:69
void OnMouseEnter(wxMouseEvent &aEvent)
void OnPaint(wxPaintEvent &WXUNUSED(aEvent))
bool m_bIsEnable
Definition: split_button.h:62
void SetBitmap(const wxBitmap &aBmp)
SPLIT_BUTTON(wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
int m_widthPadding
Definition: split_button.h:64