XUI Programming Guide
User Manual:
Open the PDF directly: View PDF
.
Page Count: 47
| Download | |
| Open PDF In Browser | View PDF |
XUI Programming Guide
V 2.0.0
PAX Computer Technology(Shenzhen)Co., Ltd.
{ This page intentionally left blank }
Copyright © 2000-2015 PAX Computer Technology (Shenzhen) Co., Ltd.
All rights reserved. No part of the contents of this document may be reproduced or
transmitted in any form without the written permission of PAX Computer Technology
(Shenzhen) Co., Ltd.
The information contained in this document is subject to change without notice. Although
PAX Computer Technology (Shenzhen) Co., Ltd. has attempted to ensure the accuracy of the
contents of this document, this document may include errors or omissions. The examples and
sample programs are for illustration only and may not be suited for your purpose. You should
verify the applicability of any example or sample program before placing the software into
productive use.
I
Revision History
Date
Version
Note
Author
2013-05-16
V1.0.0
The first issue
Xie Lihong
2013-10-18
V2.0.0
Update
Huang Lei
II
Contents
1
2
3
Introduction .....................................................................................................................1
1.1
Purpose..................................................................................................................1
1.2
Function ................................................................................................................1
1.3
Feature ..................................................................................................................2
1.4
Thinking in XUI ....................................................................................................2
Macro and Struct .............................................................................................................5
2.1
Definition of Key values ........................................................................................5
2.2
Macro Definition ...................................................................................................6
2.3
Other Macro Definition .........................................................................................8
2.4
Structure ................................................................................................................8
XUI API ........................................................................................................................ 13
3.1
XuiOpen .............................................................................................................. 13
3.2
XuiIsRunning ......................................................................................................14
3.3
XuiClose ............................................................................................................. 14
3.4
XuiSuspend ......................................................................................................... 14
3.5
XuiResume .......................................................................................................... 15
3.6
XuiRootCanvas ...................................................................................................15
3.7
XuiStatusbarCanvas ............................................................................................. 16
3.8
XuiCreateFont .....................................................................................................16
3.9
XuiDestroyFont ...................................................................................................17
3.10
XuiCanvasDrawText ........................................................................................ 17
3.11
XuiCanvasDrawImg ......................................................................................... 18
3.12
XuiCanvasDrawRect ........................................................................................ 19
3.13
XuiClearArea ...................................................................................................19
3.14
XuiTextWidth ..................................................................................................20
3.15
XuiCreateCanvas ............................................................................................. 21
3.16
XuiDestroyWindow ......................................................................................... 21
3.17
XuiShowWindow ............................................................................................. 22
III
4
5
3.18
XuiCanvasSetBackground ................................................................................ 22
3.19
XuiCreateButton .............................................................................................. 23
3.20
XuiButtonSetStat ............................................................................................. 23
3.21
XuiButtonSetKey ............................................................................................. 24
3.22
XuiCreateSignatureBoard ................................................................................. 24
3.23
XuiSigBoardSetStat ......................................................................................... 25
3.24
XuiSigBoardImg .............................................................................................. 26
3.25
XuiCreateGif .................................................................................................... 26
3.26
XuiHasKey ......................................................................................................27
3.27
XuiGetKey ....................................................................................................... 27
3.28
XuiClearKey .................................................................................................... 27
3.29
XuiCaptureScreen ............................................................................................ 28
3.30
XuiCaptureCanvas ........................................................................................... 28
3.31
XuiImgLoadFormFile ...................................................................................... 29
3.32
XuiImgSaveToFile ........................................................................................... 29
3.33
XuiImgToRgba ................................................................................................ 29
3.34
XuiImgTransform ............................................................................................ 30
3.35
XuiImgFree ......................................................................................................30
3.36
XuiSetStatusbarIcon ......................................................................................... 31
3.37
XuiGetHzString ............................................................................................... 31
3.38
XuiGetString .................................................................................................... 32
Note............................................................................................................................... 35
4.1
Multi-process Supports ........................................................................................ 35
4.2
XuiDestroyWindow ............................................................................................. 35
FAQ .............................................................................................................................. 37
IV
Table List
Table 1 Definition of Key values ....................................................................................5
Table 2 Macro Definition ................................................................................................6
Table 3 XuiTransform Rotate..........................................................................................6
Table 4 XuiButtonStatType ............................................................................................7
Table 5 XuiBgStyle ........................................................................................................7
Table 6 XuiFontSet .........................................................................................................7
Table 7 XuiTextStyle ......................................................................................................7
Table 8 XuiSigPenFlat ....................................................................................................8
Table 9 XuiWindowType ................................................................................................8
Table 10 Structure XuiWindow.......................................................................................9
Table 11 Structure XuiImg ..............................................................................................9
Table 12 Structure XuiButtonStat ...................................................................................9
Table 13 Structure XuiSigBoardStat ............................................................................. 10
Table 14 Structure XuiImeAttr...................................................................................... 10
Table 15 Structure XuiGetStrAttr.................................................................................. 11
V
{ This page intentionally left blank }
Introduction
1 Introduction
1.1 Purpose
In contrast to the GUI, XUI is relatively easier to understand and use, it is suitable for
developing the Wizard-style interface. Such as POS machine, handhold terminal, ATM, and
so on customer-oriented terminals in public place.
XUI cannot implement a variety of special effects as the complicated GUI, but in
Wizard-style interface, it needs the simple and efficient GUI.
To put it simply, XUI programming is to draw and write by some keys.
1.2 Function
The functions of XUI list as following:
Supports black-and-white screen.
Supports monochrome font and gray font.
Supports touch screen.
Supports graphical display.
Supports multi-font display.
Supports bidirectional text display.
Supports translucent. (Alpha Channel)
Supports screenshot.
Supports output the screenshot to printer, that means implement the unity of the display
interface and print interface.
PAX Computer Technology (Shenzhen) Co., Ltd.
1
XUI Programming Guide
Supports multi-platform, including Linux framebuffer, X11, SDL, windows, android, ios,
but not limited to. And without operation system.
Supports rotational screen.
1.3 Feature
Imperative programming interface.
An unification of screen buttons and physical keys.
1.4 Thinking in XUI
How to make the XUI API? For users, they always want to use the simpler programming to
make the cooler interface, but the result is contradictory. So we try to give a more balanced
solution.
Firstly, see the design of the interface,
Button
RootWindow
Text
Normal
Two state
Presse
d
Draw SomeText
SubWindow
Background
Color
RootWindow
Background
Picture
RootWindow
Background
Color
SubWindow
Background
Picture
Design ideas shown as follow:
It only has three concepts of canvas, button and key value.
Canvas
It can have sub-canvas.
Text and picture can be painted on the canvas, and the buttons are also on the canvas.
It contains background picture and background color, the background will not be cleared
when CLS.
It must have a RootCanvas.
Button
2
PAX Computer Technology (Shenzhen) Co., Ltd.
Introduction
Buttons contains two states, normal and pressed.
Each state including the following parameters: border, background color, icon, text font,
text color and text content.
Parameter value of the button is set as “key”, when clicking it, users can get the key value
by function GetKey (). The button value and physical key value are in the same queue.
Key value
The button value and key value are in the same queue.
All windows have only one queue.
Not applicable to multithreading.
So when programming you just need to paint on the canvas, if needs dialog box, display a
sub-canvas, and close it after use.
For printer, only needs to create a hidden canvas for writing, and then sending a canvas
capture to the printer.
PAX Computer Technology (Shenzhen) Co., Ltd.
3
{ This page intentionally left blank }
Macro and Struct
2 Macro and Struct
2.1 Definition of Key values
Table 1 Definition of Key values
Macro
Value
Description
#define XUI_KEY1
2
/* 1 */
#define XUI_KEY2
3
/* 2 */
#define XUI_KEY3
4
/* 3 */
#define XUI_KEY4
5
/* 4 */
#define XUI_KEY5
6
/* 5 */
#define XUI_KEY6
7
/* 6 */
#define XUI_KEY7
8
/* 7 */
#define XUI_KEY8
9
/* 8 */
#define XUI_KEY9
10
/* 9 */
#define XUI_KEY0
11
/* 0 */
PAX Computer Technology (Shenzhen) Co., Ltd.
5
XUI Programming Guide
#define XUI_KEYCANCEL
223
/* Cancel */
#define XUI_KEYCLEAR
14
/* Clear */
#define XUI_KEYENTER
28
/* Enter */
#define XUI_KEYALPHA
69
/* Alpha */
#define XUI_KEYF1
59
#define XUI_KEYFUNC
102
#define XUI_KEYUP
103
#define XUI_KEYDOWN
108
#define XUI_KEYMENU
139
2.2 Macro Definition
Table 2 Macro Definition
Macro
Description
b
Blue channel
g
Green channel
r
Red channel
a
ALPHA channel
Table 3 XuiTransform Rotate
Macro
6
Description
XUI_ROTATE_0
Without rotating
XUI_ROTATE_90
rotating clockwise by 90degrees
XUI_ROTATE_180
rotating clockwise by 180degrees
XUI_ROTATE_270
rotating clockwise by 270degrees
PAX Computer Technology (Shenzhen) Co., Ltd.
Macro and Struct
XUI_FLIP_VERT
flip vertical
XUI_FLIP_HORIZ
flip horizontal
Table 4 XuiButtonStatType
Macro
Description
XUI_BTN_NORMAL
Normal state
XUI_BTN_PRESSED
Pressed State
Table 5 XuiBgStyle
Macro
Description
Normal, display the picture from the origin x, y.
XUI_BG_NORMAL
Tile
XUI_BG_TILE
Center
XUI_BG_CENTER
Stretch to four corner
XUI_BG_FOUR_CORNER
Table 6 XuiFontSet
Macro
Description
XUI_FONT_MONO
Monochrome font(black and white)
XUI_FONT_GREY
Grey font
Table 7 XuiTextStyle
Macro
XUI_TEXT_NORMAL
PAX Computer Technology (Shenzhen) Co., Ltd.
Description
Normal
7
XUI Programming Guide
XUI_BOLD
Bold
XUI_ITALIC
Italic
XUI_TEXT_BOLD_ITALIC
Bold and italic
Table 8 XuiSigPenFlat
Macro
Description
XUI_SIG_FLAT
Signing Board with smooth processing
XUI_SIG_NORMAL
The normal Signing Board without smooth processing
Table 9 XuiWindowType
Macro
Description
XUI_WIN_CANVAS
Canvas window
XUI_WIN_BUTTON
Button window
XUI_WIN_GIF
Gif window
XUI_WIN_SIGBOARD
Signing Board window
2.3 Other Macro Definition
#define XUI_RIGHT_X(_x, _width, _extend)
Get text in the right-most position within _width(text-align right)
#define XUI_CENTER_X(_x, _width, _extend)
Get text in the middle position within _width(text-align horizontal center)
#define XUI_CENTER_Y(_y, _height, _extend)
Get text in the middle position within _height (text-align vertical center)
2.4 Structure
Structure XuiWindow
8
PAX Computer Technology (Shenzhen) Co., Ltd.
Macro and Struct
Table 10 Structure XuiWindow
Structure
Description
width
the window width
height
the window height
widget
the window widget
type
Window type
key
Key values related to the window
Structure XuiImg
Table 11 Structure XuiImg
Structure
Description
width
Img width
height
Img height
priy
Img data pointer
Structure XuiButtonStat
Table 12 Structure XuiButtonStat
Structure
btn_round
Description
rounded corner(0 means has no rounded corner, 1 means has
rounded corner, and the default value is 0)
btn_bg
background color
Text
text
text_fg
text color
text_font
text font
text_x
text position:x
text_y
text position:y
text_height
text height(font size)
PAX Computer Technology (Shenzhen) Co., Ltd.
9
XUI Programming Guide
Img
Image
img_x
Image position:x
img_y
Image position:y
img_style
Image type
Structure XuiSigBoardStat
Table 13 Structure XuiSigBoardStat
Structure
btn_round
Description
rounded corner(0 means has no rounded corner, 1 means has
rounded corner, and the default value is 0)
btn_bg
Background color(Does not support transparent)
text
text
text_fg
text color
text_font
text font
text_x
Text position: x
text_y
Text position: y
text_height
Text height(font size)
img
Image
img_x
Image position: x
img_y
Image position: y
img_style
image type
pen_fg
pen color
pen_width
Pen width(ranges from 1 to 10)
pen_flat
Pen with flat processing
Structure XuiImeAttr
Table 14 Structure XuiImeAttr
10
PAX Computer Technology (Shenzhen) Co., Ltd.
Macro and Struct
Structure
Description
parent
Parent canvas(valid canvas pointer)
x
IME position x(greater than 0)
y
IME position y(greater than 0)
width
IME width(greater than 0)
height
IME height(greater than 4*(text_size+10))
text_font
IME text font(valid font pointer)
text_size
IME text size(greater than 12)
text_fg
IME text color
focus_fg
IME select the switched color
img
IME background image
Structure XuiGetStrAttr
Table 15 Structure XuiGetStrAttr
Structure
Description
parent
Parent canvas(valid canvas pointer)
x
Inputting position x(greater than 0)
y
Inputting position y(greater than 0)
font
Inputting text font(valid font pointer)
size
Inputting text size(greater than 12)
fg
Inputting text color
PAX Computer Technology (Shenzhen) Co., Ltd.
11
{ This page intentionally left blank }
XUI API
3 XUI API
3.1 XuiOpen
Prototype
int XuiOpen(int argc,
char **argv);
Function
Open XUI and initialize it.
Parameters
Return
Instruction
argc【Input】
Number of arguments
argv【Input】
Arguments list
0
Success
<0
Fail
The format supported for argv list as below:
FB=xxxxx.
Device node of framebuffer, the default is "/dev/graphics/fb0".
INPUT=xxxx
Input can have multiple device nodes, the default is
"/dev/input/event0".
ROTATE=xxx
Screen rotation (0,90,180, the default value is 0, using the default
value when value is invalid)
TSDEV=xxxx
Device node of touch screen, the default is "/dev/input/event2".
STATUSBAR=xxx
Height of the status bar(0-64,the default value is 0, using the default
PAX Computer Technology (Shenzhen) Co., Ltd.
13
XUI Programming Guide
value when value is invalid)
For example:
char *xui_argv[] = {"ROTATE=90","STATUSBAR=18"};
XuiOpen(sizeof(xui_argv)/sizeof(xui_argv[0]), xui_argv);
1.
2.
3.
Note
4.
5.
6.
When called XuiOpen for multiple times, only the first time takes effect,
the later calls will not work unless calling XuiClose.
When argc=0, argv=NULL, it will enable the default settings.
Xui does not support multi-process, when call XuiOpen in that case, they
will grab screen during operation on canvas.
Arguments in argv are independent of each other.
For argv, after set the ROTATE arguments, the left upper corner of the
screen was defined as coordinate origin of the subsequent operations for
API.
Other functions can take effect only after call Xuiopen successfully.
3.2 XuiIsRunning
Prototype
int XuiIsRunning(void);
Function
Check if the XUI is running.
Parameters
Return
None
1
running
0
Not running.
Instruction
3.3 XuiClose
Prototype
void XuiClose(void);
Function
Close the XUI.
Parameters
None
Return
None
Instruction
Call this function when the application exits.
3.4 XuiSuspend
14
Prototype
int XuiSuspend (void);
Function
Suspend the XUI.
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
Parameters
Return
Instruction
Note
None
0
Success
-1
Fail
When the application needs to call the other process and it also
occupied resource of fb and event, and then should call this function
to release resource. Otherwise, there will be two processes to operate
fb and receive event at the same time.
1. After the suspension, it needs to call XuiResume () to resume operation.
3.5 XuiResume
Prototype
int XuiResume (void);
Function
Resume running the XUI.
Parameters
Return
Instruction
None
0
Success
-1
Fail
Resume the running status from the suspended state.
After called XuiSuspend, it is no longer to receive keystrokes or
touch events, so it cannot response to the XuiResume (), but can only
active resume in program.
3.6 XuiRootCanvas
Prototype
XuiWindow *XuiRootCanvas(void);
Function
Get the RootCanvas.
Parameters
Return
Instruction
None
NULL
Error getting
else
Pointer of the RootCanvas
Call this function when requires to operate on the RootCanvas.
For example:
XuiWindow* root;
root= XuiRootCanvas();
XuiCanvasSetBackground(root,XUI_BG_NORMAL,img_bg,color_b
g);
PAX Computer Technology (Shenzhen) Co., Ltd.
15
XUI Programming Guide
3.7 XuiStatusbarCanvas
Prototype
XuiWindow * XuiStatusbarCanvas (void);
Function
Get the Canvas of StatusBar.
Parameters
Return
Instruction
None
NULL
Error getting
else
Pointer of the status bar canvas
Same as XuiRootCanvas ().
3.8 XuiCreateFont
Prototype
XuiFont *XuiCreateFont(char *fontfile,
int index,
XuiFontSet fontset);
Function
Create the font.
fontfile 【Input】 Path of the font file.
index
【Input】 Index of the font file.
Parameters
Font style, it supports monochrome and grey
Fontset 【Input】 modes.
Details see XuiFontSet.
Return
Instruction
NULL
Error getting
else
Font pointer
Call this function to create font when requires to display text.
For Example:
XuiFont *font_simsun_0;
font_simsun_0 = XuiCreateFont("/usr/font/paxfont.ttf", 0, 0);
1.
2.
3.
Note
4.
5.
16
Support the custom font and ttc/ttf vector font.
According to the fontfile, firstly, matches custom font by default, if not,
determine whether it is the ttf or ttc, if both are not, returns NULL.
The arguments index takes effect only when using the ttc font; it is used to
distinguish the font number. The index is invalid to custom font and ttf
font since there is only one font.
Users can call XuiDestroyFont () to destroy the created fonts which are no
longer need to use.
The custom font is created by fontextract, it can create highly
customizable bitmap fonts.
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
3.9 XuiDestroyFont
Prototype
void XuiDestroyFont(XuiFont *font);
Function
Destroy fonts.
Parameters
font【Input】
Return
Instruction
Font pointer
None
Destroy the fonts which created by XuiCreateFont ().
3.10 XuiCanvasDrawText
Prototype
int XuiCanvasDrawText(XuiWindow *window,
unsigned int x,
unsigned int y,
unsigned int height,
XuiFont *font,
XuiTextStyle textstyle,
XuiColor fg,
char *text);
Function
Display character string on the window canvas.
window 【Input】
Canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
height
【Input】
Text height
font
【Input】
Font, created by XuiCreateFont
Parameters
textstyle 【Input】
Return
Text style(bold,
XuiTextStyle
italic),
fg
【Input】
Font color
text
【Input】
Text (utf-8 encoding)
0
PAX Computer Technology (Shenzhen) Co., Ltd.
details
see
the
Success
17
XUI Programming Guide
<0
1.
Fail
Does not support auto linefeed or \n, \r linefeed. When the
displayed length is beyond the canvas, the excess part will not
display.
Instruction
2.
Text only supports utf-8 encoding; other formats should be
converted to utf-8 code to display properly.
3.
Window must be a valid canvas pointer, or it will lead to a crash.
The functions mentioned below are the same as it.
3.11 XuiCanvasDrawImg
Prototype
int XuiCanvasDrawImg(XuiWindow *window,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height,
XuiBgStyle bgstyle,
XuiImg *img);
Function
Display images on the window canvas.
window
【Input】 Canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width
【Input】 Image width
height
【Input】 Image height
bgstyle
【Input】 Background style, details see the XuiBgStyle.
img
【Input】 Image pointer
Parameters
Return
Instruction
18
0
Success
<0
Fail
img
must
be
the
valid
image
pointer
created
by
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
XuiImgLoadFormFile, otherwise the image may not show correctly.
3.12 XuiCanvasDrawRect
Prototype
int XuiCanvasDrawRect(XuiWindow *window,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height,
XuiColor fg,
int round,
int fill);
Function
Display rectangle on the window canvas.
Parameters
Return
window
【Input】 Canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width
【Input】 Rectangle width
height
【Input】 Rectangle height
Fg
【Input】 Foreground color
round
【Input】 1- rounded 0- rectangular
fill
【Input】 1- filled 0- hollowed
0
Success
<0
Fail
Instruction
3.13 XuiClearArea
Prototype
int XuiClearArea(XuiWindow *window,
unsigned int x,
PAX Computer Technology (Shenzhen) Co., Ltd.
19
XUI Programming Guide
unsigned int y,
unsigned int width,
unsigned int height);
Function
Clear the canvas area and display the background color.
window 【Input】
Parameters
Return
Instruction
Canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width
【Input】 Cleared width
height
【Input】
Cleared height
0
Success
<0
Fail
When multiple canvases overlapped, only clear the area which
specified by window.
3.14 XuiTextWidth
Prototype
int XuiTextWidth(XuiFont *font,
int size,
char *text);
Function
Get the text width.
Parameters
Return
Instruction
font 【Input】
The specified font
XuiCreateFont
size 【Input】
Font size
text 【Input】
Text string
20
created
by
Returns the string width.
Use it when set text for center or right alignment.
1.
Note
which
Font must be valid and created by XuiCreateFont; otherwise, it will
cause programs to crash.
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
2.
Text must be a valid string pointer.
3.
It only supports utf-8 encoding; other formats need to be converted to
utf-8 code firstly.
3.15 XuiCreateCanvas
Prototype
XuiWindow *XuiCreateCanvas(XuiWindow *parent,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
Function
Create canvas.
Parameters
Return
parent
【Input】 Parent canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width
【Input】 Canvas width
height
【Input】 Canvas height
NULL
Fail
else
Canvas pointer
1.
Parent must be a valid canvas pointer; the interfaces mentioned
below should be the same as it.
Instruction
2.
The new canvas will be displayed on the screen by calling
XuiShowWindow (), and the parent canvas will be covered.
3.16 XuiDestroyWindow
Prototype
void XuiDestroyWindow(XuiWindow *window);
Function
Destroy the window.
Parameters
window 【Input】
PAX Computer Technology (Shenzhen) Co., Ltd.
window
21
XUI Programming Guide
Destroy
Instruction
windows
which
created
by
XuiCreateCanvas(),
XuiCreateButton(), XuiCreateSinatureBoard() and XuiCreateGif().
Users should follow the principle: First create last destroyed, last create first
Note
destroyed.
3.17 XuiShowWindow
Prototype
void XuiShowWindow(XuiWindow *window,
int show,
int flag);
Function
Show or hide the window.
Parameters
Return
window
【Input】 window
show
【Input】
flag
【Input】 Extended parameter, it is unused, fill in 0.
1- show
0- hide
None
Instruction
3.18 XuiCanvasSetBackground
Prototype
void XuiCanvasSetBackground(XuiWindow *window,
XuiBgStyle bgstyle,
XuiImg *img,
XuiColor bg);
Function
Set the canvas background.
window
【Input】 Canvas
bgstyle
【Input】 Background style. Details see the XuiBgStyle.
img
【Input】 Image, NULL indicates has no image.
Parameters
bg
Return
22
Background color.
None
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
Instruction
Note
It will clear the screen.
1.
This interface only takes effects to the specified canvas.
2.
It does not support transparent in the background.
3.19 XuiCreateButton
Prototype
XuiWindow *XuiCreateButton(XuiWindow *parent,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
Function
Create button in canvas.
parent
Parameters
【Input】
Parent canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width 【Input】
width
height 【Input】
height
NULL
Fail
else
Button pointer
Return
Instruction
3.20 XuiButtonSetStat
Prototype
int XuiButtonSetStat(XuiWindow *window,
XuiButtonStatType type,
XuiButtonStat *stat);
Function
Set the button state.
Parameters
window
【Input】 Button
PAX Computer Technology (Shenzhen) Co., Ltd.
23
XUI Programming Guide
type
【Input】 state
stat
【Input】 state variable
0
Success
<0
Fail
Return
Instruction
It will take effect immediately after setting by XuiButtonSetStat().
Stat must be a valid state pointer, otherwise, it will lead to crashes. Interfaces
mentioned below should be the same as it.
Note
When text_font and text are NULL, the function can return correctly, but
doesn‟t show the text.
3.21 XuiButtonSetKey
Prototype
int XuiButtonSetKey(XuiWindow *window,
int key);
Function
Set the key value of the button.
window
【Input】 Button
key
【Input】 Key value (key>0)
Parameters
0
Success
<0
Fail
Return
Instruction
1.
2.
After release the button, you can get key values by XuiGetKey().
The value associate with the button must be greater than 0.
3.22 XuiCreateSignatureBoard
24
Prototype
XuiWindow * XuiCreateSignatureBoard (XuiWindow *parent,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
Function
Create the signature board.
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
Parameters
parent
【Input】 Parent canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width
【Input】 width
height
【Input】 height
NULL
Fail
else
Pointer of the signature board
Return
Instruction
When create signature board, there cannot be multiple canvases
overlapped.
3.23 XuiSigBoardSetStat
Prototype
int XuiSigBoardSetStat (XuiWindow *window,
XuiSigBoardStat *stat);
Function
Set the state of signature board.
window
【Input】 Signature board
stat
【Input】
Parameters
State variable, details refer to the structure
XuiSigBoardStat.
0
Success
<0
Fail
Return
1.
It
will
take
effect immediately
after
setting
by
XuiSigBoardSetStat().
2.
Instruction
For stat arguments, when the pen_flat is XUI_SIG_FLAT, it does
not support change the pen color and pen width.
3.
When text_font and text are NULL, the function can return
correctly, but doesn‟t show the text.
PAX Computer Technology (Shenzhen) Co., Ltd.
25
XUI Programming Guide
4.
The background of signature board does not support translucent.
3.24 XuiSigBoardImg
Prototype
XuiImg * XuiSigBoardImg(XuiWindow *window);
Function
Get the signature image.
Parameters
window
【Input】 Signature board
NULL
Fail
else
Image pointer
Return
Instruction
After using, call the XuiImgFree to destroy the image.
3.25 XuiCreateGif
Prototype
XuiWindow * XuiCreateGif (XuiWindow *parent,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height ,
const char* path);
Function
Create the gif animations.
parent
【Input】 Parent canvas
x
【Input】
The position x which relative to window
canvas
y
【Input】
The position y which relative to window
canvas
width
【Input】 width
height
【Input】 height
path
【Input】 path of Gif image
Parameters
Return
26
NULL
Fail
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
else
Pointer of gif window
Instruction
3.26 XuiHasKey
Prototype
int XuiHasKey(void);
Function
Check it whether has key.
Parameters
None
1
yes
0
no
Return
Instruction
3.27 XuiGetKey
Prototype
int XuiGetKey(void);
Function
Get the key.
Parameters
None
Return
Keys
Instruction
This function will wait till has a key to return.
3.28 XuiClearKey
Prototype
void XuiClearKey(void);
Function
Get the key buffer.
Parameters
None
Return
None
Clear the keys buffer queue, this buffer is a dynamic linked list and
Instruction
has no fixed length.
PAX Computer Technology (Shenzhen) Co., Ltd.
27
XUI Programming Guide
3.29 XuiCaptureScreen
Prototype
XuiImg *XuiCaptureScreen(void);
Function
Capture the screen.
Parameters
None
NULL
Fail
else
Pointer of image
Return
Instruction
After using, call XuiImgFree() to destroy the screenshot.
3.30 XuiCaptureCanvas
Prototype
XuiImg *XuiCaptureCanvas(XuiWindow *window,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
Function
Capture the canvas.
Parameters
window
【Input】 canvas
x
【Input】
The starting position x which relative to
window canvas
y
【Input】
The starting position y which relative to
window canvas
width
【Input】 width
height
【Input】 height
NULL
Fail
else
Pointer of image
Return
After using, call XuiImgFree() to destroy the image.
It will not capture the Button on the canvas.
Instruction
It is also applicable to the hidden canvas.
This function can generate images for printer.
28
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
If the width and height are greater than the width and height of
canvas, the generated image is defined as the value, whichever is the
minimum.
3.31 XuiImgLoadFormFile
Prototype
XuiImg *XuiImgLoadFormFile(const char *file);
Function
Load the image from a file.
Parameters
file
【Input】 The file path.
NULL
Fail
else
Pointer of image
Return
Instruction
Currently only supports bmp and png.
3.32 XuiImgSaveToFile
Prototype
int XuiImgSaveToFile(XuiImg *img,
const char *file);
Function
Save the image to a file.
img
【Input】 Image pointer
file
【Input】 The file path of the image to be saved
Parameters
0
Success
<0
Fail
Return
Instruction
Currently it only supports png.
3.33 XuiImgToRgba
Prototype
int XuiImgToRgba(XuiImg *img,
const char *rgba);
Function
Save the image to the rgba buffer.
Parameters
img
【Input】 Image pointer
PAX Computer Technology (Shenzhen) Co., Ltd.
29
XUI Programming Guide
rgba
【Input】 rgba buffer.
0
Success
<0
Fail
Return
1.
It does not check the buffer size, please distribute the buffer size
of 4* width * height.
Instruction
2.
Img must be a valid XuiImg pointer; the follows should be the
same.
3.34 XuiImgTransform
Prototype
int XuiImgTransform(XuiImg *img,
XuiTransform transform);
Function
Transform images.
img
【Input】 Image pointer
Parameters
transform 【Input】
Transform
mode.
XuiTransform.
0
Success
<0
Fail
See
the
macro
Return
Instruction
3.35 XuiImgFree
Prototype
void XuiImgFree(XuiImg *img);
Function
Destroy the image.
Parameters
Return
img
【Input】 Image pointer
None
Instruction
30
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
3.36 XuiSetStatusbarIcon
Prototype
int XuiSetStatusbarIcon(int index,
const char* path);
Function
Set the status bar icon.
index
【Input】
path
【Input】
Parameters
The specified icon labels, from left to right is
0-7.
Image path.
NULL means do not display the icon.
0
Success
-1
Fail
Return
1.
It takes effect after set STATUSBAR by the parameter argv of
XuiOpen.(that means has set the height of the status bar)
Instruction
2.
When the path is NULL or wrong, the original icon will be
hidden.
3.37 XuiGetHzString
Prototype
int XuiGetHzString(XuiImeAttr attr,
char *outstr,
int maxlen,
unsigned int timeout);
Function
It is a Chinese input function with the associational function, and also
can input English and numeric characters.
Attribute of the input method, see the structure
XuiImeAttr.
attr
【Input】
outstr
【Input】 Store the input string (ending with „‗\0‟)
maxlen
【Input】
timeout
【Input】
Parameters
PAX Computer Technology (Shenzhen) Co., Ltd.
The maximum length of the input string (the
maximum permissible value is 1024 bytes)
Timeout
value(0
means
no
timeout,
【unit:second】).
31
XUI Programming Guide
Return
0x00
Success
0xFE
Illegal parameter value.
0xFD
Timeout
1.
Press key 【 Alpha 】 to switch input methods (it can
switch among“PinYin-Chinese”,“uppercase”,“lowercase”,“area c
ode”)
2.
In the method of area code input, users can input Chinese
character according to the code.
3.
Input Chinese. Press the corresponding numeric key in turn in the
mode of PinYin-Chinese. For example, inputting the Chinese
character“中”, users should input “1466” successively, then press
【Enter】and key 【1】 to select the“中”.
Instruction
4.
Input alphabet. Press letter in the mode of “Abc” inputting, and it
will display on the screen, turn pages by pressing【Enter】, then
select the target character. For example, if you press key【1】
twice in succession, character “Q” will be inputted.
5.
Input number. Press number in the mode of “123” inputting, then
it will display on the screen.
6.
Press key【Clear】to clear the inputted characters.
7.
After inputting, press【Cancel】to exit the input method, and the
inputted character can be obtained from the arguments OutStr.
Parameter description of input method in attr:
1.
All of the pointers must be valid, such as font pointer, parent pointer and
so on.
Note
2.
X and y cannot be negative.
3.
Text_size must range from 12 to 40. (12 < Text_size < 40)
4.
Height must be greater than 4*(text_size+10).
5.
It does not support transparent in the background
3.38 XuiGetString
Prototype
32
int XuiGetString(XuiGetStrAttr attr,
char *outstr,
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI API
unsigned char mode,
int minlen,
int maxlen);
Function
Parameters
Input the character string and it can display on the screen with the
specified mode, and also can input letter, amount and password.
Attribution, details
XuiImeAttr.
see
the
structure
attr
【Input】
outstr
【Input】 Store the input string (ending with „‗\0‟)
mode
D7 1(0)
reserved
D6 1(0)
reserved
D5 1(0)
whether input numbers
D4 1(0)
whether input letters
【Input】 D3 1(0)
„*‟
whether the ciphertext displays as
D2 1(0)
left(right)-aligned input
D1 1(0)
whether has a decimal point
D0 1(0)
reserved
Minlen
【Input】 The minimum length of the input string.
maxlen
【Input】
The maximum length of the input string (the
maximum permissible value is 128 bytes)
0x00
Normally complete the input
0xFE
Illegal parameter value (including the mode
value is illegal; MaxLen =0; and the initial
digital string is illegal.)
0xFD
Inputting timeout (120 seconds, and this value
is invariant.)
Return
Instruction
PAX Computer Technology (Shenzhen) Co., Ltd.
33
{ This page intentionally left blank }
Note
4 Note
4.1 Multi-process Supports
Currently, the XUI does not support multi-process, because they will grab screen when
running at the same time.
If requires to run multiple processes at the same time, users can implement it by the
remote call. Using a main process to manage the screen, and create canvas for each process,
switch screens of the multiple processes.
4.2 XuiDestroyWindow
Note that other resources used by the window should be destroyed after calling
XuiDestroyWindow (). So destroy window firstly and then resource (such as image, font)
followed.
Please abide to this principle: First create last destroyed, last create first destroyed.
For example:
The right way to destroy:
//create
font_simsun_0 = XuiCreateFont ("./res/fallback.ttf", 0, 0);
img_bg = XuiImgLoadFormFile ("./res/bg.png");
btn = XuiCreateButton(XuiRootCanvas(), 10, 50, 220, 30);
PAX Computer Technology (Shenzhen) Co., Ltd.
35
XUI Programming Guide
//destroy
XuiDestroyWindow(btn);
XuiImgFree(img_bg);
XuiDestroyFont(font_simsun_0);
The wrong way to destroy:
//create
font_simsun_0 = XuiCreateFont ("./res/fallback.ttf", 0, 0);
img_bg = XuiImgLoadFormFile ("./res/bg.png");
btn = XuiCreateButton(XuiRootCanvas(), 10, 50, 220, 30);
//destroy
XuiImgFree(img_bg);
XuiDestroyFont(font_simsun_0);
XuiDestroyWindow(btn);
36
PAX Computer Technology (Shenzhen) Co., Ltd.
FAQ
5 FAQ
1.
The root canvas exists after open the XUI, so can we directly call the function to get the
root canvas? Does the root canvas can be destroyed?
Answer: Users can call XuiRootCanvas () to get the root canvas, but cannot be destroyed. In
additional, if the XUIOpen () has set the status bar, the status bar canvas exists after calling
the XUIOpen (), users can directly operate the status bar by XuiStatusbarCanvas (), and the
canvas cannot be destroyed.
2.
Does it support canvas nesting? For example, Root canvas-> sub-canvas 1 -> sub-canvas
2-> sub-canvas 3-> ... -> sub-canvas N? Is there a limit to N?
Answer: Yes, it supports nesting, and even has no any limitation, but users need to manage
XuiWondow pointer of each canvas. Follow the principle to destroy windows: First create last
destroyed, last create first destroyed.
3.
Does the canvas support using the ShowWindow to display?
Answer: Yes.
4.
Does it need to call DestoryWindow () to release the signature boar?
Answer: Yes, the types which return XuiWindow* need to be destroyed, but except
XuiRootCanvas () and XuiStatusbarCanvas (), since they will be destroyed automatically.
PAX Computer Technology (Shenzhen) Co., Ltd.
37
XUI Programming Guide
5.
When displaying images, how to adjust the image size? Stretch or fill?
Answer: Do not stretch. If the image size is larger than the display area, it only displays the
part which is in the area. If the image size is smaller than the display area, the blank space fills
the background color.
6.
When call ClearArea (), does it clear contents in the upmost layer or all contents of the
multiple layers? Or just using the background color to cover this area?
Answer: It depends on the arguments XuiWindow *window, you can set the canvas pointer
of the layer which you want to clear, and it will display the canvas background.
38
PAX Computer Technology (Shenzhen) Co., Ltd.
XUI Progrramm
ming G
Guide
e
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.6 Linearized : No Author : wangfen Create Date : 2013:11:26 08:54:54Z Modify Date : 2013:11:27 17:50:24+08:00 Subject : V 2.0.0 Language : zh-CN Tagged PDF : Yes XMP Toolkit : Adobe XMP Core 4.2.1-c041 52.342996, 2008/05/07-20:48:00 Format : application/pdf Creator : wangfen Description : V 2.0.0 Title : XUI Programming Guide Creator Tool : Microsoft® Office Word 2007 Metadata Date : 2013:11:27 17:50:24+08:00 Producer : Microsoft® Office Word 2007 Document ID : uuid:e742ba53-2750-45c1-b84b-3b0300b8e59c Instance ID : uuid:a62e58fa-065b-4ad2-a428-393c38e56df7 Page Count : 47EXIF Metadata provided by EXIF.tools