KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 The 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/bmpbndl.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 wxBitmapBundle& aBmp );
44 void SetMinSize( const wxSize& aSize ) override;
45 void SetWidthPadding( int aPadding );
46 void SetLabel( const wxString& aLabel ) override;
47 bool Enable( bool aEnable = true ) override;
48
49protected:
50 void OnKillFocus( wxFocusEvent& aEvent );
51 void OnMouseLeave( wxMouseEvent& aEvent );
52 void OnMouseEnter( wxMouseEvent& aEvent );
53 void OnLeftButtonUp( wxMouseEvent& aEvent );
54 void OnLeftButtonDown( wxMouseEvent& aEvent );
55 void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
56 void onThemeChanged( wxSysColourChangedEvent &aEvent );
57
58private:
60 int m_stateMenu = 0;
61 bool m_bIsEnable = true;
64 bool m_bLButtonDown = false;
65 wxString m_label;
66 wxMenu* m_pMenu = nullptr;
67 wxBitmapBundle m_bitmap;
69};
70
71#endif /*__SPLIT_BUTTON_H__*/
int m_arrowButtonWidth
Definition: split_button.h:62
void SetLabel(const wxString &aLabel) override
wxString m_label
Definition: split_button.h:65
void onThemeChanged(wxSysColourChangedEvent &aEvent)
bool m_bLButtonDown
Definition: split_button.h:64
void OnLeftButtonUp(wxMouseEvent &aEvent)
void OnKillFocus(wxFocusEvent &aEvent)
void OnMouseLeave(wxMouseEvent &aEvent)
wxBitmapBundle m_bitmap
Definition: split_button.h:67
void SetBitmap(const wxBitmapBundle &aBmp)
void SetWidthPadding(int aPadding)
wxMenu * GetSplitButtonMenu()
wxMenu * m_pMenu
Definition: split_button.h:66
void OnLeftButtonDown(wxMouseEvent &aEvent)
void SetMinSize(const wxSize &aSize) override
bool Enable(bool aEnable=true) override
wxSize m_unadjustedMinSize
Definition: split_button.h:68
void OnMouseEnter(wxMouseEvent &aEvent)
void OnPaint(wxPaintEvent &WXUNUSED(aEvent))
bool m_bIsEnable
Definition: split_button.h:61
int m_widthPadding
Definition: split_button.h:63