Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. #ifndef __FLTK_LAYOUT_H__
  19. #define __FLTK_LAYOUT_H__
  20. #include <FL/fl_draw.H>
  21. /* Calculates the width of a string as printed by FLTK (pixels) */
  22. static inline int gui_str_len(const char *str)
  23. {
  24. float len;
  25. fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
  26. len = fl_width(str);
  27. return (int)(len + 0.5f);
  28. }
  29. /* Escapes all @ in text as those have special meaning in labels */
  30. static inline int fltk_escape(const char *in, char *out, size_t maxlen)
  31. {
  32. int len;
  33. len = 0;
  34. while (*in != '\0') {
  35. if (*in == '@') {
  36. if (maxlen >= 3) {
  37. *out++ = '@';
  38. *out++ = '@';
  39. maxlen -= 2;
  40. }
  41. len += 2;
  42. } else {
  43. if (maxlen >= 2) {
  44. *out++ = *in;
  45. maxlen--;
  46. }
  47. len += 1;
  48. }
  49. in++;
  50. }
  51. if (maxlen)
  52. *out = '\0';
  53. return len;
  54. }
  55. /**** MARGINS ****/
  56. #define OUTER_MARGIN 10
  57. #define INNER_MARGIN 10
  58. /* Tighter grouping of related fields */
  59. #define TIGHT_MARGIN 5
  60. /**** ADJUSTMENTS ****/
  61. #define INDENT 20
  62. /**** FLTK WIDGETS ****/
  63. /* Fl_Tabs */
  64. #define TABS_HEIGHT 30
  65. /* Fl_Input */
  66. #define INPUT_LABEL_OFFSET FL_NORMAL_SIZE
  67. #define INPUT_HEIGHT 25
  68. /* Fl_Button */
  69. #define BUTTON_WIDTH 115
  70. #define BUTTON_HEIGHT 27
  71. /* Fl_Round_Button */
  72. #define RADIO_MIN_WIDTH (FL_NORMAL_SIZE + 5)
  73. #define RADIO_HEIGHT (FL_NORMAL_SIZE + 7)
  74. /* Fl_Check_Button */
  75. #define CHECK_MIN_WIDTH RADIO_MIN_WIDTH
  76. #define CHECK_HEIGHT RADIO_HEIGHT
  77. /* Fl_Choice */
  78. #define CHOICE_HEIGHT INPUT_HEIGHT
  79. /* Fl_Group */
  80. #define GROUP_LABEL_OFFSET FL_NORMAL_SIZE
  81. #define GROUP_MARGIN 12
  82. /**** HELPERS FOR DYNAMIC TEXT ****/
  83. /* Extra space to add after any text line */
  84. #define TEXT_PADDING 2
  85. /* Use this when the text extends to the right (e.g. checkboxes) */
  86. #define LBLRIGHT(x, y, w, h, str) \
  87. (x), (y), (w) + gui_str_len(str) + TEXT_PADDING, (h), (str)
  88. /* Use this when the space for the label is taken from the left (e.g. input) */
  89. #define LBLLEFT(x, y, w, h, str) \
  90. (x) + (gui_str_len(str) + TEXT_PADDING), (y), \
  91. (w) - (gui_str_len(str) + TEXT_PADDING), (h), (str)
  92. #endif