Добрый день!
Target XC167
Compiler Keil
uc-GUI 3.98Нужен совет по использованию Widget-ов и WM.
Проблема заключается в том, что не удается их отобразить на экране.
Да и вообще, когда я компилирую библиотеку с поддержкой
WMКод
#define GUI_WINSUPPORT 1 /* Window manager package available */
перестает работать то, что работало с выключенным
WM:
Код
#include "GUI.H"
#include "MY_XC16X.h"
#include "BUTTON.h"
#include <stdlib.h> /* For malloc & free funcs */
BUTTON_Handle hButton;
unsigned char mempool[0xFE];
void main(void) {
init_mempool (mempool, sizeof (mempool));
GUI_Init();
GUI_SetTextMode(GUI_TM_TRANS);
GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetTextStyle(GUI_TS_NORMAL);
GUI_Clear();
GUI_DispString("Keil C166 compiler v 4.27");
while(1);
}
GUIConf.h у меня такой:
Код
#ifndef GUICONF_H
#define GUICONF_H
#include <stdlib.h> /* For malloc & free funcs */
#define GUI_OS (0) /* Compile with multitasking support */
#define GUI_SUPPORT_TOUCH (0) /* Support a touch screen (req. win-manager) */
#define GUI_SUPPORT_MOUSE (0) /* Support a mouse */
#define GUI_SUPPORT_UNICODE (1) /* Support mixed ASCII/UNICODE strings */
#define GUI_DEFAULT_FONT &GUI_Font6x8
//#define GUI_BLOCK_ALIGN 1
#define GUI_ALLOC_SIZE 1000 /* Size of dynamic memory ... For WM and memory devices*/
#define GUI_HMEM void *
#define GUI_ALLOC_ALLOC(Size) malloc(Size)
#define GUI_ALLOC_FREE(pMem) free(pMem)
#define GUI_ALLOC_H2P(hMem) hMem
#define GUI_ALLOC_GETMAXSIZE() 10000
/*********************************************************************
*
* Configuration of available packages
*/
#define GUI_WINSUPPORT 1 /* Window manager package available */
#define GUI_SUPPORT_MEMDEV 0 /* Memory devices available */
#define GUI_SUPPORT_AA 1 /* Anti aliasing available */
#define GUI_SUPPORT_ROTATION 0
#define GUI_SUPPORT_ARABIC 0
#define LCD_MIRROR_X (0) /* If active: X -> -X */
#define LCD_MIRROR_Y (0) /* If active: Y -> -Y */
#endif /* Avoid multiple inclusion */
Вообщем переназначил
ALLOC макросы своими родными функциями для работы с динамической памятью...
ВОПРОС почему не работает функция
GUI_DispString("Keil C166 compiler v 4.27"); ?
Покапался в дебаге...
Функция
GUI_DispString вызывает функцию
GUI__DispLine в которой как раз имеется условная компиляция
GUI_WINSUPPORT и вызов фунции
WM__InitIVRSearch через макрос
WM_ITERATE_START(&r)Код
void GUI__DispLine(const char GUI_UNI_PTR *s, int MaxNumChars, const GUI_RECT* pr) {
GUI_RECT r;
#if GUI_SUPPORT_ROTATION
if (GUI_pLCD_APIList) {
#if GUI_WINSUPPORT
WM_ITERATE_START(NULL) {
#endif
/* Do the actual drawing via routine call. */
_DispLine(s, MaxNumChars, &r);
#if GUI_WINSUPPORT
} WM_ITERATE_END();
#endif
} else
#endif
{
r = *pr;
#if GUI_WINSUPPORT
WM_ADDORG(r.x0, r.y0);
WM_ADDORG(r.x1, r.y1);
WM_ITERATE_START(&r) {
#endif
GUI_Context.DispPosX = r.x0;
GUI_Context.DispPosY = r.y0;
/* Do the actual drawing via routine call. */
_DispLine(s, MaxNumChars, &r);
#if GUI_WINSUPPORT
} WM_ITERATE_END();
WM_SUBORG(GUI_Context.DispPosX, GUI_Context.DispPosY);
#endif
}
}
В этой функции меня пугает указатель
pAWin который после присвоения
WM_H2P(GUI_Context.hAWin) содержит совершенно безобразный адрес (явно где-то не инициализирован какой-то указатель...)
Код
int WM__InitIVRSearch(const GUI_RECT* pMaxRect) {
GUI_RECT r;
WM_Obj* pAWin;
GUI_ASSERT_LOCK(); /* GUI_LOCK must have been "called" before entering this (normally done indrawing routine) */
/* If WM is not active -> nothing to do, leave cliprect alone */
if (WM_IsActive==0) {
WM__ActivateClipRect();
return 1;
}
/* If we entered multiple times, leave Cliprect alone */
if (++_ClipContext.EntranceCnt > 1)
return 1;
pAWin = WM_H2P(GUI_Context.hAWin);
_ClipContext.Cnt = -1;
/* When using callback mechanism, it is legal to reduce drawing
area to the invalid area ! */
if (WM__PaintCallbackCnt) {
WM__GetInvalidRectAbs(pAWin, &r);
} else { /* Not using callback mechanism, therefor allow entire rectangle */
if (pAWin->Status & WM_SF_ISVIS) {
r = pAWin->Rect;
} else {
--_ClipContext.EntranceCnt;
return 0; /* window is not even visible ! */
}
}
/* If the drawing routine has specified a rectangle, use it to reduce the rectangle */
if (pMaxRect) {
GUI__IntersectRect(&r, pMaxRect);
}
/* If user has reduced the cliprect size, reduce the rectangle */
if (GUI_Context.WM__pUserClipRect) {
WM_Obj* pWin = pAWin;
GUI_RECT rUser = *(GUI_Context.WM__pUserClipRect);
#if WM_SUPPORT_TRANSPARENCY
if (WM__hATransWindow) {
pWin = WM_H2P(WM__hATransWindow);
}
#endif
WM__Client2Screen(pWin, &rUser);
GUI__IntersectRect(&r, &rUser);
}
/* For transparent windows, we need to further reduce the rectangle */
#if WM_SUPPORT_TRANSPARENCY
if (WM__hATransWindow) {
if (WM__ClipAtParentBorders(&r, WM__hATransWindow) == 0) {
--_ClipContext.EntranceCnt;
return 0; /* Nothing to draw */
}
}
#endif
/* Iterate over all ancestors and clip at their borders. If there is no visible part, we are done */
if (WM__ClipAtParentBorders(&r, GUI_Context.hAWin) == 0) {
--_ClipContext.EntranceCnt;
return 0; /* Nothing to draw */
}
/* Store the rectangle and find the first rectangle of the area */
_ClipContext.ClientRect = r;
return WM__GetNextIVR();
}
ИМХО Беда
НЕобъектного написания огромных сложных программ/библиотек приводит к тому, что забыл какую-то мелкую функцию вызвать и получаешь плавающие указатели, причем есть в этой библиотеки и вызовы ф-ций по
НЕинициализированным указателям.... ИМХО я против больших программ без классов!
Вообщем подскажите, может я чего-то забыл инициализировать?
Спасибо!