1 // Aseprite UI Library
2 // Copyright (C) 2001-2016  David Capello
3 //
4 // This file is released under the terms of the MIT license.
5 // Read LICENSE.txt for more information.
6 
7 #ifndef UI_BASE_H_INCLUDED
8 #define UI_BASE_H_INCLUDED
9 #pragma once
10 
11 // Get the system's definition of NULL
12 #include <stddef.h>
13 
14 #ifndef TRUE
15   #define TRUE         (-1)
16   #define FALSE        (0)
17 #endif
18 
19 #undef MIN
20 #undef MAX
21 #undef MID
22 
23 #define MIN(x,y)     (((x) < (y)) ? (x) : (y))
24 #define MAX(x,y)     (((x) > (y)) ? (x) : (y))
25 #define MID(x,y,z)   MAX((x), MIN((y), (z)))
26 
27 #undef ABS
28 #define ABS(x)       (((x) >= 0) ? (x) : (-(x)))
29 
30 #undef SGN
31 #define SGN(x)       (((x) >= 0) ? 1 : -1)
32 
33 namespace ui {
34 
35   // Widget flags
36   enum {
37     HIDDEN           = 0x00000001, // Is hidden (not visible, not clickeable).
38     SELECTED         = 0x00000002, // Is selected.
39     DISABLED         = 0x00000004, // Is disabled (not usable).
40     HAS_FOCUS        = 0x00000008, // Has the input focus.
41     HAS_MOUSE        = 0x00000010, // Has the mouse.
42     HAS_CAPTURE      = 0x00000020, // Captured the mouse .
43     FOCUS_STOP       = 0x00000040, // The widget support the focus on it.
44     FOCUS_MAGNET     = 0x00000080, // The widget wants the focus by default (e.g. when the dialog is shown by first time).
45     EXPANSIVE        = 0x00000100, // Is expansive (want more space).
46     DECORATIVE       = 0x00000200, // To decorate windows.
47     INITIALIZED      = 0x00000400, // The widget was already initialized by a theme.
48     DIRTY            = 0x00000800, // The widget (or one child) is dirty (update_region != empty).
49     HAS_TEXT         = 0x00001000, // The widget has text (at least setText() was called one time).
50     DOUBLE_BUFFERED  = 0x00002000, // The widget is painted in a back-buffer and then flipped to the main display
51     TRANSPARENT      = 0x00004000, // The widget has transparent parts that needs the background painted before
52     CTRL_RIGHT_CLICK = 0x00008000, // The widget should transform Ctrl+click to right-click on OS X.
53     PROPERTIES_MASK  = 0x0000ffff,
54 
55     HORIZONTAL       = 0x00010000,
56     VERTICAL         = 0x00020000,
57     LEFT             = 0x00040000,
58     CENTER           = 0x00080000,
59     RIGHT            = 0x00100000,
60     TOP              = 0x00200000,
61     MIDDLE           = 0x00400000,
62     BOTTOM           = 0x00800000,
63     HOMOGENEOUS      = 0x01000000,
64     WORDWRAP         = 0x02000000,
65     ALIGN_MASK       = 0xffff0000,
66   };
67 
68 } // namespace ui
69 
70 #endif  // UI_BASE_H_INCLUDED
71