00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "lcd.h"
00022 #include "screen.h"
00023 #include "module.h"
00024 #include "string.h"
00025 #include "vector.h"
00026
00031 typedef struct _tag_window
00032 {
00033 int x;
00034
00035 int y;
00036
00037 int width;
00038
00039 int height;
00040
00041 LPMODULE pModule;
00042
00043 } WINDOW, * LPWINDOW;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 typedef enum
00071 {
00072 SCREEN_TYPE_TEXT,
00073 SCREEN_TYPE_BAR
00074
00075 } SCREEN_TYPE;
00076
00077 typedef struct _tag_screen
00078 {
00079 int type;
00080
00081 int width;
00082
00083 int height;
00084
00085 LPVECTOR pWindowList;
00086
00087 } SCREEN;
00088
00089 int screenGetSize(LPSCREEN pScreen, int * width, int * height)
00090 {
00091 *width = pScreen->width;
00092 *height = pScreen->height;
00093
00094 return 0;
00095 }
00096
00097
00098 int screenCreate(LPSCREEN * ppScreen, unsigned int uWidth, unsigned int uHeight)
00099 {
00100 int rc = 0;
00101 LPSCREEN pScreen = NULL;
00102
00103 pScreen = calloc(1, sizeof(SCREEN));
00104 pScreen->height = uHeight;
00105 pScreen->width = uWidth;
00106
00107 vectorCreate(&(pScreen->pWindowList));
00108
00109
00110 *ppScreen = pScreen;
00111
00112 return rc;
00113 }
00114
00115
00116 int screenAddWindow(LPSCREEN pScreen, int x, int y, int width, int height, LPMODULE pModule)
00117 {
00118 int rc = 0;
00119 LPWINDOW pWindow = NULL;
00120
00121 pWindow = (LPWINDOW) calloc(1, sizeof(WINDOW));
00122 pWindow->x = x;
00123 pWindow->y = y;
00124 pWindow->width = width;
00125 pWindow->height = height;
00126 pWindow->pModule = pModule;
00127
00128 vectorAdd(pScreen->pWindowList, pWindow);
00129
00130 return rc;
00131 }
00132
00133
00134
00135 int screenDoRender(LPSCREEN pScreen, char * pszScreen)
00136 {
00137 int rc = 0;
00138 int i = 0, w = 0;
00139 int nWindowCount = 0;
00140 int nScreenSize = 0;
00141
00142
00143 nScreenSize = pScreen->width * pScreen->height;
00144 memset(pszScreen, ' ', nScreenSize);
00145
00146
00147 vectorGetSize(pScreen->pWindowList, &nWindowCount);
00148 for (w = 0; w < nWindowCount; w++) {
00149
00150 LPWINDOW pWindow = NULL;
00151 int windowY = 0;
00152
00153
00154 int offset = 0;
00155
00156 vectorGetElementAt(pScreen->pWindowList, w, (void **) &pWindow);
00157
00158
00159 offset = pWindow->x + (pWindow->y * pScreen->width);
00160
00161
00162 for (windowY = 0; windowY < pWindow->height; windowY++) {
00163
00164
00165 char buf[1024];
00166 memset(buf, 0, sizeof(buf));
00167
00168
00169 moduleRender(pWindow->pModule, windowY, pWindow->width, buf);
00170
00171
00172 for (i = 0; (i < pWindow->width) && (buf[i] != 0); i++) {
00173 pszScreen[offset + i] = buf[i];
00174 }
00175
00176
00177 offset += pScreen->width;
00178 }
00179
00180
00181 }
00182
00183 return rc;
00184 }
00185
00186
00187 void * RenderThread(void * arg)
00188 {
00189 int running = 0;
00190
00191 printf("RenderThread\n");
00192
00193 while (running)
00194 {
00195
00196
00197 }
00198
00199 return NULL;
00200 }