📄 gleinput.c
字号:
/*
* Copyright (C) AU-System AB, 2000.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and AU-System AB, and may be used and copied
* only in accordance with the terms of the said agreement.
*
* AU-System AB does not assume any responsibility or
* liability for any errors or inaccuracies in this
* software, or any consequential, incidental or indirect
* damage arising out of the use of the Generic Layout Engine
* software.
*/
#include "gledef.h"
#include "engine.h"
#include "gleinput.h"
#include "aapigle.h"
#include "capigle.h"
#include "ansilibs.h"
VOID* WIPAlloc(UINT32 size);
VOID WIPFree( VOID* memory );
#ifdef SUPPORT_PEN_NAVIGATION
BOOL GleInputContains(GleViewType* viewP, const GleInput *self, GlePointType point)
{
GleRectangleType r;
GleRectangleType intersectionR;
GleRctSetRectangle(&r,viewP->horizOffset,viewP->vertOffset, viewP->width, viewP->height);
GleRctGetIntersection(&r,(GleRectanglePtr)&(self->bounds), &intersectionR);
return( GleRctPtInRectangle( point.x + viewP->horizOffset, point.y + viewP->vertOffset, &intersectionR));
}
#endif
VOID GleInputDraw(GleViewType* viewP, const GleInput* self) {
BOOL isInverted;
GleRectangleType inputBounds;
isInverted = (viewP->markedGleElement == (GleElement*)self);
memmove(&inputBounds, &self->bounds, sizeof(GleRectangleType) );
inputBounds.topLeft.x += - viewP->horizOffset;
inputBounds.topLeft.y += - viewP->vertOffset;
GLEa_inputDraw(viewP->viewId, self->text, isInverted, self->size, self->nChars, self->isPassword, self->format,(GleRectangleType*)&inputBounds);
}
BOOL GleInputRenderX(GleInput* self, UINT16 *xSum, UINT16 *ySum, UINT16 *ascentMax, UINT16 *descenderMax, GleElementType *gleType, UINT16 *currentFontLineHeight, INT8 *myAlign, BOOL *myWrap, INT16 *columnLeftX, INT16 *columnWidth, VOID* viewP){
INT16 neededWidth;
*gleType = self->type;
/* self->maxWidth = *descenderMax;*/
if(*xSum) {
GLEa_inputSize(self->size, self->nChars, -1, &self->bounds.extent.x, &self->bounds.extent.y, &self->ascent);
neededWidth = self->bounds.extent.x + gle_horizontalSpaceBetweenElements;
}
else {
INT16 maxWidth = *columnWidth;
GLEa_inputSize(self->size, self->nChars, maxWidth, &self->bounds.extent.x, &self->bounds.extent.y, &self->ascent);
neededWidth = self->bounds.extent.x;
}
if ((*xSum + neededWidth < *columnWidth) || (!*xSum)) {
self->bounds.topLeft.x = *xSum + neededWidth - self->bounds.extent.x;
*xSum += neededWidth;
if (*xSum > *columnWidth)
*xSum = *columnWidth;
if (self->ascent > *ascentMax)
*ascentMax = self->ascent;
if (self->bounds.extent.y - self->ascent + gle_verticalSpaceBetweenElements > *descenderMax)
*descenderMax = self->bounds.extent.y - self->ascent + gle_verticalSpaceBetweenElements ;
return (TRUE);
}
else
return (FALSE);
}
VOID GleInputRenderY(GleInput* self, INT16* xOffSet, INT16* ySum, INT16* ascentMax) {
self->bounds.topLeft.y = *ySum - self->ascent + *ascentMax;
self->bounds.topLeft.x += *xOffSet;
}
#ifdef SUPPORT_KEY_NAVIGATION
BOOL GleInputIsMarkable(GleViewType* viewP, const GleInput* self) {
BOOL onScreen = FALSE;
if (self->bounds.topLeft.y >= viewP->vertOffset)
if ((self->bounds.topLeft.y + self->bounds.extent.y) < (viewP->vertOffset + viewP->height))
onScreen=TRUE;
return onScreen;
}
#endif
VOID GleInputSelected(GleViewType* viewP, GleInput* self) {
if(!viewP->mMIa_wait)
{
GLEa_playSoundClick();
GLEa_inputDialog(self);
}
}
VOID GleInputDestruct(GleInput* self){
WIPFree(self->text);
WIPFree(self->title);
WIPFree(self->format);
WIPFree(self);
}
GleElement *GleInputConstruct(UINT8 viewId, UINT8 inputId, const WCHAR *title, const WCHAR *text, BOOL isPassword, BOOL emptyOK, const WCHAR *format, INT8 size , INT8 nChars, INT8 tabIndex){
GleInput *self;
INT32 n1;
INT32 n2;
INT32 n3;
INT16 nullChar = 0;
INT16 length;
FormatInfoType info;
FormatErrorType* formatError;
BOOL containsConstantChars;
BOOL inputStringValid;
const WCHAR defaultFormat[] = {'*','M',0};
/*BOOL GLEc_formatStringValid(const WCHAR* format, INT16* length, FormatInfoType* info, BOOL* containsConstantChars)*/
BOOL formatStringValid = GLEc_formatStringValid(format, &length, &info, &containsConstantChars);
if(text)
n1 = GLEa_sizeofString(text);
else
n1 = GLEa_sizeofString((WCHAR*)&nullChar);
if(title)
n2 = GLEa_sizeofString(title);
else
n2 = GLEa_sizeofString((WCHAR*)&nullChar);
if(formatStringValid)
n3 = GLEa_sizeofString(format);
else
n3 = GLEa_sizeofString((WCHAR*)&defaultFormat);
if(length!=-1)
nChars=length;
self = (GleInput*)WIPAlloc(sizeof(GleInput));
self->text = WIPAlloc(n1);
self->title = WIPAlloc(n2);
self->format = WIPAlloc(n3);
/*BOOL GLEc_inputStringValid(const WCHAR* str, const WCHAR* format, FormatErrorType* error);*/
if(formatStringValid)
inputStringValid = GLEc_inputStringValid(text, format, (FormatErrorType*)&formatError);
else
inputStringValid = GLEc_inputStringValid(text, (WCHAR*)&defaultFormat, (FormatErrorType*)&formatError);
if(text && inputStringValid)
GLEa_strcpyWchar2Gle(self->text, text);
else
GLEa_strcpyWchar2Gle(self->text, (WCHAR*)&nullChar);
if(title)
GLEa_strcpyWchar2Gle(self->title, title);
else
GLEa_strcpyWchar2Gle(self->title, (WCHAR*)&nullChar);
if(formatStringValid)
GLEa_strcpyWchar2Gle(self->format, format);
else
GLEa_strcpyWchar2Gle(self->format, (WCHAR*)&defaultFormat);
self->type = Input;
self->chunkSize = sizeof(GleInput) + n1 + n2 + n3;
self->viewId = viewId;
self->inputId = inputId;
self->isPassword = isPassword;
self->size = size;
self->nChars = nChars;
self->tabIndex=tabIndex;
if (!formatStringValid)
self->emptyOK = TRUE;
else{
if (format[0]=='*')
self->emptyOK = TRUE;
else
self->emptyOK = emptyOK;
}
/*self->viewId = viewId;*/
#ifdef SUPPORT_PEN_NAVIGATION
self->Contains=&GleInputContains;
#endif
self->Draw=&GleInputDraw; /* *(p->Draw)();*/
self->RenderX=&GleInputRenderX;
self->RenderY=&GleInputRenderY;
self->Destruct=&GleInputDestruct; /* *(p->Destruct)();*/
#ifdef SUPPORT_KEY_NAVIGATION
self->IsMarkable=&GleInputIsMarkable;
#endif
self->Selected=&GleInputSelected;
return (GleElement*)self;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -