diff --git a/data/common/icons16.png b/data/common/icons16.png index 171fdf9aaa..5079521e45 100644 Binary files a/data/common/icons16.png and b/data/common/icons16.png differ diff --git a/programs/cmm/lib/gui/sensor.h b/programs/cmm/lib/gui/sensor.h index b6fd40ea90..97b40f9d1b 100644 --- a/programs/cmm/lib/gui/sensor.h +++ b/programs/cmm/lib/gui/sensor.h @@ -24,22 +24,18 @@ :void sensor::draw_wrapper() { DrawRectangle(x-1, y-1, w+1, h+1, sc.work_graph); - DrawRectangle3D(x-2, y-2, w+3, h+3, sc.work_dark, sc.work_light); + DrawRectangle3D(x-2, y-2, w+3, h+3, sc.work, sc.work_light); } -:void sensor::draw_progress(dword progress_w, active_value, bg_value, mesure) +:void sensor::draw_progress(dword progress_w) { - if (progress_w < MIN_PB_BLOCK_W) progress_w = MIN_PB_BLOCK_W; - if (progress_w > w-MIN_PB_BLOCK_W) progress_w = w-MIN_PB_BLOCK_W; - + char textp[16]; DrawBar(x, y, w-progress_w, 1, MixColors(PROGRESS_ACTIVE, PROGRESS_BG, 200)); DrawBar(x, y+1, w-progress_w, h-2, PROGRESS_ACTIVE); DrawBar(x, y+h-1, w-progress_w, 1, MixColors(PROGRESS_ACTIVE, sc.work_graph, 200)); - - sprintf(#param, "%i%s", active_value, mesure); - WriteText(w-progress_w- calc(strlen(#param)*8) /2 + x, h/2-7+y, 0x90, PROGRESS_BG, #param); - DrawBar(x+w-progress_w, y, progress_w, h, PROGRESS_BG); - sprintf(#param, "%i%s", bg_value, mesure); - WriteText(-progress_w - calc(strlen(#param)*8)/2 + w+x, h/2-7+y, 0x90, PROGRESS_BG_TEXT, #param); + + strcpy(#textp, itoa(w-progress_w*100/w)); + chrcat(#textp, '%'); + WriteText(-strlen(#textp)*8 + w / 2 + x, h/2-7+y, 0x90, 0x000000, #textp); } \ No newline at end of file diff --git a/programs/cmm/lib/gui/tabs.h b/programs/cmm/lib/gui/tabs.h index cafc751cb1..281f1f98a8 100644 --- a/programs/cmm/lib/gui/tabs.h +++ b/programs/cmm/lib/gui/tabs.h @@ -1,12 +1,14 @@ - +#ifndef TAB_PADDING #define TAB_PADDING 15 +#endif + #define TAB_HEIGHT 28 :struct _tabs { int active_tab; int x,y,w,h; - void draw_button(); + dword draw_button(); int click(); void draw_wrapper(); }; @@ -14,10 +16,10 @@ :void _tabs::draw_wrapper() { DrawRectangle(x,y+TAB_HEIGHT,w-1,h-TAB_HEIGHT, sc.work_graph); - DrawRectangle(x+1,y+1+TAB_HEIGHT,w-3,h-2-TAB_HEIGHT, sc.work_light); + DrawBar(x+1,y+1+TAB_HEIGHT,w-3,1, sc.work_light); } -:void _tabs::draw_button(dword xx, but_id, text) +:dword _tabs::draw_button(dword xx, but_id, text) { dword col_bg, col_text; dword ww=strlen(text)*8, hh=TAB_HEIGHT; @@ -36,6 +38,7 @@ WriteText(xx, y+6, 0x90, col_text, text); DrawBar(xx, y+hh-3, ww, 3, col_bg); //DrawStandartCaptButton(xx, y, but_id, text); //GetFreeButtonId() + return xx; } :int _tabs::click(int N) diff --git a/programs/cmm/lib/patterns/libimg_load_skin.h b/programs/cmm/lib/patterns/libimg_load_skin.h index a9f1d0e972..ce85dd9c2b 100644 --- a/programs/cmm/lib/patterns/libimg_load_skin.h +++ b/programs/cmm/lib/patterns/libimg_load_skin.h @@ -43,4 +43,15 @@ if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32); } +:libimg_image icons16draw; +:void DrawIcon16(dword x,y, bg, icon_n) { + //load_dll(libimg, #libimg_init,1); + if (!icons16draw.image) { + Libimg_LoadImage(#icons16draw, "/sys/icons16.png"); + Libimg_ReplaceColor(icons16draw.image, icons16draw.w, icons16draw.h, 0xffFFFfff, bg); + Libimg_ReplaceColor(icons16draw.image, icons16draw.w, icons16draw.h, 0xffCACBD6, MixColors(bg, 0, 220)); + } + if (icon_n>=0) img_draw stdcall(icons16draw.image, x, y, 16, 16, 0, icon_n*16); +} + #endif \ No newline at end of file diff --git a/programs/cmm/sysmon/cpu_ram.h b/programs/cmm/sysmon/cpu_ram.h new file mode 100644 index 0000000000..614041eda0 --- /dev/null +++ b/programs/cmm/sysmon/cpu_ram.h @@ -0,0 +1,96 @@ +//===================================================// +// // +// DATA // +// // +//===================================================// + +sensor cpu; +sensor ram; + +//===================================================// +// // +// CODE // +// // +//===================================================// + +void DrawIconWithText(dword _x, _y, _icon, _title) +{ + DrawIcon16(_x, _y, sc.work, _icon); + DrawBar(_x+ICONGAP, _y, WIN_CONTENT_W - ICONGAP - _x, 20, sc.work); + WriteText(_x+ICONGAP, _y, 0x90, sc.work_text, _title); +} + +void CPUnRAM__Main() +{ + dword cpu_frequency = GetCpuFrequency()/1000; + SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON); + goto _GENERAL_REDRAW_2; + loop() + { + WaitEventTimeout(25); + switch(EAX & 0xFF) + { + case evButton: Sysmon__ButtonEvent(); break; + case evKey: Sysmon__KeyEvent(); break; + case evReDraw: + _GENERAL_REDRAW_2: + Sysmon__DefineAndDrawWindow(); + cpu.set_size(WIN_PAD, WIN_CONTENT_Y+25, WIN_CONTENT_W, 100); + ram.set_size(WIN_PAD, WIN_CONTENT_Y+170, WIN_CONTENT_W, 23); + default: + MonitorCpu(); + MonitorRam(); + } + } +} + +dword GetCpuLoad(dword max_h) +{ + dword idle; + dword CPU_SEC = GetCpuFrequency() >> 20 + 1; + dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h; + + EAX = IDLE_SEC; + EBX = CPU_SEC; + $cdq + $div ebx + idle = EAX; + + return max_h - idle; +} + +int pos=0; +void MonitorCpu() +{ + static dword cpu_stack[1980*3]; + int i; + if (!cpu.w) return; + + cpu_stack[pos] = GetCpuLoad(cpu.h); + if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2; + + sprintf(#param, "CPU load %i%%", cpu_stack[pos]); + DrawIconWithText(WIN_PAD, cpu.y - 25, 48, #param); + + for (i=0; i=WIN_CONTENT_W) { + pos = WIN_CONTENT_W-1; + for (i=0; i> 20 + 1; - dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h; - - EAX = IDLE_SEC; - EBX = CPU_SEC; - $cdq - $div ebx - idle = EAX; - - return max_h - idle; -} - -dword GetDiskSize(dword disk_n) -{ - BDVK bdvk; - char tmp_path[8]; - strcpy(#tmp_path, "/tmp0/1"); - tmp_path[4] = disk_n + '0'; - GetFileInfo(#tmp_path, #bdvk); - return bdvk.sizelo; -} -void GetTmpDiskSizes() -{ - char i; - for (i=0; i<=9; i++) - { - tmp_size[i] = GetDiskSize(i) / 1024 / 1024; - } -} - -//===================================================// -// // -// MONITORS // -// // -//===================================================// - -int pos=0; -void MonitorCpu() -{ - int i; - if (!cpu.w) return; - - cpu_stack[pos] = GetCpuLoad(cpu.h); - if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2; - - DrawBar(cpu.x+cpu.w-30, cpu.y-25, 30, 20, sc.work); - sprintf(#param, "%i%%", cpu_stack[pos]); - WriteText(cpu.x+cpu.w-calc(strlen(#param)*8), cpu.y-25, 0x90, sc.work_text, #param); - - for (i=0; i=WIN_CONTENT_W) { - pos = WIN_CONTENT_W-1; - for (i=0; i2) return false; + //if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } + //if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } + tabs.draw_wrapper(); + butx = tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_CPU_AND_RAM); + butx = tabs.draw_button(strlen(T_CPU_AND_RAM)*8+TAB_PADDING+butx, TAB_DRIVES, T_DRIVES); + tabs.draw_button(strlen(T_DRIVES)*8+TAB_PADDING+butx, TAB_PROCESSES, T_PROCESSES); + return true; +} + +int Sysmon__ButtonEvent() +{ + int bid = GetButtonID(); + if (1==bid) ExitProcess(); + if (TAB_GENERAL==bid) { + tabs.active_tab = TAB_GENERAL; + CPUnRAM__Main(); + } + if (TAB_PROCESSES==bid) { + tabs.active_tab = TAB_PROCESSES; + Processes__Main(); + } + if (TAB_DRIVES==bid) { + tabs.active_tab = TAB_DRIVES; + Drives__Main(); + } + return bid; +} + +void Sysmon__KeyEvent() +{ + GetKeys(); + if (key_scancode == SCAN_CODE_ESC) ExitProcess(); +} + +#include "cpu_ram.h" +#include "drives.h" +#include "process.h" void main() { @@ -56,42 +117,5 @@ void main() load_dll(libimg, #libimg_init,1); load_dll(libini, #lib_init,1); load_dll(boxlib, #box_lib_init,0); - General__Main(); -} - -int Sysmon__DefineAndDrawWindow() -{ - sc.get(); - DefineAndDrawWindow(screen.width - WIN_CONTENT_H - 200, 100, WIN_CONTENT_W + WIN_PAD + WIN_PAD +9, - WIN_CONTENT_H + TAB_HEIGHT + skin_height + 4, 0x34, sc.work, "System Monitor",0); - GetProcessInfo(#Form, SelfInfo); - if (Form.status_window>2) return false; - //if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } - //if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } - tabs.draw_wrapper(); - tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_GENERAL); - tabs.draw_button(strlen(T_GENERAL)*8+tabs.x+TAB_PADDING+TAB_PADDING, TAB_PROCESSES, T_PROCESSES); - return true; -} - -//===================================================// -// // -// EVENTS // -// // -//===================================================// - -void Sysmon__ButtonEvent(dword id) -{ - if (1==id) ExitProcess(); - if (TAB_GENERAL==id) { - tabs.active_tab = TAB_GENERAL; - General__Main(); - } - if (TAB_PROCESSES==id) { - tabs.active_tab = TAB_PROCESSES; - Processes__Main(); - } -} - - -stop: \ No newline at end of file + CPUnRAM__Main(); +} \ No newline at end of file diff --git a/programs/develop/libraries/box_lib/trunk/editbox.asm b/programs/develop/libraries/box_lib/trunk/editbox.asm index a130c8ac25..40ebf2b850 100644 --- a/programs/develop/libraries/box_lib/trunk/editbox.asm +++ b/programs/develop/libraries/box_lib/trunk/editbox.asm @@ -82,7 +82,10 @@ edit_box: mov ed_height,eax call .draw_border .draw_bg_cursor_text: + ;test word ed_flags,ed_focus ; for unfocused controls => + ;jz .sjip_offset ; do not recalculate offset (big OS behaviour) call .check_offset +;.sjip_offset: call .draw_bg test word ed_flags,ed_focus ; for unfocused controls => jz .draw_cursor_text ; do not draw selection(named shift)