Fl_Time_Input.H 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // Fl_Time.h
  2. // Header file for the time Widget class
  3. //
  4. // Copyright (C) 2000 Softfield Research Ltd.
  5. //
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU General Public License
  8. // as published by the Free Software Foundation; either version 2
  9. // of the License, or (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. #ifndef __TIME_INPUT_WIDGET_H
  20. #define __TIME_INPUT_WIDGET_H
  21. #include "sys/time.h"
  22. #include "unistd.h"
  23. #include <FL/Fl.H>
  24. #include <FL/Fl_Group.H>
  25. #include <FL/Fl_Repeat_Button.H>
  26. #include <FL/Fl_Input.H>
  27. #define FL_TIME_24HOUR 0
  28. #define FL_TIME_12HOUR 1
  29. /** @package libflek_ui
  30. * Fl_Time is a widget that allows a user to select a time
  31. * (hour and minute).
  32. * <p><img src="Fl_Time.png">
  33. */
  34. class Fl_Time_Input : public Fl_Group {
  35. private:
  36. Fl_Repeat_Button* button_decrease_hour;
  37. Fl_Repeat_Button* button_decrease_minute;
  38. Fl_Input* input_time;
  39. Fl_Repeat_Button* button_increase_minute;
  40. Fl_Repeat_Button* button_increase_hour;
  41. struct timeval current_tv;
  42. struct timeval display_tv;
  43. char time_string[20];
  44. bool last_valid;
  45. int look_;
  46. static void input_changed_cb(Fl_Widget* widget, void* data);
  47. static void button_cb(Fl_Widget* widget, void* data);
  48. public:
  49. /**
  50. * The constructor for an empty Fl_Time widget.
  51. */
  52. Fl_Time_Input(int x, int y, int w, int h, char *l=0);
  53. /**
  54. * Gets the hour.
  55. *
  56. * @return The hour associated with this widget.
  57. */
  58. int hour();
  59. /**
  60. * Sets the hour.
  61. *
  62. * @param hour The hour associated with this widget.
  63. */
  64. void hour(int value);
  65. /**
  66. * Gets the minute.
  67. *
  68. * @return The minute associated with this widget.
  69. */
  70. int minute();
  71. /**
  72. * Sets the minute.
  73. *
  74. * @param minute The minute associated with this widget.
  75. */
  76. void minute(int value);
  77. // Be sure to run this after using hour and min to change the clock value.
  78. void redisplay();
  79. /**
  80. * Sets the minute and hour at the same time.
  81. *
  82. * @param minute The minute associated with this widget.
  83. * @param hour The hour associated with this widget.
  84. */
  85. void value(int h, int m);
  86. /**
  87. * Sets the minute and hour to the system minute and hour.
  88. */
  89. void current_time();
  90. /**
  91. * Refreshes the widget.
  92. */
  93. void refresh();
  94. /**
  95. * Sets the size of the label text which is used for the M+,
  96. * M-, Y+, and Y- labels.
  97. *
  98. * @param size The size of the label font.
  99. */
  100. void labelsize(int size);
  101. /**
  102. * Sets the label font which is used for the M+,
  103. * M-, Y+, and Y- labels.
  104. *
  105. * @param font The label font.
  106. */
  107. void labelfont(Fl_Font font);
  108. /**
  109. * Sets the label color which is used for the M+,
  110. * M-, Y+, and Y- labels.
  111. *
  112. * @param font The label color.
  113. */
  114. void labelcolor(Fl_Color color);
  115. /**
  116. * Sets the size of the text which is used to display
  117. * the set time.
  118. *
  119. * @param size The size of the text font.
  120. */
  121. void textsize(int size);
  122. /**
  123. * Sets the font of the text which is used to display
  124. * the set time.
  125. *
  126. * @param font The font of the text font.
  127. */
  128. void textfont(Fl_Font);
  129. /**
  130. * Sets the color of the text which is used to display
  131. * the set time.
  132. *
  133. * @param color The color of the text font.
  134. */
  135. void textcolor(Fl_Color);
  136. /**
  137. * Gets the size of the label text which is used for the M+,
  138. * M-, Y+, and Y- labels.
  139. *
  140. * @return The size of the label font.
  141. */
  142. int labelsize();
  143. /**
  144. * Gets the label font which is used for the M+,
  145. * M-, Y+, and Y- labels.
  146. *
  147. * @return The label font.
  148. */
  149. Fl_Font labelfont();
  150. /**
  151. * Gets the label color which is used for the M+,
  152. * M-, Y+, and Y- labels.
  153. *
  154. * @return The label color.
  155. */
  156. Fl_Color labelcolor();
  157. /**
  158. * Gets the size of the text which is used to display
  159. * the set time.
  160. *
  161. * @return The size of the text font.
  162. */
  163. int textsize();
  164. /**
  165. * Gets the font of the text which is used to display
  166. * the set time.
  167. *
  168. * @return The font of the text font.
  169. */
  170. Fl_Font textfont();
  171. /**
  172. * Gets the color of the text which is used to display
  173. * the set time.
  174. *
  175. * @return The color of the text font.
  176. */
  177. Fl_Color textcolor();
  178. /**
  179. * Determines if the entered time is a recognized format.
  180. *
  181. * @return True if it is a valid time format, otherwise false.
  182. */
  183. bool valid();
  184. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Time_Input, Fl_Group)
  185. };
  186. #endif