eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_group_box.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 //Internal API
52 
54 {
58  D4D_GROUP_BOX_FRAME_MARGIN
59 };
60 
62 {
63  D4D_DEFSTR("Group Box"),
65  NULL,
66  NULL
67 };
68 
69 /*******************************************************
70 *
71 * GROUP_BOX Drawing routine
72 *
73 *******************************************************/
74 
75 static void D4D_GroupBoxOnDraw(D4D_MESSAGE* pMsg)
76 {
77  D4D_OBJECT* pThis = pMsg->pObject;
78  D4D_GROUP_BOX* pGroupBox = D4D_GET_GROUP_BOX(pMsg->pObject);
79 
80  D4D_POINT pnt = D4D_GetClientToScreenPoint(pThis, &pThis->position);
81  D4D_POINT pntLoc = pnt;
82  D4D_SIZE size;
84  D4D_COLOR clrT = D4D_ObjectGetForeColor(pThis, pMsg->prm.draw);
85 
86  // only draw if complete draw is needed
88  {
89  D4D_FillRRect(&pntLoc, &pThis->size, clrB, pThis->radius);
90  }
91 
92  // Draw the frame
94  D4D_DrawFrame(pThis, clrT, clrB);
95 
96 
97  // Draw Focus rect
98 
100  {
101  pntLoc.x += (pThis->pMargin->left / 2);
102  pntLoc.y += (pThis->pMargin->top / 2);
103  size = pThis->size;
104  size.cx -= ((pThis->pMargin->left + pThis->pMargin->right) / 2);
105  size.cy -= ((pThis->pMargin->top + pThis->pMargin->bottom) / 2);
106 
107  #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
108  if(pThis->radius)
109  {
110  D4D_COOR radius = 0;
111  if(pThis->radius - (pThis->pMargin->left / 2) > 0)
112  radius = (D4D_COOR)(pThis->radius - (pThis->pMargin->left / 2));
113 
115  }
116  else
117  #endif
119  }
120 
121 
122  if(pGroupBox->textBuff.pText)
123  {
124  D4D_COOR activeSize = 2 * D4D_GROUP_BOX_TEXT_OFFSET;
125 
126  #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
127  activeSize += (D4D_COOR)(pThis->radius * 2);
128  #endif
129 
131  activeSize += D4D_BEVEL_WIDTH * 2;
132 
133  size.cy = pThis->pMargin->top;
134  size.cx = (D4D_COOR)(D4D_GetTextWidth(pGroupBox->textBuff.fontId, pGroupBox->textBuff.pText) + (2 * D4D_GROUP_BOX_TEXT_OFFSET));
135 
137  size.cx += D4D_BEVEL_WIDTH * 2;
138 
139  if(size.cx > (pThis->size.cx - activeSize))
140  size.cx = (D4D_COOR)(pThis->size.cx - activeSize);
141 
143 
145  {
146  pnt.x += D4D_BEVEL_WIDTH;
147  pnt.y += D4D_BEVEL_WIDTH;
148 
149  if(size.cy - D4D_BEVEL_WIDTH > 0)
150  size.cy -= D4D_BEVEL_WIDTH;
151  else
152  size.cy = 0;
153  }
154 
155  #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
156  if(pThis->radius)
157  pnt.x += pThis->radius;
158  #endif
159 
160  D4D_DrawTextRect(&pnt, &size, &pGroupBox->textBuff, clrT, clrB);
161  }
162 
163  // draw the bitmap
164 #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
165 #else
166 #endif
167 }
168 
169 /**************************************************************/
179 /*******************************************************
180 *
181 * The main GROUP_BOX message handler
182 *
183 *******************************************************/
184 
186 {
187  switch(pMsg->nMsgId)
188  {
189  case D4D_MSG_DRAW:
190  D4D_GroupBoxOnDraw(pMsg);
191  break;
192 
193  default:
194  // call the default behavior
195  D4D_ObjOnMessage(pMsg);
196  }
197 }
#define D4D_GROUP_BOX_F_CONTENT_OUTLINE
Enable group box content outline.
Definition: d4d_group_box.h:69
#define D4D_BEVEL_BCKG_INTENSITY
D4D_BEVEL_BCKG_INTENSITY constant default declaration. Sets the percentual change of color for bevel ...
D4D_STRING textBuff
D4D_COLOR D4D_ObjectGetBckgFillColor(D4D_OBJECT *pObj)
Function return object current fill background color.
Definition: d4d_scheme.c:225
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_COOR left
Margin of left side.
Definition: d4d_types.h:246
D4D_STRING * D4D_GroupBoxGetTextBuffer(D4D_OBJECT *pThis)
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
D4D_OBJECT_INITFLAGS initFlags
The initializations object flags.
Definition: d4d_object.h:178
#define D4D_DrawTextRect(ppt, psz, buffText, colorText, colorBkgd)
Function that draw text into defined rectangle on the screen.
D4D_FONT fontId
index of used font
Definition: d4d_string.h:104
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.
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.
void D4D_Rect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_LINETYPE ltype, D4D_COLOR color)
Function draw rectangle on the screen.
#define D4D_GROUP_BOX_HEADER_MARGIN
This is margin of group box header (to keep place for title text) If not defined, it sets to 16 pixel...
Definition: d4d_group_box.h:89
#define D4D_OBJECT_DRAWFLAGS_COMPLETE
Draw complete flag.
Definition: d4d_base.h:361
#define D4D_GET_GROUP_BOX(pObj)
D4D Driver private header file.
#define D4D_DEFSTR(str)
Macro that helps declare the strings in eGUI.
Definition: d4d_string.h:246
D4D_COOR cx
Size in axis X (width)
Definition: d4d_types.h:232
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
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
D4D_COOR bottom
Margin of bottom side.
Definition: d4d_types.h:249
void D4D_ObjOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_object.c:443
const D4D_OBJECT_SYS_FUNCTION d4d_groupBoxSysFunc
Definition: d4d_group_box.c:61
D4D_COLOR D4D_ChangeColorIntesity(D4D_COLOR color, sByte intensity)
Compute change of color intesity.
Definition: d4d_scheme.c:286
D4D_COOR right
Margin of right side.
Definition: d4d_types.h:248
#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_COOR y
Coordination in axis Y.
Definition: d4d_types.h:226
D4D_MSGID nMsgId
Type of message.
Definition: d4d_base.h:404
D4D_SIZE size
Size of the object.
Definition: d4d_object.h:170
void D4D_RRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_LINETYPE ltype, D4D_COLOR color, D4D_COOR radius)
Function draw rectangle on the screen with round corners.
#define D4D_GROUP_BOX_FRAME_MARGIN
This is margin of group box rest frame (left, right and bottom) If not defined, it sets to 4 pixel as...
Definition: d4d_group_box.h:95
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
#define D4D_BEVEL_WIDTH
D4D_BEVEL_WIDTH constant declaration - can&#39;t be changed!
Draw message - is send when the object should be redrawed.
Definition: d4d_base.h:371
D4D_MARGIN groupBox_marginDefault
Definition: d4d_group_box.c:53
D4D_COOR cy
Size in axis Y (height)
Definition: d4d_types.h:233
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
Type definition of eGUI size structure.
Definition: d4d_types.h:230
#define D4D_GROUP_BOX_TEXT_OFFSET
This is offset of title text in horizontal line If not defined, it sets to 6 pixel as a default...
Definition: d4d_group_box.h:83
D4D_COOR D4D_GetTextWidth(D4D_FONT ix, D4D_TCHAR *pText)
The function returns width of text in pixels.
Definition: d4d_string.c:357
D4D_OBJECT_DRAWFLAGS draw
Contains draw flags - is valid with D4D_MSG_DRAW and D4D_MSG_DRAWDONE message.
Definition: d4d_base.h:408
void D4D_FillRRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_COLOR color, D4D_COOR radius)
Function draw filled rectangle on the screen with round corners.
Line type thin.
Definition: d4d_types.h:293
D4D_MARGIN * pMargin
Object inner margin.
Definition: d4d_object.h:172
#define D4D_OBJECT_F_BEVEL_MASK
Object bevel border mask.
Definition: d4d_object.h:81
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
void D4D_GroupBoxOnMessage(D4D_MESSAGE *pMsg)
D4D_COOR top
Margin of top side.
Definition: d4d_types.h:247
D4D_COOR x
Coordination in axis X.
Definition: d4d_types.h:225
union D4D_MESSAGE_S::@0 prm
Additional data for some type of messages.
Type definition of eGUI client area margin structure.
Definition: d4d_types.h:244
static void D4D_GroupBoxOnDraw(D4D_MESSAGE *pMsg)
Definition: d4d_group_box.c:75