static void DrawBullyShip(int xOnBase,int yOnBase,double course,GUI_COLOR Color) { double basex = screen_hcenter+(xOnBase-half_x)*Diff; double basey = screen_vcenter-(yOnBase-half_y)*Diff; double _cos = cos(course); double _sin = sin(course); GUI_SetLineStyle(GUI_LS_SOLID); GUI_SetColor(Color); GUI_DrawLine(basex-7*_cos-10*_sin , basey-7*_sin+10*_cos ,basex+10*_sin , basey-10*_cos); GUI_DrawLine(basex+10*_sin , basey-10*_cos,basex+7*_cos-10*_sin , basey+7*_sin+10*_cos); GUI_DrawLine(basex+7*_cos-10*_sin , basey+7*_sin+10*_cos,basex-7*_cos-10*_sin , basey-7*_sin+10*_cos ); GUI_SetColor(GUI_BLACK); }
/******************************************************************* * * _DemoAntialiasing Draws lines with different antialiasing factors */ static void _DemoAntialiasing(void) { int i, x1, x2, y1, y2; const GUI_FONT *font_old; y1 = 65; y2 = 5; /* Set drawing attributes */ GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_BLACK); GUI_SetPenShape(GUI_PS_FLAT); GUI_Clear(); /* draw headline */ font_old = GUI_SetFont(&GUI_Font24_ASCII); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringAt("AA_Lines - Sample", 160, 5); /* Draw lines without antialiased */ GUI_Delay(1000); GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("draw normal lines using", 5, 40); GUI_DispStringAtCEOL("GUI_DrawLine", 5, 55); GUI_Delay(2500); x1 = 20; x2 = 100; GUI_SetFont(font_old); GUI_DispStringHCenterAt("Normal", (x1 + x2) / 2, 30 + y1); for (i = 1; i < 8; i++) { GUI_SetPenSize(i); GUI_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2); } /* Draw lines with antialiasing quality factor 2 */ GUI_Delay(3000); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAtCEOL("", 5, 40); GUI_DispStringAtCEOL("", 5, 55); GUI_Delay(200); GUI_DispStringAtCEOL("draw antialiased lines using", 5, 40); GUI_DispStringAtCEOL("GUI_AA_DrawLine", 5, 55); GUI_Delay(3500); x1 = 120; x2 = 200; GUI_AA_SetFactor(2); GUI_SetFont(font_old); GUI_DispStringHCenterAt("Antialiased\nusing factor 2", (x1 + x2) / 2, 30 + y1); for (i = 1; i < 8; i++) { GUI_SetPenSize(i); GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2); } /* Draw lines with antialiasing quality factor 6 */ GUI_Delay(1500); x1 = 220; x2 = 300; GUI_AA_SetFactor(6); GUI_SetFont(font_old); GUI_DispStringHCenterAt("Antialiased\nusing factor 6", (x1 + x2) / 2, 30 + y1); for (i = 1; i < 8; i++) { GUI_SetPenSize(i); GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2); } GUI_Delay(7500); }
void drawpoint(FR_DATA_POINT_T* actualpoint,FR_DATA_POINT_T* nextpoint,FR_GUI_GRAPH_T* gr){ xaxis_t* xaxis; yaxis_t* yaxis; int x0,y0,x1,y1; xaxis=&(gr->x_axis); yaxis=&(gr->y_axis); if(actualpoint->x>xaxis->minEU && actualpoint->x<xaxis->maxEU && nextpoint->x>xaxis->minEU && nextpoint->x<xaxis->maxEU && actualpoint->y>yaxis->minEU && actualpoint->y<yaxis->maxEU && nextpoint->y>yaxis->minEU && nextpoint->y<yaxis->maxEU){ int deltaXEU; int deltaYEU; deltaXEU=abs(xaxis->maxEU-xaxis->minEU); deltaYEU=abs(yaxis->maxEU-yaxis->minEU); x0=(int)((((double)(actualpoint->x-xaxis->minEU)/deltaXEU)*gr->w)+gr->x); y0=(int)((-((double)(actualpoint->y-yaxis->minEU)/deltaYEU)*gr->h)+gr->y+gr->h); x1=(int)((((double)(nextpoint->x-xaxis->minEU)/deltaXEU)*gr->w)+gr->x); y1=(int)((-((double)(nextpoint->y-yaxis->minEU)/deltaYEU)*gr->h)+gr->y+gr->h); GUI_DrawLine(x0,y0,x1,y1); } }
void OUI_DrawGraph(){ GUI_MEMDEV_Select(OUI_MemoryDeviceGrid.DeviceHandle); GUI_SetBkColor(OUI_GRAPH_BACKGROUND); GUI_Clear(); GUI_SetColor(OUI_GRAPH_LINES); for(int i = 0; i <= 180; i += 20){ GUI_DrawLine(0, i, 270, i); } for(int i = 0; i <= 270; i += 30){ GUI_DrawLine(i, 0, i, 180); } OUI_Components[2]->DrawGraph(OUI_Components[1], 0, 0); OUI_Components[1]->DrawGraph(OUI_Components[1], 0, 0); GUI_MEMDEV_CopyToLCDAt(OUI_MemoryDeviceGrid.DeviceHandle,OUI_MemoryDeviceGrid.X,OUI_MemoryDeviceGrid.Y); GUI_MEMDEV_Clear(OUI_MemoryDeviceGrid.DeviceHandle); }
void Draw_GraphGrid(uint16_t XSize, uint16_t YSize, uint8_t XDense, uint8_t YDense){ // // THIS CAN BE DONE FASTER. // uint16_t XStart,YStart; uint8_t Xstep = XSize/XDense; uint8_t Ystep = YSize/YDense; uint8_t i=0; //unsigned char Cur_Ls; //unsigned char Cur_Color; XStart = 34; YStart = 5; GUI_SetLineStyle(GUI_LS_DOT); GUI_SetColor(GUI_DARKGRAY); for(i=1;i<=Xstep;i++) GUI_DrawLine(XStart+i*XDense,YStart,XStart + i*XDense,YStart+YSize); for(i=1;i<=Ystep;i++) GUI_DrawLine(XStart,YStart+i*YDense,XStart+XSize,YStart+i*YDense); }
/***************************************************************************** * Function...: Redraw * DESCRIPTION: Redraws this element *****************************************************************************/ bool PumpGroupGraphic::Redraw() { Component::Redraw(); mpLabelGroupName[PUMP_GROUP_1]->Redraw(); mpLabelGroupName[PUMP_GROUP_2]->Redraw(); mpImgPumps->Redraw(); if (mGroupDividerPosition > 0 && mGroupDividerPosition < mVisibleImageWidth) { SelectWindow(); GUI_SetColor(GetColour()); GUI_SetLineStyle(GUI_LS_DOT); GUI_DrawLine(mGroupDividerPosition, 0, mGroupDividerPosition, GetHeight()); GUI_SetLineStyle(GUI_LS_SOLID); } Validate(); return true; }
//在指定位置显示指定颜色的按钮 //(x,y):按钮起始坐标 //xlen,ylen:x,y方向的长度 //str:按钮上要显示的字符 //color:字符颜色 void GUI_Draw_Button(u16 x,u16 y,u16 xlen,u16 ylen,u8 *str,u16 color) { u16 tback_color,tpoint_color; //////////////////画按钮部分////////////////////// LCD_Fill(x,y,x+xlen,y+ylen,LGRAY);//画实体 GUI_DrawLine(x,y,xlen,0,WHITE); //上外边框 GUI_DrawLine(x,y,0,ylen,WHITE); //左外边框 GUI_DrawLine(x+1,y+1,xlen-1,0,0XB5B6);//上内边框 GUI_DrawLine(x+1,y+1,0,ylen-1,0XB5B6);//左内边框 GUI_DrawLine(x,y+ylen,xlen,0,0X8431); //下外边框 GUI_DrawLine(x+xlen,y,0,ylen,0X8431); //右外边框 GUI_DrawLine(x+1,y+ylen-1,xlen-2,0,0XA535);//下内边框 GUI_DrawLine(x+xlen-1,y,0,ylen-1,0XA535); //右内边框 //////////////////显示按钮上面的信息/////////////// if(ylen<16)return;//不够画 tback_color=BACK_COLOR; tpoint_color=POINT_COLOR; BACK_COLOR=LGRAY; POINT_COLOR=color; Show_Str_Mid(x,y+(ylen-16)/2,str,16,xlen);//只对16字体 BACK_COLOR=tback_color; //恢复之前的颜色 POINT_COLOR=tpoint_color; }
GUI_MainWin::GUI_MainWin(GUI_WinBase *pw,const char *t,int x,int y,int dx,int dy,SDL_Color _bgcol,int _border,void (*client_d_cmd)(GUI_WinBase *)): GUI_WinBase(pw,t,x,y,dx,dy,_bgcol), titleBar(0), closeButton(0), clientWin(0) { border = _border; canMove = 2; isMainWin = true; #if __IPHONEOS__ titleBarGap = 0; titleBarSize += titleBarGap; #endif titleBar = new GUI_WinBase( this, t, border, border, dx-(2*border), titleBarSize-border, _bgcol, []( GUI_WinBase *w ) { GUI_DrawLine( 0, w->tw_area.h-1, w->tw_area.w, w->tw_area.h-1, cBlack ); GUI_Rect r = w->title_area; r.y += titleBarGap; SDL_RenderCopy(GUI_renderer, w->titleTexture, NULL, &r); }); titleBar->titleColor = cWhite; titleBar->createTitleTexture(); titleBar->title_area.y -= titleBarGap / 2; closeButton = new GUI_WinBase( titleBar, "Close", dx-24-border, (titleBarSize-15)/2-border, 16, 15, cWhite, [](GUI_WinBase *w) { GUI_DrawRect2( GUI_MakeRect(0, 0, w->tw_area.w, w->tw_area.h), cBlack ); SDL_RenderCopy(GUI_renderer, GUI_crossTexture, NULL, GUI_MakeRect(1, 1, w->tw_area.w-2, w->tw_area.h-2)); } ); clientWin = new GUI_WinBase( this, "Client", border, titleBarSize, dx-(2*border), dy-titleBarSize-border, cWhite, client_d_cmd ); }
/** * Redraw parts of the viewport that require redrawing. * * @param forceRedraw If true, dirty flags are ignored, and everything is drawn. * @param arg08 ?? * @param drawToMainScreen True if and only if we are drawing to the main screen and not some buffer screen. */ void GUI_Widget_Viewport_Draw(bool forceRedraw, bool arg08, bool drawToMainScreen) { static const uint16 values_32A4[8][2] = { {0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {3, 1}, {2, 1}, {1, 1} }; uint16 x; uint16 y; uint16 i; uint16 curPos; bool updateDisplay; Screen oldScreenID; uint16 oldValue_07AE_0000; int16 minX[10]; int16 maxX[10]; PoolFindStruct find; updateDisplay = forceRedraw; memset(minX, 0xF, sizeof(minX)); memset(maxX, 0, sizeof(minX)); oldScreenID = GFX_Screen_SetActive(SCREEN_1); oldValue_07AE_0000 = Widget_SetCurrentWidget(2); if (g_dirtyViewportCount != 0 || forceRedraw) { for (y = 0; y < 10; y++) { uint16 top = (y << 4) + 0x28; for (x = 0; x < (drawToMainScreen ? 15 : 16); x++) { Tile *t; uint16 left; curPos = g_viewportPosition + Tile_PackXY(x, y); if (x < 15 && !forceRedraw && BitArray_Test(g_dirtyViewport, curPos)) { if (maxX[y] < x) maxX[y] = x; if (minX[y] > x) minX[y] = x; updateDisplay = true; } if (!BitArray_Test(g_dirtyMinimap, curPos) && !forceRedraw) continue; BitArray_Set(g_dirtyViewport, curPos); if (x < 15) { updateDisplay = true; if (maxX[y] < x) maxX[y] = x; if (minX[y] > x) minX[y] = x; } t = &g_map[curPos]; left = x << 4; if (!g_debugScenario && g_veiledSpriteID == t->overlaySpriteID) { GUI_DrawFilledRectangle(left, top, left + 15, top + 15, 12); continue; } GFX_DrawSprite(t->groundSpriteID, left, top, t->houseID); if (t->overlaySpriteID == 0 || g_debugScenario) continue; GFX_DrawSprite(t->overlaySpriteID, left, top, t->houseID); } } g_dirtyViewportCount = 0; } find.type = UNIT_SANDWORM; find.index = 0xFFFF; find.houseID = HOUSE_INVALID; while (true) { Unit *u; uint8 *sprite; u = Unit_Find(&find); if (u == NULL) break; if (!u->o.flags.s.isDirty && !forceRedraw) continue; u->o.flags.s.isDirty = false; if (!g_map[Tile_PackTile(u->o.position)].isUnveiled && !g_debugScenario) continue; sprite = GUI_Widget_Viewport_Draw_GetSprite(g_table_unitInfo[u->o.type].groundSpriteID, Unit_GetHouseID(u)); s_spriteFlags = 0x200; if (Map_IsPositionInViewport(u->o.position, &x, &y)) GUI_DrawSprite(g_screenActiveID, sprite, x, y, 2, s_spriteFlags | 0xC000); if (Map_IsPositionInViewport(u->targetLast, &x, &y)) GUI_DrawSprite(g_screenActiveID, sprite, x, y, 2, s_spriteFlags | 0xC000); if (Map_IsPositionInViewport(u->targetPreLast, &x, &y)) GUI_DrawSprite(g_screenActiveID, sprite, x, y, 2, s_spriteFlags | 0xC000); if (u != g_unitSelected) continue; if (!Map_IsPositionInViewport(u->o.position, &x, &y)) continue; GUI_DrawSprite(g_screenActiveID, g_sprites[6], x, y, 2, 0xC000); } if (g_unitSelected == NULL && (g_var_3A08 != 0 || arg08) && (Structure_Get_ByPackedTile(g_selectionRectanglePosition) != NULL || g_selectionType == SELECTIONTYPE_PLACE || g_debugScenario)) { uint16 x1 = (Tile_GetPackedX(g_selectionRectanglePosition) - Tile_GetPackedX(g_minimapPosition)) << 4; uint16 y1 = ((Tile_GetPackedY(g_selectionRectanglePosition) - Tile_GetPackedY(g_minimapPosition)) << 4) + 0x28; uint16 x2 = x1 + (g_selectionWidth << 4) - 1; uint16 y2 = y1 + (g_selectionHeight << 4) - 1; GUI_SetClippingArea(0, 40, 239, SCREEN_HEIGHT - 1); GUI_DrawWiredRectangle(x1, y1, x2, y2, 0xFF); if (g_selectionState == 0 && g_selectionType == SELECTIONTYPE_PLACE) { GUI_DrawLine(x1, y1, x2, y2, 0xFF); GUI_DrawLine(x2, y1, x1, y2, 0xFF); } GUI_SetClippingArea(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); g_var_3A08 = 0; } if (g_dirtyUnitCount != 0 || forceRedraw || updateDisplay) { find.type = 0xFFFF; find.index = 0xFFFF; find.houseID = HOUSE_INVALID; while (true) { Unit *u; UnitInfo *ui; uint16 packed; uint8 orientation; uint16 index; u = Unit_Find(&find); if (u == NULL) break; if (u->o.index < 20 || u->o.index > 101) continue; packed = Tile_PackTile(u->o.position); if ((!u->o.flags.s.isDirty || u->o.flags.s.isNotOnMap) && !forceRedraw && !BitArray_Test(g_dirtyViewport, packed)) continue; u->o.flags.s.isDirty = false; if (!g_map[packed].isUnveiled && !g_debugScenario) continue; ui = &g_table_unitInfo[u->o.type]; if (!Map_IsPositionInViewport(u->o.position, &x, &y)) continue; x += g_table_tilediff[0][u->wobbleIndex].x; y += g_table_tilediff[0][u->wobbleIndex].y; orientation = Orientation_Orientation256ToOrientation8(u->orientation[0].current); if (u->spriteOffset >= 0 || ui->destroyedSpriteID == 0) { static const uint16 values_32C4[8][2] = { {0, 0}, {1, 0}, {1, 0}, {1, 0}, {2, 0}, {1, 1}, {1, 1}, {1, 1} }; index = ui->groundSpriteID; switch (ui->displayMode) { case DISPLAYMODE_UNIT: case DISPLAYMODE_ROCKET: if (ui->movementType == MOVEMENT_SLITHER) break; index += values_32A4[orientation][0]; s_spriteFlags = values_32A4[orientation][1]; break; case DISPLAYMODE_INFANTRY_3_FRAMES: { static const uint16 values_334A[4] = {0, 1, 0, 2}; index += values_32C4[orientation][0] * 3; index += values_334A[u->spriteOffset & 3]; s_spriteFlags = values_32C4[orientation][1]; } break; case DISPLAYMODE_INFANTRY_4_FRAMES: index += values_32C4[orientation][0] * 4; index += u->spriteOffset & 3; s_spriteFlags = values_32C4[orientation][1]; break; default: s_spriteFlags = 0; break; } } else { index = ui->destroyedSpriteID - u->spriteOffset - 1; s_spriteFlags = 0; } if (u->o.type != UNIT_SANDWORM && u->o.flags.s.isHighlighted) s_spriteFlags |= 0x100; if (ui->o.flags.blurTile) s_spriteFlags |= 0x200; GUI_DrawSprite(g_screenActiveID, GUI_Widget_Viewport_Draw_GetSprite(index, (u->deviated != 0) ? u->deviatedHouse : Unit_GetHouseID(u)), x, y, 2, s_spriteFlags | 0xE000, s_paletteHouse, g_paletteMapping2, 1); if (u->o.type == UNIT_HARVESTER && u->actionID == ACTION_HARVEST && u->spriteOffset >= 0 && (u->actionID == ACTION_HARVEST || u->actionID == ACTION_MOVE)) { uint16 type = Map_GetLandscapeType(packed); if (type == LST_SPICE || type == LST_THICK_SPICE) { static const int16 values_334E[8][2] = { {0, 7}, {-7, 6}, {-14, 1}, {-9, -6}, {0, -9}, { 9, -6}, { 14, 1}, { 7, 6} }; GUI_DrawSprite(g_screenActiveID, GUI_Widget_Viewport_Draw_GetSprite((u->spriteOffset % 3) + 0xDF + (values_32A4[orientation][0] * 3), Unit_GetHouseID(u)), x + values_334E[orientation][0], y + values_334E[orientation][1], 2, values_32A4[orientation][1] | 0xC000); } } if (u->spriteOffset >= 0 && ui->turretSpriteID != 0xFFFF) { int16 offsetX = 0; int16 offsetY = 0; uint16 spriteID = ui->turretSpriteID; orientation = Orientation_Orientation256ToOrientation8(u->orientation[ui->o.flags.hasTurret ? 1 : 0].current); switch (ui->turretSpriteID) { case 0x8D: /* sonic tank */ offsetY = -2; break; case 0x92: /* rocket launcher */ offsetY = -3; break; case 0x7E: { /* siege tank */ static const int16 values_336E[8][2] = { { 0, -5}, { 0, -5}, { 2, -3}, { 2, -1}, {-1, -3}, {-2, -1}, {-2, -3}, {-1, -5} }; offsetX = values_336E[orientation][0]; offsetY = values_336E[orientation][1]; } break; case 0x88: { /* devastator */ static const int16 values_338E[8][2] = { { 0, -4}, {-1, -3}, { 2, -4}, {0, -3}, {-1, -3}, { 0, -3}, {-2, -4}, {1, -3} }; offsetX = values_338E[orientation][0]; offsetY = values_338E[orientation][1]; } break; default: break; } s_spriteFlags = values_32A4[orientation][1]; spriteID += values_32A4[orientation][0]; GUI_DrawSprite(g_screenActiveID, GUI_Widget_Viewport_Draw_GetSprite(spriteID, Unit_GetHouseID(u)), x + offsetX, y + offsetY, 2, s_spriteFlags | 0xE000, s_paletteHouse); } if (u->o.flags.s.isSmoking) { uint16 spriteID = 180 + (u->spriteOffset & 3); if (spriteID == 183) spriteID = 181; GUI_DrawSprite(g_screenActiveID, g_sprites[spriteID], x, y - 14, 2, 0xC000); } if (u != g_unitSelected) continue; GUI_DrawSprite(g_screenActiveID, g_sprites[6], x, y, 2, 0xC000); } g_dirtyUnitCount = 0; } for (i = 0; i < EXPLOSION_MAX; i++) { Explosion *e = Explosion_Get_ByIndex(i); curPos = Tile_PackTile(e->position); if (BitArray_Test(g_dirtyViewport, curPos)) e->isDirty = true; if (e->commands == NULL) continue; if (!e->isDirty && !forceRedraw) continue; if (e->spriteID == 0) continue; e->isDirty = false; if (!g_map[curPos].isUnveiled && !g_debugScenario) continue; if (!Map_IsPositionInViewport(e->position, &x, &y)) continue; s_spriteFlags = 0xC000; GUI_DrawSprite(g_screenActiveID, GUI_Widget_Viewport_Draw_GetSprite(e->spriteID, e->houseID), x, y, 2, s_spriteFlags, s_paletteHouse); } if (g_dirtyAirUnitCount != 0 || forceRedraw || updateDisplay) { find.type = 0xFFFF; find.index = 0xFFFF; find.houseID = HOUSE_INVALID; while (true) { static const uint16 values_32E4[8][2] = { {0, 0}, {1, 0}, {2, 0}, {1, 2}, {0, 2}, {1, 3}, {2, 1}, {1, 1} }; Unit *u; UnitInfo *ui; uint8 orientation; uint8 *sprite; uint16 index; u = Unit_Find(&find); if (u == NULL) break; if (u->o.index > 15) continue; curPos = Tile_PackTile(u->o.position); if ((!u->o.flags.s.isDirty || u->o.flags.s.isNotOnMap) && !forceRedraw && !BitArray_Test(g_dirtyViewport, curPos)) continue; u->o.flags.s.isDirty = false; if (!g_map[curPos].isUnveiled && !g_debugScenario) continue; ui = &g_table_unitInfo[u->o.type]; if (!Map_IsPositionInViewport(u->o.position, &x, &y)) continue; index = ui->groundSpriteID; orientation = u->orientation[0].current; s_spriteFlags = 0xC000; switch (ui->displayMode) { case DISPLAYMODE_SINGLE_FRAME: if (u->o.flags.s.bulletIsBig) index++; break; case DISPLAYMODE_UNIT: orientation = Orientation_Orientation256ToOrientation8(orientation); index += values_32E4[orientation][0]; s_spriteFlags |= values_32E4[orientation][1]; break; case DISPLAYMODE_ROCKET: { static const uint16 values_3304[16][2] = { {0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {3, 2}, {2, 2}, {1, 2}, {0, 2}, {3, 3}, {2, 3}, {3, 3}, {4, 1}, {3, 1}, {2, 1}, {1, 1} }; orientation = Orientation_Orientation256ToOrientation16(orientation); index += values_3304[orientation][0]; s_spriteFlags |= values_3304[orientation][1]; } break; case DISPLAYMODE_ORNITHOPTER: { static const uint16 values_33AE[4] = {2, 1, 0, 1}; orientation = Orientation_Orientation256ToOrientation8(orientation); index += (values_32E4[orientation][0] * 3) + values_33AE[u->spriteOffset & 3]; s_spriteFlags |= values_32E4[orientation][1]; } break; default: s_spriteFlags = 0x0; break; } if (ui->flags.hasAnimationSet && u->o.flags.s.animationFlip) index += 5; if (u->o.type == UNIT_CARRYALL && u->o.flags.s.inTransport) index += 3; sprite = GUI_Widget_Viewport_Draw_GetSprite(index, Unit_GetHouseID(u)); if (ui->o.flags.hasShadow) GUI_DrawSprite(g_screenActiveID, sprite, x + 1, y + 3, 2, (s_spriteFlags & 0xDFFF) | 0x300, g_paletteMapping1, 1); if (ui->o.flags.blurTile) s_spriteFlags |= 0x200; GUI_DrawSprite(g_screenActiveID, sprite, x, y, 2, s_spriteFlags | 0x2000, s_paletteHouse); } g_dirtyAirUnitCount = 0; } if (updateDisplay) { memset(g_dirtyMinimap, 0, sizeof(g_dirtyMinimap)); memset(g_dirtyViewport, 0, sizeof(g_dirtyViewport)); } if (g_changedTilesCount != 0) { bool init = false; bool update = false; Screen oldScreenID2 = SCREEN_1; for (i = 0; i < g_changedTilesCount; i++) { curPos = g_changedTiles[i]; BitArray_Clear(g_changedTilesMap, curPos); if (!init) { init = true; oldScreenID2 = GFX_Screen_SetActive(SCREEN_1); GUI_Mouse_Hide_InWidget(3); } GUI_Widget_Viewport_DrawTile(curPos); if (!update && BitArray_Test(g_displayedMinimap, curPos)) update = true; } if (update) Map_UpdateMinimapPosition(g_minimapPosition, true); if (init) { GUI_Screen_Copy(32, 136, 32, 136, 8, 64, g_screenActiveID, SCREEN_0); GFX_Screen_SetActive(oldScreenID2); GUI_Mouse_Show_InWidget(); } if (g_changedTilesCount == lengthof(g_changedTiles)) { g_changedTilesCount = 0; for (i = 0; i < 4096; i++) { if (!BitArray_Test(g_changedTilesMap, i)) continue; g_changedTiles[g_changedTilesCount++] = i; if (g_changedTilesCount == lengthof(g_changedTiles)) break; } } else { g_changedTilesCount = 0; } } if ((g_viewportMessageCounter & 1) != 0 && g_viewportMessageText != NULL && (minX[6] <= 14 || maxX[6] >= 0 || arg08 || forceRedraw)) { GUI_DrawText_Wrapper(g_viewportMessageText, 112, 139, 15, 0, 0x132); minX[6] = -1; maxX[6] = 14; } if (updateDisplay && !drawToMainScreen) { if (g_viewport_fadein) { GUI_Mouse_Hide_InWidget(g_curWidgetIndex); /* ENHANCEMENT -- When fading in the game on start, you don't see the fade as it is against the already drawn screen. */ if (g_dune2_enhanced) { Screen oldScreenID2 = g_screenActiveID; GFX_Screen_SetActive(SCREEN_0); GUI_DrawFilledRectangle(g_curWidgetXBase << 3, g_curWidgetYBase, (g_curWidgetXBase + g_curWidgetWidth) << 3, g_curWidgetYBase + g_curWidgetHeight, 0); GFX_Screen_SetActive(oldScreenID2); } GUI_Screen_FadeIn(g_curWidgetXBase, g_curWidgetYBase, g_curWidgetXBase, g_curWidgetYBase, g_curWidgetWidth, g_curWidgetHeight, g_screenActiveID, SCREEN_0); GUI_Mouse_Show_InWidget(); g_viewport_fadein = false; } else { bool init = false; for (i = 0; i < 10; i++) { uint16 width; uint16 height; if (arg08) { minX[i] = 0; maxX[i] = 14; } if (maxX[i] < minX[i]) continue; x = minX[i] * 2; y = (i << 4) + 0x28; width = (maxX[i] - minX[i] + 1) * 2; height = 16; if (!init) { GUI_Mouse_Hide_InWidget(g_curWidgetIndex); init = true; } GUI_Screen_Copy(x, y, x, y, width, height, g_screenActiveID, SCREEN_0); } if (init) GUI_Mouse_Show_InWidget(); } } GFX_Screen_SetActive(oldScreenID); Widget_SetCurrentWidget(oldValue_07AE_0000); }
// // PrintWinCallback // static void _cbDialog(WM_MESSAGE *pMsg) { WM_KEY_INFO *KEY; MENU_MSG_DATA * pData; switch (pMsg->MsgId) { case USER_MSG_LANGUAGE: //pLanguage = &Lguprintwin[Language]; //TEXT_SetText(hPrintText,pLanguage->PrintTitle); break; case WM_PAINT: GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetFont(&GUI_Font30); GUI_SetColor(GUI_BLACK); //GUI_DispStringAt("打印选项",40,25); if (Language == 0) { GUI_DispStringAt("打印选项",40,25); GUI_DrawLine(0,59,193,59); GUI_DrawLine(193,20,193,59); GUI_DrawLine(0,20,193,20); } else //ENGLISH { GUI_DispStringAt("PRINT OPTIONS",30,25); GUI_DrawLine(0,59,240,59); GUI_DrawLine(240,20,240,59); GUI_DrawLine(0,20,240,20); } break; case WM_MENU: pData = (MENU_MSG_DATA*)pMsg->Data.p; switch (pData->MsgType) { case MENU_ON_ITEMSELECT: // 选中 INFO("ISOK"); MENU_SetSel(hPrintMenu, 0); PrintActiveId = ID_Print_All; switch (pData->ItemId) { case ID_Print_Fre_Int: case ID_Print_Fre_Loc1: case ID_Print_Fre_Loc2: case ID_Print_Fre_Chs : case ID_Print_Info_Prt: case ID_Print_Site_Prt: case ID_Print_All: case ID_Print_Showing: pTooltip = &Lgutooltip[Language]; StarPrint = 1; //ptipText = "正在打印......"; WM_BringToTop(ToolTip); WM_SetFocus(ToolTip); WM_HideWindow(ToolTip_BUTTON[0]); WM_HideWindow(ToolTip_BUTTON[1]); WM_HideWindow(ToolTipText1); TEXT_SetText(ToolTipText0,pTooltip->Text1[4]); PrintTimer = WM_CreateTimer(ToolTip,0,2000,0); break; } break; case MENU_ON_ITEMACTIVATE: //高亮 PrintActiveId = pData->ItemId; _SetHintText(PrintHintText,PrintActiveId,1); //设置提示信息 switch (pData->ItemId) //用于修正第三级菜单的窗口位置 { case ID_Print_Site_SiteSet_Prt_0: if(Language == 0) { if (PrintMenuThird == 0) { WM_MoveWindow(hSiteSet,195,81); PrintMenuThird = 1; } } else { if (PrintMenuThird == 0) { WM_MoveWindow(hSiteSet,240,90); PrintMenuThird = 1; } } break; case ID_Print_Info_InfoSet_Prt_0: if (Language == 0) { if(PrintMenuThird == 0) { WM_MoveWindow(hInfoSet,195,121); PrintMenuThird = 1; } } else { if(PrintMenuThird == 0) { WM_MoveWindow(hInfoSet,240,121); PrintMenuThird = 1; } } break; default: WM_DefaultProc(pMsg); break; } break; default: WM_DefaultProc(pMsg); break; } break; default: WM_DefaultProc(pMsg); break; } WM_DefaultProc(pMsg); }
// //MenuCallback // static void MenuCall(WM_MESSAGE *pMsg) { WM_HWIN hWin = pMsg->hWin; WM_KEY_INFO *KEY; MENU_ITEM_DATA *pData; int16_t PrintMenuID; PrintMenuID = WM_GetId(hWin); switch (pMsg->MsgId) { case USER_MSG_LANGUAGE: pLanguage = &Lguprintwin[Language]; PrintSetItemText(hWin,PrintMenuID); TEXT_SetText(PrintHintText,""); break; case WM_KEY: KEY = (WM_KEY_INFO*)pMsg->Data.p; switch (KEY->Key) { case GUI_KEY_MENU: WM_BringToTop(Menuwin); WM_SetFocus(WM_GetDialogItem(Menuwin,ID_MENU)); MENU_SetSel(WM_GetDialogItem(Menuwin,ID_MENU),0); MenuSel = 0; break; case GUI_KEY_PRINT: WM_BringToTop(mainwin); WM_SetFocus(mainwin); break; case GUI_KEY_LEFT: case GUI_KEY_RIGHT: if(PrintActiveId >= ID_Print_Site_SiteSet_Prt_0 && PrintActiveId <= ID_Print_Site_SiteSet_Prt_4) { PrintSiteindex = PrintActiveId - 2068; if (Language == 0) { if (PrintSiteSet[PrintSiteindex] == 0) { sprintf(pStrBuf,"%c""%s",PrintSiteindex+65,"不打印"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintSiteindex] = 1; } else { sprintf(pStrBuf,"%c""%s",PrintSiteindex+65,"打印"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintSiteindex] = 0; } } else //english { if (PrintSiteSet[PrintSiteindex] == 0) { sprintf(pStrBuf,"%c"" ""%s",PrintSiteindex+65,"REJ"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintSiteindex] = 1; } else { sprintf(pStrBuf,"%c"" ""%s",PrintSiteindex+65,"SEL"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintSiteindex] = 0; } } } else if(PrintActiveId >= ID_Print_Info_InfoSet_Prt_0 && PrintActiveId <= ID_Print_Info_InfoSet_Prt_4) { PrintInfoindex = PrintActiveId - 2073; if(Language == 0) { if (PrintInfoSet[PrintInfoindex] == 0) { INFO("INDEX = %d",PrintInfoindex); sprintf(pStrBuf,"%c""%s",PrintInfoindex+65,"不打印"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintInfoindex] = 1; } else { sprintf(pStrBuf,"%c""%s",PrintInfoindex+65,"打印"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintInfoindex] = 0; } } else //english { if (PrintInfoSet[PrintInfoindex] == 0) { INFO("INDEX = %d",PrintInfoindex); sprintf(pStrBuf,"%c"" ""%s",PrintInfoindex+65,"REJ"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintInfoindex] = 1; } else { sprintf(pStrBuf,"%c"" ""%s",PrintInfoindex+65,"SEL"); _SetMenuItem(pMsg->hWin,0,pStrBuf,PrintActiveId,0); PrintSiteSet[PrintInfoindex] = 0; } } } break; case GUI_KEY_ESCAPE: PrintMenuThird = 0; if (PrintActiveId >= ID_Print_All && PrintActiveId <= ID_Print_Info) break; case GUI_KEY_ENTER: PrintMenuThird = 0; default: MENU_Callback(pMsg); break; } break; case WM_POST_PAINT: if(PrintMenuID == ID_PrintMenu) { GUI_SetColor(GUI_BLACK); if (Language == 0) { GUI_DrawLine(193,0,193,197); GUI_DrawLine(0,197,193,197); } else //english { GUI_DrawLine(240,0,240,147); GUI_DrawLine(0,147,240,147); } } break; default: MENU_Callback(pMsg); break; } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; static uint8_t sel = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: memset(Video_Path, 0, 256); hItem = BUTTON_CreateEx(574, 0, 65, 65, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT); WM_SetCallback(hItem, _cbButton_exit); hItem = ST_AnimatedIconView_CreateEx(100, 70, LCD_GetXSize() - 0, LCD_GetYSize() - 30, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, ID_ICONVIEW_SUBMENU, 200, 250, 5, 5); ST_AnimatedIconView_SetDualFont(hItem, GUI_FONT_20_1, GUI_FONT_20_1); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5); ST_AnimatedIconView_SetSel(hItem, -1); ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, 0x00DCA939); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE); ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, 0x00DCA939, 0x00522000); ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video"); ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Add to playlist"); break; case WM_PAINT: GUI_SetColor(GUI_BLACK); GUI_DrawLine(639, 0, 639, 480); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch(Id) { case ID_BUTTON_EXIT: switch(NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_ICONVIEW_SUBMENU: switch(NCode) { case WM_NOTIFICATION_RELEASED: sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc); if(sel == 0) { osDelay(100); /* Playlist not empty, so start play first item */ if(VideoList.ptr > 0) { GUI_SetLayerVisEx (1, 1); GUI_SelectLayer(1); playbackwin = WM_CreateWindowAsChild(-1, 0, 640, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0); WM_CreateWindowAsChild(0, 70, 640, 300, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0); GUI_SelectLayer(0); _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0); VideoPlayer_State = VIDEO_PLAY; hFrame = WM_CreateWindowAsChild(-1, 0, 640, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0); GUI_SelectLayer(1); } else {/* There is no item yet in the playlist: Show hint message */ hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, GUI_COUNTOF(_aFileInfoDialogCreate), _cbFileInfoDialog, pMsg->hWin, 100, 80); WM_MakeModal(hItem); } } else /* Add file to playlist icon item action */ { hItem = GUI_CreateDialogBox(_aPlaylistDialogCreate, GUI_COUNTOF(_aPlaylistDialogCreate), _cbPlaylistDialog, pMsg->hWin, 100, 80); WM_MakeModal(hItem); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief callback for video window * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbplaybackwin(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; char tmp[64]; switch (pMsg->MsgId) { case WM_CREATE: SelLayer = 1; hItem = BUTTON_CreateEx(398 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_BACK); WM_SetCallback(hItem, _cbButton_back); hItem = BUTTON_CreateEx(449 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_STOP); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(495 - 160, 441, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, PLAY_VIDEO_ID); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(540 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_FORE); WM_SetCallback(hItem, _cbButton_fore); hItem = SLIDER_CreateEx(72, 420, 510, 13, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDER_DURATION); SLIDER_SetBkColor(hItem, GUI_TRANSPARENT); SLIDER_SetFocusColor (hItem, 0x00DCA939); SLIDER_SetValue(hItem, 0); SLIDER_SetWidth(hItem, 0); SLIDER_SetSTSkin(hItem); hItem = BUTTON_CreateEx(568, 0, 70, 70, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_MENU); WM_SetCallback(hItem, _cbButton_menu); hItem = BUTTON_CreateEx(0, 410, 70, 70, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT_FROM_VIDEO); WM_SetCallback(hItem, _cbButton_exit1); /* Title Initialization in play list */ hItem = TEXT_CreateEx(10, 20, 100, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_ELAPSED_TIME, "00:00"); TEXT_SetFont(hItem, GUI_FONT_20B_1); TEXT_SetTextColor(hItem, GUI_WHITE); /* Title Initialization in play list */ hItem = TEXT_CreateEx(50, 40, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_TIME, "00:00"); TEXT_SetFont(hItem, GUI_FONT_16B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(150, 20, 350, 30, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_NAME, "File Name"); TEXT_SetFont(hItem, GUI_FONT_20B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(150, 48, 350, 30, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_FORMAT, "Format : MJPEG"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 200, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FPS, "Rate : 20 fps"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 220, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_FPU, "FPU : ON"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 240, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_IC, "I-Cache : ON"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 260, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_DC, "D-Cache : ON"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 280, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_CPU, "MCU Load : 0%"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); break; case WM_TIMER: { WM_RestartTimer(pMsg->Data.v, 1000); /* show elapsed time */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); elapsed_time++; sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 ); TEXT_SetText(hItem, tmp); sprintf((char *)tmp , "MCU Load : %d%%", ((osGetCPUUsage() > 90) ? (osGetCPUUsage() - 10) : osGetCPUUsage())); hItem = WM_GetDialogItem(pMsg->hWin, ID_FEATURES_CPU); TEXT_SetText(hItem, tmp); hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION); SLIDER_SetValue(hItem, (GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames); if(step == 0) { step = ((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames); } if(((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames) > (100 - 2*step - 1)) { SLIDER_SetValue(hItem, 100); GUI_Exec(); } } break; case WM_DELETE: if(hTimer != 0) { WM_DeleteTimer(hTimer); hTimer = 0; } case WM_PAINT: GUI_SetColor(0xFF000000 | GUI_BLACK); GUI_SetBkColor(GUI_TRANSPARENT); GUI_Clear(); GUI_SetColor(GUI_BLACK); GUI_DrawHLine(0, 0, 640); GUI_DrawHLine(479, 0, 640); GUI_DrawLine(639, 0, 639, 480); GUI_DrawLine(0, 0, 0, 480); /* Background for total time */ GUI_SetColor(0x00DCA939); GUI_AA_FillRoundedRect((-30), 5, 90, 65, 30); /*Video Information */ GUI_AA_FillRoundedRect(150, 5, 500, 65, 30); /*H/W Information */ GUI_AA_FillRoundedRect(538, 180, 780, 320, 30); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch(Id) { case ID_BUTTON_EXIT_FROM_VIDEO: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State != VIDEO_IDLE) { _StopPlay(&hvideo, &Video_File); } GUI_EndDialog(pMsg->hWin, 0); SelLayer = 0; GUI_SetLayerVisEx (1, 0); GUI_SelectLayer(0); WM_HideWindow(hFrame); WM_Exec(); WM_DeleteWindow(hFrame); WM_InvalidateWindow(VideoWin); break; } break; case ID_BUTTON_MENU: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State != VIDEO_IDLE) { _StopPlay(&hvideo, &Video_File); } GUI_EndDialog(pMsg->hWin, 0); SelLayer = 0; GUI_SetLayerVisEx (1, 0); GUI_SelectLayer(0); WM_DeleteWindow(hFrame); WM_HideWindow(VideoWin); WM_Exec(); WM_DeleteWindow(VideoWin); break; } break; case ID_BUTTON_STOP: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State != VIDEO_IDLE) { VideoPlayer_State = VIDEO_STOP; _StopPlay(&hvideo, &Video_File); } WM_InvalidateWindow(pMsg->hWin); break; } break; case ID_BUTTON_FORE: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State == VIDEO_PLAY) { if(file_pos < (VideoList.ptr - 1)) { file_pos++; } else { file_pos = 0; } _StopPlay(&hvideo, &Video_File); _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0); } break; } break; /* Notifications sent by 'progress' Slider */ case ID_SLIDER_DURATION: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION); int32_t newpos; if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hvideo); hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION); newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100; GUI_MOVIE_GotoFrame(hvideo, newpos); GUI_MOVIE_Play(hvideo); elapsed_time = (Video_Info.msPerFrame * newpos)/ 1000; hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME); sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 ); TEXT_SetText(hItem, tmp); WM_InvalidateWindow(hItem); WM_Paint(hItem); } } break; case ID_BUTTON_BACK: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State == VIDEO_PLAY) { if(file_pos > 0) { file_pos--; } else { file_pos = VideoList.ptr - 1; } _StopPlay(&hvideo, &Video_File); _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0); } break; } break; case PLAY_VIDEO_ID: switch(NCode) { case WM_NOTIFICATION_RELEASED: if((VideoPlayer_State == VIDEO_IDLE) || (VideoPlayer_State == VIDEO_PAUSE)) { hTimer = WM_CreateTimer(playbackwin, 0, 1000, 0); GUI_MOVIE_Play(hvideo); VideoPlayer_State = VIDEO_PLAY; } else if(VideoPlayer_State == VIDEO_STOP) { _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0); VideoPlayer_State = VIDEO_PLAY; } else { GUI_MOVIE_Pause(hvideo); VideoPlayer_State = VIDEO_PAUSE; if(hTimer != 0) { WM_DeleteTimer(hTimer); hTimer = 0; } } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Callback routine of the video main dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; static uint8_t sel = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: memset(Video_Path, 0, 256); hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT); WM_SetCallback(hItem, _cbButton_exit); hItem = ST_AnimatedIconView_CreateEx(120, 50, LCD_GetXSize() - 220, LCD_GetYSize() - 150, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, ID_ICONVIEW_SUBMENU, 240, 300, 100, 5); ST_AnimatedIconView_SetDualFont(hItem, &GUI_FontLubalGraph24, &GUI_FontLubalGraph24); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5); ST_AnimatedIconView_SetSel(hItem, -1); ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE); ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE); ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video"); ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Open playlist"); break; case WM_PAINT: GUI_SetColor(GUI_BLACK); GUI_DrawLine(799, 0, 799, 480); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch(Id) { case ID_BUTTON_EXIT: switch(NCode) { case WM_NOTIFICATION_CLICKED: /* avoid icon view animation */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU); WM_HideWindow(hItem); break; case WM_NOTIFICATION_MOVED_OUT: hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU); WM_ShowWindow(hItem); break; case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_ICONVIEW_SUBMENU: switch(NCode) { case WM_NOTIFICATION_RELEASED: sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc); if(sel == 0) { if(VNC_IsRunning() == 0) { /* Playlist not empty, so start play first item */ if(VideoList.ptr > 0) { GUI_SetLayerVisEx (1, 1); GUI_SelectLayer(1); playbackwin = WM_CreateWindowAsChild(0, 0, 800, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0); WM_CreateWindowAsChild(100, 100, 600, 280, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0); GUI_SelectLayer(0); _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0); VideoPlayer_State = VIDEO_PLAY; hFrame = WM_CreateWindowAsChild(0, 0, 800, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0); GUI_SelectLayer(1); } else {/* There is no item yet in the playlist: Show hint message */ hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, GUI_COUNTOF(_aFileInfoDialogCreate), _cbFileInfoDialog, pMsg->hWin, 100, 50); WM_MakeModal(hItem); } } else { hItem = GUI_CreateDialogBox(_aFileErrorDialogCreate, GUI_COUNTOF(_aFileErrorDialogCreate), _cbFileInfoDialog, pMsg->hWin, 100, 50); WM_MakeModal(hItem); } } else if(sel == 1) { hPlaylistWin = GUI_CreateDialogBox(_aPlaylistDialogCreate, GUI_COUNTOF(_aPlaylistDialogCreate), _cbPlaylistDialog, pMsg->hWin, 100, 50); WM_MakeModal(hPlaylistWin); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
static void GUI_Purchase_ShowInvoice(void) { Widget *w = g_widgetInvoiceTail; Screen oldScreenID; uint16 y = 48; uint16 total = 0; uint16 x; char textBuffer[12]; oldScreenID = GFX_Screen_SetActive(SCREEN_1); GUI_DrawFilledRectangle(128, 48, 311, 159, 20); GUI_DrawText_Wrapper(String_Get_ByIndex(STR_ITEM_NAME_QTY_TOTAL), 128, y, 12, 0, 0x11); y += 7; GUI_DrawLine(129, y, 310, y, 12); y += 2; if (g_factoryWindowOrdered != 0) { uint16 i; for (i = 0; i < g_factoryWindowTotal; i++) { ObjectInfo *oi; uint16 amount; if (g_factoryWindowItems[i].amount == 0) continue; amount = g_factoryWindowItems[i].amount * g_factoryWindowItems[i].credits; total += amount; snprintf(textBuffer, sizeof(textBuffer), "%02d %5d", g_factoryWindowItems[i].amount, amount); oi = g_factoryWindowItems[i].objectInfo; GUI_DrawText_Wrapper(String_Get_ByIndex(oi->stringID_full), 128, y, 8, 0, 0x11); GUI_DrawText_Monospace(textBuffer, 311 - strlen(textBuffer) * 6, y, 15, 0, 6); y += 8; } } else { GUI_DrawText_Wrapper(String_Get_ByIndex(STR_NO_UNITS_ON_ORDER), 220, 99, 6, 0, 0x112); } GUI_DrawLine(129, 148, 310, 148, 12); GUI_DrawLine(129, 150, 310, 150, 12); snprintf(textBuffer, sizeof(textBuffer), "%d", total); x = 311 - strlen(textBuffer) * 6; /* "Total Cost :" */ GUI_DrawText_Wrapper(GUI_String_Get_ByIndex(STR_TOTAL_COST_), x - 3, 152, 11, 0, 0x211); GUI_DrawText_Monospace(textBuffer, x, 152, 11, 0, 6); GUI_Mouse_Hide_Safe(); GUI_Screen_Copy(16, 48, 16, 48, 23, 112, SCREEN_1, SCREEN_0); GUI_Mouse_Show_Safe(); GFX_Screen_SetActive(SCREEN_0); GUI_FactoryWindow_DrawCaption(String_Get_ByIndex(STR_INVOICE_OF_UNITS_ON_ORDER)); Input_History_Clear(); for (; GUI_Widget_HandleEvents(w) == 0; sleepIdle()) { GUI_DrawCredits(g_playerHouseID, 0); GUI_FactoryWindow_UpdateSelection(false); GUI_PaletteAnimate(); } GFX_Screen_SetActive(oldScreenID); w = GUI_Widget_Get_ByIndex(w, 10); if (w != NULL && Mouse_InsideRegion(w->offsetX, w->offsetY, w->offsetX + w->width, w->offsetY + w->height) != 0) { while (Input_Test(0x41) != 0 || Input_Test(0x42) != 0) sleepIdle(); Input_History_Clear(); } if (g_factoryWindowResult == FACTORY_CONTINUE) GUI_FactoryWindow_DrawDetails(); }
/******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { /* ================================================================ */ /* Board Initializations and Configurations except OLED */ /* (clocks, I/Os, on-chip peripherals, on-board ICs) */ /* ================================================================ */ LBF_Board_Init(); Red_Led_ON(); /* ================================================================ */ /* Optional initialization of Middleware libraries : */ /* USBD drivers, FatFS File System, STemWin GUI */ /* ================================================================ */ // UNCOMMENT IF YOU WELL BE USING ...: /* ... La BlueFrog as USB Mass Storage (Full Speed) */ /* (based on ST-provided stack part of STM32 Cube offering */ // Delay_ms(1000); // LBF_LaunchUSB_MassStorage(); /* ... the FAT File System (FatFS) */ /* (based on ChanN's FatFS included in STM32 Cube offering) */ // LBF_FatFS_Init(); /* ... the STemWin Graphical Library */ /* (based on Segger's emWin included in STM32 Cube offering)*/ LBF_emWin_Init(); Red_Led_OFF(); /* ================================================================ */ /* Application Code Below */ /* ================================================================ */ /* == User Declarations ========================================== */ uint16_t fconfig[11]; // configuration file to control some OLED parameters GUI_MEMDEV_Handle hMemDevice; //handle to a memory device /* == Body ========================================== */ fconfig[0]=0xFFFF; // to use default settings LBF_OLED_Init(fconfig); //sets up OLED register and powers on OLED VDDH(13V) OLED_Fill(0, 0, 160, 128, CYAN); Red_Led_ON(); /*** Start Demo *******************************************************/ /* Different options posible */ /* Use Display Cache or Use Memory Device or use Banded Memory Device */ /* With 32K SRAM only the latter allows to cover full screen */ // ============================================================= // == Using the dislay cache ================================== // Usage of display cache can be enabled through parameters of function // GUIDRV_FlexColor_SetFunc() called in LCDConf_FlexColor_LBF.c // found in library LBF_STemWin // !!! ISSUE !!! // XSIZE_PHYS x YSIZE_PHYS (defined in above files) need to be set to 160x128 // to hold full display. However at 16bpp that represents about 40BK // but available SRAM is only 32KB... // Work-Around: define a smaller display cache (XSIZE_PHYS, YSIZE_PHYS) // -- but will not allow to address full screen // Not much interest vs use of "Memory Device", below, anyway /* GUI_SetFont(&GUI_Font20_1); GUI_SetTextMode(GUI_TM_TRANS); // write with transparent background GUI_DispStringAt("Hello from La BlueFrog !", LCD_GetXSize()/8, LCD_GetYSize()/2); Green_Led_ON(); */ // ============================================================= // == Using a "Memory Device" (refer to emWin documentation) // Work with a centered 128x64 window // (cannot cover full screen for same memory limitation as above) #define X_FULL_SCREEN 160 #define Y_FULL_SCREEN 128 #define MD_X_LEFT (X_FULL_SCREEN -128)/2 #define MD_X_RIGHT 160-MD_X_LEFT #define MD_Y_TOP (Y_FULL_SCREEN -64)/2 #define MD_Y_BOT 128-MD_Y_TOP // Create Memory Device (top left & bottom right coordinates) on Layer 0: GUI_SelectLayer(0); hMemDevice = GUI_MEMDEV_Create(MD_X_LEFT, MD_Y_TOP, (MD_X_RIGHT-MD_X_LEFT+1), (MD_Y_BOT-MD_Y_TOP+1) ); // Caution: // Memory allocated by GUI_X_Config in GUIConf_LBF.c must be sufficient to fit MemDevice buffer // plus other needs of emWin // Else GUI_MEMDEV_Create will fail (returns 0) and operations will be done directly to screen // Activate it: GUI_MEMDEV_Select(hMemDevice); // Draw Stuff (refer to emWin documentation) GUI_DrawGradientRoundedH( MD_X_LEFT, MD_Y_TOP, MD_X_RIGHT, MD_Y_BOT, 10, // rounded corner radius 0xFF0000, 0xFFFF00); // red to yellow GUI_SetPenSize(6); GUI_DrawLine(MD_X_LEFT, MD_Y_TOP, MD_X_RIGHT, MD_Y_BOT); GUI_DrawLine(MD_X_LEFT, MD_Y_BOT, MD_X_RIGHT, MD_Y_TOP); GUI_SetFont(&GUI_Font13_1); GUI_SetColor(GUI_BLACK); GUI_SetTextMode(GUI_TM_TRANS); // write with transparent background GUI_DispStringAt("Hello !\n", MD_X_LEFT+10, MD_Y_TOP+10 ); // Copy to display GUI_MEMDEV_CopyToLCD(hMemDevice); // Free memory GUI_MEMDEV_Delete(hMemDevice); // ============================================================= // == Using a "Banded Memory Device" (refer to emWin documentation) // == (Banding, aka tiling, allows to cover full screen by processing // == a number of bands successively) //TODO // use function: GUI_MEMDEV_Draw (GUI_RECT * pRect, GUI_CALLBACK_VOID_P * pfDraw, // void* pData, int NumLines, int Flags); while(1); }
void _cbWindowSetting(WM_MESSAGE* pMsg) { WM_HWIN hWin = pMsg->hWin; WM_HWIN _edit0; WM_HWIN _edit1; int edit_id = 256; int VALUE; int i = 0; switch (pMsg->MsgId) { case WM_CREATE: WIDGET_SetDefaultEffect (&WIDGET_Effect_None); EDIT_SetDefaultTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetDefaultFont(&GUI_Font28); EDIT_CreateEx(200,60,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT0,1);//夜间模式 EDIT_CreateEx(150,110,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT1,1);//音量 EDIT_CreateEx(150,160,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT2,1);//亮度 EDIT_CreateEx(150,210,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT3,2);//时区 EDIT_CreateEx(240,260,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT4,1);//报警音1 EDIT_CreateEx(170,310,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT5,1);//按键音1 EDIT_CreateEx(200,360,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT6,1);//单位显示 EDIT_CreateEx(200,410,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT7,1);//船形显示 for (i = 0; i < 8; i++) { _edit0 = WM_GetDialogItem(hWin, GUI_ID_EDIT0 + i); EDIT_SetText(_edit0,"0"); EDIT_SetpfAddKeyEx (_edit0,_cbEditAddKey); EDIT_SetBkColor(_edit0,1,GUI_LIGHTBLUE); EDIT_SetBkColor(_edit0,0,GUI_WHITE); } break; case WM_PAINT: GUI_SetBkColor (GUI_LIGHTBLUE); GUI_Clear(); for (i = 0; i < 8; i++) { _edit0 = WM_GetDialogItem(hWin, GUI_ID_EDIT0 + i); EDIT_SetTextColor(_edit0,0,GUI_BLACK); } EDIT_SetTextColor (WM_GetDialogItem(hWin, edit_id),0,GUI_WHITE); GUI_SetTextMode(GUI_TEXTMODE_TRANS); GUI_SetColor (GUI_BLACK); GUI_SetFont (&GUI_Font28); GUI_DispStringAt ("系统设置",230,10); GUI_DispStringAt ("01:夜间模式:",5,60); GUI_DispStringAt ("02:音量:",5,110); GUI_DispStringAt ("03:亮度:",5,160); GUI_DispStringAt ("04:时区:",5,210); GUI_DispStringAt ("05:报警音选择:",5,260); GUI_DispStringAt ("06:按键音:",5,310); GUI_DispStringAt ("07:单位设置:",5,360); GUI_DispStringAt ("08:船位显示:",5,410); GUI_DispStringAt ("09:船迹存储时间:",330,60); GUI_DispStringAt ("10:软件更新:",330,110); GUI_DispStringAt ("11:系统版本:",330,160); GUI_SetColor (GUI_WHITE); GUI_SetPenSize(2); GUI_DrawLine(1,50,1,470); GUI_DrawLine(1,50,673,50); GUI_DrawLine(673,50,673,470); GUI_DrawLine(1,470,673,470); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_TAB: //判断当前焦点所在的位置,将焦点移至下一个窗口 downlistfocus++; if (downlistfocus == 369) downlistfocus = 384; if (downlistfocus == 388) downlistfocus = 256; if (downlistfocus == 257) downlistfocus = 368; //设置焦点 WM_SetFocus(WM_GetDialogItem (hWin, downlistfocus)); break; case GUI_KEY_BACKTAB: //判断当前焦点所在的位置,将焦点移至上一个窗口 downlistfocus--; if (downlistfocus == 383) downlistfocus = 368; if (downlistfocus == 367) downlistfocus = 256; if (downlistfocus == 255) downlistfocus = 387; //设置焦点 WM_SetFocus (WM_GetDialogItem(hWin, downlistfocus)); break; case GUI_KEY_RIGHT: break; case GUI_KEY_F1: break; case GUI_KEY_F2: break; case GUI_KEY_SPACE: printf ("ddsf"); break; case GUI_KEY_ENTER: break; case GUI_KEY_UP: break; case GUI_KEY_DOWN: WM_SetFocusOnNextChild(hWin); //edit_id ++; break; case GUI_KEY_LEFT: menufocus -= 5; focuschange = 0; WM_SetFocus(WM_GetDialogItem (hDlg_Menu, menufocus)); WM_Paint(hDlg_Menu); break; case GUI_KEY_MENU: WM_BringToTop (hDlg_FishMap); WM_SetFocus (hDlg_FishMap); menufocus = 368; break; } break; default: WM_DefaultProc(pMsg); } }
void Draw_graph_struct(FR_GUI_GRAPH_T* gr){ TM_TOUCH_t* TS; point_t* zero_loc; TS=gr->TS; zero_loc=&(gr->zero_loc); // Touch Status gr->touchstatus=0; if (TS->NumPresses) { int i; /* Go through all presses on LCD */ for (i = 0; i < TS->NumPresses; i++) { /* Draw circle */ int xtouch; int ytouch; xtouch=LCD_GetXSize()-TS->X[i]; ytouch=LCD_GetYSize()-TS->Y[i]; if((xtouch>(gr->x))&&(xtouch<((gr->x)+(gr->w)))&&(ytouch>(gr->y))&&(ytouch<((gr->y)+(gr->h)))){ gr->touchstatus=1; } } } //Draw zero_loc->x=gr->x; zero_loc->y=gr->y+gr->h; //x_axis GUI_DrawLine(zero_loc->x,zero_loc->y,gr->x+gr->w,gr->zero_loc.y); //Arrow GUI_DrawLine(zero_loc->x+gr->w,zero_loc->y+5,zero_loc->x+gr->w,zero_loc->y-5); GUI_DrawLine(zero_loc->x+gr->w+5,zero_loc->y,zero_loc->x+gr->w,zero_loc->y+5); GUI_DrawLine(zero_loc->x+gr->w+5,zero_loc->y,zero_loc->x+gr->w,zero_loc->y-5); // Draw Xaxis function should be called here //Draw axis Label and Ticks //Y_axis GUI_DrawLine(gr->zero_loc.x,gr->zero_loc.y,gr->zero_loc.x,gr->y); //Arrow GUI_DrawLine(zero_loc->x-5,gr->y,zero_loc->x+5,gr->y); GUI_DrawLine(zero_loc->x-5,gr->y,zero_loc->x,gr->y-5); GUI_DrawLine(zero_loc->x+5,gr->y,zero_loc->x,gr->y-5); // Draw Yaxis function should be called here //Draw axis Label and Ticks //Draw Graph title GUI_SetFont(&GUI_Font16_1); GUI_DispStringHCenterAt(gr->Title,gr->x+((gr->w)/2),(gr->y)-16); //Draw Graph here draw_data(gr,&(gr->Data)); /* Do actions */ if(gr->touchstatus && !(gr->touchstatus_mem) && gr->TouchAction!=NULL){ gr->TouchAction(); } if(!(gr->touchstatus) && gr->touchstatus_mem && gr->ReleaseAction!=NULL){ gr->ReleaseAction(); } gr->touchstatus_mem=gr->touchstatus; }
/********************************************************************* * * _DrawLine */ static void _DrawLine(int x0, int y0, int x1, int y1) { GUI_SetColor(GUI_GREEN); GUI_SetLineStyle(GUI_LS_DOT); GUI_DrawLine(x0, y0, x1, y1); GUI_SetLineStyle(GUI_LS_SOLID); }
static void DrawForgBullyShip(int xOnBase,int yOnBase,double course) { int drawsitex,drawsitey; double _cos = cos(course); double _sin = sin(course); int oppositex=xOnBase-half_x; int oppositey=yOnBase-half_y; int Flag; if(oppositex/Diff>350||oppositex/Diff<-350||oppositey/Diff<-160||oppositey/Diff>160) { _cos = cos(course); _sin = sin(course); if((2*fabs(oppositey))>fabs(oppositex)) { if(oppositey>0) { Flag=0; } else { Flag=2; } } else { if(oppositex>0) { Flag=1; } else { Flag=3; } } switch(Flag){ case 0: drawsitex=390+195*oppositex/oppositey; drawsitey=65; break; case 1: drawsitex=770; drawsitey=220-380*oppositey/oppositex; break; case 2: drawsitex=390-195*oppositex/oppositey; drawsitey=460; break; case 3: drawsitex=15; drawsitey=220+380*oppositey/oppositex; break; } GUI_SetColor(pColor->forgBullyColor); GUI_DrawLine(drawsitex-7*_cos-10*_sin , drawsitey-7*_sin+10*_cos,drawsitex+10*_sin , drawsitey-10*_cos ); GUI_DrawLine(drawsitex+10*_sin , drawsitey-10*_cos ,drawsitex+7*_cos-10*_sin , drawsitey+7*_sin+10*_cos); GUI_DrawLine(drawsitex+7*_cos-10*_sin , drawsitey+7*_sin+10*_cos,drawsitex-7*_cos-10*_sin , drawsitey-7*_sin+10*_cos); GUI_SetColor(GUI_BLACK); } else{ DrawBullyShip(xOnBase,yOnBase,course,pColor->forgBullyColor); } }
/********************************************************************* * * _cbDialog * * Purpose: Dialog callback routine */ static void _cbDialog(WM_MESSAGE *pMsg) { int NCode, Id; WM_HWIN hDlg; BUTTON_Handle hButton; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: WM_DefaultProc(pMsg); /* Handle dialog items */ /* After drawing the dialog items add some user drawn items to the window */ GUI_SetPenSize(10); GUI_SetColor(GUI_GREEN); GUI_DrawLine( 95, 5, 185, 95); GUI_SetColor(GUI_RED); GUI_DrawLine( 95, 95, 185, 5); break; case WM_INIT_DIALOG: hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0); WM_SetHasTrans(hButton); /* Set transparency flag for button */ break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hDlg, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hDlg, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0); if (Id == GUI_ID_BUTTON1) { /* Toggle callback */ if (_pcbCallback) { WM_SetCallback(hButton, _pcbCallback); _pcbCallback = 0; } else { _pcbCallback = WM_SetCallback(hButton, _cbButton); } WM_InvalidateWindow(hButton); } if (Id == GUI_ID_BUTTON2) { /* Toggle font */ if (_Font) { BUTTON_SetFont(hButton, &GUI_Font13_1); } else { BUTTON_SetFont(hButton, &GUI_Font8x16); } _Font ^= 1; } if (Id == GUI_ID_BUTTON3) { /* Toggle color */ if (_Color) { BUTTON_SetBkColor(hButton, 0, 0xaaaaaa); BUTTON_SetBkColor(hButton, 1, GUI_WHITE); BUTTON_SetTextColor(hButton, 0, GUI_BLACK); BUTTON_SetTextColor(hButton, 1, GUI_BLACK); } else { BUTTON_SetBkColor(hButton, 0, GUI_BLUE); BUTTON_SetBkColor(hButton, 1, GUI_RED); BUTTON_SetTextColor(hButton, 0, GUI_WHITE); BUTTON_SetTextColor(hButton, 1, GUI_YELLOW); } _Color ^= 1; } if (Id == GUI_ID_OK) { /* OK Button */ GUI_EndDialog(hDlg, 0); } if (Id == GUI_ID_CANCEL) { /* Cancel Button */ GUI_EndDialog(hDlg, 1); } break; } break; default: WM_DefaultProc(pMsg); } }
static void mylistview(WM_MESSAGE *pMsg) { WM_HWIN hWin; CHAR RowNum; CHAR RowLineIndex; const WM_KEY_INFO *pInfo; int16_t i = 0; static char addrow = 0; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch (pInfo->Key) { case GUI_KEY_MENU: WM_BringToTop(Menuwin); WM_SetFocus(WM_GetDialogItem(Menuwin,ID_MENU)); MENU_SetSel(WM_GetDialogItem(Menuwin,ID_MENU),0); MenuSel = 0; break; case GUI_KEY_PRINT: WM_BringToTop(PrintWin); WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu)); break; case GUI_KEY_LOC1: pCannel = " 490 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_LOC2: pCannel = "4209.5横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_CHS: pCannel = " 486 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_LOCK: SelRow = LISTVIEW_GetSel(hListview); LISTVIEW_GetItemText(hListview,0,SelRow,pStrBuf,5); InfoId = atoi(pStrBuf); Info = pInfoHeader; if (pInfoHeader) do { if (Info->ID == InfoId) { if (Info->isLocked == 0) { LISTVIEW_SetItemText(hListview,6,SelRow," 锁"); Info->isLocked = 1; } else if (Info->isLocked == 1) { LISTVIEW_SetItemText(hListview,6,SelRow,""); Info->isLocked = 0; } break; } }while (Info = Info->pNext); break; case GUI_KEY_DOWN: SelRow = LISTVIEW_GetSel(hListview); if (thispage < pageNum) { if (SelRow == 7) { thispage++; InfoSel(InfoType,thispage); DisPage(); //WM_InvalidateRect(mainwin,&PageRect); } } break; case GUI_KEY_UP: SelRow = LISTVIEW_GetSel(hListview); if(SelRow == 0 && thispage == 1) WM_SetFocus(hButton); if (thispage>1) { if(SelRow == 0) { SelBottom = 1; thispage--; InfoSel(InfoType,thispage); DisPage(); GUI_StoreKeyMsg(GUI_KEY_RIGHT,1); //选择列表中最后一行 } } break; case GUI_KEY_RIGHT: if (SelBottom == 1) { LISTVIEW_SetSel(hListview,7); SelBottom = 0; } break; case GUI_KEY_ESCAPE: SelRow = LISTVIEW_GetSel(hListview); WM_SetFocus(hButton); break; case GUI_KEY_ENTER: SelRow = LISTVIEW_GetSel(hListview); LISTVIEW_GetItemText(hListview,0,SelRow,pStrBuf,5); InfoId = atoi(pStrBuf); Info = pInfoHeader; if (pInfoHeader) do { if (Info->ID == InfoId) { if (Info->state == INFO_STT_New) LISTVIEW_SetItemBitmap(hListview,6,SelRow,10,7,NULL); if (Info->isLocked == 0) TEXT_SetText(WM_GetDialogItem(InfoText,ID_TEXT_0),""); else TEXT_SetText(WM_GetDialogItem(InfoText,ID_TEXT_0),"锁"); Info->state = INFO_STT_Choosen; sprintf(pStrBuf,"%s",pStrBuf); BUTTON_SetText(WM_GetDialogItem(InfoText,ID_BUTTON_0),pStrBuf); MULTIEDIT_SetText(WM_GetDialogItem(InfoText, ID_MULTIEDIT_0),Info->pContent); break; } }while (Info = Info->pNext); WM_BringToTop (InfoText); WM_SetFocus (InfoText); break; } case WM_POST_PAINT: //行分割线 RowNum = LISTVIEW_GetNumRows(hListview); GUI_SetColor(GUI_BLACK); for (RowLineIndex = 0; RowLineIndex<RowNum; RowLineIndex++) GUI_DrawLine(0,(68+40*(RowLineIndex)),720,(68+40*(RowLineIndex))); default : LISTVIEW_Callback(pMsg); break; } }