LRESULT draw_item(DRAWITEMSTRUCT* button_draw) { if (button_draw->itemAction & ODA_FOCUS) { /* Filter drawing for focus-events and key-down events */ return 0; } /* draw the background */ RECT rc_background(button_draw->rcItem); if (button_draw->itemState & ODS_SELECTED) { FillRect(button_draw->hDC, &rc_background, CreateSolidBrush(RGB(0, 0, 0))); InflateRect(&rc_background, -2, -2); } else if (this->is_hovered) { FillRect(button_draw->hDC, &rc_background, CreateSolidBrush(RGB(60, 126, 176))); InflateRect(&rc_background, -2, -2); } else { FillRect(button_draw->hDC, &rc_background, CreateSolidBrush(RGB(195, 202, 206))); InflateRect(&rc_background, -2, -2); } int y_old = rc_background.bottom; rc_background.bottom = rc_background.top + ((rc_background.bottom - rc_background.top) / 2); FillRect(button_draw->hDC, &rc_background, CreateSolidBrush(RGB(255, 255, 255))); rc_background.bottom = y_old; rc_background.top = rc_background.bottom - ((rc_background.bottom - rc_background.top) / 2); FillRect(button_draw->hDC, &rc_background, CreateSolidBrush(RGB(214, 214, 214))); /* draw text labels */ RECT rc_text(button_draw->rcItem); int background_mode = SetBkMode(button_draw->hDC, TRANSPARENT); COLORREF text_color = SetTextColor(button_draw->hDC, RGB(0, 0, 0)); std::size_t text_length = Button_GetTextLength(button_draw->hwndItem); char* text_buffer = new char[text_length + 1]; text_length = Button_GetText(button_draw->hwndItem, text_buffer, text_length + 1); RECT rc_align(rc_text); DrawText(button_draw->hDC, text_buffer, -1, &rc_align, DT_CALCRECT); DrawText(button_draw->hDC, text_buffer, -1, &rc_text, DT_CENTER | DT_SINGLELINE | DT_VCENTER); SetTextColor(button_draw->hDC, text_color); SetBkMode(button_draw->hDC, background_mode); delete[] text_buffer; return 0; }
VOID WINAPI pistaParaAterrarOuDescolar(HWND hControl, INT idLane, HWND hStatic) { Button_GetText(hControl,buffer,MAX_BUFFER); if(buffer[0]=='A') { gestor->SetLanePriorityTo(Plane::LAND,idLane); Button_SetText(hControl,_T("Descolar")); Static_SetText(hStatic,_T("Dá prioridade a aterragens")); } else if(buffer[0]=='D') { gestor->SetLanePriorityTo(Plane::LIFTOFF,idLane); Button_SetText(hControl,_T("Aterrar")); Static_SetText(hStatic,_T("Dá prioridade a descolagens")); } }
VOID WINAPI fecharOuAbrirPista(HWND hControl,INT idLane, HWND hStatic) { Button_GetText(hControl,buffer,MAX_BUFFER); if(buffer[0]=='A') { gestor->abrirPista(idLane); Button_SetText(hControl,_T("Fechar")); Static_SetText(hStatic,_T("Encontra-se aberta")); } else if(buffer[0]=='F') { gestor->fecharPista(idLane); Button_SetText(hControl,_T("Abrir")); Static_SetText(hStatic,_T("Encontra-se fechada")); } }