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.

107 lines
2.8 KiB

11 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014-2015 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #ifndef __STATUS_POPUP_H_
  26. #define __STATUS_POPUP_H_
  27. #include <math/vector2d.h>
  28. #include <wx/popupwin.h>
  29. #include <wx/timer.h>
  30. #include <wx/panel.h>
  31. #include <wx/stattext.h>
  32. #include <wx/sizer.h>
  33. #include <wx/statbmp.h>
  34. class EDA_DRAW_FRAME;
  35. /**
  36. * A tiny, headerless popup window used to display useful status (e.g. line length
  37. * tuning info) next to the mouse cursor.
  38. */
  39. class STATUS_POPUP: public wxPopupWindow
  40. {
  41. public:
  42. STATUS_POPUP( wxWindow* aParent );
  43. virtual ~STATUS_POPUP() { Hide(); }
  44. virtual void Popup( wxWindow* aFocus = nullptr );
  45. virtual void PopupFor( int aMsecs );
  46. virtual void Move( const wxPoint& aWhere );
  47. virtual void Move( const VECTOR2I& aWhere );
  48. /**
  49. * Hide the popup after a specified time.
  50. *
  51. * @param aMsecs is the time expressed in milliseconds
  52. */
  53. void Expire( int aMsecs );
  54. wxWindow* GetPanel() { return m_panel; }
  55. protected:
  56. void updateSize();
  57. void onCharHook( wxKeyEvent& aEvent );
  58. /// Expire timer even handler.
  59. void onExpire( wxTimerEvent& aEvent );
  60. protected:
  61. wxPanel* m_panel;
  62. wxBoxSizer* m_topSizer;
  63. wxTimer m_expireTimer;
  64. };
  65. /**
  66. * Extension of #STATUS_POPUP for displaying a single line text.
  67. */
  68. class STATUS_TEXT_POPUP : public STATUS_POPUP
  69. {
  70. public:
  71. STATUS_TEXT_POPUP( wxWindow* aParent );
  72. virtual ~STATUS_TEXT_POPUP() {}
  73. /**
  74. * Display a text.
  75. *
  76. * @param aText text to be displayed.
  77. */
  78. void SetText( const wxString& aText );
  79. /**
  80. * Change text color.
  81. *
  82. * @param aColor new text color.
  83. */
  84. void SetTextColor( const wxColour& aColor );
  85. protected:
  86. wxStaticText* m_statusLine;
  87. };
  88. #endif /* __STATUS_POPUP_H_*/