Guiliani  Version 2.6 revision 7293 (documentation build 12)
GUICalendar.h
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#ifndef GUICALENDAR_H
11#define GUICALENDAR_H
12
13#include "GUIObject.h"
14#include "GUIColorPropertyObserver.h"
15
16#include "GUIFontResource.h"
17#include "GUIImageResource.h"
18#include "GUITextResource.h"
19#include "GUINinePatch.h"
20
36{
37public:
47 CGUICompositeObject* const pkParent,
48 const eC_Value& vX, const eC_Value& vY,
49 const eC_Value& vWidth, const eC_Value& vHeight,
50 const ObjectHandle_t &eID = NO_HANDLE);
51
54
55 virtual ~CGUICalendar();
56
57 virtual void OnNotification();
58
59 virtual eC_Bool IsHighlightable() const { return false; }
60
61#if defined(GUILIANI_STREAM_GUI)
66 virtual void ReadFromStream();
67#endif
68
69#if defined(GUILIANI_WRITE_GUI)
75 virtual void WriteToStream(const eC_Bool bWriteClassID = false);
76#endif
77
78 virtual void SetWidth(const eC_Value& vX);
79
80 virtual void SetHeight(const eC_Value& vY);
81
82 virtual eC_Bool DoButtonDown(
83 const eC_Value& vAbsX,
84 const eC_Value& vAbsY);
85
86 virtual eC_Bool DoDrag(
87 const eC_Value& vDeltaX,
88 const eC_Value& vDeltaY,
89 const eC_Value& vAbsX,
90 const eC_Value& vAbsY);
91
92 virtual eC_Bool DoDragEnd(
93 const eC_Value& vAbsX,
94 const eC_Value& vAbsY);
95
96 virtual eC_Bool DoClick(
97 const eC_Value& vAbsX,
98 const eC_Value& vAbsY);
99
104 void SetImages(const ImageResource_t& eBackgroundImage, const ImageResource_t& eMarkerImage);
105
110 void GetImages(ImageResource_t& eBackgroundImage, ImageResource_t& eMarkerImage) const;
111
116
121
126 void SetDaySize(const eC_Value& vDayWidth, const eC_Value& vDayHeight);
127
132 void GetDaySize(eC_Value& vDayWidth, eC_Value& vDayHeight) const;
133
136 void SetHeadlineColor(const eC_UInt& uiHeadlineColor);
137
140 void SetHeadlineColor(const GlobalProperty_t& eHeadlineColor);
141
144 eC_UInt GetHeadlineColor() const;
145
149 void SetShowHeadLine(const eC_Bool& bShowHeadLine);
150
154 eC_Bool GetShowHeadLine() const;
155
159 void SetHeadlineHeight(const eC_Value& vHeadlineHeight);
160
164 eC_Value GetHeadlineHeight() const;
165
169 void SetHeadlineFont(const FontResource_t& eHeadlineFont);
170
175
178 void SetFontColor(const eC_UInt& uiFontColor);
179
182 void SetFontColor(const GlobalProperty_t& eFontColor);
183
186 eC_UInt GetFontColor() const;
187
191 void SetFont(const FontResource_t& eFont);
192
197
200 void SetInactiveFontColor(const eC_UInt& uiInactiveFontColor);
201
204 void SetInactiveFontColor(const GlobalProperty_t& eInactiveFontColor);
205
208 eC_UInt GetInactiveFontColor() const;
209
213 void SetInactiveFont(const FontResource_t& eInactiveFont);
214
219
223 void SetShowWeekDays(const eC_Bool& bShowWeekDays);
224
228 eC_Bool GetShowWeekDays() const;
229
233 void SetFirstDayOfWeek(const eC_UByte& ubFirstDayOfWeek);
234
238 eC_UByte GetFirstDayOfWeek() const;
239
243 void SetFillEmptySpaces(const eC_Bool& bFillEmptySpaces);
244
248 eC_Bool GetFillEmptySpaces() const;
249
254 void SetTouchControl(const eC_Bool& bTouchControl);
255
259 eC_Bool GetTouchControl() const;
260
265 void SetMonthText(const eC_UByte& ubIndex, const TextResource_t& eTextID);
266
271 void SetMonthText(const eC_UByte& ubIndex, const eC_String& kTextString);
272
277 eC_String GetMonthText(const eC_UByte& ubIndex) const;
278
283 void SetDayText(const eC_UByte& ubIndex, const TextResource_t& eTextID);
284
289 void SetDayText(const eC_UByte& ubIndex, const eC_String& kTextString);
290
295 eC_String GetDayText(const eC_UByte& ubIndex) const;
296
302 void SetDate(const eC_UByte& ubDay, const eC_UByte& ubMonth, const eC_UInt& uiYear);
303
309 void GetDate(eC_UByte& ubDay, eC_UByte& ubMonth, eC_UInt& uiYear);
310
314
317 void NextMonth();
318
322
325 void NextYear();
326
327protected:
328 virtual eC_Bool DoDraw();
329
330private:
331 void Init();
332
333 void DeInit();
334
335 eC_Bool IsValidInput(const eC_UByte& ubDay, const eC_UByte& ubMonth, const eC_UInt& uiYear) const;
336
337 void UpdateValues();
338
339#if defined(GUILIANI_STREAM_GUI)
340 void ReadTexts();
341#endif
342
343#if defined(GUILIANI_WRITE_GUI)
344 void WriteTexts();
345#endif
346
347 void RefreshTexts();
348
349 void PrintDayCentered(const eC_String& kDay, const eC_Value& vX, const eC_Value& vY, const eC_Value& vAdvanceX, const eC_Value& vAdvanceY);
350
351 static eC_Bool IsLeapYear(eC_UInt uiYear);
352
353 static eC_UByte CalculateNumberOfDays(eC_UByte ubMonth, eC_UInt uiYear);
354
355 static eC_UByte CalcWeekdayFromDate(eC_UByte ubDay, eC_UByte ubMonth, eC_UInt uiYear);
356
357private:
358 static const eC_UInt INDEX_HEADLINECOLOR;
359 static const eC_UInt INDEX_ACTIVECOLOR;
360 static const eC_UInt INDEX_INACTIVECOLOR;
361
362 // streamed members
363 eC_UByte m_ubDay;
364 eC_UByte m_ubMonth;
365 eC_UInt m_uiYear;
366
367 eC_Value m_vDayWidth;
368 eC_Value m_vDayHeight;
369
370 eC_Bool m_bShowHeadLine;
371 eC_Value m_vHeadlineHeight;
372 FontResource_t m_eHeadlineFontID;
373
374 ImageResource_t m_eBackgroundImageID;
375 CGUINinePatch m_kBackground;
376
377 ImageResource_t m_eMarkerImageID;
378 CGUINinePatch m_kMarker;
379
380 FontResource_t m_eFontID;
381 FontResource_t m_eInactiveFontID;
382
383 eC_Bool m_bShowWeekDays;
384
385 eC_UByte m_ubFirstDayOfWeek;
386 eC_Bool m_bFillEmptySpaces;
387
388 eC_Bool m_bTouchControl;
389
390 // texts for months and days
391 TextResource_t m_eTextMonths[12];
392 eC_String m_kTextMonths[12];
393 TextResource_t m_eTextDays[7];
394 eC_String m_kTextDays[7];
395
396 // internal members
397 eC_UByte m_ubFirstWeekDayOfMonth;
398 eC_UByte m_ubNumberOfDays;
399 eC_Value m_vAdvanceX;
400 eC_Value m_vAdvanceY;
401 eC_Value m_vDragStartX;
402 eC_Value m_vDragStartY;
403 eC_Value m_vYOffset;
404 eC_UByte m_ubStartCell;
405};
406
407#endif
Helper Macros in Guiliani
FontResource_t
List of font resource ids.
Definition: GUIFontResource.h:54
Helper Macros in Guiliani
ImageResource_t
Enumeration of image resource ids.
Definition: GUIImageResource.h:126
ObjectHandle_t
List of object resource ids.
Definition: GUIObjectHandleResource.h:55
GlobalProperty_t
List of property resource ids.
Definition: GUIPropertyResource.h:67
Helper Macros in Guiliani
TextResource_t
List of text resource ids.
Definition: GUITextResource.h:40
Calendar-widget for easy access.
Definition: GUICalendar.h:36
eC_UInt GetHeadlineColor() const
virtual eC_Bool IsHighlightable() const
Definition: GUICalendar.h:59
eC_UByte GetFirstDayOfWeek() const
eC_Bool GetShowWeekDays() const
virtual void SetWidth(const eC_Value &vX)
eC_Bool GetTouchControl() const
CGUICalendar(CGUICompositeObject *const pkParent, const eC_Value &vX, const eC_Value &vY, const eC_Value &vWidth, const eC_Value &vHeight, const ObjectHandle_t &eID=NO_HANDLE)
eC_String GetMonthText(const eC_UByte &ubIndex) const
void NextMonth()
virtual eC_Bool DoClick(const eC_Value &vAbsX, const eC_Value &vAbsY)
void SetImages(const ImageResource_t &eBackgroundImage, const ImageResource_t &eMarkerImage)
virtual void SetHeight(const eC_Value &vY)
void SetShowHeadLine(const eC_Bool &bShowHeadLine)
void SetMonthText(const eC_UByte &ubIndex, const TextResource_t &eTextID)
void SetTouchControl(const eC_Bool &bTouchControl)
virtual eC_Bool DoDragEnd(const eC_Value &vAbsX, const eC_Value &vAbsY)
FontResource_t GetInactiveFont() const
virtual eC_Bool DoButtonDown(const eC_Value &vAbsX, const eC_Value &vAbsY)
eC_UInt GetFontColor() const
void GetDate(eC_UByte &ubDay, eC_UByte &ubMonth, eC_UInt &uiYear)
virtual void OnNotification()
Called by CGUISubject whenever an observed object triggers an update.
void GetDaySize(eC_Value &vDayWidth, eC_Value &vDayHeight) const
virtual void WriteToStream(const eC_Bool bWriteClassID=false)
CGUINinePatch GetMarkerNinePatch()
void SetHeadlineColor(const eC_UInt &uiHeadlineColor)
void SetHeadlineColor(const GlobalProperty_t &eHeadlineColor)
CGUICalendar()
Default constructor to be used by the factory.
void PreviousMonth()
void SetInactiveFontColor(const eC_UInt &uiInactiveFontColor)
eC_Bool GetShowHeadLine() const
FontResource_t GetHeadlineFont() const
void SetDate(const eC_UByte &ubDay, const eC_UByte &ubMonth, const eC_UInt &uiYear)
void SetDaySize(const eC_Value &vDayWidth, const eC_Value &vDayHeight)
void SetInactiveFont(const FontResource_t &eInactiveFont)
void SetShowWeekDays(const eC_Bool &bShowWeekDays)
void SetFontColor(const eC_UInt &uiFontColor)
void SetFirstDayOfWeek(const eC_UByte &ubFirstDayOfWeek)
void GetImages(ImageResource_t &eBackgroundImage, ImageResource_t &eMarkerImage) const
void SetInactiveFontColor(const GlobalProperty_t &eInactiveFontColor)
void SetFont(const FontResource_t &eFont)
void SetDayText(const eC_UByte &ubIndex, const TextResource_t &eTextID)
void SetDayText(const eC_UByte &ubIndex, const eC_String &kTextString)
eC_UInt GetInactiveFontColor() const
virtual eC_Bool DoDrag(const eC_Value &vDeltaX, const eC_Value &vDeltaY, const eC_Value &vAbsX, const eC_Value &vAbsY)
void NextYear()
void SetMonthText(const eC_UByte &ubIndex, const eC_String &kTextString)
CGUINinePatch GetBackgroundNinePatch()
void SetFontColor(const GlobalProperty_t &eFontColor)
virtual eC_Bool DoDraw()
void SetFillEmptySpaces(const eC_Bool &bFillEmptySpaces)
FontResource_t GetFont() const
eC_Value GetHeadlineHeight() const
void SetHeadlineFont(const FontResource_t &eHeadlineFont)
void SetHeadlineHeight(const eC_Value &vHeadlineHeight)
eC_String GetDayText(const eC_UByte &ubIndex) const
void PreviousYear()
virtual void ReadFromStream()
eC_Bool GetFillEmptySpaces() const
This observer provides the base-interface for controls when using color-properties.
Definition: GUIColorPropertyObserver.h:23
This is the Guiliani base class for all composite objects.
Definition: GUICompositeObject.h:70
Helper class to for storing Nine-Patch images.
Definition: GUINinePatch.h:41
This is the Guiliani base class all controls are derived from.
Definition: GUIObject.h:81