You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB

3 years ago
  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. #ifndef STD_BITMAP_BUTTON_H
  25. #define STD_BITMAP_BUTTON_H
  26. #include <kicommon.h>
  27. #include <wx/bmpbndl.h>
  28. #include <wx/panel.h>
  29. class wxButton;
  30. /**
  31. * A bitmap button widget that behaves like a standard dialog button except with an icon.
  32. * Specifically:
  33. * * It has a border
  34. * * It has no hover/focused state
  35. *
  36. * In wxWidgets 3.2 the native button control is used on Mac for wxBitmapButton with or without
  37. * text. Said widget has margins that are more than twice what previous versions had. This class
  38. * allows our bitmap buttons to match the layout of our SPLIT_BUTTON.
  39. */
  40. class KICOMMON_API STD_BITMAP_BUTTON : public wxPanel
  41. {
  42. public:
  43. // For use with wxFormBuilder on a sub-classed wxBitmapButton
  44. STD_BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxBitmap& aDummyBitmap,
  45. const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize,
  46. int aStyle = 0 );
  47. ~STD_BITMAP_BUTTON();
  48. void SetBitmap( const wxBitmapBundle& aBmp );
  49. bool Enable( bool aEnable = true ) override;
  50. protected:
  51. void OnKillFocus( wxFocusEvent& aEvent );
  52. void OnMouseLeave( wxMouseEvent& aEvent );
  53. void OnMouseEnter( wxMouseEvent& aEvent );
  54. void OnLeftButtonUp( wxMouseEvent& aEvent );
  55. void OnLeftButtonDown( wxMouseEvent& aEvent );
  56. void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
  57. void onThemeChanged( wxSysColourChangedEvent &aEvent );
  58. private:
  59. int m_stateButton = 0;
  60. bool m_bIsEnable = true;
  61. wxBitmapBundle m_bitmap;
  62. };
  63. #endif /*STD_BITMAP_BUTTON_H*/