The tcGuiFramework class provides the top level management of the GGUI library created widgets and views. On construction, tcGuiFramework class parses a provided GGUI skins directory and XML skins file and creates all of the defined widgets and views. Once the widgets have been created the tcGuiFramework class then spawns a GUI thread which periodically handles invalidation requests and HMI input events such as mouse buttons or keystrokes. The tcGuiFramework class and GUI thread should be considered the primary "owners" of the provided tcGuiDisplay hardware object, as it coordinates with it's managed widgets all repaint and animation events.
This is an example of initializing the GGUI library using the tcGuiFramework management class. This example includes initialization of the hardware display class and touchscreen as well as the loading of three font descriptor sets.
#define BIT8FONT_HEIGHT 13
#define BIT8FONT_MAXWIDTH 8
#define BYTES_PER_BIT8FONT \
(BIT8FONT_HEIGHT * ((BIT8FONT_MAXWIDTH + 7) / 8))
#define BIT10FONT_HEIGHT 15
#define BIT10FONT_MAXWIDTH 8
#define BYTES_PER_BIT10FONT \
(BIT10FONT_HEIGHT * ((BIT10FONT_MAXWIDTH + 7) / 8))
#define BIT12FONT_HEIGHT 19
#define BIT12FONT_MAXWIDTH 16
#define BYTES_PER_BIT12FONT \
(BIT12FONT_HEIGHT * ((BIT12FONT_MAXWIDTH + 7) / 8))
unsigned char Font8Bitmaps[CHARS_PER_FONT][BYTES_PER_BIT8FONT] =
{
#include "Bits8.bit"
};
int Font8Width[CHARS_PER_FONT] =
{
#include "Bits8.wid"
};
unsigned char Font10Bitmaps[CHARS_PER_FONT][BYTES_PER_BIT10FONT] =
{
#include "Bits10.bit"
};
int Font10Width[CHARS_PER_FONT] =
{
#include "Bits10.wid"
};
unsigned char Font12Bitmaps[CHARS_PER_FONT][BYTES_PER_BIT12FONT] =
{
#include "Bits12.bit"
};
int Font12Width[CHARS_PER_FONT] =
{
#include "Bits12.wid"
};
extern tsDspRomFsNode GGUI_FILE_SYSTEM[];
some_class_initializer()
{
int i;
void *lpDisplayScreens[DISPLAY_SCREENS];
mpDisplayDma = new tcDspFpgaDma((void *)DISPLAY_DMA_BASE);
mpQvgaDisplay = new tcDspQvga16((void *)QVGA_DISPLAY_BASE,
mpDisplayDma, tcDspFpgaDma::eeChannel1, true );
mhTouchSemaphore = SEM_create(0, NULL);
mpTouchScreen = new tcDspTouchScreen((void *)TOUCHSCREEN_BASE,
mpQvgaDisplay->GetWidthPixels(),
mpQvgaDisplay->GetHeightPixels(),
mhTouchSemaphore,
true);
for (i=0; i<DISPLAY_SCREENS; i++)
{
lpDisplayScreens[i] = new int [(mpQvgaDisplay->GetFrameBufferBytes() / sizeof(int)) + 3];
lpDisplayScreens[i] = (void *)((unsigned int)(lpDisplayScreens[i]) & 0xFFFFFFF0);
memset(lpDisplayScreens[i], NULL, mpQvgaDisplay->GetFrameBufferBytes());
}
tcDspFont* lpFont = new tcDspFont("medium", START_CHAR, CHARS_PER_FONT,
BYTES_PER_MEDFONT, MEDFONT_HEIGHT,
MedFontWidth, &MedFontBitmaps[0][0]);
mpDisplay = new tcGuiDspDisplay(mpQvgaDisplay, DISPLAY_SCREENS, lpDisplayScreens, lpFont, true);
tcBench::tsFontDecl laFontDecls[3];
laFontDecls[0].FontName = "8Bit";
laFontDecls[0].StartChar = START_CHAR;
laFontDecls[0].NumChars = CHARS_PER_FONT;
laFontDecls[0].BytesPerFont = BYTES_PER_BIT8FONT;
laFontDecls[0].FontHeight = BIT8FONT_HEIGHT;
laFontDecls[0].CharWidths = Font8Width;
laFontDecls[0].bitmap = &Font8Bitmaps[0][0];
laFontDecls[1].FontName = "10Bit";
laFontDecls[1].StartChar = START_CHAR;
laFontDecls[1].NumChars = CHARS_PER_FONT;
laFontDecls[1].BytesPerFont = BYTES_PER_BIT10FONT;
laFontDecls[1].FontHeight = BIT10FONT_HEIGHT;
laFontDecls[1].CharWidths = Font10Width;
laFontDecls[1].bitmap = &Font10Bitmaps[0][0];
laFontDecls[2].FontName = "12Bit";
laFontDecls[2].StartChar = START_CHAR;
laFontDecls[2].NumChars = CHARS_PER_FONT;
laFontDecls[2].BytesPerFont = BYTES_PER_BIT12FONT;
laFontDecls[2].FontHeight = BIT12FONT_HEIGHT;
laFontDecls[2].CharWidths = Font12Width;
laFontDecls[2].bitmap = &Font12Bitmaps[0][0];
mpFrameWork = new tcGuiFramework( laFontDecls, 3, mpDisplay, GGUI_FILE_SYSTEM, 8);
mpFrameWork->AddTouchscreenHandler(mpTouchScreen);
mpNumEntry = new tcNumEntry(mpFrameWork);
mpAboutScreen = new tcAboutScreen(mpFrameWork);
mpMainScreen = new tcMainScreen(mpFrameWork, mpITTConfig, mpFaultScreen);
mpFrameWork->ShowView("MAINSCREEN");
}