blob: 5119188c8410884122ec25ed24d811ab586cfd10 [file] [log] [blame]
Pierre Ossmand463b572011-05-16 12:04:43 +00001/* 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
19#ifndef __FLTK_LAYOUT_H__
20#define __FLTK_LAYOUT_H__
21
22#include <FL/fl_draw.H>
23
24/* Calculates the width of a string as printed by FLTK (pixels) */
25static inline int gui_str_len(const char *str)
26{
27 float len;
28
29 fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
30
31 len = fl_width(str);
32
33 return (int)(len + 0.5f);
34}
35
36/**** MARGINS ****/
37
38#define OUTER_MARGIN 10
39#define INNER_MARGIN 10
40
41/* Tighter grouping of related fields */
42#define TIGHT_MARGIN 5
43
44/**** ADJUSTMENTS ****/
45#define INDENT 20
46
47/**** FLTK WIDGETS ****/
48
49/* Fl_Tabs */
50#define TABS_HEIGHT 30
51
52/* Fl_Input */
53#define INPUT_LABEL_OFFSET FL_NORMAL_SIZE
54#define INPUT_HEIGHT 25
55
56/* Fl_Button */
57#define BUTTON_WIDTH 115
58#define BUTTON_HEIGHT 27
59
60/* Fl_Round_Button */
61#define RADIO_MIN_WIDTH (FL_NORMAL_SIZE + 5)
62#define RADIO_HEIGHT (FL_NORMAL_SIZE + 7)
63
64/* Fl_Check_Button */
65#define CHECK_MIN_WIDTH RADIO_MIN_WIDTH
66#define CHECK_HEIGHT RADIO_HEIGHT
67
68/* Fl_Group */
69#define GROUP_LABEL_OFFSET FL_NORMAL_SIZE
70#define GROUP_MARGIN 12
71
72/**** HELPERS FOR DYNAMIC TEXT ****/
73
74/* Extra space to add after any text line */
75#define TEXT_PADDING 2
76
77/* Use this when the text extends to the right (e.g. checkboxes) */
78#define LBLRIGHT(x, y, w, h, str) \
79 (x), (y), (w) + gui_str_len(str) + TEXT_PADDING, (h), (str)
80
81/* Use this when the space for the label is taken from the left (e.g. input) */
82#define LBLLEFT(x, y, w, h, str) \
83 (x) + (gui_str_len(str) + TEXT_PADDING), (y), \
84 (w) - (gui_str_len(str) + TEXT_PADDING), (h), (str)
85
86#endif