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 
31 class wxButton;
32 class wxMenu;
33 
34 class SPLIT_BUTTON : public wxPanel
35 {
36 public:
37  SPLIT_BUTTON( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
38  const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize );
39 
40  ~SPLIT_BUTTON();
41 
42  wxMenu* GetSplitButtonMenu();
43  void SetBitmap( const wxBitmap& aBmp );
44  void SetMinSize( const wxSize& aSize ) override;
45  void SetWidthPadding( int aPadding );
46 
47 protected:
48  void OnKillFocus( wxFocusEvent& aEvent );
49  void OnMouseLeave( wxMouseEvent& aEvent );
50  void OnMouseEnter( wxMouseEvent& aEvent );
51  void OnLeftButtonUp( wxMouseEvent& aEvent );
52  void OnLeftButtonDown( wxMouseEvent& aEvent );
53  void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
54 
55  bool Enable( bool aEnable = true ) override;
56 
57 private:
58  int m_stateButton = 0;
59  int m_stateMenu = 0;
60  bool m_bIsEnable = true;
61  wxColor m_colorNormal;
62  wxColor m_colorDisabled;
63  const int m_arrowButtonWidth = 20;
64  int m_widthPadding = 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__*/
int m_widthPadding
Definition: split_button.h:64
bool m_bIsEnable
Definition: split_button.h:60
void OnPaint(wxPaintEvent &WXUNUSED(aEvent))
bool m_bLButtonDown
Definition: split_button.h:65
void SetBitmap(const wxBitmap &aBmp)
wxMenu * GetSplitButtonMenu()
wxSize m_unadjustedMinSize
Definition: split_button.h:69
wxBitmap m_bitmap
Definition: split_button.h:68
void SetMinSize(const wxSize &aSize) override
void OnKillFocus(wxFocusEvent &aEvent)
void OnLeftButtonUp(wxMouseEvent &aEvent)
void OnMouseLeave(wxMouseEvent &aEvent)
void OnLeftButtonDown(wxMouseEvent &aEvent)
wxColor m_colorNormal
Definition: split_button.h:61
wxMenu * m_pMenu
Definition: split_button.h:67
void SetWidthPadding(int aPadding)
const int m_arrowButtonWidth
Definition: split_button.h:63
SPLIT_BUTTON(wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
bool Enable(bool aEnable=true) override
wxString m_label
Definition: split_button.h:66
void OnMouseEnter(wxMouseEvent &aEvent)
wxColor m_colorDisabled
Definition: split_button.h:62