// полна¤ отрисовка главного окна программы (1) void DrawMainWindow() { char line[64]; // kos_WindowRedrawStatus( WRS_BEGIN ); // окно kos_DefineAndDrawWindow( WNDLEFT, WNDTOP, mcx + 1, mcy + 21, 0x54, 0x0, // Skinned fixed size window, dont fill working area, window has caption 0, WNDHEADCOLOUR, mainWndTitle ); // заголовок окна kos_ChangeWindowCaption(mainWndTitle); mainWndFace.Draw( 1, 21 ); // перва¤ строка kos_WriteTextToWindow( 8, 32, 0, 0x0, mainWndMenuStart, sizeof(mainWndMenuStart)-1 ); // треть¤ строка sprintf( line, mainWndMenuLevel, startGameLevel); kos_WriteTextToWindow( 8, 64, 0, 0x0, line, strlen( line ) ); // кнопки kos_DefineButton( mcx - 29, 64, 12, 12, BT_SIZE_X_MINUS, 0xCCCCCC ); // kos_PutImage( bmPMButton + 12, 6, 2, mcx - 29 + 3, 69 ); // kos_DefineButton( mcx - 16, 64, 12, 12, BT_SIZE_X_PLUS, 0xCCCCCC ); // kos_PutImage( bmPMButton, 6, 6, mcx - 16 + 3, 67 ); // копирайт kos_WriteTextToWindow( 8, mcy - 16 + 21, 0, 0x000066, mainWndCopyright, sizeof(mainWndCopyright)-1 ); // kos_WindowRedrawStatus( WRS_END ); }
void OnMouseMove() { Dword old_buttons = ms.buttons; kos_GetMouseWindowXY(ms.x, ms.y); kos_GetMouseButtonsState(ms.buttons); if ((old_buttons & 0x00000001) == 0 && (ms.buttons & 0x00000001) == 1) { ms.lbclick = 1; } else { ms.lbclick = 0; } kos_WriteTextToWindow(8, 10, 0, TEXT_COLOR, "Population: %", 16); kos_DisplayNumberToWindowBg(health, 3, 79, 10, TEXT_COLOR, BG_COLOR, nbDecimal, false); kos_WriteTextToWindow(8, 22, 0, TEXT_COLOR, "Score:", 6); kos_DisplayNumberToWindowBg(score, 4, 49, 22, TEXT_COLOR, BG_COLOR, nbDecimal, false); if (ms.x >= 0 && ms.x < WINDOW_WIDTH && ms.y >= 0 && ms.y < WINDOW_HEIGHT) { gun->DrawAngle(ms.x, ms.y, G_COLOR); } if (HARDWARE_CURSOR == 0) { cursor->Draw(ms.x, ms.y, CUR_COLOR); } /*if (DEBUG == 1) { kos_DisplayNumberToWindowBg(ms.x, 3, WINDOW_WIDTH - 30, 10, TEXT_COLOR, BG_COLOR, nbDecimal, false); kos_DisplayNumberToWindowBg(ms.y, 3, WINDOW_WIDTH - 30, 22, TEXT_COLOR, BG_COLOR, nbDecimal, false); kos_DisplayNumberToWindowBg(ms.buttons, 1, WINDOW_WIDTH - 30, 34, TEXT_COLOR, BG_COLOR, nbDecimal, false); }*/ }
void OnExit() { kos_WriteTextToWindow(WINDOW_WIDTH / 2 - 35, WINDOW_HEIGHT / 2 - 10, 0, TEXT_COLOR, "Game Over", 9); //while(kos_WaitForEvent() != 2); kos_Pause(200); /*kos_DeleteMouseCursor(cur_handle); for (int i = 0; i < R_COUNT; i++) { delete crosses[i]; delete rockets[i]; } for (int i = 0; i < B_COUNT; i++) { delete bombs[i]; } for (int i = 0; i < R_COUNT + B_COUNT; i++) { delete explodes[i]; } delete[] crosses; delete[] rockets; delete[] bombs; delete[] explodes; delete gun; delete house; if (HARDWARE_CURSOR == 0) { delete cursor; }*/ kos_ExitApp(); }
void draw_window() { double xx0=0.0, yy0=0.0; sProcessInfo info; void *p; if (sel_end_move) sel_moved = 0; memset((Byte*)&info, 0, 1024); kos_ProcessInfo(&info, 0xFFFFFFFF); p = info.rawData + 42; // magic wi = *(Dword *)(p); he = *(Dword *)((Byte *)p + 4); win_x = *(Dword *)((Byte *)p - 8); win_y = *(Dword *)((Byte *)p - 4); myPID = *(Dword*)((Byte *)p - 12); if (wi == 0) wi = WND_W; if (he == 0) he = WND_H; he -= kos_GetSkinHeight() + MENU_PANEL_HEIGHT; // доступная высота окна wi -= 10; if (window_drawall==true){ kos_WindowRedrawStatus(1); kos_DefineAndDrawWindow(10,40,WND_W,WND_H,0x33,0x40FFFFFF,0,0,(Dword)"Table v" TABLE_VERSION); kos_WindowRedrawStatus(2); if (info.rawData[70]&0x04) return; //ничего не делать если окно схлопнуто в заголовок if (he < 100) kos_ChangeWindow( -1, -1, -1, 180 ); if (wi < 340) kos_ChangeWindow( -1, -1, 350, -1 ); } // edit_box_draw((dword)&ebox); int y = he + kos_GetSkinHeight() - 10; if (!sel_moved) { kos_DrawBar(wi-15,he - kos_GetSkinHeight() +7,16,16,0xe4dfe1); kos_DrawBar(0,he - kos_GetSkinHeight() + 23,wi + 1,MENU_PANEL_HEIGHT-5,0xe4dfe1); kos_WriteTextToWindow(3 + 1, y + 3, 0x80 , 0x000000, (char*)sFilename, strlen(sFilename)); } //DWORD fn_line_color = fn_edit ? 0x000000 : 0xc0c0c0; //kos_DrawRegion(61, y - 2, 102, 18, fn_line_color, 0); // дальше editbox width = 100 // border around edit box file_box.left = 64; file_box.top = y - 1; file_box.width = 98; //editbox_h = 18; // сохранить kos_DefineButton(20 + 160, y - 5, 60, 20, SAVE_BUTTON, 0xd0d0d0); kos_WriteTextToWindow(22 + 160 + (60 - strlen(sSave) * 6) / 2, y + 2, 0, 0x000000, (char*)sSave, strlen(sSave)); // загрузить kos_DefineButton(90 + 160, y - 5, 60, 20, LOAD_BUTTON, 0xd0d0d0); kos_WriteTextToWindow(92 + 160 + (60 - strlen(sLoad) * 6) / 2, y + 2, 0, 0x000000, (char*)sLoad, strlen(sLoad)); // создать. только эту кнопу воткнуть некуда о_О /* kos_DefineButton(90 + 160 + 70, y - 5, 60, 20, NEW_BUTTON, 0xd0d0d0); kos_WriteTextToWindow(92 + 160 + 10 + 70, y + 2, 0, 0x000000, (char*)sNew, strlen(sNew)); */ panel_y = y; if ((void*)edit_box_draw != NULL) { if (is_edit) edit_box_draw((DWORD)&cell_box); edit_box_draw((DWORD)&file_box); } draw_grid(); window_drawall=false; sel_moved = 0; }
void draw_grid() { int i,j; long x0 = 0, y0 = 0, x = 0, y = 0, dx, popravka; DWORD text_color; //int lx, ly; // sprintf(debuf, "%U,%U", scroll_x, scroll_y); // rtlDebugOutString(debuf); nx=ny=0; // очистить область около выделенной ячейки if (sel_moved) { clear_cell_slow(sel_x, sel_y); clear_cell_slow(prev_x, prev_y); } else { // очистить всю область ячеек //kos_DrawBar(col_width[0]+1, row_height[0]+1, wi - SCROLL_BAR_WIDTH-col_width[0]-1, he - SCROLL_BAR_HEIGHT-row_height[0]-1, 0xffffff); } col_left[0] = 0; // ячейки - заголовки столбцов + вертикальные линии x = col_width[0]; nx = 1; for (i = 1; i < col_count; i++) { col_left[i] = -1; if (i >= scroll_x) { { if (!sel_moved || is_x_changed(i)) kos_DrawLine(x-x0, 0, x-x0, row_height[0], GRID_COLOR, 0); // и заголовок ячейки по х text_color = TEXT_COLOR; dx = (col_width[i]-6)/2; int dy = (row_height[0] - 8) / 2 + 1; int cur_width = col_width[i] - 1; if (cur_width + x - x0 > wi - SCROLL_BAR_WIDTH) cur_width = wi - SCROLL_BAR_WIDTH - x + x0; if (!sel_moved || (is_x_changed(i))) if (is_between(i,sel_x,sel_end_x)) { kos_DrawBar(x - x0 + 1,0,cur_width,row_height[0],SEL_FIXED_CELL_COLOR); //0x0000CC text_color = TEXT_SEL_FIXED_COLOR; } else { kos_DrawBar(x - x0 + 1,0,cur_width,row_height[0],FIXED_CELL_COLOR); text_color = TEXT_COLOR; } if (!sel_moved || (is_x_changed(i))) kos_WriteTextToWindow(x-x0+2+dx,dy,0,text_color,cells[i][0],strlen(cells[i][0])); // есть кнопка стоблца и еще кнопка изменения ширины if (x - x0 + col_width[i] <= wi - col_width[0]) { //kos_DeleteButton(COL_HEAD_BUTTON+i); kos_DefineButton(x-x0+5,0,cur_width - 10,row_height[0]-1,0x60000000+COL_HEAD_BUTTON+i,0); } //kos_DefineButton(x-x0+col_width[i]-10,0,15,row_height[0]-1,0x60000000+COL_SIZE_BUTTON+i,0); col_left[i] = x - x0; } if (x - x0 > wi - col_width[0]) { x += col_width[i]; nx++; break; } } else { x0 += col_width[i]; } x += col_width[i]; nx++; } //kos_DefineButton(0,0,0,0,0x80000000+COL_HEAD_BUTTON+i,0); for (j = i + 1; j < col_count; j++) col_left[j] = wi; //if (!sel_moved || (is_x_changed(nx))) kos_DrawLine(x - x0, 0, x - x0, he, GRID_COLOR, 0); // ячейки - заголовки строк + горизонт. линии y = row_height[0]; ny = 1; row_top[0] = 0; for (i = 1; i < row_count && y - y0 < he - 10; i++) { row_top[i] = -1; if (i >= scroll_y) { { if (!sel_moved || (is_y_changed(i))) kos_DrawLine(0, y - y0, wi - SCROLL_BAR_WIDTH, y - y0, GRID_COLOR, 0); // и заголовок ячейки по y text_color = TEXT_COLOR; dx = (col_width[0]-6 * strlen(cells[0][i]))/2; // optimize this, change strlen int dy = (row_height[i] - 8) / 2 + 1; if (!sel_moved || (is_y_changed(i))) if (is_between(i,sel_y,sel_end_y)) { kos_DrawBar(0,y-y0+1,col_width[0],row_height[i] - 1,SEL_FIXED_CELL_COLOR); text_color = TEXT_SEL_FIXED_COLOR; } else { kos_DrawBar(0,y-y0+1,col_width[0],row_height[i] - 1,FIXED_CELL_COLOR); text_color = TEXT_COLOR; } if (!sel_moved || (is_y_changed(i))) kos_WriteTextToWindow(2+dx,y-y0+dy,0,text_color,cells[0][i],strlen(cells[0][i])); kos_DefineButton(0,y-y0+5,col_width[0]-1,row_height[i]-6,0x60000000+ROW_HEAD_BUTTON+i,0); //kos_DefineButton(0,y-y0+row_height[i]-5,col_width[0]-1,10,0x60000000+ROW_SIZE_BUTTON+i,0); row_top[i] = y - y0; } } else { y0 += row_height[i]; } y += row_height[i]; ny++; } kos_DefineButton(0,0,0,0,0x80000000+ROW_HEAD_BUTTON+ny-1,0); for (j = i + 1; j < row_count; j++) row_top[j] = he; if (!sel_moved || (is_y_changed(ny))) kos_DrawLine(0, y - y0, wi - SCROLL_BAR_WIDTH, y - y0, GRID_COLOR, 0); if (!sel_moved || (is_x_changed(0) && is_y_changed(0))) kos_DrawBar(0,0,col_width[0],row_height[0],FIXED_CELL_COLOR); // ЛВ ячейка //sprintf(debuf, "%U, %U; %U, %U", x0, y0, nx, ny); //rtlDebugOutString(debuf); // popravka = (y - y0 < he - 10); //sprintf(debuf, "%U, %U", scroll_y, ny); //rtlDebugOutString(debuf); // сами ячейки y = row_height[0]; for (i = scroll_y; i < ny; i++) { x = col_width[0]; if (!sel_moved) kos_DrawBar(col_width[0]+1, y+1, wi - SCROLL_BAR_WIDTH-col_width[0]-1, row_height[i]-1, 0xffffff); for (j = scroll_x; j < nx-1; j++) { if (!sel_moved || is_x_changed(j) || is_y_changed(i)) kos_DrawLine(col_left[j], row_top[i], col_left[j], row_height[i], GRID_COLOR, 0); // заголовки уже нарисованы - пропускаем их if (i && j) { //kos_DrawBar(x+1, y+1, col_width[i]-1, row_height[i]-1, 0xffffff); //rtlDebugOutString(cap); //if (j >= sel_x && j <= sel_end_x && i >= sel_y && i <= sel_end_y) if (is_between(j,sel_x,sel_end_x) && is_between(i, sel_y, sel_end_y) // (j,i) - выделена && ((!sel_moved) || (is_x_changed(j) && is_y_changed(i)))) // и ее нужно нарисовать { if (i == sel_y && j == sel_x) // рамка { kos_DrawBar(x,y,col_width[j],2,TEXT_COLOR); // up kos_DrawBar(x,y,2,row_height[i],TEXT_COLOR); // left kos_DrawBar(x,y+row_height[i]-2,col_width[j]-2-3,2,TEXT_COLOR); // bottom kos_DrawBar(x+col_width[j]-2,y, 2,row_height[i]-2-3,TEXT_COLOR); // right kos_DrawBar(x+col_width[j]-4,y+row_height[i]-4,4,4,TEXT_COLOR); //kos_DefineButton(x+col_width[j]-2,y+row_height[i]-2,4,4,0x60000000+DRAG_BUTTON,0x000000); drag_x = x + col_width[j] - 4; drag_y = y + row_height[i] - 4; } else kos_DrawBar(x + 1,y + 1,col_width[j] - 2,row_height[i] - 2,SEL_CELL_COLOR); // выделена но не основная(серая) } //kos_DefineButton(x,y,col_width[j]-1,row_height[i]-1,0x60000000+CELL_BUTTON+((i << 8) + j),0); char *text; if (values[j][i] && values[j][i][0] == '#') { text = cells[j][i]; kos_DrawRegion(x+1, y+1, col_width[j]-1, row_height[i]-1, 0xff0000, 0); } else text = (values[j][i] && !display_formulas ? values[j][i] : cells[j][i]); int dy = (row_height[i] - 8) / 2 + 1; if (text) if (strlen(text) < col_width[j]/6) kos_WriteTextToWindow(x+2,y+dy,0,text_color,text,strlen(text)); else kos_WriteTextToWindow(x+2,y+dy,0,text_color,text,col_width[j]/6); } if (!sel_moved || is_x_changed(j) || is_y_changed(i)) kos_DrawLine(col_left[j]+col_width[j], row_top[i], col_left[j]+col_width[j], row_height[i], GRID_COLOR, 0); x += col_width[j]; } y += row_height[i]; } // Scrolls: // horizontal //if (!sel_moved) kos_DrawBar(0, he - SCROLL_BAR_HEIGHT, wi - SCROLL_BAR_WIDTH, SCROLL_BAR_HEIGHT, FIXED_CELL_COLOR); //if (!sel_moved) kos_DrawBar(scroll_x * wi / col_count, he - SCROLL_BAR_HEIGHT, wi / col_count, SCROLL_BAR_HEIGHT, SEL_FIXED_CELL_COLOR); if (!sel_moved) { // горизонталь kos_DrawBar(17, he - SCROLL_BAR_HEIGHT, wi - SCROLL_BAR_WIDTH - 32, SCROLL_BAR_HEIGHT, 0xced0d0); // синие линии kos_DrawRegion(0, he - SCROLL_BAR_HEIGHT, wi - SCROLL_BAR_WIDTH, SCROLL_BAR_HEIGHT+1, 0x94aece, 0); // левая кнопка draw_custom_button(1, he - SCROLL_BAR_HEIGHT + 1, 14, 14, 1); kos_WriteTextToWindow(6, he - SCROLL_BAR_HEIGHT + 5, 0, 0, "\x1B", 1); // правая draw_custom_button(wi - SCROLL_BAR_WIDTH * 2 + 1, he - SCROLL_BAR_HEIGHT + 1, 14, 14, 1); kos_WriteTextToWindow(wi - SCROLL_BAR_WIDTH * 2 + 6, he - SCROLL_BAR_HEIGHT + 5, 0, 0, "\x1A", 1); // ползунок int tmp_w = (nx - scroll_x) * (wi - SCROLL_BAR_WIDTH - 2 * 14 - 14) / (col_count + 1); if (tmp_w < 16) tmp_w = 16; draw_custom_button(17 + (scroll_x - 1) * (wi - SCROLL_BAR_WIDTH - 2 * 14 - 14) / (col_count + 1), he - SCROLL_BAR_HEIGHT + 1, tmp_w, 14, 1); #define sw(x,y) y,x // не пинайте меня за это, было лень переставлять руками... // вертикаль kos_DrawBar(sw(17, wi - SCROLL_BAR_WIDTH), sw(he - SCROLL_BAR_HEIGHT - 33, SCROLL_BAR_WIDTH), 0xced0d0); // синие линии kos_DrawRegion(sw(0, wi - SCROLL_BAR_WIDTH), sw(he - SCROLL_BAR_HEIGHT, SCROLL_BAR_WIDTH+1), 0x94aece, 0); // up // верхняя кнопка draw_custom_button(sw(1, wi - SCROLL_BAR_WIDTH + 1), 14, 14, 1); kos_WriteTextToWindow(sw(5, wi - SCROLL_BAR_WIDTH + 6), 0, 0, "\x18", 1); // нижняя draw_custom_button(sw(he - SCROLL_BAR_HEIGHT * 2 + 1, wi - SCROLL_BAR_WIDTH + 1), 14, 14, 1); //draw_custom_button(sw(he - SCROLL_BAR_HEIGHT * 2 + 1, wi - SCROLL_BAR_WIDTH + 1), 14, 14, 1); kos_WriteTextToWindow(sw(he - SCROLL_BAR_HEIGHT * 2 + 5, wi - SCROLL_BAR_WIDTH + 6), 0, 0, "\x19", 1); // ползунок int tmp_h = (ny - scroll_y) * (he - SCROLL_BAR_HEIGHT - 2 * 14 - 14) / (row_count + 1); if (tmp_h < 16) tmp_h = 16; draw_custom_button(sw(17 + (scroll_y - 1) * (he - SCROLL_BAR_HEIGHT - 2 * 14 - 14) / (row_count + 1), wi - SCROLL_BAR_WIDTH + 1), sw(tmp_h, 14), 1); } #define NO_DRAW 0x60000000 kos_DefineButton(1, he - SCROLL_BAR_HEIGHT + 1, 14, 14, NO_DRAW + SCROLL_LEFT_BUTTON,0); kos_DefineButton(wi - SCROLL_BAR_WIDTH * 2 + 2, he - SCROLL_BAR_HEIGHT + 1, 14, 14, NO_DRAW + SCROLL_RIGHT_BUTTON,0); kos_DefineButton(17, he - SCROLL_BAR_HEIGHT + 1, (wi - SCROLL_BAR_WIDTH - 2 * 14), 14, NO_DRAW + SCROLL_WIDTH,0); kos_DefineButton(sw(1, wi - SCROLL_BAR_WIDTH + 1), 14, 14, NO_DRAW + SCROLL_UP_BUTTON,0); kos_DefineButton(sw(he - SCROLL_BAR_HEIGHT * 2 + 2, wi - SCROLL_BAR_WIDTH + 1), 14, 14, NO_DRAW + SCROLL_DOWN_BUTTON,0); kos_DefineButton(sw(17, wi - SCROLL_BAR_WIDTH + 1), sw((he - SCROLL_BAR_HEIGHT - 2 * 14), 14), NO_DRAW + SCROLL_HEIGHT,0); }
void process_button() { Dword mouse_btn, ckeys, shift, ctrl; int mouse_x, mouse_y, i, p, dx = 0, dy = 0; int redraw = 0; Dword button; kos_GetButtonID(button); /* sprintf(debuf, "button %U", button); rtlDebugOutString(debuf); //*/ switch (button) { case 1: kos_ExitApp(); case SCROLL_LEFT_BUTTON: //rtlDebugOutString("scroll left btn"); stop_edit(); scroll_x--; if (scroll_x <= 0) scroll_x = 1; sel_moved = 0; /*if (sel_x > nx - 1) { nx - 1; sel_end_x = sel_x; }*/ draw_window(); return; case SCROLL_RIGHT_BUTTON: //rtlDebugOutString("scroll right btn"); stop_edit(); scroll_x++; if (scroll_x >= col_count - 1) scroll_x = col_count - 1; sel_moved = 0;/* if (sel_x < scroll_x) { sel_x = scroll_x; sel_end_x = sel_x; }*/ draw_window(); return; case SCROLL_WIDTH: { //rtlDebugOutString("scroll width btn"); stop_edit(); kos_GetMouseState(mouse_btn, mouse_x, mouse_y); mouse_x -= 5; mouse_y -= kos_GetSkinHeight(); // всего: wi - SCROLL_BAR_WIDTH - 2 * 14 int tmp_w = (nx - scroll_x) * (wi - SCROLL_BAR_WIDTH - 3 * 14) / (col_count + 1); if (tmp_w < 16) tmp_w = 16; scroll_x = (mouse_x - 14 - tmp_w / 2) * (col_count + 1) / (wi - SCROLL_BAR_WIDTH - 3 * 14) + 1; if (scroll_x <= 0) scroll_x = 1; else if (scroll_x >= col_count - 1) scroll_x = col_count - 1; sel_moved = 0; draw_window(); return; } case SCROLL_UP_BUTTON: stop_edit(); scroll_y--; if (scroll_y <= 0) scroll_y = 1; sel_moved = 0; //draw_window(); draw_grid(); /* if (sel_y > ny - 1) { sel_y = ny - 1; sel_end_y = sel_y; }*/ return; case SCROLL_DOWN_BUTTON: stop_edit(); scroll_y++; if (scroll_y >= row_count - 1) scroll_y = row_count - 1; sel_moved = 0;/* if (sel_y < scroll_y) { sel_y = scroll_y; sel_end_y = sel_y; }*/ draw_grid(); return; case SCROLL_HEIGHT: { stop_edit(); kos_GetMouseState(mouse_btn, mouse_x, mouse_y); mouse_x -= 5; mouse_y -= kos_GetSkinHeight(); int tmp_h = (ny - scroll_y) * (he - SCROLL_BAR_HEIGHT - 2 * 14) / row_count; if (tmp_h < 16) tmp_h = 16; scroll_y = (mouse_y - 2 * 14) * (row_count + 1) / (he - SCROLL_BAR_HEIGHT - 3 * 14) + 1; if (scroll_y <= 0) scroll_y = 1; else if (scroll_y >= row_count - 1) scroll_y = row_count - 1; sel_moved = 0; draw_grid(); return; } case NEW_BUTTON: // clear the table reinit(); draw_window(); break; case FILENAME_BUTTON: sel_moved = 1; stop_edit(); fn_edit = 1; strcpy(edit_text, fname); draw_window(); break; case SAVE_BUTTON: stop_edit(); kos_DrawBar(320, panel_y, wi - 320 - 10, 10, 0xe4dfe1); if (SaveFile(fname)) kos_WriteTextToWindow(320, panel_y, 0, 0x000000, (char*)msg_save, strlen(msg_save)); break; case LOAD_BUTTON: stop_edit(); int r = LoadFile(fname); kos_DrawBar(320, panel_y, wi - 320 - 10, 10, 0xe4dfe1); if (r > 0) { calculate_values(); sel_moved = 0; draw_window(); kos_WriteTextToWindow(320, panel_y,0,0x000000,(char*)msg_load, strlen(msg_load)); } else if (r == -1) kos_WriteTextToWindow(320, panel_y,0,0x000000,(char*)er_file_not_found,strlen(er_file_not_found)); else if (r == -2) kos_WriteTextToWindow(320, panel_y,0,0x000000,(char*)er_format,strlen(er_format)); break; } if (button >= COL_HEAD_BUTTON && button < ROW_HEAD_BUTTON) { sel_end_x = sel_x = button - COL_HEAD_BUTTON; sel_y = 1; sel_end_y = row_count - 1; stop_edit(); draw_window(); return; } else if (button >= ROW_HEAD_BUTTON && button < CELL_BUTTON) { sel_end_y = sel_y = button - ROW_HEAD_BUTTON; sel_x = 1; sel_end_x = col_count - 1; stop_edit(); draw_window(); return; } }
void outtextxy( int x, int y, char *s, int len) { kos_WriteTextToWindow(x,y,0,SysColor,s,len); }
void draw_window(void){ //Рисуем окно sProcessInfo sPI; kos_WindowRedrawStatus(1); kos_DefineAndDrawWindow(10,10,619,179+kos_GetSkinHeight(),0x74, 0xDDDDFF, 0,0, (Dword)header); kos_WindowRedrawStatus(2); kos_ProcessInfo( &sPI ); if (sPI.rawData[70]&0x04) return; //ничего не делать если окно схлопнуто в заголовок if (status==0){ //Меню kos_DrawBar(0,0,610,175,0xFFFFBB); kos_WriteTextToWindow (10,10,0x80,0x000000, "Љв® е®зҐв Ўлвм ¬Ё««Ё®Ґа®¬?", 3); kos_WriteTextToWindow (10,25,0x80,0x000000, sVersion, 3); kos_WriteTextToWindow (10,70,0x80,0x770000, "<ENTER> - з вм ЁЈаг", 0); kos_WriteTextToWindow (10,85,0x80,0x770000, "<ESC> - ўл室", 0); kos_WriteTextToWindow (10,150,0x80,0x000000, "(C) 2008 Ђ¤аҐ© ЊЁе ©«®ўЁз aka Dron2004", 0); //kos_DisplayNumberToWindow (questioncount,3,40,60,0x000000, nbDecimal, false); } if (status==1){ //Игра kos_DrawBar(0,0,610,175,0xEEEEFF); kos_WriteTextToWindow (10,10,0x0,0x000000, question, questionlength-1); if (drawA==true){ kos_WriteTextToWindow (10,40,0x80,0x000000, "A. ", 0); kos_WriteTextToWindow (30,40,0x0,0x000000, answerA, answerAlength-1); } if (drawB==true){ kos_WriteTextToWindow (10,60,0x80,0x000000, "B. ", 0); kos_WriteTextToWindow (30,60,0x0,0x000000, answerB, answerBlength-1); } if (drawC==true){ kos_WriteTextToWindow (10,80,0x80,0x000000, "C. ", 0); kos_WriteTextToWindow (30,80,0x0,0x000000, answerC, answerClength-1); } if (drawD==true){ kos_WriteTextToWindow (10,100,0x80,0x000000, "D. ", 0); kos_WriteTextToWindow (30,100,0x0,0x000000, answerD, answerDlength-1); } if (na50available==true){kos_WriteTextToWindow (30,150,0x80,0x000000, "<7> 50 50", 0);} if (callfriendavailable==true){kos_WriteTextToWindow (150,150,0x80,0x000000, "<8> ‡ў®®Є ¤агЈг", 0);} if (zalavailable==true){kos_WriteTextToWindow (280,150,0x80,0x000000, "<9> Џ®¤бЄ §Є § « ", 0);} if((na50available==false)&&(callfriendavailable==false)&&(zalavailable==false)) {kos_WriteTextToWindow (30,150,0x80,0x000000, "<BACKSPACE> - § Ўа вм ¤ҐмЈЁ Ё г©вЁ", 0);} kos_WriteTextToWindow (430,130,0x80,0x000000, "‚®Їа®б ", 0); kos_WriteTextToWindow (500,130,0x80,0x000000, summs[currentquestion], 0); kos_WriteTextToWindow (430,150,0x80,0x000000, "“ ў б", 0); kos_WriteTextToWindow (500,150,0x80,0x000000, summs[currentquestion-1], 0); } if (status==2){ //Окно "Это - правильный ответ" kos_DrawBar(0,0,610,175,0xDDFFDD); kos_WriteTextToWindow (10,10,0x80,0x000000, "„ , нв® Їа ўЁ«мл© ®вўҐв!", 0); kos_WriteTextToWindow (10,150,0x80,0x000000, "<ENTER> - Їа®¤®«¦Ёвм", 0); } if (status==3){ //Вы выиграли миллион, однако ж!!! kos_DrawBar(0,0,610,175,0x00FF00); kos_WriteTextToWindow (10,10,0x80,0x000000, "‚л ўлЁЈа «Ё ¬Ё««Ё®!!!", 0); kos_WriteTextToWindow (10,150,0x80,0x000000, "<ESC> - ўл室", 0); } if (status==4){ //Звонок другу kos_DrawBar(0,0,610,175,0xAAFFFF); kos_WriteTextToWindow (10,10,0x80,0x000000, "„агЈ б®ўҐвгҐв ў ¬ ®вўҐв", 0); kos_WriteTextToWindow (165,10,0x80,0x000000, friendsAdvice, 0); kos_WriteTextToWindow (10,150,0x80,0x000000, "<ENTER> - Їа®¤®«¦Ёвм", 0); } if (status==5){ //Подсказка зала kos_DrawBar(0,0,610,175,0xAAFFFF); kos_WriteTextToWindow (10,10,0x80,0x000000, "ЊҐЁҐ г¤Ёв®аЁЁ а бЇаҐ¤Ґ«Ё«®бм в Є:", 0); if (drawA==true){ kos_WriteTextToWindow (10,30,0x80,0x000000, "ЋвўҐв A: ", 0); kos_DisplayNumberToWindow(zalA,3,60,30,0x000000,nbDecimal,0); kos_WriteTextToWindow (80,30,0x80,0x000000, "%", 0); } if (drawB==true){ kos_WriteTextToWindow (10,45,0x80,0x000000, "ЋвўҐв B: ", 0); kos_DisplayNumberToWindow(zalB,3,60,45,0x000000,nbDecimal,0); kos_WriteTextToWindow (80,45,0x80,0x000000, "%", 0); } if (drawC==true){ kos_WriteTextToWindow (10,60,0x80,0x000000, "ЋвўҐв C: ", 0); kos_DisplayNumberToWindow(zalC,3,60,60,0x000000,nbDecimal,0); kos_WriteTextToWindow (80,60,0x80,0x000000, "%", 0); } if (drawD==true){ kos_WriteTextToWindow (10,75,0x80,0x000000, "ЋвўҐв D: ", 0); kos_DisplayNumberToWindow(zalD,3,60,75,0x000000,nbDecimal,0); kos_WriteTextToWindow (80,75,0x80,0x000000, "%", 0); } kos_WriteTextToWindow (10,150,0x80,0x000000, "<ENTER> - Їа®¤®«¦Ёвм", 0); } if (status==6){ //Вы забрали деньги ;-) kos_DrawBar(0,0,610,175,0xBBFFBB); kos_WriteTextToWindow (10,10,0x80,0x000000, "‚л § Ўа «Ё ¤ҐмЈЁ Ё ги«Ё. ‚ и ўлЁЈали б®бв ўЁ«:", 0); kos_WriteTextToWindow (10,20,0x80,0x000000, summs[currentquestion-1], 0); kos_WriteTextToWindow (10,150,0x80,0x000000, "<ESC> - ўл室", 0); } if (status==-1){ //Вы ошиблись :-( kos_DrawBar(0,0,610,175,0xFF8888); kos_WriteTextToWindow (10,10,0x80,0x000000, "Љ ᮦ «ҐЁо, ўл ®иЁЎ«Ёбм... Џа ўЁ«мл© ®вўҐв -", 0); switch (correctanswer){ case 0x01: kos_WriteTextToWindow (10,25,0x80,0x000000, "A. ", 0); kos_WriteTextToWindow (30,25,0x0,0x000000, answerA, answerAlength-1); break; case 0x02: kos_WriteTextToWindow (10,25,0x80,0x000000, "B. ", 0); kos_WriteTextToWindow (30,25,0x0,0x000000, answerB, answerBlength-1); break; case 0x03: kos_WriteTextToWindow (10,25,0x80,0x000000, "C. ", 0); kos_WriteTextToWindow (30,25,0x0,0x000000, answerC, answerClength-1); break; case 0x04: kos_WriteTextToWindow (10,25,0x80,0x000000, "D. ", 0); kos_WriteTextToWindow (30,25,0x0,0x000000, answerD, answerDlength-1); break; } kos_WriteTextToWindow (10,50,0x80,0x000000, "‚ १г«мв ⥠ўл ўлЁЈа «Ё:", 0); if (currentquestion<6) {kos_WriteTextToWindow (220,50,0x80,0x000000,summs[0], 0);} if ((currentquestion>5)&&(currentquestion<11)) {kos_WriteTextToWindow (220,50,0x80,0x000000,summs[5], 0);} if (currentquestion>10) {kos_WriteTextToWindow (220,50,0x80,0x000000,summs[10], 0);} kos_WriteTextToWindow (10,150,0x80,0x000000, "<ESC> - ўл室", 0); } }