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.

186 lines
5.6 KiB

15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
  1. /**
  2. * @file dialog_helpers.h
  3. * @brief Helper dialog and control classes.
  4. * @note Due to use of wxFormBuilder to create dialogs many of them should be removed.
  5. */
  6. #ifndef _DIALOG_HELPERS_H_
  7. #define _DIALOG_HELPERS_H_
  8. #include <common.h> // EDA_UNITS_T
  9. class EDA_DRAW_FRAME;
  10. /**
  11. * class EDA_LIST_DIALOG
  12. *
  13. * Used to display a list of elements for selection, and an help of info line
  14. * about the selected item.
  15. */
  16. class EDA_LIST_DIALOG : public wxDialog
  17. {
  18. private:
  19. wxListBox* m_listBox;
  20. wxTextCtrl* m_messages;
  21. void (*m_callBackFct)( wxString& Text );
  22. public:
  23. /**
  24. * Constructor:
  25. * @param aParent Pointer to the parent window.
  26. * @param aTitle The title shown on top.
  27. * @param aItemList A wxArrayString of the list of elements.
  28. * @param aRefText An item name if an item must be preselected.
  29. * @param aCallBackFunction callback function to display comments
  30. * @param aPos The position of the dialog.
  31. */
  32. EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
  33. const wxArrayString& aItemList, const wxString& aRefText,
  34. void(* aCallBackFunction)(wxString& Text) = NULL,
  35. wxPoint aPos = wxDefaultPosition );
  36. ~EDA_LIST_DIALOG();
  37. void SortList();
  38. void Append( const wxString& aItemStr );
  39. void InsertItems( const wxArrayString& aItemList, int aPosition = 0 );
  40. void MoveMouseToOrigin();
  41. wxString GetTextSelection();
  42. private:
  43. void OnClose( wxCloseEvent& event );
  44. void OnCancelClick( wxCommandEvent& event );
  45. void OnOkClick( wxCommandEvent& event );
  46. void ClickOnList( wxCommandEvent& event );
  47. void D_ClickOnList( wxCommandEvent& event );
  48. void OnKeyEvent( wxKeyEvent& event );
  49. DECLARE_EVENT_TABLE()
  50. };
  51. /**
  52. * Class EDA_GRAPHIC_TEXT_CTRL
  53. * is a custom text edit control to edit/enter Kicad dimensions ( INCHES or MM )
  54. */
  55. class EDA_GRAPHIC_TEXT_CTRL
  56. {
  57. public:
  58. EDA_UNITS_T m_UserUnit;
  59. int m_Internal_Unit;
  60. wxTextCtrl* m_FrameText;
  61. wxTextCtrl* m_FrameSize;
  62. private:
  63. wxStaticText* m_Title;
  64. public:
  65. EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title,
  66. const wxString& TextToEdit, int textsize,
  67. EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200,
  68. int internal_unit = EESCHEMA_INTERNAL_UNIT );
  69. ~EDA_GRAPHIC_TEXT_CTRL();
  70. const wxString GetText() const;
  71. int GetTextSize();
  72. void Enable( bool state );
  73. void SetTitle( const wxString& title );
  74. void SetFocus() { m_FrameText->SetFocus(); }
  75. void SetValue( const wxString& value );
  76. void SetValue( int value );
  77. /**
  78. * Function FormatSize
  79. * formats a string containing the size in the desired units.
  80. */
  81. static wxString FormatSize( int internalUnit, EDA_UNITS_T user_unit, int textSize );
  82. static int ParseSize( const wxString& sizeText, int internalUnit,
  83. EDA_UNITS_T user_unit );
  84. };
  85. /**************************************************************************/
  86. /* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */
  87. /* dialog boxes, */
  88. /**************************************************************************/
  89. class EDA_POSITION_CTRL
  90. {
  91. public:
  92. EDA_UNITS_T m_UserUnit;
  93. int m_Internal_Unit;
  94. wxPoint m_Pos_To_Edit;
  95. wxTextCtrl* m_FramePosX;
  96. wxTextCtrl* m_FramePosY;
  97. private:
  98. wxStaticText* m_TextX, * m_TextY;
  99. public:
  100. EDA_POSITION_CTRL( wxWindow* parent, const wxString& title,
  101. const wxPoint& pos_to_edit,
  102. EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
  103. int internal_unit = EESCHEMA_INTERNAL_UNIT );
  104. ~EDA_POSITION_CTRL();
  105. void Enable( bool x_win_on, bool y_win_on );
  106. void SetValue( int x_value, int y_value );
  107. wxPoint GetValue();
  108. };
  109. /*************************************************************
  110. * Class to edit/enter a size (pair of values for X and Y size)
  111. * ( INCHES or MM ) in dialog boxes
  112. ***************************************************************/
  113. class EDA_SIZE_CTRL : public EDA_POSITION_CTRL
  114. {
  115. public:
  116. EDA_SIZE_CTRL( wxWindow* parent, const wxString& title,
  117. const wxSize& size_to_edit,
  118. EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
  119. int internal_unit = EESCHEMA_INTERNAL_UNIT );
  120. ~EDA_SIZE_CTRL() { }
  121. wxSize GetValue();
  122. };
  123. /****************************************************************/
  124. /* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */
  125. /****************************************************************/
  126. class EDA_VALUE_CTRL
  127. {
  128. public:
  129. EDA_UNITS_T m_UserUnit;
  130. int m_Value;
  131. wxTextCtrl* m_ValueCtrl;
  132. private:
  133. int m_Internal_Unit;
  134. wxStaticText* m_Text;
  135. public:
  136. EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value,
  137. EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
  138. int internal_unit = EESCHEMA_INTERNAL_UNIT );
  139. ~EDA_VALUE_CTRL();
  140. int GetValue();
  141. void SetValue( int new_value );
  142. void Enable( bool enbl );
  143. void SetToolTip( const wxString& text )
  144. {
  145. m_ValueCtrl->SetToolTip( text );
  146. }
  147. };
  148. #endif // _DIALOG_HELPERS_H_