KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef __SPLIT_BUTTON_H__
22#define __SPLIT_BUTTON_H__
23
24#include <wx/bmpbndl.h>
25#include <wx/panel.h>
26
27class wxButton;
28class wxMenu;
29
30class SPLIT_BUTTON : public wxPanel
31{
32public:
33 SPLIT_BUTTON( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
34 const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize );
35
37
38 wxMenu* GetSplitButtonMenu();
39 void SetBitmap( const wxBitmapBundle& aBmp );
40 void SetMinSize( const wxSize& aSize ) override;
41 void SetWidthPadding( int aPadding );
42 void SetLabel( const wxString& aLabel ) override;
43 bool Enable( bool aEnable = true ) override;
44
45protected:
46 void OnKillFocus( wxFocusEvent& aEvent );
47 void OnMouseLeave( wxMouseEvent& aEvent );
48 void OnMouseEnter( wxMouseEvent& aEvent );
49 void OnLeftButtonUp( wxMouseEvent& aEvent );
50 void OnLeftButtonDown( wxMouseEvent& aEvent );
51 void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
52 void onThemeChanged( wxSysColourChangedEvent &aEvent );
53
54private:
56 int m_stateMenu = 0;
57 bool m_bIsEnable = true;
60 bool m_bLButtonDown = false;
61 wxString m_label;
62 wxMenu* m_pMenu = nullptr;
63 wxBitmapBundle m_bitmap;
65};
66
67#endif /*__SPLIT_BUTTON_H__*/
int m_arrowButtonWidth
void SetLabel(const wxString &aLabel) override
wxString m_label
void onThemeChanged(wxSysColourChangedEvent &aEvent)
bool m_bLButtonDown
void OnLeftButtonUp(wxMouseEvent &aEvent)
void OnKillFocus(wxFocusEvent &aEvent)
void OnMouseLeave(wxMouseEvent &aEvent)
wxBitmapBundle m_bitmap
void SetBitmap(const wxBitmapBundle &aBmp)
void SetWidthPadding(int aPadding)
wxMenu * GetSplitButtonMenu()
wxMenu * m_pMenu
void OnLeftButtonDown(wxMouseEvent &aEvent)
void SetMinSize(const wxSize &aSize) override
bool Enable(bool aEnable=true) override
wxSize m_unadjustedMinSize
void OnMouseEnter(wxMouseEvent &aEvent)
void OnPaint(wxPaintEvent &WXUNUSED(aEvent))
SPLIT_BUTTON(wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)