commandlinkbutton.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/commandlinkbutton.h
  3. // Purpose: interface of wxCommandLinkButton
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxCommandLinkButton
  9. Objects of this class are similar in appearance to the normal wxButtons but
  10. are similar to the links in a web page in functionality.
  11. Pressing such button usually results in switching to another window of the
  12. program and so they can be used as a replacement for the "Next" button in a
  13. multi-page dialog (such as wxWizard), for example.
  14. Their advantage compared to the ordinary wxButtons is that they emphasize
  15. the action of switching the window and also that they allow to give more
  16. detailed explanation to the user because, in addition to the short button
  17. label, they also show a longer description string.
  18. The short, title-like, part of the label is called the <em>main label</em>
  19. and the longer description is the <em>note</em>. Both of them can be set
  20. and queried independently using wxCommandLinkButton-specific methods such
  21. as SetMainLabel() or GetNote() or also via SetLabel() and GetLabel()
  22. methods inherited from wxButton. When using the latter, the main label and
  23. the note are concatenated into a single string using a new line character
  24. between them (notice that the note part can have more new lines in it).
  25. wxCommandLinkButton generates the same event as wxButton but doesn't
  26. support any of wxButton-specific styles nor adds any new styles of its own.
  27. Currently this class uses native implementation under Windows Vista and
  28. later versions and a generic implementation for the other platforms and
  29. earlier Windows versions.
  30. @since 2.9.2
  31. @library{wxadv}
  32. @category{ctrl}
  33. @appearance{commandlinkbutton}
  34. @see wxButton, wxBitmapButton
  35. */
  36. class wxCommandLinkButton : public wxButton
  37. {
  38. public:
  39. /**
  40. Default constructor.
  41. Use Create() to really create the control.
  42. */
  43. wxCommandLinkButton();
  44. /**
  45. Constructor really creating a command Link button.
  46. The button will be decorated with stock icons under GTK+ 2.
  47. @param parent
  48. Parent window. Must not be @NULL.
  49. @param id
  50. Button identifier. A value of wxID_ANY indicates a default value.
  51. @param mainLabel
  52. First line of text on the button, typically the label of an action
  53. that will be made when the button is pressed.
  54. @param note
  55. Second line of text describing the action performed when the button
  56. is pressed.
  57. @param pos
  58. Button position.
  59. @param size
  60. Button size. If the default size is specified then the button is sized
  61. appropriately for the text.
  62. @param style
  63. Window style. See wxButton class description.
  64. @param validator
  65. Window validator.
  66. @param name
  67. Window name.
  68. @see Create(), wxValidator
  69. */
  70. wxCommandLinkButton(wxWindow* parent, wxWindowID id,
  71. const wxString& mainLabel = wxEmptyString,
  72. const wxString& note = wxEmptyString,
  73. const wxPoint& pos = wxDefaultPosition,
  74. const wxSize& size = wxDefaultSize,
  75. long style = 0,
  76. const wxValidator& validator = wxDefaultValidator,
  77. const wxString& name = wxButtonNameStr);
  78. /**
  79. Button creation function for two-step creation.
  80. For more details, see wxCommandLinkButton().
  81. */
  82. bool Create(wxWindow* parent, wxWindowID id,
  83. const wxString& mainLabel = wxEmptyString,
  84. const wxString& note = wxEmptyString,
  85. const wxPoint& pos = wxDefaultPosition,
  86. const wxSize& size = wxDefaultSize,
  87. long style = 0,
  88. const wxValidator& validator = wxDefaultValidator,
  89. const wxString& name = wxButtonNameStr);
  90. /**
  91. Sets a new main label and note for the button.
  92. Neither of the arguments can be empty, if you need to change just the
  93. label or just the note, use SetMainLabel() or SetNote() instead of this
  94. function.
  95. @param mainLabel
  96. New main label to use.
  97. @param note
  98. New note to use.
  99. */
  100. void SetMainLabelAndNote(const wxString& mainLabel, const wxString& note);
  101. /**
  102. Sets the string label and note for the button.
  103. @param label
  104. The label and note to set, with the two separated
  105. by the first newline or none to set a blank note.
  106. */
  107. virtual void SetLabel(const wxString& label);
  108. /**
  109. Returns the string label for the button.
  110. @see SetLabel()
  111. @return
  112. A string with the main label and note concatenated
  113. together with a newline separating them.
  114. */
  115. wxString GetLabel() const;
  116. /**
  117. Changes the main label.
  118. @param mainLabel
  119. New main label to use.
  120. */
  121. void SetMainLabel(const wxString& mainLabel);
  122. /**
  123. Changes the note.
  124. @param note
  125. New note to use.
  126. */
  127. void SetNote(const wxString& note);
  128. /**
  129. Returns the current main label.
  130. @return
  131. Main label currently displayed.
  132. */
  133. wxString GetMainLabel() const;
  134. /**
  135. Returns the currently used note.
  136. @return
  137. Note currently displayed.
  138. */
  139. wxString GetNote() const;
  140. };