Compile fixes
This commit is contained in:
parent
15e7342fd7
commit
af76c04767
3 changed files with 17 additions and 18 deletions
|
@ -35,7 +35,7 @@ static GHandle ghTextedit2;
|
||||||
static GHandle ghTextedit3;
|
static GHandle ghTextedit3;
|
||||||
static GListener gl;
|
static GListener gl;
|
||||||
|
|
||||||
static void guiCreate()
|
static void guiCreate(void)
|
||||||
{
|
{
|
||||||
GWidgetInit wi;
|
GWidgetInit wi;
|
||||||
gwinWidgetClearInit(&wi);
|
gwinWidgetClearInit(&wi);
|
||||||
|
@ -69,7 +69,7 @@ static void guiCreate()
|
||||||
wi.g.height = 35;
|
wi.g.height = 35;
|
||||||
wi.text = "to switch between";
|
wi.text = "to switch between";
|
||||||
ghTextedit2 = gwinTexteditCreate(0, &wi, 20);
|
ghTextedit2 = gwinTexteditCreate(0, &wi, 20);
|
||||||
gwinTexteditSetBorder(ghTextedit2, FALSE);
|
//gwinTexteditSetBorder(ghTextedit2, FALSE);
|
||||||
|
|
||||||
// TextEdit3
|
// TextEdit3
|
||||||
wi.g.show = TRUE;
|
wi.g.show = TRUE;
|
||||||
|
@ -79,7 +79,7 @@ static void guiCreate()
|
||||||
wi.g.height = 35;
|
wi.g.height = 35;
|
||||||
wi.text = "the different widgets";
|
wi.text = "the different widgets";
|
||||||
ghTextedit3 = gwinTexteditCreate(0, &wi, 100);
|
ghTextedit3 = gwinTexteditCreate(0, &wi, 100);
|
||||||
gwinTexteditSetBorder(ghTextedit3, TRUE);
|
//gwinTexteditSetBorder(ghTextedit3, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
|
@ -30,11 +30,11 @@ const int CURSOR_EXTRA_HEIGHT = 1;
|
||||||
// cursorPos is the position of the next character
|
// cursorPos is the position of the next character
|
||||||
// textBuffer[cursorPos++] = readKey();
|
// textBuffer[cursorPos++] = readKey();
|
||||||
|
|
||||||
static void _shiftTextLeft(char* buffer, size_t bufferSize, size_t index)
|
static void _shiftTextLeft(char* buffer, size_t maxSize, size_t index)
|
||||||
{
|
{
|
||||||
// Find the end of the string
|
// Find the end of the string
|
||||||
size_t indexTerminator = index;
|
size_t indexTerminator = index;
|
||||||
while (buffer[indexTerminator] != '\0' && indexTerminator < bufferSize-1) {
|
while (buffer[indexTerminator] != '\0' && indexTerminator < maxSize-1) {
|
||||||
indexTerminator++;
|
indexTerminator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ static void _shiftTextLeft(char* buffer, size_t bufferSize, size_t index)
|
||||||
buffer[indexTerminator-1] = '\0';
|
buffer[indexTerminator-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char fillChar)
|
static void _shiftTextRight(char* buffer, size_t maxSize, size_t index, char fillChar)
|
||||||
{
|
{
|
||||||
// Find the end of the string
|
// Find the end of the string
|
||||||
size_t indexTerminator = index;
|
size_t indexTerminator = index;
|
||||||
while (buffer[indexTerminator] != '\0' && indexTerminator < bufferSize-1) {
|
while (buffer[indexTerminator] != '\0' && indexTerminator < maxSize-1) {
|
||||||
indexTerminator++;
|
indexTerminator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char
|
||||||
if (gw2obj->cursorPos == 0) {
|
if (gw2obj->cursorPos == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_shiftTextLeft(gw2obj->textBuffer, gw2obj->bufferSize, gw2obj->cursorPos--);
|
_shiftTextLeft(gw2obj->textBuffer, gw2obj->maxSize, gw2obj->cursorPos--);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it delete?
|
// Is it delete?
|
||||||
|
@ -107,7 +107,7 @@ static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char
|
||||||
if (gw2obj->textBuffer[gw2obj->cursorPos] == '\0') {
|
if (gw2obj->textBuffer[gw2obj->cursorPos] == '\0') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_shiftTextLeft(gw2obj->textBuffer, gw2obj->bufferSize, gw2obj->cursorPos+1);
|
_shiftTextLeft(gw2obj->textBuffer, gw2obj->maxSize, gw2obj->cursorPos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new character
|
// Add a new character
|
||||||
|
@ -117,7 +117,7 @@ static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Shift everything right from the cursor by one character. This includes the '\0'. Then inser the new character.
|
// Shift everything right from the cursor by one character. This includes the '\0'. Then inser the new character.
|
||||||
_shiftTextRight(gw2obj->textBuffer, gw2obj->bufferSize, gw2obj->cursorPos++, pke->c[0]);
|
_shiftTextRight(gw2obj->textBuffer, gw2obj->maxSize, gw2obj->cursorPos++, pke->c[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the new text
|
// Set the new text
|
||||||
|
@ -172,21 +172,19 @@ static const gwidgetVMT texteditVMT = {
|
||||||
|
|
||||||
GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit, size_t maxSize)
|
GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit, size_t maxSize)
|
||||||
{
|
{
|
||||||
uint16_t flags = 0;
|
|
||||||
|
|
||||||
// Create the underlying widget
|
// Create the underlying widget
|
||||||
if (!(wt = (GTexteditObject*)_gwidgetCreate(g, &wt->w, pInit, &texteditVMT)))
|
if (!(wt = (GTexteditObject*)_gwidgetCreate(g, &wt->w, pInit, &texteditVMT)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Allocate the text buffer
|
// Allocate the text buffer
|
||||||
wt->maxSize = maxSize;
|
wt->maxSize = maxSize;
|
||||||
wt->textBuffer = gfxAlloc(widget->maxSize);
|
wt->textBuffer = gfxAlloc(wt->maxSize);
|
||||||
if (wt->textBuffer == 0)
|
if (wt->textBuffer == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Initialize the text buffer
|
// Initialize the text buffer
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (i = 0; i < bufSize; i++) {
|
for (i = 0; i < wt->maxSize; i++) {
|
||||||
wt->textBuffer[i] = '\0';
|
wt->textBuffer[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ static void gwidgetEvent(void *param, GEvent *pe) {
|
||||||
|
|
||||||
#undef pme
|
#undef pme
|
||||||
#undef pte
|
#undef pte
|
||||||
|
#undef pke
|
||||||
#undef pde
|
#undef pde
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +297,7 @@ static void gwidgetEvent(void *param, GEvent *pe) {
|
||||||
|
|
||||||
// This new window still needs to be marked for redraw (but don't actually do it yet).
|
// This new window still needs to be marked for redraw (but don't actually do it yet).
|
||||||
gh->flags |= GWIN_FLG_NEEDREDRAW;
|
gh->flags |= GWIN_FLG_NEEDREDRAW;
|
||||||
RedrawPending |= DOREDRAW_VISIBLES;
|
// RedrawPending |= DOREDRAW_VISIBLES; - FIX LATER
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,13 +306,13 @@ static void gwidgetEvent(void *param, GEvent *pe) {
|
||||||
_widgetInFocus = 0;
|
_widgetInFocus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _gwidgetDrawFocusRect(GWidgetObject *gw, coord_t x, coord_t y, coord_t cx, coord_t cy) {
|
void _gwidgetDrawFocusRect(GWidgetObject *gx, coord_t x, coord_t y, coord_t cx, coord_t cy) {
|
||||||
// Don't do anything if we don't have the focus
|
// Don't do anything if we don't have the focus
|
||||||
if (&gw->g != _widgetInFocus)
|
if (&gx->g != _widgetInFocus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Use the very simplest possible focus rectangle for now.
|
// Use the very simplest possible focus rectangle for now.
|
||||||
gdispGDrawBox(gw->g.display, gw->g.x+x, gw->g.y+y, cx, cy, gw->pstyle.focus);
|
gdispGDrawBox(gx->g.display, gx->g.x+x, gx->g.y+y, cx, cy, gx->pstyle->focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue