eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_label.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #include "d4d.h"
48 
49 
50 // Internal API
53 
55 {
56  D4D_DEFSTR("Label"),
58  NULL,
60 };
61 
62 typedef struct
63 {
64  D4D_POINT position;
65  D4D_GEOMETRY contentGeom;
66 } D4D_LBL_TMP_VAL;
67 
68 #define _calc (*((D4D_LBL_TMP_VAL*)d4d_scratchPad))
69 
70 
71 static void D4D_LblValue2Coor(D4D_OBJECT* pThis)
72 {
73  _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position);
74  D4D_ComputeGeometry(&_calc.contentGeom, pThis);
75 }
76 
77 
78 
79 /*******************************************************
80 *
81 * LABEL Drawing routine
82 *
83 *******************************************************/
84 
85 static void D4D_LabelOnDraw(D4D_MESSAGE* pMsg)
86 {
87  D4D_OBJECT* pThis = pMsg->pObject;
88  D4D_LABEL* pLbl = D4D_GET_LABEL(pThis);
89  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
90  D4D_COLOR clrT, clrB;
91 
92  D4D_LblValue2Coor(pThis);
93 
94  clrT = D4D_ObjectGetForeColor(pThis, draw);
95  clrB = D4D_ObjectGetBckgColor(pThis, draw);
96 
97  // Draw the frame
99  D4D_DrawFrame(pThis, clrT, clrB);
100 
101  // draw the text
102  if(pLbl->textBuff.pText)
103  D4D_DrawTextRRect(&_calc.contentGeom.pnt, &_calc.contentGeom.sz, &pLbl->textBuff, clrT, clrB, pThis->radius);
104 }
105 
106 /**************************************************************/
116 /*******************************************************
117 *
118 * The LABEL message handler
119 *
120 *******************************************************/
121 
123 {
124  switch(pMsg->nMsgId)
125  {
126  case D4D_MSG_DRAW:
127  D4D_LabelOnDraw(pMsg);
128  break;
129 #ifdef D4D_LLD_TCH
130  case D4D_MSG_TOUCHED:
131  D4D_FocusSet(pMsg->pScreen, pMsg->pObject);
132  break;
133 #endif
134  default:
135  // call the default behavior of all objects
136  D4D_ObjOnMessage(pMsg);
137  }
138 }
139 
140 /*******************************************************
141 *
142 * The LABEL check coordinators handler
143 *
144 *******************************************************/
145 
146 /**************************************************************/
152 {
153  return &(D4D_GET_LABEL(pThis)->textBuff);
154 }
D4D_COLOR D4D_ObjectGetBckgColor(D4D_OBJECT *pObj, D4D_OBJECT_DRAWFLAGS draw)
Function return object current background color.
Definition: d4d_scheme.c:185
const D4D_OBJECT_SYS_FUNCTION d4d_labelSysFunc
Definition: d4d_label.c:54
D4D_COLOR D4D_ObjectGetForeColor(D4D_OBJECT *pObj, D4D_OBJECT_DRAWFLAGS draw)
Function return object current fore color.
Definition: d4d_scheme.c:161
Type definition of eGUI point structure.
Definition: d4d_types.h:223
D4D object messages structure.
Definition: d4d_base.h:400
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
void D4D_DrawFrame(D4D_OBJECT *pObject, D4D_COLOR clrT, D4D_COLOR clrB)
Function draw standard object frame based on the object settings and current state.
void D4D_LabelOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_label.c:122
struct D4D_OBJECT_S * pObject
Pointer to object who is receiver of this message. If the receiver is just screen this field must be ...
Definition: d4d_base.h:402
D4D Driver main header file.
#define _calc
Definition: d4d_label.c:68
static void D4D_LblValue2Coor(D4D_OBJECT *pThis)
Definition: d4d_label.c:71
#define D4D_OBJECT_DRAWFLAGS_COMPLETE
Draw complete flag.
Definition: d4d_base.h:361
D4D Driver private header file.
#define D4D_DEFSTR(str)
Macro that helps declare the strings in eGUI.
Definition: d4d_string.h:246
D4D_POINT position
Position on the screen/object.
Definition: d4d_object.h:169
#define D4D_OBJECT_DRAWFLAGS_STATE
Draw just change of state flag.
Definition: d4d_base.h:364
D4D_COOR radius
Object corners radius.
Definition: d4d_object.h:171
#define D4D_GET_LABEL(pObj)
Definition: d4d_label.h:97
void D4D_ObjOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_object.c:443
void D4D_FocusSet(const D4D_SCREEN *pScreen, D4D_OBJECT_PTR pObject)
The function set the obejct focus to new object.
Definition: d4d_screen.c:430
static void D4D_LabelOnDraw(D4D_MESSAGE *pMsg)
Definition: d4d_label.c:85
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
D4D_TCHAR * pText
pointer to text array
Definition: d4d_string.h:102
D4D_STRING * D4D_LabelGetTextBuffer(D4D_OBJECT *pThis)
Definition: d4d_label.c:151
D4D_MSGID nMsgId
Type of message.
Definition: d4d_base.h:404
D4D_POINT D4D_GetClientToScreenPoint(D4D_OBJECT *pObject, D4D_POINT *nClientPoint)
The function convert client point on the screen to the global screen point.
Definition: d4d_screen.c:536
The object main structure type definition.
Definition: d4d_object.h:167
Draw message - is send when the object should be redrawed.
Definition: d4d_base.h:371
void D4D_ComputeGeometry(D4D_GEOMETRY *pGeometry, D4D_OBJECT *pObject)
Definition: d4d_base.c:1047
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
Touched message - is send when the object is touched by touch screen driver.
Definition: d4d_base.h:379
#define D4D_DrawTextRRect(ppt, psz, buffText, colorText, colorBkgd, radius)
Function that draw text into defined rectangle on the screen with corner radius.
D4D_OBJECT_DRAWFLAGS draw
Contains draw flags - is valid with D4D_MSG_DRAW and D4D_MSG_DRAWDONE message.
Definition: d4d_base.h:408
Type definition of eGUI geometry structure.
Definition: d4d_types.h:237
D4D_STRING textBuff
Definition: d4d_label.h:88
Byte D4D_OBJECT_DRAWFLAGS
Drawing object flags type, handled to object in D4D_MSG_DRAW events.
Definition: d4d_base.h:359
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
struct D4D_SCREEN_S * pScreen
Pointer to screen who is receiver of this message.
Definition: d4d_base.h:403
union D4D_MESSAGE_S::@0 prm
Additional data for some type of messages.