Reference Guide
Reference Guide
Reference Guide
www.embeddedlightning.com
(visit for latest updates)
➞Achim Döbler
Contents
1 Introduction 2
1.1 What is ➭GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 ➭GUI Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 ➭GUI Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Windows 2
2.1 Window Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Update Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Callback Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 Driver Support 6
4.1 Hardware Acceleration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.1.1 DRIVER DRAW LINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.1.2 DRIVER FILL FRAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Colors 7
5.1 Color Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.2 Predefined Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
6 Fonts 10
6.1 FONT 4X6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6.2 FONT 5X8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6.3 FONT 5X12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.4 FONT 6X8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.5 FONT 6X10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.6 FONT 7X12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.7 FONT 8X8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.8 FONT 8X12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.9 FONT 8X14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.10 FONT 10X16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.11 FONT 12X16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.12 FONT 12X20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.13 FONT 16X26 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6.14 FONT 22X36 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.15 FONT 24X40 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.16 FONT 32X53 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7 Functions 19
7.1 Classic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.1.1 UG Init() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.1.2 UG SelectGUI() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.1.3 UG FontSelect() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.1.4 UG FillScreen() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.1.5 UG FillFrame() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1
7.1.6 UG FillRoundFrame() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.1.7 UG DrawMesh() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.1.8 UG DrawFrame() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7.1.9 UG DrawRoundFrame() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.1.10 UG DrawPixel() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.1.11 UG DrawCircle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7.1.12 UG FillCircle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.1.13 UG DrawArc() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.1.14 UG DrawLine() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.1.15 UG PutString() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7.1.16 UG PutChar() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.1.17 UG ConsolePutString() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.1.18 UG ConsoleSetArea() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
7.1.19 UG ConsoleSetForecolor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.1.20 UG ConsoleSetBackcolor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.1.21 UG SetForecolor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.1.22 UG SetBackcolor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.1.23 UG GetXDim() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.1.24 UG GetYDim() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.1.25 UG FontSetHSpace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7.1.26 UG FontSetVSpace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7.2 Driver Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.2.1 UG DriverRegister() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.2.2 UG DriverEnable() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.2.3 UG DriverDisable() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.3 Window Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.3.1 UG WindowCreate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.3.2 UG WindowDelete() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.3.3 UG WindowShow() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.3.4 UG WindowHide() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.3.5 UG WindowResize() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.3.6 UG WindowAlert() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.3.7 UG WindowSetForeColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.3.8 UG WindowSetBackColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7.3.9 UG WindowSetTitleTextColor() . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.3.10 UG WindowSetTitleColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.3.11 UG WindowSetTitleInactiveTextColor() . . . . . . . . . . . . . . . . . . . . 54
7.3.12 UG WindowSetTitleInactiveColor() . . . . . . . . . . . . . . . . . . . . . . . 55
7.3.13 UG WindowSetTitleText() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.3.14 UG WindowSetTitleTextFont() . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.3.15 UG WindowSetTitleTextHSpace() . . . . . . . . . . . . . . . . . . . . . . . . 58
7.3.16 UG WindowSetTitleTextVSpace() . . . . . . . . . . . . . . . . . . . . . . . . 59
7.3.17 UG WindowSetTitleTextAlignment() . . . . . . . . . . . . . . . . . . . . . . 59
7.3.18 UG WindowSetTitleHeight() . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.3.19 UG WindowSetXStart() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.3.20 UG WindowSetYStart() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.3.21 UG WindowSetXEnd() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2
7.3.22 UG WindowSetYEnd() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.3.23 UG WindowSetStyle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.3.24 UG WindowGetForeColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.3.25 UG WindowGetBackColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.3.26 UG WindowGetTitleTextColor() . . . . . . . . . . . . . . . . . . . . . . . . 65
7.3.27 UG WindowGetTitleColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
7.3.28 UG WindowGetTitleInactiveTextColor() . . . . . . . . . . . . . . . . . . . . 66
7.3.29 UG WindowGetTitleInactiveColor() . . . . . . . . . . . . . . . . . . . . . . 67
7.3.30 UG WindowGetTitleText() . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.3.31 UG WindowGetTitleTextFont() . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.3.32 UG WindowGetTitleTextHSpace() . . . . . . . . . . . . . . . . . . . . . . . 68
7.3.33 UG WindowGetTitleTextVSpace() . . . . . . . . . . . . . . . . . . . . . . . 69
7.3.34 UG WindowGetTitleTextAlignment() . . . . . . . . . . . . . . . . . . . . . . 69
7.3.35 UG WindowGetTitleHeight() . . . . . . . . . . . . . . . . . . . . . . . . . . 70
7.3.36 UG WindowGetXStart() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
7.3.37 UG WindowGetYStart() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
7.3.38 UG WindowGetXEnd() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.3.39 UG WindowGetYEnd() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.3.40 UG WindowGetStyle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.3.41 UG WindowGetArea() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.3.42 UG WindowGetInnerWidth() . . . . . . . . . . . . . . . . . . . . . . . . . . 74
7.3.43 UG WindowGetOuterWidth() . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.3.44 UG WindowGetInnerHeight() . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.3.45 UG WindowGetOuterHeight() . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.4 Button Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
7.4.1 UG ButtonCreate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
7.4.2 UG ButtonDelete() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
7.4.3 UG ButtonShow() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.4.4 UG ButtonHide() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.4.5 UG ButtonSetForeColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.4.6 UG ButtonSetBackColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.4.7 UG ButtonSetAlternateForeColor() . . . . . . . . . . . . . . . . . . . . . . . 83
7.4.8 UG ButtonSetAlternateBackColor() . . . . . . . . . . . . . . . . . . . . . . . 84
7.4.9 UG ButtonSetText() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.4.10 UG ButtonSetFont() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.4.11 UG ButtonSetStyle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.4.12 UG ButtonGetForeColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.4.13 UG ButtonGetBackColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.4.14 UG ButtonGetAlternateForeColor() . . . . . . . . . . . . . . . . . . . . . . . 87
7.4.15 UG ButtonGetAlternateBackColor() . . . . . . . . . . . . . . . . . . . . . . 88
7.4.16 UG ButtonGetText() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.4.17 UG ButtonGetFont() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.4.18 UG ButtonGetStyle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.5 Textbox Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.5.1 UG TextboxCreate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.5.2 UG TextboxDelete() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.5.3 UG TextboxShow() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3
7.5.4 UG TextboxHide() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.5.5 UG TextboxSetForeColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.5.6 UG TextboxSetBackColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.5.7 UG TextboxSetText() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.5.8 UG TextboxSetFont() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.5.9 UG TextboxSetHSpace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.5.10 UG TextboxSetVSpace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.5.11 UG TextboxSetAlignment() . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.5.12 UG TextboxGetForeColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.5.13 UG TextboxGetBackColor() . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.5.14 UG TextboxGetText() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.5.15 UG TextboxGetFont() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.5.16 UG TextboxGetHSpace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.5.17 UG TextboxGetVSpace() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.5.18 UG TextboxGetAlignment() . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.6 Image Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.6.1 UG ImageCreate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.6.2 UG ImageDelete() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
7.6.3 UG ImageShow() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.6.4 UG ImageHide() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.6.5 UG ImageSetBMP() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
4
1 Introduction
2 Windows
In addition to its 2D geometric functions, ➭GUI also supports windows. Each window can contain
several objects like buttons, textboxes or images. The following section describes how to use
windows.
5
Figure 1: ➭GUI window example
Each window needs its own dedicated object buffer. In this buffer all window objects will be stored.
Therefore, the size of this buffer defines the maximum object count of its associated window.
6
The link between a window and its object buffer will be established by calling the UG WindowCre-
ate() function. This function also connects a callback function to the window which will be called
on incoming events like touches on a button. Once a window has been created, ➭GUI takes care
of all window-related processes:
❼ drawing the window itself (including all objects)
❼ handling all object-related events
❼ processing incoming touch data
❼ calling the callback function which has been linked to the window
Since different objects support different features, not all object-specific data can be stored in the
object buffer. Therefore, each object needs additionally its own container (e.g. UG BUTTON
button 1) to store special object-specific data. The linking process between a window and such
a container takes place by calling the corresponding object create function (e.g. UG ButtonCre-
ate).
Example:
v o i d w i n d o w 1 c a l l b a c k ( UG MESSAGE✯ msg )
{
// . . .
}
#d e f i n e MAX OBJECTS 10
i n t main ( v o i d )
{
UG WINDOW window 1 ; /✯ Window ✯/
UG BUTTON b u t t o n 1 ; /✯ Button container ✯/
UG BUTTON b u t t o n 2 ; /✯ Button container ✯/
UG BUTTON b u t t o n 3 ; /✯ Button container ✯/
UG OBJECT o b j b u f f w n d 1 [MAX OBJECTS ] ; /✯ Object buffer ✯/
// . . .
/ ✯ C r e a t e t h e window ( l i n k t h e o b j e c t b u f f e r and t h e c a l l b a c k f u n c t i o n t o t h e
window ) ✯ /
UG WindowCreate ( &window 1 , o b j b u f f w n d 1 , MAX OBJECTS, w i n d o w 1 c a l l b a c k ) ;
/ ✯ F i n a l l y , show t h e window ✯ /
UG WindowShow ( &window 1 ) ;
// . . .
}
7
2.2 Update Function
➭GUI controls the refreshing process of each window including all daughter objects. This is all
done by the function UG Update(). Therefore, this function has to be called periodically either in
an ISR or in background.
Note: If the user forgets to call this function, nothing will happen.
While beeing created, every window will be linked to a dedicated callback function. Once the
window has detected an event (e.g. touch on a button), it will prepare a message which describes
the event and pass it on to the callback function. The callback function receives this message and
can then decide how to react to the event.
Example:
v o i d w i n d o w 1 c a l l b a c k ( UG MESSAGE✯ msg )
{
i f ( msg✁>type == MSG TYPE OBJECT )
{
i f ( msg✁>i d == OBJ TYPE BUTTON )
{
s w i t c h ( msg✁>s u b i d )
{
c a s e BTN ID 0 :
{
/ ✯ Do something ! ✯ /
break ;
}
}
}
}
}
TouchData = ReadTouchData ( ) ;
i f ( TouchData✁>TouchDetected )
{
8
UG TouchUpdate ( TouchData✁>X, TouchData✁>Y, TOUCH STATE PRESSED ) ;
}
else
{
UG TouchUpdate ( ✁ 1 , ✁ 1, TOUCH STATE RELEASED ) ;
}
Note: Mouses or joysticks are currently not supported since those input devices require a cursor
which is not available at the moment.
4 Driver Support
➭GUI can be enhanced by linking external driver modules to the core system. The following section
describes how to use them and which drivers are supported.
Although ➭GUI only needs a user pset function in order to work properly, filling large areas on the
target display could be very slow (especially on small microcontroller systems). Therefore, ➭GUI
supports platform-specific hardware acceleration. By using this feature the user gives ➭GUI control
of special hardware functions which are supported by the target platform. After an accelerator has
been registered, the respective function will be done in hardware. Compared to a non-hardware
accelerated function, a hardware accelerated one can be easily 100 times faster. Each user-provided
hardware accelerator has to have a prototype which is identical to its non-accelerated counterpart
except for its return type. If the hardware accelerator was able to handle the requested operation,
it returns UG RESULT OK, otherwise UG RESULT FAIL. If ➭GUI detects that a hardware ac-
celerator has returned UG RESULT FAIL, it will perform the operation again, but this time in
software. All drivers can be registered and controlled by using the UG DRIVER x - functions.
Please refer to the corresponding function section (7.2) for further information.
9
5 Colors
10
C GREEN YELLOW 0xADFF2F
C DARK GREEN 0x006400
C GREEN 0x008000
C FOREST GREEN 0x228B22
C LIME 0x00FF00
C LIME GREEN 0x32CD32
C LIGHT GREEN 0x90EE90
C PALE GREEN 0x98FB98
C DARK SEA GREEN 0x8FBC8F
C MEDIUM SPRING GREEN 0x00FA9A
C SPRING GREEN 0x00FF7F
C SEA GREEN 0x2E8B57
C MEDIUM AQUA MARINE 0x66CDAA
C MEDIUM SEA GREEN 0x3CB371
C LIGHT SEA GREEN 0x20B2AA
C DARK SLATE GRAY 0x2F4F4F
C TEAL 0x008080
C DARK CYAN 0x008B8B
C AQUA 0x00FFFF
C CYAN 0x00FFFF
C LIGHT CYAN 0xE0FFFF
C DARK TURQUOISE 0x00CED1
C TURQUOISE 0x40E0D0
C MEDIUM TURQUOISE 0x48D1CC
C PALE TURQUOISE 0xAFEEEE
C AQUA MARINE 0x7FFFD4
C POWDER BLUE 0xB0E0E6
C CADET BLUE 0x5F9EA0
C STEEL BLUE 0x4682B4
C CORN FLOWER BLUE 0x6495ED
C DEEP SKY BLUE 0x00BFFF
C DODGER BLUE 0x1E90FF
C LIGHT BLUE 0xADD8E6
C SKY BLUE 0x87CEEB
C LIGHT SKY BLUE 0x87CEFA
C MIDNIGHT BLUE 0x191970
C NAVY 0x000080
C DARK BLUE 0x00008B
C MEDIUM BLUE 0x0000CD
C BLUE 0x0000FF
C ROYAL BLUE 0x4169E1
C BLUE VIOLET 0x8A2BE2
C INDIGO 0x4B0082
C DARK SLATE BLUE 0x483D8B
C SLATE BLUE 0x6A5ACD
C MEDIUM SLATE BLUE 0x7B68EE
C MEDIUM PURPLE 0x9370DB
11
C DARK MAGENTA 0x8B008B
C DARK VIOLET 0x9400D3
C DARK ORCHID 0x9932CC
C MEDIUM ORCHID 0xBA55D3
C PURPLE 0x800080
C THISTLE 0xD8BFD8
C PLUM 0xDDA0DD
C VIOLET 0xEE82EE
C MAGENTA 0xFF00FF
C ORCHID 0xDA70D6
C MEDIUM VIOLET RED 0xC71585
C PALE VIOLET RED 0xDB7093
C DEEP PINK 0xFF1493
C HOT PINK 0xFF69B4
C LIGHT PINK 0xFFB6C1
C PINK 0xFFC0CB
C ANTIQUE WHITE 0xFAEBD7
C BEIGE 0xF5F5DC
C BISQUE 0xFFE4C4
C BLANCHED ALMOND 0xFFEBCD
C WHEAT 0xF5DEB3
C CORN SILK 0xFFF8DC
C LEMON CHIFFON 0xFFFACD
C LIGHT GOLDEN ROD YELLOW 0xFAFAD2
C LIGHT YELLOW 0xFFFFE0
C SADDLE BROWN 0x8B4513
C SIENNA 0xA0522D
C CHOCOLATE 0xD2691E
C PERU 0xCD853F
C SANDY BROWN 0xF4A460
C BURLY WOOD 0xDEB887
C TAN 0xD2B48C
C ROSY BROWN 0xBC8F8F
C MOCCASIN 0xFFE4B5
C NAVAJO WHITE 0xFFDEAD
C PEACH PUFF 0xFFDAB9
C MISTY ROSE 0xFFE4E1
C LAVENDER BLUSH 0xFFF0F5
C LINEN 0xFAF0E6
C OLD LACE 0xFDF5E6
C PAPAYA WHIP 0xFFEFD5
C SEA SHELL 0xFFF5EE
C MINT CREAM 0xF5FFFA
C SLATE GRAY 0x708090
C LIGHT SLATE GRAY 0x778899
C LIGHT STEEL BLUE 0xB0C4DE
C LAVENDER 0xE6E6FA
12
C FLORAL WHITE 0xFFFAF0
C ALICE BLUE 0xF0F8FF
C GHOST WHITE 0xF8F8FF
C HONEYDEW 0xF0FFF0
C IVORY 0xFFFFF0
C AZURE 0xF0FFFF
C SNOW 0xFFFAFA
C BLACK 0x000000
C DIM GRAY 0x696969
C GRAY 0x808080
C DARK GRAY 0xA9A9A9
C SILVER 0xC0C0C0
C LIGHT GRAY 0xD3D3D3
C GAINSBORO 0xDCDCDC
C WHITE SMOKE 0xF5F5F5
C WHITE 0xFFFFFF
6 Fonts
➭GUI comes with the following fonts2 .
Note: A font has to be enabled in the config section of ugui.h before it can be used!
13
6.3 FONT 5X12
14
6.6 FONT 7X12
15
6.9 FONT 8X14
16
6.11 FONT 12X16
17
6.13 FONT 16X26
18
6.14 FONT 22X36
19
6.15 FONT 24X40
20
6.16 FONT 32X53
21
7 Functions
7.1.1 UG Init()
This function initializes the GUI module. Furthermore it links the user pset function to the ➭GUI
core.
Prototype:
Parameters:
UG GUI g u i ; // G l o b a l GUI s t r u c t u r e
i n t main ( v o i d )
{
UG Init (& gui , U s e r P i x e l S e t F u n c t i o n , 3 2 0 , 2 4 0 ) ;
// . . .
// . . .
}
7.1.2 UG SelectGUI()
With this function you can switch between different GUIs / displays.
Prototype:
22
Parameters:
i n t main ( v o i d )
{
UG Init (& g u i o l e d , OLEDPixelSetFunction , 1 2 8 , 6 4 ) ;
UG Init (& g u i t f t , TFTPixelSetFunction , 4 8 0 , 2 7 2 ) ;
UG SelectGUI ( &g u i o l e d ) ;
// . . .
UG SelectGUI ( &g u i t f t ) ;
// . . .
}
7.1.3 UG FontSelect()
FONT 4X6
FONT 5X8
FONT 5X12
FONT 6X8
FONT 6X10
FONT 7X12
FONT 8X8
FONT 8X12
FONT 8X14
FONT 10X16
FONT 12X16
FONT 12X20
FONT 16X26
FONT 22X36
FONT 24X40
FONT 32X53
Note:
A font has to be enabled in the config section of ugui.h before it can be used!
Prototype:
23
v o i d UG FontSelect ( c o n s t UG FONT✯ f o n t )
Parameters:
i n t main ( v o i d )
{
// . . .
UG FontSelect ( &FONT 8X8 ) ;
// . . .
}
7.1.4 UG FillScreen()
Prototype:
v o i d U G F i l l S c r e e n ( UG COLOR c ) ;
Parameters:
UG COLOR c Color
Example:
i n t main ( v o i d )
{
// . . .
U G F i l l S c r e e n ( C RED ) ;
// . . .
}
24
(a) Before (b) After
7.1.5 UG FillFrame()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG FillFrame ( 0 , 0 , 1 0 0 , 1 5 0 , C YELLOW) ;
// . . .
}
25
(a) Before (b) After
7.1.6 UG FillRoundFrame()
Fills a rectangular area with a selected color. The rectangular area has rounded corners.
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG FillRoundFrame ( 0 , 0 , 1 0 0 , 1 5 0 , 1 0 , C YELLOW) ;
// . . .
}
26
(a) Before (b) After
7.1.7 UG DrawMesh()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG DrawMesh ( 0 , 0 , 1 0 0 , 1 5 0 , C YELLOW) ;
// . . .
}
27
(a) Before (b) After
7.1.8 UG DrawFrame()
Parameters:
i n t main ( v o i d )
{
// . . .
UG DrawFrame ( 0 , 0 , 1 0 0 , 1 5 0 , C YELLOW) ;
// . . .
}
28
(a) Before (b) After
7.1.9 UG DrawRoundFrame()
Draws a frame with a selected color. The frame has rounded corners.
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG DrawRoundFrame ( 0 , 0 , 1 0 0 , 1 5 0 , 1 0 , C YELLOW) ;
// . . .
}
29
(a) Before (b) After
7.1.10 UG DrawPixel()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG DrawPixel ( 2 0 , 7 0 , C GREEN) ;
// . . .
}
30
(a) Before (b) After
7.1.11 UG DrawCircle()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG DrawCircle ( 1 0 0 , 1 0 0 , 3 0 , C WHITE) ;
// . . .
}
31
(a) Before (b) After
7.1.12 UG FillCircle()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
U G F i l l C i r c l e ( 1 0 0 , 1 0 0 , 3 0 , C YELLOW) ;
// . . .
}
32
(a) Before (b) After
7.1.13 UG DrawArc()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG U16 s e c ;
UG U8 j , t o g ;
w h i l e ( 1 ) / ✯ Guess what i t d o e s : ) ✯ /
{
f o r ( s e c = 1 ; s e c != 0 x100 ; s e c <<=1 )
{
j ++;
i f ( j >=9 )
{
j = 0;
tog = ! tog ;
}
33
i f ( tog )
{
UG DrawArc ( 1 0 0 , 2 0 0 , 2 0 , s e c , C BLACK ) ;
}
else
{
UG DrawArc ( 1 0 0 , 2 0 0 , 2 0 , s e c , C WHITE ) ;
}
/ ✯ Some d e l a y ✯ /
delay ms (60) ;
}
}
// . . .
}
7.1.14 UG DrawLine()
Parameters:
34
i n t main ( v o i d )
{
// . . .
UG DrawLine ( 0 , 0 , 1 2 0 , 7 0 , C BLUE) ;
// . . .
}
7.1.15 UG PutString()
Draws a string.
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG FontSelect ( &FONT 24X40 ) ;
UG SetBackcolor ( C BLACK ) ;
U G S e t F o r e c o l o r ( C CYAN ) ;
UG PutString ( 0 , 0 , ” H e l l o World ! ” ) ;
// . . .
}
35
(a) Before (b) After
7.1.16 UG PutChar()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG FontSelect ( &FONT 24X40 ) ;
UG PutChar ( ’X ’ , 2 0 , 2 0 , C YELLOW, C BLUE ) ;
// . . .
}
36
(a) Before (b) After
7.1.17 UG ConsolePutString()
Prototype:
v o i d UG ConsolePutString ( c h a r ✯ s t r ) ;
Parameters:
i n t main ( v o i d )
{
// . . .
UG FontSelect ( &FONT 12X16 ) ;
UG ConsoleSetBackcolor ( C BLACK ) ;
U G C o n s o l e S e t F o r e c o l o r ( C WHITE ) ;
UG ConsolePutString ( ” System i n i t i a l i z e d ! \ n” ) ;
// . . .
UG ConsolePutString ( ”SD✁Card mounted ! \ n” ) ;
// . . .
UG ConsolePutString ( ”BLDC: ” ) ;
// . . .
U G C o n s o l e S e t F o r e c o l o r ( C GREEN ) ;
UG ConsolePutString ( ” T r a p e z o i d a l mode\n” ) ;
// . . .
U G C o n s o l e S e t F o r e c o l o r ( C WHITE ) ;
UG ConsolePutString ( ”CPU c o r e v o l t a g e : ” ) ;
U G C o n s o l e S e t F o r e c o l o r ( C RED ) ;
37
UG ConsolePutString ( ” >1.9V! \ n” ) ;
// . . .
}
7.1.18 UG ConsoleSetArea()
Prototype:
Parameters:
i n t main ( v o i d )
{
// . . .
UG ConsoleSetArea ( 0 , 0 , 2 0 0 , 200 ) ;
// . . .
}
38
7.1.19 UG ConsoleSetForecolor()
Prototype:
v o i d U G C o n s o l e S e t F o r e c o l o r ( UG COLOR c ) ;
Parameters:
i n t main ( v o i d )
{
// . . .
U G C o n s o l e S e t F o r e c o l o r ( C YELLOW ) ;
// . . .
}
7.1.20 UG ConsoleSetBackcolor()
Prototype:
v o i d UG ConsoleSetBackcolor ( UG COLOR c ) ;
Parameters:
UG COLOR c Backcolor
Example:
i n t main ( v o i d )
{
// . . .
UG ConsoleSetBackcolor ( C BLUE ) ;
// . . .
}
39
7.1.21 UG SetForecolor()
v o i d U G S e t F o r e c o l o r ( UG COLOR c ) ;
Parameters:
i n t main ( v o i d )
{
// . . .
U G S e t F o r e c o l o r ( C YELLOW ) ;
// . . .
}
7.1.22 UG SetBackcolor()
Prototype:
v o i d UG SetBackcolor ( UG COLOR c ) ;
Parameters:
UG COLOR c Backcolor
Example:
i n t main ( v o i d )
{
// . . .
UG SetBackcolor ( C BLUE ) ;
// . . .
}
40
7.1.23 UG GetXDim()
Prototype:
UG S16 UG GetXDim( v o i d ) ;
Returns:
UG S16 X-Dimension
Example:
i n t main ( v o i d )
{
// . . .
v a l = UG GetXDim( ) ;
// . . .
}
7.1.24 UG GetYDim()
Prototype:
UG S16 UG GetYDim( v o i d ) ;
Returns:
UG S16 Y-Dimension
Example:
i n t main ( v o i d )
{
// . . .
v a l = UG GetYDim( ) ;
// . . .
}
41
7.1.25 UG FontSetHSpace()
Prototype:
v o i d UG FontSetHSpace ( UG U16 s ) ;
Parameters:
i n t main ( v o i d )
{
// . . .
UG FontSetHSpace ( 4 ) ;
// . . .
}
7.1.26 UG FontSetVSpace()
v o i d UG FontSetVSpace ( UG U16 s ) ;
Parameters:
i n t main ( v o i d )
{
// . . .
UG FontSetVSpace ( 4 ) ;
// . . .
}
42
7.2 Driver Functions
7.2.1 UG DriverRegister()
Registers a driver.
Prototype:
v o i d U G D r i v e r R e g i s t e r ( UG U8 type , v o i d ✯ d r i v e r ) ;
Parameters:
/✯ h o r i z o n t a l l i n e ✯/
i f ( y1 == y2 )
{
DMA2D InitStruct . DMA2D OutputOffset = 0;
DMA2D InitStruct . DMA2D NumberOfLine = 1;
DMA2D InitStruct . DMA2D PixelPerLine = x2✁x1 +1;
}
/✯ v e r t i c a l l i n e ✯/
e l s e i f ( x1 == x2 )
{
DMA2D InitStruct . DMA2D OutputOffset = LCD PIXEL WIDTH ✁ 1;
DMA2D InitStruct . DMA2D NumberOfLine = y2✁y1 +1;
DMA2D InitStruct . DMA2D PixelPerLine = 1;
}
else
{
r e t u r n UG RESULT FAIL ;
43
}
i f ( l t d c w o r k l a y e r == LAYER 1 )
{
DMA2D InitStruct . DMA2D OutputMemoryAdd = SDRAM BANK ADDR + LAYER 1 OFFSET +
2 ✯ (LCD PIXEL WIDTH ✯ y1 + x1 ) ;
}
else
{
DMA2D InitStruct . DMA2D OutputMemoryAdd = SDRAM BANK ADDR + LAYER 2 OFFSET +
2 ✯ (LCD PIXEL WIDTH ✯ y1 + x1 ) ;
}
DMA2D Init(&DMA2D InitStruct ) ;
DMA2D StartTransfer ( ) ;
w h i l e ( DMA2D GetFlagStatus (DMA2D FLAG TC) == RESET) { } ;
r e t u r n UG RESULT OK ;
}
DMA2D DeInit ( ) ;
DMA2D InitStruct . DMA2D Mode = DMA2D R2M;
DMA2D InitStruct . DMA2D CMode = DMA2D RGB565 ;
/ ✯ Convert UG COLOR t o RGB565 ✯ /
DMA2D InitStruct . DMA2D OutputBlue = ( c>>3) & 0x1F ;
DMA2D InitStruct . DMA2D OutputGreen = ( c >>10) & 0x3F ;
DMA2D InitStruct . DMA2D OutputRed = ( c >>19) & 0x1F ;
DMA2D InitStruct . DMA2D OutputAlpha = 0x0F ;
DMA2D InitStruct . DMA2D OutputOffset = (LCD PIXEL WIDTH ✁ ( x2✁x1+1) ) ;
DMA2D InitStruct . DMA2D NumberOfLine = y2✁y1 +1;
DMA2D InitStruct . DMA2D PixelPerLine = x2✁x1 +1;
i f ( l t d c w o r k l a y e r == LAYER 1 )
{
DMA2D InitStruct . DMA2D OutputMemoryAdd = SDRAM BANK ADDR + LAYER 1 OFFSET +
2 ✯ (LCD PIXEL WIDTH ✯ y1 + x1 ) ;
}
else
{
DMA2D InitStruct . DMA2D OutputMemoryAdd = SDRAM BANK ADDR + LAYER 2 OFFSET +
2 ✯ (LCD PIXEL WIDTH ✯ y1 + x1 ) ;
}
DMA2D Init(&DMA2D InitStruct ) ;
DMA2D StartTransfer ( ) ;
w h i l e ( DMA2D GetFlagStatus (DMA2D FLAG TC) == RESET) {}
r e t u r n UG RESULT OK ;
}
i n t main ( v o i d )
{
// . . .
/ ✯ Unleash t h e p e r f o r m a n c e o f t h e STM32 ✯ /
44
U G D r i v e r R e g i s t e r ( DRIVER DRAW LINE, ( v o i d ✯ ) HW DrawLine ) ;
U G D r i v e r R e g i s t e r ( DRIVER FILL FRAME , ( v o i d ✯ ) HW FillFrame ) ;
// . . .
}
7.2.2 UG DriverEnable()
Enables a driver.
Prototype:
v o i d UG DriverEnable ( UG U8 type ) ;
Parameters:
i n t main ( v o i d )
{
// . . .
UG DriverEnable ( DRIVER DRAW LINE ) ;
// . . .
}
7.2.3 UG DriverDisable()
Disables a driver.
Prototype:
v o i d UG D ri v er D is a bl e ( UG U8 type ) ;
Parameters:
45
i n t main ( v o i d )
{
// . . .
U G D ri v er D is a bl e ( DRIVER DRAW LINE ) ;
// . . .
}
7.3.1 UG WindowCreate()
Creates a window.
Prototype:
Parameters:
v o i d w i n d o w 1 c a l l b a c k ( UG MESSAGE✯ msg )
{
i f ( msg✁>type == MSG TYPE OBJECT )
{
i f ( msg✁>i d == OBJ TYPE BUTTON )
{
s w i t c h ( msg✁>s u b i d )
{
c a s e BTN ID 0 :
{
// . . .
break ;
}
c a s e BTN ID 1 :
{
// . . .
break ;
}
c a s e BTN ID 2 :
46
{
// . . .
break ;
}
}
}
}
}
#d e f i n e MAX OBJECTS 10
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG BUTTON b u t t o n 1 ;
UG BUTTON b u t t o n 2 ;
UG BUTTON b u t t o n 3 ;
UG TEXTBOX t e x t b o x 1 ;
UG OBJECT o b j b u f f w n d 1 [MAX OBJECTS ] ;
// . . .
/ ✯ C r e a t e t h e window ✯ /
UG WindowCreate ( &window 1 , o b j b u f f w n d 1 , MAX OBJECTS, w i n d o w 1 c a l l b a c k ) ;
/ ✯ Modify t h e window t i t l e ✯ /
UG WindowSetTitleText ( &window 1 , ”uGUI Demo Window” ) ;
UG WindowSetTitleTextFont ( &window 1 , &FONT 12X20 ) ;
/ ✯ C r e a t e some b u t t o n s ✯ /
UG ButtonCreate ( &window 1 , &b ut to n 1 , BTN ID 0 , 1 0 , 1 0 , 1 1 0 , 60 ) ;
UG ButtonCreate ( &window 1 , &b ut to n 2 , BTN ID 1 , 1 0 , 8 0 , 1 1 0 , 130 ) ;
UG ButtonCreate ( &window 1 , &b ut to n 3 , BTN ID 2 , 1 0 , 1 5 0 , 1 1 0 , 200 ) ;
/ ✯ L ab el t h e b u t t o n s ✯ /
UG ButtonSetFont ( &window 1, BTN ID 0, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 0, ” Button \nA” );
UG ButtonSetFont ( &window 1, BTN ID 1, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 1, ” Button \nB” );
UG ButtonSetFont ( &window 1, BTN ID 2, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 2, ” Button \nC” );
/ ✯ C r e a t e a Textbox ✯ /
UG TextboxCreate ( &window 1 , &t e x t b o x 1 , TXB ID 0 , 1 2 0 , 1 0 , 3 1 0 , 200 ) ;
UG TextboxSetFont ( &window 1 , TXB ID 0 , &FONT 12X16 ) ;
UG TextboxSetText ( &window 1 , TXB ID 0 ,
” This i s j u s t \na v e r y s i m p l e \nwindow t o \ ndemonstrate \nsome b a s i c \ n f e a t u r e s o f
uGUI ! ” ) ;
UG TextboxSetForeColor ( &window 1 , TXB ID 0 , C BLACK ) ;
UG TextboxSetAlignment ( &window 1 , TXB ID 0 , ALIGN CENTER ) ;
/ ✯ F i n a l l y , show t h e window ✯ /
UG WindowShow ( &window 1 ) ;
// . . .
}
47
(a) Before (b) After
7.3.2 UG WindowDelete()
Deletes a window.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowDelete ( &window 1 ) ;
// . . .
}
7.3.3 UG WindowShow()
Shows a window.
Prototype:
48
UG RESULT UG WindowShow ( UG WINDOW✯ wnd ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowShow ( &window 1 ) ;
// . . .
}
7.3.4 UG WindowHide()
Hides a window.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowHide ( &window 1 ) ;
// . . .
}
49
7.3.5 UG WindowResize()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowResize ( &window 1 , 2 0 , 2 0 , 319 ✁ 20 , 239 ✁ 20 ) ;
// . . .
}
50
7.3.6 UG WindowAlert()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowAlert ( &window 1 ) ;
// . . .
}
7.3.7 UG WindowSetForeColor()
Changes the fore color of the window. The fore color of a window is the default fore color of all
objects.
Prototype:
51
UG RESULT UG WindowSetForeColor ( UG WINDOW✯ wnd , UG COLOR f c ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG BUTTON b u t t o n 1 ;
UG BUTTON b u t t o n 2 ;
UG BUTTON b u t t o n 3 ;
UG TEXTBOX t e x t b o x 1 ;
UG OBJECT o b j b u f f w n d 1 [MAX OBJECTS ] ;
// . . .
/ ✯ C r e a t e t h e window ✯ /
UG WindowCreate ( &window 1 , o b j b u f f w n d 1 , MAX OBJECTS, w i n d o w 1 c a l l b a c k ) ;
/ ✯ Modify t h e window t i t l e ✯ /
UG WindowSetTitleText ( &window 1 , ”uGUI Demo Window” ) ;
UG WindowSetTitleTextFont ( &window 1 , &FONT 12X20 ) ;
/ ✯ Change t h e window f o r e c o l o r ( b e f o r e c r e a t i n g t h e o b j e c t s ) ✯ /
UG WindowSetForeColor ( &window 1 , C RED ) ;
/ ✯ C r e a t e some b u t t o n s ✯ /
UG ButtonCreate ( &window 1 , &b ut to n 1 , BTN ID 0 , 1 0 , 1 0 , 1 1 0 , 60 ) ;
UG ButtonCreate ( &window 1 , &b ut to n 2 , BTN ID 1 , 1 0 , 8 0 , 1 1 0 , 130 ) ;
UG ButtonCreate ( &window 1 , &b ut to n 3 , BTN ID 2 , 1 0 , 1 5 0 , 1 1 0 , 200 ) ;
/ ✯ L ab el t h e b u t t o n s ✯ /
UG ButtonSetFont ( &window 1, BTN ID 0, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 0, ” Button \nA” );
UG ButtonSetFont ( &window 1, BTN ID 1, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 1, ” Button \nB” );
UG ButtonSetFont ( &window 1, BTN ID 2, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 2, ” Button \nC” );
/ ✯ C r e a t e a Textbox ✯ /
UG TextboxCreate ( &window 1 , &t e x t b o x 1 , TXB ID 0 , 1 2 0 , 1 0 , 3 1 0 , 200 ) ;
UG TextboxSetFont ( &window 1 , TXB ID 0 , &FONT 12X16 ) ;
UG TextboxSetText ( &window 1 , TXB ID 0 ,
” This i s j u s t \na v e r y s i m p l e \nwindow t o \ ndemonstrate \nsome b a s i c \ n f e a t u r e s o f
uGUI ! ” ) ;
UG TextboxSetForeColor ( &window 1 , TXB ID 0 , C BLACK ) ;
52
UG TextboxSetAlignment ( &window 1 , TXB ID 0 , ALIGN CENTER ) ;
/ ✯ F i n a l l y , show t h e window ✯ /
UG WindowShow ( &window 1 ) ;
// . . .
}
7.3.8 UG WindowSetBackColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG BUTTON b u t t o n 1 ;
UG BUTTON b u t t o n 2 ;
UG BUTTON b u t t o n 3 ;
UG TEXTBOX t e x t b o x 1 ;
53
UG OBJECT o b j b u f f w n d 1 [MAX OBJECTS ] ;
// . . .
/ ✯ C r e a t e t h e window ✯ /
UG WindowCreate ( &window 1 , o b j b u f f w n d 1 , MAX OBJECTS, w i n d o w 1 c a l l b a c k ) ;
/ ✯ Modify t h e window t i t l e ✯ /
UG WindowSetTitleText ( &window 1 , ”uGUI Demo Window” ) ;
UG WindowSetTitleTextFont ( &window 1 , &FONT 12X20 ) ;
/ ✯ C r e a t e some b u t t o n s ✯ /
UG ButtonCreate ( &window 1 , &b ut to n 1 , BTN ID 0 , 1 0 , 1 0 , 1 1 0 , 60 ) ;
UG ButtonCreate ( &window 1 , &b ut to n 2 , BTN ID 1 , 1 0 , 8 0 , 1 1 0 , 130 ) ;
UG ButtonCreate ( &window 1 , &b ut to n 3 , BTN ID 2 , 1 0 , 1 5 0 , 1 1 0 , 200 ) ;
/ ✯ L ab el t h e b u t t o n s ✯ /
UG ButtonSetFont ( &window 1, BTN ID 0, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 0, ” Button \nA” );
UG ButtonSetFont ( &window 1, BTN ID 1, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 1, ” Button \nB” );
UG ButtonSetFont ( &window 1, BTN ID 2, &FONT 12X20 );
UG ButtonSetText ( &window 1, BTN ID 2, ” Button \nC” );
/ ✯ C r e a t e a Textbox ✯ /
UG TextboxCreate ( &window 1 , &t e x t b o x 1 , TXB ID 0 , 1 2 0 , 1 0 , 3 1 0 , 200 ) ;
UG TextboxSetFont ( &window 1 , TXB ID 0 , &FONT 12X16 ) ;
UG TextboxSetText ( &window 1 , TXB ID 0 , ” This i s j u s t \na v e r y s i m p l e \nwindow t o \
ndemonstrate \nsome b a s i c \ n f e a t u r e s o f \nuGUI ! ” ) ;
UG TextboxSetAlignment ( &window 1 , TXB ID 0 , ALIGN CENTER ) ;
/ ✯ F i n a l l y , show t h e window ✯ /
UG WindowShow ( &window 1 ) ;
// . . .
}
54
(a) Before (b) After
7.3.9 UG WindowSetTitleTextColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleTextColor ( &window 1 , C RED ) ;
// . . .
}
55
(a) Before (b) After
7.3.10 UG WindowSetTitleColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleColor ( &window 1 , C GREEN ) ;
// . . .
}
56
(a) Before (b) After
7.3.11 UG WindowSetTitleInactiveTextColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleInactiveTextColor ( &window 1 , C BLACK ) ;
UG WindowShow ( &window 2 ) ;
// . . .
}
57
(a) Before (b) After
7.3.12 UG WindowSetTitleInactiveColor()
UG RESULT UG Wind owSet Title Inact iveCo lor ( UG WINDOW✯ wnd , UG COLOR c ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG Wind owSet Title Inact iveCo lor ( &window 1 , C GRAY ) ;
UG WindowShow ( &window 2 ) ;
// . . .
}
58
(a) Before (b) After
7.3.13 UG WindowSetTitleText()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleText ( &window 1 , ” ✯✯✯ NEW TEXT : ) ✯✯✯ ” ) ;
// . . .
}
59
(a) Before (b) After
7.3.14 UG WindowSetTitleTextFont()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleTextFont ( &window 1 , &FONT 8X8 ) ;
// . . .
}
60
(a) Before (b) After
7.3.15 UG WindowSetTitleTextHSpace()
Changes the horizontal space between the characters in the window title.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleTextHSpace ( &window 1 , 4 ) ;
// . . .
}
61
(a) Before (b) After
7.3.16 UG WindowSetTitleTextVSpace()
Changes the vertical space between the characters in the window title.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleTextVSpace ( &window 1 , 3 ) ;
// . . .
}
7.3.17 UG WindowSetTitleTextAlignment()
62
ALIGN BOTTOM RIGHT
ALIGN BOTTOM CENTER
ALIGN BOTTOM LEFT
ALIGN CENTER RIGHT
ALIGN CENTER
ALIGN CENTER LEFT
ALIGN TOP RIGHT
ALIGN TOP CENTER
ALIGN TOP LEFT
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleTextAlignment ( &window 1 , ALIGN CENTER ) ;
// . . .
}
7.3.18 UG WindowSetTitleHeight()
Parameters:
63
Returns:
UG RESULT Result of the function
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetTitleHeight ( &window 1 , 25 ) ;
// . . .
}
7.3.19 UG WindowSetXStart()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetXStart ( &window 1 , 40 ) ;
// . . .
}
7.3.20 UG WindowSetYStart()
64
UG RESULT UG WindowSetYStart ( UG WINDOW✯ wnd , UG S16 ys ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetYStart ( &window 1 , 40 ) ;
// . . .
}
7.3.21 UG WindowSetXEnd()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetXEnd ( &window 1 , 200 ) ;
// . . .
}
65
7.3.22 UG WindowSetYEnd()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetYEnd ( &window 1 , 150 ) ;
// . . .
}
7.3.23 UG WindowSetStyle()
WND STYLE 2D WND STYLE 3D WND STYLE HIDE TITLE WND STYLE SHOW TITLE
Prototype:
Parameters:
66
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowSetStyle ( &window 1 , WND STYLE 3D | WND STYLE HIDE TITLE ) ;
// . . .
}
7.3.24 UG WindowGetForeColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
c o l o r = UG WindowGetForeColor ( &window 1 ) ;
// . . .
}
7.3.25 UG WindowGetBackColor()
Parameters:
67
UG WINDOW* wnd Pointer to the window
Returns:
UG COLOR Back color of the window
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
c o l o r = UG WindowGetBackColor ( &window 1 ) ;
// . . .
}
7.3.26 UG WindowGetTitleTextColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
c o l o r = UG WindowGetTitleTextColor ( &window 1 ) ;
// . . .
}
7.3.27 UG WindowGetTitleColor()
68
UG COLOR UG WindowGetTitleColor ( UG WINDOW✯ wnd ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
c o l o r = UG WindowGetTitleColor ( &window 1 ) ;
// . . .
}
7.3.28 UG WindowGetTitleInactiveTextColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
c o l o r = UG WindowGetTitleInactiveTextColor ( &window 1 ) ;
// . . .
}
69
7.3.29 UG WindowGetTitleInactiveColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
c o l o r = UG WindowGetTitleInactiveColor ( &window 1 ) ;
// . . .
}
7.3.30 UG WindowGetTitleText()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
70
s t r = ( c h a r ✯ ) UG WindowGetTitleText ( &window 1 ) ;
// . . .
}
7.3.31 UG WindowGetTitleTextFont()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
f o n t = (UG FONT✯ ) UG WindowGetTitleTextFont ( &window 1 ) ;
// . . .
}
7.3.32 UG WindowGetTitleTextHSpace()
Returns the horizontal space between the characters in the window title.
Prototype:
Parameters:
71
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG S8 s p a c e ;
// . . .
s p a c e = UG WindowGetTitleTextHSpace ( &window 1 ) ;
// . . .
}
7.3.33 UG WindowGetTitleTextVSpace()
Returns the vertical space between the characters in the window title.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG S8 s p a c e ;
// . . .
s p a c e = UG WindowGetTitleTextVSpace ( &window 1 ) ;
// . . .
}
7.3.34 UG WindowGetTitleTextAlignment()
Parameters:
72
UG WINDOW* wnd Pointer to the window
Returns:
UG U8 Alignment of the text in the window title
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
a l i g n = UG WindowGetTitleTextAlignment ( &window 1 ) ;
// . . .
}
7.3.35 UG WindowGetTitleHeight()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
h e i g h t = UG WindowGetTitleHeight ( &window 1 ) ;
// . . .
}
7.3.36 UG WindowGetXStart()
73
UG S16 UG WindowGetXStart ( UG WINDOW✯ wnd ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
pos = UG WindowGetXStart ( &window 1 ) ;
// . . .
}
7.3.37 UG WindowGetYStart()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
pos = UG WindowGetYStart ( &window 1 ) ;
// . . .
}
74
7.3.38 UG WindowGetXEnd()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
pos = UG WindowGetXEnd ( &window 1 ) ;
// . . .
}
7.3.39 UG WindowGetYEnd()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
75
pos = UG WindowGetYEnd ( &window 1 ) ;
// . . .
}
7.3.40 UG WindowGetStyle()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
s t y l e = UG WindowGetStyle ( &window 1 ) ;
// . . .
}
7.3.41 UG WindowGetArea()
Parameters:
76
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG WindowGetArea ( &window 1 , &a r e a ) ;
// . . .
}
7.3.42 UG WindowGetInnerWidth()
77
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
width = UG WindowGetInnerWidth ( &window 1 ) ;
// . . .
}
78
7.3.43 UG WindowGetOuterWidth()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
width = UG WindowGetOuterWidth ( &window 1 ) ;
// . . .
}
79
Figure 47: UG WindowGetOuterWidth() example
7.3.44 UG WindowGetInnerHeight()
Parameters:
80
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
h e i g h t = UG WindowGetInnerHeight ( &window 1 ) ;
// . . .
}
7.3.45 UG WindowGetOuterHeight()
81
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
h e i g h t = UG WindowGetOuterHeight ( &window 1 ) ;
// . . .
}
82
7.4 Button Functions
7.4.1 UG ButtonCreate()
Creates a button.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG BUTTON b u t t o n 1 ;
// . . .
UG ButtonCreate ( &window 1 , &b ut to n 1 , BTN ID 0 , 1 0 , 1 0 , 1 1 0 , 60 ) ;
// . . .
}
7.4.2 UG ButtonDelete()
Deletes a button.
Prototype:
Parameters:
83
Returns:
UG RESULT Result of the function
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonDelete ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.3 UG ButtonShow()
Shows a button.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonShow ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.4 UG ButtonHide()
Hides a button.
Prototype:
84
UG RESULT UG ButtonHide ( UG WINDOW✯ wnd , UG U8 i d ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonHide ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.5 UG ButtonSetForeColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonSetForeColor ( &window 1 , BTN ID 0 , C BLACK ) ;
// . . .
}
85
7.4.6 UG ButtonSetBackColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonSetBackColor ( &window 1 , BTN ID 0 , C GRAY ) ;
// . . .
}
7.4.7 UG ButtonSetAlternateForeColor()
Parameters:
86
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
U G B u t t o nS e t A l t e r na t e F o r e C o l o r ( &window 1 , BTN ID 0 , C BLUE ) ;
// . . .
}
7.4.8 UG ButtonSetAlternateBackColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonSetAlternateBackColor ( &window 1 , BTN ID 0 , C YELLOW ) ;
// . . .
}
7.4.9 UG ButtonSetText()
Parameters:
87
UG WINDOW* wnd Pointer to the window which contains the button
UG U8 id Button ID
char* str Pointer to the button text
Returns:
UG RESULT Result of the function
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonSetText ( &window 1 , BTN ID 0 , ” Button \n : ) ” ) ;
// . . .
}
7.4.10 UG ButtonSetFont()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonSetFont ( &window 1 , BTN ID 0 , &FONT 12X20 ) ;
// . . .
}
88
7.4.11 UG ButtonSetStyle()
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ButtonSetStyle ( &window 1 , BTN ID 0 , BTN STYLE 3D | BTN STYLE TOGGLE COLORS )
;
// . . .
}
7.4.12 UG ButtonGetForeColor()
Parameters:
89
Returns:
UG COLOR Fore color of the button
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG COLOR f c ;
// . . .
f c = UG ButtonGetForeColor ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.13 UG ButtonGetBackColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG COLOR bc ;
// . . .
bc = UG ButtonGetBackColor ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.14 UG ButtonGetAlternateForeColor()
90
UG COLOR UG ButtonGetAlternateForeColor ( UG WINDOW✯ wnd , UG U8 i d ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG COLOR a f c ;
// . . .
a f c = UG ButtonGetAlternateForeColor ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.15 UG ButtonGetAlternateBackColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG COLOR abc ;
// . . .
abc = UG ButtonGetAlternateBackColor ( &window 1 , BTN ID 0 ) ;
// . . .
}
91
7.4.16 UG ButtonGetText()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
char ✯ s t r ;
// . . .
s t r = UG ButtonGetText ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.17 UG ButtonGetFont()
Parameters:
92
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG FONT✯ f o n t ;
// . . .
f o n t = UG ButtonGetFont ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.4.18 UG ButtonGetStyle()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG U8 s t y l e ;
// . . .
s t y l e = UG ButtonGetStyle ( &window 1 , BTN ID 0 ) ;
// . . .
}
7.5.1 UG TextboxCreate()
Creates a textbox.
Prototype:
93
UG RESULT UG TextboxCreate ( UG WINDOW✯ wnd , UG TEXTBOX✯ txb , UG U8 id , UG S16 xs ,
UG S16 ys , UG S16 xe , UG S16 ye ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG TEXTBOX t e x t b o x 1 ;
// . . .
UG TextboxCreate ( &window 1 , &t e x t b o x 1 , TXB ID 0 , 1 0 , 1 0 , 1 0 0 , 100 ) ;
// . . .
}
7.5.2 UG TextboxDelete()
Deletes a textbox.
Prototype:
Parameters:
94
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxDelete ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.3 UG TextboxShow()
Shows a textbox.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxShow ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.4 UG TextboxHide()
Hides a textbox.
Prototype:
Parameters:
95
UG WINDOW* wnd Pointer to the window which contains the textbox
UG U8 id Textbox ID
Returns:
UG RESULT Result of the function
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxHide ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.5 UG TextboxSetForeColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxSetForeColor ( &window 1 , TXB ID 0 , C BLACK ) ;
// . . .
}
7.5.6 UG TextboxSetBackColor()
96
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxSetBackColor ( &window 1 , TXB ID 0 , C YELLOW ) ;
// . . .
}
7.5.7 UG TextboxSetText()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
97
UG TextboxSetText ( &window 1 , TXB ID 0 , ” H e l l o World ! ” ) ;
// . . .
}
7.5.8 UG TextboxSetFont()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxSetFont ( &window 1 , TXB ID 0 , &FONT 12X20 ) ;
// . . .
}
7.5.9 UG TextboxSetHSpace()
Parameters:
98
Returns:
UG RESULT Result of the function
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxSetHSpace ( &window 1 , TXB ID 0 , 4 ) ;
// . . .
}
7.5.10 UG TextboxSetVSpace()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxSetVSpace ( &window 1 , TXB ID 0 , 4 ) ;
// . . .
}
7.5.11 UG TextboxSetAlignment()
99
ALIGN BOTTOM RIGHT
ALIGN BOTTOM CENTER
ALIGN BOTTOM LEFT
ALIGN CENTER RIGHT
ALIGN CENTER
ALIGN CENTER LEFT
ALIGN TOP RIGHT
ALIGN TOP CENTER
ALIGN TOP LEFT
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG TextboxSetAlignment ( &window 1 , TXB ID 0 , ALIGN CENTER ) ;
// . . .
}
7.5.12 UG TextboxGetForeColor()
Parameters:
100
Returns:
UG COLOR Fore color
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG COLOR f c ;
// . . .
f c = UG TextboxGetForeColor ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.13 UG TextboxGetBackColor()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG COLOR bc ;
// . . .
bc = UG TextboxGetBackColor ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.14 UG TextboxGetText()
101
c h a r ✯ UG TextboxGetText ( UG WINDOW✯ wnd , UG U8 i d ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
char ✯ s t r ;
// . . .
s t r = UG TextboxGetText ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.15 UG TextboxGetFont()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG FONT✯ f o n t ;
// . . .
f o n t = UG TextboxGetFont ( &window 1 , TXB ID 0 ) ;
// . . .
}
102
7.5.16 UG TextboxGetHSpace()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG S8 s p a c e ;
// . . .
s p a c e = UG TextboxGetHSpace ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.17 UG TextboxGetVSpace()
Parameters:
103
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG S8 s p a c e ;
// . . .
s p a c e = UG TextboxGetVSpace ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.5.18 UG TextboxGetAlignment()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG U8 a l i g n ;
// . . .
a l i g n = UG TextboxGetAlignment ( &window 1 , TXB ID 0 ) ;
// . . .
}
7.6.1 UG ImageCreate()
Creates an image.
Prototype:
104
UG RESULT UG ImageCreate ( UG WINDOW✯ wnd , UG IMAGE✯ img , UG U8 id , UG S16 xs ,
UG S16 ys , UG S16 xe , UG S16 ye ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
UG TEXTBOX t e x t b o x 1 ;
UG TEXTBOX t e x t b o x 2 ;
UG BUTTON b u t t o n 1 ;
UG IMAGE image 1 ;
c o n s t UG BMP l o g o =
{
( v o i d ✯ ) logo bmp ,
80 ,
80 ,
BMP BPP 16 ,
BMP RGB565
};
// . . .
/ ✯ C r e a t e t h e window ✯ /
UG WindowCreate ( &window 1 , o b j b u f f w n d 1 , MAX OBJECTS, w i n d o w 1 c a l l b a c k ) ;
UG WindowSetTitleText ( &window 1 , ” I n f o ” ) ;
UG WindowSetTitleTextFont ( &window 1 , &FONT 12X20 ) ;
/ ✯ C r e a t e t h e button ✯ /
UG ButtonCreate ( &window 1 , &b ut to n 1 , BTN ID 0 , 1 0 0 , 1 5 0 ,
UG WindowGetInnerWidth ( &window 1 ) ✁ 100 , 200 ) ;
UG ButtonSetFont ( &window 1 , BTN ID 0 , &FONT 22X36 ) ;
UG ButtonSetText ( &window 1 , BTN ID 0 , ”OK! ” ) ;
/✯ C r e a t e t e x t b o x 1 ✯/
UG TextboxCreate ( &window 1 , &t e x t b o x 1 , TXB ID 0 , 1 0 , 1 0 ,
UG WindowGetInnerWidth ( &window 1 ) ✁ 10, 40 ) ;
105
UG TextboxSetFont ( &window 1 , TXB ID 0 , &FONT 16X26 ) ;
UG TextboxSetText ( &window 1 , TXB ID 0 , ”uGUI v0 . 3 ” ) ;
UG TextboxSetAlignment ( &window 1 , TXB ID 0 , ALIGN TOP CENTER ) ;
/✯ C r e a t e t e x t b o x 2 ✯/
UG TextboxCreate(&window 1 , &t e x t b o x 2 , TXB ID 1 , 1 0 , 1 2 5 ,
UG WindowGetInnerWidth ( &window 1 ) ✁ 10, 135 ) ;
UG TextboxSetFont(&window 1 , TXB ID 1 , &FONT 6X8 ) ;
UG TextboxSetText(&window 1 , TXB ID 1 , ”www. e m b e d d e d l i g h t n i n g . com” ) ;
UG TextboxSetAlignment(&window 1 , TXB ID 1 , ALIGN BOTTOM CENTER ) ;
UG TextboxSetForeColor ( &window 1 , TXB ID 1 , C BLUE ) ;
UG TextboxSetHSpace ( &window 1 , TXB ID 1 , 1 ) ;
/ ✯ C r e a t e t h e image ✯ /
UG ImageCreate ( &window 1 , &image 1 , IMG ID 0 , ( UG WindowGetInnerWidth ( &
window 1 )>>1) ✁ ( l o g o . width >>1) , 4 0 , 0 , 0 ) ;
UG ImageSetBMP ( &window 1 , IMG ID 0 , &l o g o ) ;
UG WindowShow ( &window 1 ) ;
// . . .
}
7.6.2 UG ImageDelete()
Deletes an image.
Prototype:
Parameters:
106
Returns:
UG RESULT Result of the function
Example:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ImageDelete ( &window 1 , IMG ID 0 ) ;
// . . .
}
7.6.3 UG ImageShow()
Shows an image.
Prototype:
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ImageShow ( &window 1 , IMG ID 0 ) ;
// . . .
}
7.6.4 UG ImageHide()
Hides an image.
Prototype:
107
UG RESULT UG ImageHide ( UG WINDOW✯ wnd , UG U8 i d ) ;
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
// . . .
UG ImageHide ( &window 1 , IMG ID 0 ) ;
// . . .
}
7.6.5 UG ImageSetBMP()
Parameters:
i n t main ( v o i d )
{
UG WINDOW window 1 ;
c o n s t UG U16 logo bmp [ ] = { . . . } ;
c o n s t UG BMP l o g o =
{
108
( v o i d ✯ ) logo bmp ,
80 ,
80 ,
BMP BPP 16 ,
BMP RGB565
};
// . . .
UG ImageSetBMP ( &window 1 , IMG ID 0 , &l o g o ) ;
// . . .
}
List of Figures
1 ➭GUI window example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Object buffer mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 FONT 4X6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 FONT 5X8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5 FONT 5X12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6 FONT 6X8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7 FONT 6X10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
8 FONT 7X12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
9 FONT 8X8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
10 FONT 8X12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
11 FONT 8X14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
12 FONT 10X16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
13 FONT 12X16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
14 FONT 12X20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
15 FONT 16X26 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
16 FONT 22X36 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
17 FONT 24X40 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
18 FONT 32X53 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
19 UG FillScreen() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
20 UG FillFrame() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
21 UG FillRoundFrame() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
22 UG DrawMesh() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
23 UG DrawFrame() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
24 UG DrawRoundFrame() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
25 UG DrawPixel() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
26 UG DrawCircle() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
27 UG FillCircle() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
28 UG DrawArc() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
29 UG DrawLine() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
30 UG PutString() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
31 UG PutChar() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
32 UG ConsolePutString() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
33 UG WindowCreate() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
109
34 UG WindowResize() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
35 UG WindowAlert() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
36 UG WindowSetForeColor() example . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
37 UG WindowSetBackColor() example . . . . . . . . . . . . . . . . . . . . . . . . . . 52
38 UG WindowSetTitleTextColor() example . . . . . . . . . . . . . . . . . . . . . . . . 53
39 UG WindowSetTitleColor() example . . . . . . . . . . . . . . . . . . . . . . . . . . 54
40 UG WindowSetTitleInactiveTextColor() example . . . . . . . . . . . . . . . . . . . 55
41 UG WindowSetTitleInactiveColor() example . . . . . . . . . . . . . . . . . . . . . . 56
42 UG WindowSetTitleText() example . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
43 UG WindowSetTitleTextFont() example . . . . . . . . . . . . . . . . . . . . . . . . 58
44 UG WindowSetTitleTextHSpace() example . . . . . . . . . . . . . . . . . . . . . . . 59
45 UG WindowGetArea() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
46 UG WindowGetInnerWidth() example . . . . . . . . . . . . . . . . . . . . . . . . . 75
47 UG WindowGetOuterWidth() example . . . . . . . . . . . . . . . . . . . . . . . . . 77
48 UG WindowGetInnerHeight() example . . . . . . . . . . . . . . . . . . . . . . . . . 78
49 UG WindowGetOuterHeight() example . . . . . . . . . . . . . . . . . . . . . . . . . 79
50 UG ImageCreate() example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
110
8 Revision history
8.1 Software
111
✌ Function UG WindowGetXStart() added.
✌ Function UG WindowGetYStart() added.
✌ Function UG WindowGetXEnd() added.
✌ Function UG WindowGetYEnd() added.
✌ Function UG WindowGetStyle() added.
✌ Function UG WindowGetArea() added.
✌ Function UG WindowGetInnerWidth() added.
✌ Function UG WindowGetOuterWidth() added.
✌ Function UG WindowGetInnerHeight() added.
✌ Function UG WindowGetOuterHeight() added.
✌ Function UG ButtonCreate() added.
✌ Function UG ButtonDelete() added.
✌ Function UG ButtonShow() added.
✌ Function UG ButtonHide() added.
✌ Function UG ButtonSetForeColor() added.
✌ Function UG ButtonSetBackColor() added.
✌ Function UG ButtonSetAlternateForeColor() added.
✌ Function UG ButtonSetAlternateBackColor() added.
✌ Function UG ButtonSetText() added.
✌ Function UG ButtonSetFont() added.
✌ Function UG ButtonSetStyle() added.
✌ Function UG ButtonGetForeColor() added.
✌ Function UG ButtonGetBackColor() added.
✌ Function UG ButtonGetAlternateForeColor() added.
✌ Function UG ButtonGetAlternateBackColor() added.
✌ Function UG ButtonGetText() added.
✌ Function UG ButtonGetFont() added.
✌ Function UG ButtonGetStyle() added.
✌ Function UG TextboxCreate() added.
✌ Function UG TextboxDelete() added.
✌ Function UG TextboxShow() added.
✌ Function UG TextboxHide() added.
✌ Function UG TextboxSetForeColor() added.
✌ Function UG TextboxSetBackColor() added.
✌ Function UG TextboxSetText() added.
✌ Function UG TextboxSetFont() added.
✌ Function UG TextboxSetHSpace() added.
✌ Function UG TextboxSetVSpace() added.
✌ Function UG TextboxSetAlignment() added.
✌ Function UG TextboxGetForeColor() added.
✌ Function UG TextboxGetBackColor() added.
✌ Function UG TextboxGetText() added.
✌ Function UG TextboxGetFont() added.
✌ Function UG TextboxGetHSpace() added.
✌ Function UG TextboxGetVSpace() added.
✌ Function UG TextboxGetAlignment() added.
✌ Function UG ImageCreate() added.
112
✌ Function UG ImageDelete() added.
✌ Function UG ImageShow() added.
✌ Function UG ImageHide() added.
✌ Function UG ImageSetBMP() added.
✌ Function UG WaitForUpdate() added.
✌ Function UG Update() added.
✌ Function UG DrawBMP() added.
✌ Function UG TouchUpdate() added.
✌ Fixed some minor bugs.
v0.2 Oct 20, 2014 ✌ Function UG DrawRoundFrame() added.
✌ Function UG FillRoundFrame() added.
✌ Function UG DrawArc() added.
✌ Fixed some minor bugs.
v0.1 Oct 11, 2014 ✌ First release.
8.2 Document
113