CGfxWrapeGML* pkWrap = dynamic_cast<CGfxWrapeGML*>(&GETGFX);
if (NULL != pkWrap)
{
eGML_Screen* pkScreen = pkWrap->GetScreen();
unsigned short* memory = (unsigned short*)pkScreen->Lock();
eC_UInt uiWidth = pkScreen->GetWidth();
eC_UInt uiHeight = pkScreen->GetHeight();
memset(memory, 0xf1, uiWidth * uiHeight);
for (eC_UInt y = 0; y < uiHeight; ++y)
{
for (eC_UInt x = 0; x < uiWidth; ++x)
{
unsigned short val = memory[y * uiWidth + x];
memory[y * uiWidth + x] = (val + (x * y)) & 0xffff;
}
}
pkScreen->Unlock();
// pkScreen->DrawLine(eGML_Vector2(0, 0), eGML_Vector2(10, 10), 0xff004400, 0, 1, 1);
}
----------------
eC_Bool ExampleBehaviour::DoClick(
const eC_Value &vAbsX,
const eC_Value &vAbsY)
{
if (
(m_eContainer != NO_HANDLE) &&
(m_eTargetObject != NO_HANDLE)
)
{
CGUICompositeObject* pkContainer = dynamic_cast<CGUICompositeObject*>(GETGUI.GetObjectByID(m_eContainer));
if (NULL != pkContainer)
{
for (eC_UInt uiChild = 0; uiChild < pkContainer->GetNumberOfChildren(); ++uiChild)
{
CGUIObject* pkCurrentChild = pkContainer->GetChild(uiChild);
if (pkCurrentChild->GetID() == m_eTargetObject)
pkCurrentChild->SetInvisible(false);
else
pkCurrentChild->SetInvisible(true);
}
}
}
return true;
}
----------------
eC_UInt CalcDayNumFromDate(eC_UInt y, eC_UByte m, eC_UByte d)
{
m = (m + 9) % 12;
y -= m / 10;
eC_UInt dn = 365 * y + y / 4 - y / 100 + y / 400 + (m * 306 + 5) / 10 + (d - 1) + 3;
return dn % 7;
}
------------------
/*
* Copyright (C) TES Electronic Solutions GmbH,
* All Rights Reserved.
* Contact: info@guiliani.de
*
* This file is part of the Guiliani HMI framework
* for the development of graphical user interfaces on embedded systems.
*/
#if !defined(EXAMPLE_CONTROL_H)
#define EXAMPLE_CONTROL_H
#include "GUIObject.h"
#include "GUIFontResource.h"
#include "GUIImageResource.h"
#include "GUINinePatch.h"
/** An example CGUIObject implementation that draws a rectangle with
configureable border width and configurable colors.
*/
class ExampleControl : public CGUIObject
{
public:
/** Constructor.
@param pParent Pointer to the designated parent object.
@param vX X-position relative to its parent object, i.e. the x-offset from the left border of the parent object
@param vY Y-position relative to its parent object, i.e. the y-offset from the upper border of the parent object
@param vWidth Width of the object
@param vHeight Height of the object
@param uiInnerColor Color to be used for drawing this control's center
rectangle (everything except the border) in ARGB format.
@param uiBorderColor Color to be used for drawing this control's frame
in ARGB format.
@param vBorderWidth The width of the border in pixels.
@param eID Object identifier of this object (choose NO_HANDLE if none is required).
*/
ExampleControl(
CGUICompositeObject *const pParent,
const eC_Value &vX, const eC_Value &vY,
const eC_Value &vWidth, const eC_Value &vHeight,
eC_UInt uiInnerColor, eC_UInt uiBorderColor,
eC_Value vBorderWidth = eC_FromInt(1),
const ObjectHandle_t &eID = NO_HANDLE);
/// Default constructor to be used by the factory.
ExampleControl();
#if defined(GUILIANI_STREAM_GUI)
/** Reads all object attributes from streaming file.
This method is called by CGUIFactoryManager after one of the registered
factories has created an instance of this class.
*/
virtual void ReadFromStream();
#endif
#if defined(GUILIANI_WRITE_GUI)
/** Writes all object attributes to the streaming file. A CGUIStreamWriter
has to be initialized first.
@param bWriteClassID This flag is used to select if writing of ControlID,
leading and trailing tags is performed.
*/
virtual void WriteToStream(const eC_Bool bWriteClassID=false);
#endif
protected:
/// Called by the Guiliani framework when this control should paint itself.
eC_Bool DoDraw();
private:
void Init();
private:
/// The color used for drawing the center of this control.
eC_UInt m_uiInnerColor;
/// The color used for drawing the border of this control.
eC_UInt m_uiBorderColor;
/// The width of the border in (sub-) pixels.
eC_Value m_vBorderWidth;
eC_UByte m_ubDay;
eC_UByte m_ubMonth;
eC_UInt m_uiYear;
ImageResource_t m_eBackgroundImageID;
CGUINinePatch m_kBackground;
ImageResource_t m_eMarkerImageID;
CGUINinePatch m_kMarker;
FontResource_t m_eFontID;
eC_Value m_vRowHeight;
eC_Bool m_bFillEmptySpaces;
eC_UByte m_ubStartingWeekday;
eC_UByte m_ubNumberOfDays;
};
#endif // EXAMPLE_CONTROL_H
--------------------
#include "ExampleControl.h"
#include "GfxWrap.h"
#include "GUIStreamReader.h"
#include "GUIStreamWriter.h"
#include "GUIStreamingException.h"
#include "GUIControlResource.h"
#include <string>
#include "GUIResourceManager.h"
#include "GUIMemLeakWatcher.h" // <-- has to be the last include
#define EXAMPLE_CONTROL_CLASS_VERSION 2
// The minimal class version allowed.
#define EXAMPLE_CONTROL_CLASS_MIN_VERSION 1
ExampleControl::ExampleControl(
CGUICompositeObject *const pParent,
const eC_Value &vX, const eC_Value &vY,
const eC_Value &vWidth, const eC_Value &vHeight,
eC_UInt uiInnerColor, eC_UInt uiBorderColor,
eC_Value vBorderWidth,
const ObjectHandle_t &eID) :
CGUIObject(pParent, vX, vY, vWidth, vHeight, eID),
m_uiInnerColor(uiInnerColor),
m_uiBorderColor(uiBorderColor),
m_vBorderWidth(vBorderWidth)
{
Init();
}
ExampleControl::ExampleControl() :
m_uiInnerColor(0),
m_uiBorderColor(0),
m_vBorderWidth(eC_FromInt(0))
{
Init();
}
eC_Bool IsLeapYear(eC_UInt uiYear)
{
if (uiYear % 400 == 0)
return true;
else if (uiYear % 100 == 0)
return false;
else if (uiYear % 4 == 0)
return true;
else
return false;
}
eC_UByte CalculateNumberOfDays(eC_UByte ubMonth, eC_UInt uiYear)
{
const eC_UByte aubDayCount[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if ((ubMonth == 2) && (IsLeapYear(uiYear)))
return 29;
else
return aubDayCount[ubMonth - 1];
}
eC_UByte CalcWeekdayFromDate(eC_UByte ubDay, eC_UByte ubMonth, eC_UInt uiYear)
{
ubMonth = (ubMonth + 9) % 12;
uiYear -= ubMonth / 10;
eC_UInt uiWeekday = 365 * uiYear + uiYear / 4 - uiYear / 100 + uiYear / 400 + (ubMonth * 306 + 5) / 10 + (ubDay - 1) + 3;
return uiWeekday % 7;
}
void ExampleControl::Init()
{
m_ubDay = 19;
m_ubMonth = 1;
m_uiYear = 1982;
m_eBackgroundImageID = IMG_NAVIGATION;
m_kBackground.Assign(0, 0, 0, 0);
m_eMarkerImageID = IMG_MAIN_PLAY;
m_kMarker.Assign(0, 0, 0, 0);
m_eFontID = FNT_DEFAULT;
m_vRowHeight = eC_FromInt(40);
m_ubStartingWeekday = 0;
m_ubNumberOfDays = 0;
m_ubStartingWeekday = CalcWeekdayFromDate(1, m_ubMonth, m_uiYear);
m_ubNumberOfDays = CalculateNumberOfDays(m_ubMonth, m_uiYear);
GETRESMANAGER.RequestImageResource(m_eBackgroundImageID);
GETRESMANAGER.RequestImageResource(m_eMarkerImageID);
SetXMLTag("ExampleControl");
}
eC_Bool ExampleControl::DoDraw()
{
CGUIRect kAbsRect(GetAbsRect());
GETGFX.BlitImgNinePatch(m_eBackgroundImageID, kAbsRect, m_kBackground);
m_vRowHeight = eC_Div(GetHeight(), eC_FromInt(6));
eC_Value vDayWidth = eC_Div(GetWidth(), eC_FromInt(7));
GETGFX.SetFont(FNT_KEYBOARD);
eC_String kDay;
eC_UByte ubCurrentDay = m_ubStartingWeekday;
kAbsRect.Move(eC_Mul(eC_FromInt(m_ubStartingWeekday - 1), vDayWidth), eC_FromInt(0));
for (eC_UByte ubDayIndex = 1; ubDayIndex <= m_ubNumberOfDays; ++ubDayIndex)
{
kDay = eC_String(ubDayIndex);
if (ubDayIndex == m_ubDay)
GETGFX.BlitImgNinePatch(m_eMarkerImageID, CGUIRect(kAbsRect.GetTopLeft(), vDayWidth, m_vRowHeight), m_kMarker);
GETGFX.Text(kAbsRect.GetX1(), kAbsRect.GetY1(), &kDay);
if ((ubCurrentDay % 7) == 0)
kAbsRect.MoveTo(GetAbsXPos(), kAbsRect.GetY1() + m_vRowHeight);
else
kAbsRect.Move(vDayWidth, eC_FromInt(0));
++ubCurrentDay;
}
return true;
}
#if defined(GUILIANI_STREAM_GUI)
void ExampleControl::ReadFromStream()
{
const eC_UInt cuiVersion = ReadStreamingHeader(EXAMPLE_CONTROL_CLASS_VERSION, EXAMPLE_CONTROL_CLASS_MIN_VERSION);
if (cuiVersion <= 1)
{
m_uiInnerColor = GETINPUTSTREAM.READ_HEX("InnerColor");
m_uiBorderColor = GETINPUTSTREAM.READ_HEX("BorderColor");
m_vBorderWidth = eC_FromFloat(GETINPUTSTREAM.READ_FLOAT("BorderWidth"));
CGUIObject::ReadFromStream();
}
else
{
// always base-class first
CGUIObject::ReadFromStream();
// remove grouping
GETINPUTSTREAM.DELETE_COMMENT_TAG("ExampleControl");
m_uiInnerColor = GETINPUTSTREAM.READ_HEX("InnerColor");
m_uiBorderColor = GETINPUTSTREAM.READ_HEX("BorderColor");
m_vBorderWidth = eC_FromFloat(GETINPUTSTREAM.READ_FLOAT("BorderWidth"));
// remove grouping
GETINPUTSTREAM.DELETE_COMMENT_TAG("/ExampleControl");
}
}
#endif
#if defined(GUILIANI_WRITE_GUI)
void ExampleControl::WriteToStream(const eC_Bool bWriteClassID)
{
WriteStreamingHeader(bWriteClassID, XMLTAG_CONTROLCLASSID, CTL_EXAMPLE, EXAMPLE_CONTROL_CLASS_VERSION);
CGUIObject::WriteToStream();
GETOUTPUTSTREAM.WriteCommentTag("ExampleControl");
GETOUTPUTSTREAM.WriteHex(m_uiInnerColor, "InnerColor");
GETOUTPUTSTREAM.WriteHex(m_uiBorderColor, "BorderColor");
GETOUTPUTSTREAM.WriteFloat(eC_ToFloat(m_vBorderWidth), "BorderWidth");
// write attribute-group end
GETOUTPUTSTREAM.WriteCommentTag("/ExampleControl");
WriteStreamingFooter(bWriteClassID);
}
#endif
------------------
https://www.appcues.com/blog/30-awesome-free-ui-vector-kits-for-your-mockups-and-wireframes
designmodo.github.io/Flat-UI/
https://mashable.com/2013/07/29/flat-design-ui-kits/?europe=true
- auto-stretch for text
- invalidate layout after resizing
- calendar-widget
- rating-slider (bargraph)
- multiedge-slider