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.

layout.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining
  4. * a copy of this software and associated documentation files (the
  5. * "Software"), to deal in the Software without restriction, including
  6. * without limitation the rights to use, copy, modify, merge, publish,
  7. * distribute, sublicense, and/or sell copies of the Software, and to
  8. * permit persons to whom the Software is furnished to do so, subject to
  9. * the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be
  12. * included in all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  18. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  19. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. #ifndef __FLTK_LAYOUT_H__
  24. #define __FLTK_LAYOUT_H__
  25. #include <FL/fl_draw.H>
  26. /* Calculates the width of a string as printed by FLTK (pixels) */
  27. static inline int gui_str_len(const char *str)
  28. {
  29. float len;
  30. fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
  31. len = fl_width(str);
  32. return (int)(len + 0.5f);
  33. }
  34. /**** MARGINS ****/
  35. #define OUTER_MARGIN 10
  36. #define INNER_MARGIN 10
  37. /* Tighter grouping of related fields */
  38. #define TIGHT_MARGIN 5
  39. /**** ADJUSTMENTS ****/
  40. #define INDENT 20
  41. /**** FLTK WIDGETS ****/
  42. /* Fl_Tabs */
  43. #define TABS_HEIGHT 30
  44. /* Fl_Input */
  45. #define INPUT_LABEL_OFFSET FL_NORMAL_SIZE
  46. #define INPUT_HEIGHT 25
  47. /* Fl_Button */
  48. #define BUTTON_WIDTH 115
  49. #define BUTTON_HEIGHT 27
  50. /* Fl_Round_Button */
  51. #define RADIO_MIN_WIDTH (FL_NORMAL_SIZE + 5)
  52. #define RADIO_HEIGHT (FL_NORMAL_SIZE + 7)
  53. /* Fl_Check_Button */
  54. #define CHECK_MIN_WIDTH RADIO_MIN_WIDTH
  55. #define CHECK_HEIGHT RADIO_HEIGHT
  56. /* Fl_Choice */
  57. #define CHOICE_HEIGHT INPUT_HEIGHT
  58. /* Fl_Group */
  59. #define GROUP_LABEL_OFFSET FL_NORMAL_SIZE
  60. #define GROUP_MARGIN 12
  61. /**** HELPERS FOR DYNAMIC TEXT ****/
  62. /* Extra space to add after any text line */
  63. #define TEXT_PADDING 2
  64. /* Use this when the text extends to the right (e.g. checkboxes) */
  65. #define LBLRIGHT(x, y, w, h, str) \
  66. (x), (y), (w) + gui_str_len(str) + TEXT_PADDING, (h), (str)
  67. /* Use this when the space for the label is taken from the left (e.g. input) */
  68. #define LBLLEFT(x, y, w, h, str) \
  69. (x) + (gui_str_len(str) + TEXT_PADDING), (y), \
  70. (w) - (gui_str_len(str) + TEXT_PADDING), (h), (str)
  71. #endif