/programs/cmm/misc/Tupfile.lua |
---|
0,0 → 1,13 |
if tup.getconfig("NO_CMM") ~= "" then return end |
if tup.getconfig("LANG") == "ru" |
then C_LANG = "LANG_RUS" |
else C_LANG = "LANG_ENG" -- this includes default case without config |
end |
tup.rule("easyshot.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "easyshot.com") |
tup.rule("calypte.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "calypte.com") |
tup.rule("kolibrin.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "kolibrin.com") |
tup.rule("mblocks.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "mblocks.com") |
tup.rule("notify.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "notify.com") |
tup.rule("pipet.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "pipet.com") |
tup.rule("software_widget.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "software_widget.com") |
/programs/cmm/misc/build.bat |
---|
0,0 → 1,13 |
@echo off |
del *.kex |
For /R %%i In (*.c) Do c-- "%%i" |
rename *.com *.kex |
mkdir bin |
move *.kex bin\ |
del warning.txt |
pause |
/programs/cmm/misc/calypte.c |
---|
0,0 → 1,492 |
//Calypte 0.35 - Leency |
//Calypte 0.15 - Punk Joker |
/* |
TODO |
- word wrap |
- draw by line |
- text selection |
*/ |
#define MEMSIZE 1024*200 |
#ifndef AUTOBUILD |
#include "lang.h--" |
#endif |
//===================================================// |
// // |
// LIB // |
// // |
//===================================================// |
#include "../lib/kolibri.h" |
#include "../lib/fs.h" |
#include "../lib/gui.h" |
#include "../lib/list_box.h" |
#include "../lib/collection.h" |
#include "../lib/obj/iconv.h" |
#include "../lib/obj/box_lib.h" |
#include "../lib/obj/libio.h" |
#include "../lib/obj/proc_lib.h" |
#include "../lib/obj/librasterworks.h" |
#include "../lib/patterns/simple_open_dialog.h" |
//===================================================// |
// // |
// DATA // |
// // |
//===================================================// |
char default_dir[] = "/rd/1"; |
od_filter filter2 = { 8, "TXT\0\0" }; |
/*========= MENU ==========*/ |
?define MENU1 "File" |
?define MENU2 "Encoding" |
?define MENU3 "Reopen" |
char menu_file_list[] = |
"Open|Ctrl+O |
Close |
Properties |
Exit"; |
char menu_encoding_list[] = |
"UTF-8 |
KOI8-RU |
CP1251 |
CP1252 |
ISO8859-5 |
CP866"; |
char menu_reopen_list[] = |
"Tinypad |
TextEdit |
TextRead |
WebView |
FB2Read |
HexView"; |
enum |
{ |
MENU_ID_FILE=10, |
FILE_SUBMENU_ID_OPEN=10, |
FILE_SUBMENU_ID_CLOSE, |
FILE_SUBMENU_ID_PROPERTIES, |
FILE_SUBMENU_ID_EXIT, |
MENU_ID_ENCODING=20, |
MENU_ID_REOPEN=30, |
FILE_SUBMENU_ID_TINYPAD=30, |
FILE_SUBMENU_ID_TEXTEDIT, |
FILE_SUBMENU_ID_TEXTREAD, |
FILE_SUBMENU_ID_WEBVIEW, |
FILE_SUBMENU_ID_FB2READ, |
FILE_SUBMENU_ID_HEXVIEW |
}; |
int menu_file_x = 6; |
int menu_encoding_x = NULL; |
int menu_reopen_x = NULL; |
/*======== MENU END ==========*/ |
#define TITLE "Calypte v0.38 dev" |
char win_title[4096] = TITLE; |
#define TOPPANELH 23 |
#define BOTPANELH 10 |
#define WIN_W 750 |
#define WIN_H 550 |
#define SCROLL_SIZE 15 |
proc_info Form; |
llist rows; |
int encoding; |
dword old_width,old_height; |
dword bufpointer; |
dword bufsize; |
scroll_bar scroll_v = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
scroll_bar scroll_h = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
collection s; |
//===================================================// |
// // |
// CODE // |
// // |
//===================================================// |
void main() |
{ |
int id; |
load_dll(boxlib, #box_lib_init, 0); |
load_dll(libio, #libio_init, 1); |
//load_dll(libini, #lib_init, 1); |
load_dll(iconv_lib, #iconv_open, 0); |
load_dll(Proc_lib, #OpenDialog_init,0); |
load_dll(librasterworks, #rasterworks_drawText,0); |
OpenDialog_init stdcall (#o_dialog); |
if (param) |
{ |
draw_window(); |
OpenFile(#param); |
Prepare(); |
DrawText(); |
} |
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
loop() |
{ |
switch(WaitEvent()) |
{ |
case evMouse: |
mouse.get(); |
rows.wheel_size = 3; |
if (rows.MouseScroll(mouse.vert)) |
{ |
DrawText(); |
} |
break; |
case evButton: |
id=GetButtonID(); |
if (id==1) |
{ |
ExitProcess(); |
} |
if (id==MENU_ID_FILE) |
{ |
EventShowMenu(menu_file_x, #menu_file_list, MENU_ID_FILE, NULL); |
} |
if (id==MENU_ID_ENCODING) |
{ |
EventShowMenu(menu_encoding_x, #menu_encoding_list, MENU_ID_ENCODING, encoding+1); |
} |
if (id==MENU_ID_REOPEN) |
{ |
EventShowMenu(menu_reopen_x, #menu_reopen_list, MENU_ID_REOPEN, NULL); |
} |
break; |
case evKey: |
GetKeys(); |
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) |
{ |
if (key_scancode == SCAN_CODE_KEY_O) |
{ |
EventOpenFile(); |
} |
break; |
} |
if (rows.ProcessKey(key_scancode)) |
{ |
DrawText(); |
} |
break; |
case evReDraw: |
if (CheckActiveProcess(Form.ID)) EventMenuClick(); |
draw_window(); |
break; |
} |
} |
} |
int DrawMenuButton(dword x,y,id,text) |
{ |
int textlen = strlen(text)*8; |
int padding = 12; |
DefineHiddenButton(x, y, textlen+padding+padding, TOPPANELH-2, id); |
WriteText(x+padding,y+4, 0x90, MixColors(sc.work, sc.work_text, 70), text); |
return textlen+padding+padding; |
} |
void draw_window() |
{ |
sc.get(); |
DefineAndDrawWindow(screen.width-WIN_W/2,screen.height-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title,0); |
GetProcessInfo(#Form, SelfInfo); |
DrawBar(0, 0, Form.cwidth, TOPPANELH-1, sc.work); |
DrawBar(0, TOPPANELH-1, Form.cwidth, 1, sc.work_dark); |
DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, sc.work); |
menu_encoding_x = menu_file_x + DrawMenuButton(menu_file_x, 0, MENU_ID_FILE, MENU1); |
menu_reopen_x = menu_encoding_x + DrawMenuButton(menu_encoding_x, 0, MENU_ID_ENCODING, MENU2); |
DrawMenuButton(menu_reopen_x, 0, MENU_ID_REOPEN, MENU3); |
if (old_width!=Form.width) || (old_height!=Form.height) |
{ |
old_width = Form.width; |
old_height = Form.height; |
rows.no_selection = true; |
rows.SetFont(8, 14, 0x90); |
rows.SetSizes(0, TOPPANELH, Form.cwidth - SCROLL_SIZE, Form.cheight - TOPPANELH - BOTPANELH, 20); |
rows.column_max = rows.w / rows.font_w; |
if (bufpointer) |
{ |
Prepare(); |
} |
rows.CheckDoesValuesOkey(); |
} |
DrawRectangle(rows.x+rows.w-1, rows.y, SCROLL_SIZE, rows.h-1, 0xEEEeee); |
DrawText(); |
} |
void OpenFile(dword _path) |
{ |
strcpy(#param, _path); |
sprintf(#win_title, "%s - %s", TITLE, #param); |
rows.KeyHome(); |
file_size stdcall (#param); |
bufsize = EBX; |
if (bufsize) |
{ |
bufpointer = mem_Free(bufpointer); |
bufpointer = mem_Alloc(bufsize); |
if (ReadFile(0, bufsize, bufpointer, #param) != 0) |
{ |
bufpointer = 0; |
notify("'Error opening file'-E"); |
return; |
} |
} |
if (encoding!=CH_CP866) |
{ |
ChangeCharset(encoding, "CP866", bufpointer); |
} |
} |
enum |
{ |
PARSE_CALCULATE_ROWS_COUNT, |
PARSE_DRAW_PREPARE, |
}; |
void Parse(int mode) |
{ |
int pos=0; |
int sub_pos=0; |
int len_str = 0; |
bool do_eof = false; |
word bukva[2]; |
while(1) |
{ |
while(1) |
{ |
bukva = DSBYTE[bufpointer+pos+len_str]; |
if (bukva=='\0') |
{ |
do_eof = true; |
break; |
} |
if (bukva==0x0a) |
{ |
break; |
} |
else |
{ |
len_str++; |
} |
} |
if (len_str<=rows.column_max) |
{ |
if (mode==PARSE_DRAW_PREPARE) |
{ |
s.addn(bufpointer+pos, len_str); |
} |
pos += len_str+1; |
} |
else |
{ |
if (mode==PARSE_DRAW_PREPARE) |
{ |
s.addn(bufpointer+pos, rows.column_max); |
} |
pos += rows.column_max; |
} |
sub_pos++; |
if (mode==PARSE_CALCULATE_ROWS_COUNT) && (do_eof) |
{ |
break; |
} |
if (mode==PARSE_DRAW_PREPARE) && (pos>=bufsize-1) |
{ |
break; |
} |
len_str = 0; |
} |
if (mode == PARSE_CALCULATE_ROWS_COUNT) |
{ |
rows.count = sub_pos; |
Parse(PARSE_DRAW_PREPARE); |
} |
} |
void Prepare() |
{ |
Parse(PARSE_CALCULATE_ROWS_COUNT); |
} |
void DrawText() |
{ |
int i=0, top; |
if (rows.count<rows.visible) |
{ |
top = rows.count; |
} |
else |
{ |
if (rows.count-rows.first<=rows.visible) |
{ |
top = rows.count-rows.first-1; |
} |
else |
{ |
top = rows.visible; |
} |
} |
if (bufpointer) |
{ |
for (i=0; i<top; i++) |
{ |
DrawBar(0, i*rows.item_h+TOPPANELH, rows.w, rows.item_h, 0xFFFFFF); |
WriteText(2, i*rows.item_h+TOPPANELH, 0x90, 0x000000, s.get(i+rows.first)); |
} |
} |
DrawBar(0, i*rows.item_h+rows.y, rows.w, -i*rows.item_h + rows.h, 0xFFFfff); |
DrawVerticalScroll(); |
} |
void DrawVerticalScroll() |
{ |
scroll_v.max_area = rows.count; |
scroll_v.cur_area = rows.visible; |
scroll_v.position = rows.first; |
scroll_v.start_y = rows.y; |
scroll_v.size_y = rows.h; |
scroll_v.start_x = rows.w + rows.x -1; |
scroll_v.all_redraw = 0; |
scrollbar_v_draw(#scroll_v); |
} |
//===================================================// |
// // |
// EVENTS // |
// // |
//===================================================// |
dword menu_id; |
void EventMenuClick() |
{ |
dword click_id = get_menu_click(); |
if (click_id) switch(click_id + menu_id - 1) |
{ |
//File |
case FILE_SUBMENU_ID_OPEN: |
EventOpenFile(); |
break; |
case FILE_SUBMENU_ID_CLOSE: |
EventCloseFile(); |
break; |
case FILE_SUBMENU_ID_PROPERTIES: |
EventShowFileProperties(); |
break; |
case FILE_SUBMENU_ID_EXIT: |
ExitProcess(); |
break; |
//Encoding |
case MENU_ID_ENCODING...MENU_ID_ENCODING+9: |
EventChangeEncoding(click_id-1); |
break; |
//Reopen |
case FILE_SUBMENU_ID_TINYPAD: |
EventOpenFileInAnotherProgram("/sys/tinypad"); |
break; |
case FILE_SUBMENU_ID_TEXTEDIT: |
EventOpenFileInAnotherProgram("/sys/develop/t_edit"); |
break; |
case FILE_SUBMENU_ID_TEXTREAD: |
EventOpenFileInAnotherProgram("/sys/txtread"); |
break; |
case FILE_SUBMENU_ID_WEBVIEW: |
EventOpenFileInAnotherProgram("/sys/network/webview"); |
break; |
case FILE_SUBMENU_ID_FB2READ: |
EventOpenFileInAnotherProgram("/sys/fb2read"); |
break; |
case FILE_SUBMENU_ID_HEXVIEW: |
EventOpenFileInAnotherProgram("/sys/develop/heed"); |
break; |
} |
} |
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected) |
{ |
open_lmenu(Form.left+5 + _menu_item_x, Form.top+skin_height + TOPPANELH, |
MENU_ALIGN_TOP_LEFT, _selected, _menu_list); |
menu_id = _id; |
} |
void EventOpenFile() |
{ |
OpenDialog_start stdcall (#o_dialog); |
if (o_dialog.status) |
{ |
OpenFile(#openfile_path); |
Prepare(); |
draw_window(); |
} |
} |
void EventCloseFile() |
{ |
if (bufpointer) |
{ |
s.drop(); |
bufpointer = mem_Free(bufpointer); |
strcpy(#win_title, TITLE); |
draw_window(); |
} |
} |
void EventShowFileProperties() |
{ |
char ss_param[4096]; |
if (bufpointer) |
{ |
sprintf(#ss_param, "-p %s", #param); |
RunProgram("/sys/File managers/Eolite", #ss_param); |
} |
} |
void EventChangeEncoding(dword id) |
{ |
encoding = id; |
OpenFile(#openfile_path); |
Prepare(); |
draw_window(); |
} |
void EventOpenFileInAnotherProgram(dword _app) |
{ |
RunProgram(_app, #param); |
} |
stop: |
/programs/cmm/misc/easyshot.c |
---|
0,0 → 1,189 |
#define MEMSIZE 1024 * 50 |
#include "../lib/kolibri.h" |
#include "../lib/strings.h" |
#include "../lib/mem.h" |
#include "../lib/gui.h" |
#include "../lib/obj/libimg.h" |
#include "../lib/obj/box_lib.h" |
#include "../lib/obj/proc_lib.h" |
#ifndef AUTOBUILD |
#include "lang.h--" |
#endif |
/* === TRANSLATIONS === */ |
#ifdef LANG_RUS |
?define T_TAKE_SCREENSHOT "¤¥« âì áªà¨è®â" |
?define T_SETTINGS " áâனª¨" |
?define T_EDITBOX_FRAME "ãâì á®åà ¥¨ï áªà¨è®â " |
?define T_DELAY " ¤¥à¦ª ¢ ᥪ㤠å" |
?define T_NO_DIR "' ¯ª ¥ áãé¥áâ¢ã¥â!' -E" |
#else |
?define T_TAKE_SCREENSHOT "Take a screenshot" |
?define T_SETTINGS "Settings" |
?define T_EDITBOX_FRAME "Save path" |
?define T_DELAY "Delay in seconds" |
?define T_NO_DIR "'Directory does not exists!' -E" |
#endif |
/* === DATA === */ |
proc_info Form; |
enum { |
BTN_MAKE_SCREENSHOT=10, |
BTN_SETTINGS, |
BTN_CHOOSE_SAVING_PATH |
}; |
#define PD 18 //padding |
#define SETTINGS_Y PD+PD+30+10 |
char save_path[4096]; |
char open_dir[4096]; |
more_less_box delay = { 1, 0, SETTINGS_Y, T_DELAY }; |
edit_box edit_save = {260,PD,SETTINGS_Y+50,0xffffff,0x94AECE,0xFFFfff,0xffffff, |
0x10000000,sizeof(save_path)-2,#save_path,0, 0b}; |
bool show_settings = false; |
opendialog open_folder_dialog = |
{ |
2, //0-file, 2-save, 3-select folder |
#Form, |
#communication_area_name, |
0, |
0, //dword opendir_path, |
#open_dir, //dword dir_default_path, |
#open_dialog_path, |
#DrawWindow, |
0, |
#open_dir, //dword openfile_path, |
0, //dword filename_area, |
0, //dword filter_area, |
420, |
NULL, |
320, |
NULL |
}; |
/* === CODE === */ |
void init_libraries() |
{ |
load_dll(libio, #libio_init, 1); |
load_dll(libimg, #libimg_init, 1); |
load_dll(boxlib, #box_lib_init,0); |
load_dll(Proc_lib, #OpenDialog_init,0); |
OpenDialog_init stdcall (#open_folder_dialog); |
} |
void main() |
{ |
int id; |
init_libraries(); |
strcpy(#save_path, "/tmp0/1"); |
EditBox_UpdateText(#edit_save, 0); |
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
loop() switch(WaitEvent()) |
{ |
case evMouse: |
edit_box_mouse stdcall (#edit_save); |
break; |
case evButton: |
id = GetButtonID(); |
switch(id){ |
case CLOSE_BTN: ExitProcess(); |
case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break; |
case BTN_SETTINGS: EventClickSettings(); break; |
case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break; |
default: delay.click(id); |
} |
break; |
case evKey: |
GetKeys(); |
if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); |
if (SCAN_CODE_ESC == key_scancode) ExitProcess(); |
EAX = key_editbox; |
edit_box_key stdcall (#edit_save); |
break; |
case evReDraw: |
DrawWindow(); |
} |
} |
void DrawWindow() |
{ |
int i; |
sc.get(); |
DefineAndDrawWindow(screen.width-400, screen.height/3, 270, |
skin_height + 30+PD+PD, 0x34, sc.work, "EasyShot",0); |
GetProcessInfo(#Form, SelfInfo); |
DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT); |
DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, sc.button); |
for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, sc.button_text); |
delay.draw(PD, SETTINGS_Y); |
DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH); |
} |
void EventChooseSavePath() |
{ |
OpenDialog_start stdcall (#open_folder_dialog); |
if (open_folder_dialog.status) { |
strcpy(#save_path, open_folder_dialog.opendir_path); |
EditBox_UpdateText(#edit_save, 0); |
} |
} |
void EventClickSettings() |
{ |
show_settings ^= 1; |
MoveSize(OLD, OLD, show_settings*75 + 270, |
show_settings*110 + skin_height + PD+PD+30); |
} |
void EventTakeScreenshot() |
{ |
int i=0; |
char save_file_name[4096]; |
static dword screenshot; |
if (!screenshot) screenshot = malloc(screen.width * screen.height * 3); |
do { |
i++; |
//sprintf(, "%s/screen_%i.png", #save_path, i); |
strcpy(#save_file_name, #save_path); |
if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/'); |
strcat(#save_file_name, "screen_"); |
strcat(#save_file_name, itoa(i)); |
strcat(#save_file_name, ".png"); |
} while (file_exists(#save_file_name)); |
if (!dir_exists(#save_path)) { |
notify(T_NO_DIR); |
return; |
} |
MinimizeWindow(); |
pause(delay.value*100); |
CopyScreen(screenshot, 0, 0, screen.width, screen.height); |
save_image(screenshot, screen.width, screen.height, #save_file_name); |
ActivateWindow(GetProcessSlot(Form.ID)); |
} |
/programs/cmm/misc/mblocks.c |
---|
0,0 → 1,206 |
/* |
Memory Blocks for KolibriOS v1.11 |
Leency&Veliant Edition |
2008-2019 |
*/ |
#define MEMSIZE 4096 * 15 |
#include "..\lib\gui.h" |
#include "..\lib\random.h" |
#include "..\lib\obj\libio.h" |
#include "..\lib\obj\libimg.h" |
proc_info Form; |
#ifndef AUTOBUILD |
#include "lang.h--" |
#endif |
#define COLOR_CELL_BG 0xFFFfff |
#define COLOR_CELL_BORDER 0x94AECE |
#define CELL_SIZE 43 |
#define PANEL_Y CELL_SIZE+4*6 + 4 |
#define PANEL_H 36 |
#define strok 6 //cell count x |
#define stolbcov 10 //cell count y |
#ifdef LANG_RUS |
#define LABEL_NEW_GAME "®¢ ï ¨£à (F2)"; |
#else |
#define LABEL_NEW_GAME "New game (F2)"; |
#endif |
int bitstat[60], bitpict[60]; |
dword butonsx[60], butonsy[60]; |
dword firstbit, secondbit; |
int count; |
void main() |
{ |
dword id; |
load_dll(libio, #libio_init,1); |
load_dll(libimg, #libimg_init,1); |
Libimg_LoadImage(#skin, "/sys/icons32.png"); |
Libimg_FillTransparent(skin.image, skin.w, skin.h, COLOR_CELL_BG); |
NewGame(); |
loop() switch(WaitEvent()) |
{ |
case evKey: |
GetKeys(); |
if (key_scancode==60) NewGame(); |
break; |
case evButton: |
id = GetButtonID(); |
if (id==1) ExitProcess(); |
else if (id==5) NewGame(); |
else { |
if (bitstat[id-100] == 0) |
{ |
if (firstbit <> 0x0BAD) |
{ |
if (secondbit <> 0x0BAD) |
{ |
if (bitpict[firstbit-100] == bitpict[secondbit-100]) |
bitstat[firstbit-100] = bitstat[secondbit-100] = 2; |
else |
bitstat[firstbit-100] = bitstat[secondbit-100] = 0; |
ReDraw_Game_Button(firstbit - 100); |
ReDraw_Game_Button(secondbit - 100); |
secondbit = 0x0BAD; |
firstbit = id; |
bitstat[id-100] = 1; |
ReDraw_Game_Button(id - 100); |
count++; |
} |
else if (firstbit<>id) |
{ |
secondbit = id; |
bitstat[id-100] = 1; |
ReDraw_Game_Button(id - 100); |
count++; |
} |
} |
else |
{ |
firstbit = id; |
bitstat[id-100] = 1; |
ReDraw_Game_Button(id - 100); |
count++; |
} |
} |
Draw_Count(); |
} |
break; |
case evReDraw: |
sc.get(); |
DefineAndDrawWindow(215,100,CELL_SIZE+4*10 + 4 + 9,PANEL_Y+4+PANEL_H+skin_height, |
0x34,0xC0C0C0,"Memory Blocks",0); |
GetProcessInfo(#Form, SelfInfo); |
Draw_Panel(); |
Draw_Game_Pole(); |
break; |
} |
} |
void NewGame() |
{ |
int off; |
int i; |
FOR (i = 0; i < 60; i++) |
{ |
bitstat[i] = 0; |
bitpict[i] = 0; |
} |
count = 0; |
firstbit = secondbit = 0x0BAD; |
FOR (i = 0; i < 30; i++) |
{ |
do off = random(60); while (bitpict[off] != 0); |
bitpict[off] = i; |
do off = random(60); while (bitpict[off] != 0); |
bitpict[off] = i; |
} |
Draw_Game_Pole(); |
Draw_Panel(); |
} |
void ReDraw_Game_Button(int id) |
{ |
DefineButton(butonsx[id], butonsy[id], CELL_SIZE, CELL_SIZE, 100 + id + BT_HIDE, 0); |
switch (bitstat[id]) |
{ |
case 0: |
Draw_Block(butonsx[id], butonsy[id]); |
break; |
case 1: |
Draw_Pressed_Block(butonsx[id], butonsy[id]); |
img_draw stdcall(skin.image, butonsx[id]+6, butonsy[id]+6, 32, 32, 0, bitpict[id]*32); |
BREAK; |
case 2: |
Draw_Open_Block(butonsx[id], butonsy[id]); |
img_draw stdcall(skin.image, butonsx[id]+6, butonsy[id]+6, 32, 32, 0, bitpict[id]*32); |
BREAK; |
} |
} |
void Draw_Game_Pole() |
{ |
int i; |
byte j; |
for (j = 0; j < stolbcov; j++) for (i = 0; i < strok; i++) |
{ |
butonsx[j*strok+i] = CELL_SIZE+4 * j + 4; //save coordinates to avoid |
butonsy[j*strok+i] = CELL_SIZE+4 * i + 4; //their recalculation after |
ReDraw_Game_Button(j*strok + i); |
} |
} |
void Draw_Block(dword x, y) |
{ |
DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border |
DrawRectangle3D(x + 1, y + 1, CELL_SIZE-2, CELL_SIZE-2, 0xFFFFFF, 0xDEDEDE);//bump |
DrawBar(x + 2, y + 2, CELL_SIZE-3, CELL_SIZE-3, 0xBDC7D6);//background |
} |
void Draw_Open_Block(dword x, y) |
{ |
DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border |
DrawBar(x + 1, y + 1, CELL_SIZE-1, CELL_SIZE-1, COLOR_CELL_BG);//background |
} |
void Draw_Pressed_Block(dword x, y) |
{ |
DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border |
DrawWideRectangle(x + 1, y + 1, CELL_SIZE-1, CELL_SIZE-1, 2, 0x94DB00);//border green |
DrawBar(x + 3, y + 3, CELL_SIZE-5, CELL_SIZE-5, COLOR_CELL_BG);//background |
} |
void Draw_Panel() |
{ |
DrawBar(0, PANEL_Y, Form.cwidth, 1, sc.work_dark); |
DrawBar(0, PANEL_Y+1, Form.cwidth, 1, sc.work_light); |
DrawBar(0, PANEL_Y+2, Form.cwidth, PANEL_H-2, sc.work); |
DrawStandartCaptButton(9, PANEL_Y+5, 5, LABEL_NEW_GAME); |
Draw_Count(); |
} |
void Draw_Count() |
{ |
DrawBar(Form.cwidth-32,PANEL_Y + 12,30,12,sc.work); |
WriteNumber(Form.cwidth-32, PANEL_Y + 12, 0x90, sc.work_text, 3, count); |
} |
stop: |
/programs/cmm/misc/notify.c |
---|
0,0 → 1,150 |
//notify 0.8 |
//SoUrcerer 2010, Leency 2012-2013, GNU GPLv2 |
#define MEMSIZE 0x2F00 |
#include "..\lib\kolibri.h" |
#include "..\lib\strings.h" |
#include "..\lib\mem.h" |
#include "..\lib\gui.h" |
dword shadow_buf_24, shadow_buf_32, lighter_pixel1, lighter_pixel2; |
?define PADDING 15; |
int SCREEN_SIZE_X, |
SCREEN_SIZE_Y; |
int WIN_X, |
WIN_Y, |
WIN_SIZE_X=256, |
WIN_SIZE_Y=28; |
int TEXT_X=PADDING, |
TEXT_Y; |
int delay = 400; |
#ifdef LANG_RUS |
?define DEFAULT_TEXT "â ¯à®£à ¬¬ ¯®ª §ë¢ ¥â 㢥¤®¬«¥¨ï."; |
#else |
?define DEFAULT_TEXT "This program shows notices. Open it with params."; |
#endif |
void PutText(dword x, y) { |
WriteBufText(x,y, 0x88, 0, #param, shadow_buf_32); |
} |
void Text() |
{ |
PutText(TEXT_X-1,TEXT_Y+1); |
PutText(TEXT_X-1,TEXT_Y-1); |
PutText(TEXT_X-1,TEXT_Y ); |
PutText(TEXT_X+1,TEXT_Y-1); |
PutText(TEXT_X+1,TEXT_Y ); |
PutText(TEXT_X+1,TEXT_Y+1); |
PutText(TEXT_X, TEXT_Y+1); |
PutText(TEXT_X, TEXT_Y-1); |
WriteBufText(TEXT_X, TEXT_Y, 0x88, 0xFFFfff, #param, shadow_buf_32); |
} |
void from24to32(ESI, EDI, EAX, EBX) //src,dst,w,h |
{ |
conv24to32: |
$mul ebx |
$mov ecx, eax |
$xor al, al |
_next: |
$movsw |
$movsb |
$stosb |
$loop _next |
} |
void DrawBackground() |
{ |
PutPaletteImage(shadow_buf_32+8,WIN_SIZE_X,WIN_SIZE_Y,0,0,32,0); |
PutPixel(0,0,ESDWORD[lighter_pixel1]); |
PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]); |
} |
void GetBackground() |
{ |
int i; |
static int was_once; |
if (was_once) |
{ |
DrawBackground(); |
return; |
} |
for (i=1; i<=6; i++) |
{ |
was_once = 1; |
ShadowImage(shadow_buf_24, WIN_SIZE_X, WIN_SIZE_Y, 1); |
if (i%2 == 0) ShadowImage(lighter_pixel1, 1, 1, 1); |
if (i%2 == 0) ShadowImage(lighter_pixel2, 1, 1, 1); |
from24to32(shadow_buf_24, shadow_buf_32+8, WIN_SIZE_X, WIN_SIZE_Y); |
Text(); |
DrawBackground(); |
pause(5); |
} |
} |
void Exit() |
{ |
ExitProcess(); |
} |
void main() |
{ |
if (!param) strcpy(#param, DEFAULT_TEXT); |
if (strlen(#param)*6>WIN_SIZE_X) |
{ |
WIN_SIZE_X=strlen(#param)*6+PADDING; |
delay = strlen(#param)*10; |
} |
SCREEN_SIZE_X=GetScreenWidth()+1; |
WIN_X = SCREEN_SIZE_X-WIN_SIZE_X-1; |
WIN_Y = GetClientTop(); |
TEXT_X = -6*strlen(#param)+WIN_SIZE_X/2+1; |
TEXT_Y = WIN_SIZE_Y/2-4; |
//emulate multithread :) |
while (GetPixelColorFromScreen(SCREEN_SIZE_X-1, WIN_Y)==0x333333) WIN_Y+=WIN_SIZE_Y+17; |
shadow_buf_24 = malloc(WIN_SIZE_X*WIN_SIZE_Y*3); |
shadow_buf_32 = malloc(WIN_SIZE_X*WIN_SIZE_Y*4+8); |
lighter_pixel1 = malloc(3); |
lighter_pixel2 = malloc(3); |
CopyScreen(shadow_buf_24, WIN_X, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y); |
CopyScreen(lighter_pixel1, WIN_X, WIN_Y, 1, 1); |
CopyScreen(lighter_pixel2, WIN_X, WIN_Y+WIN_SIZE_Y, 1, 1); |
ESDWORD[shadow_buf_32] = WIN_SIZE_X; |
ESDWORD[shadow_buf_32+4] = WIN_SIZE_Y; |
loop() |
{ |
WaitEventTimeout(delay); |
switch(EAX & 0xFF) |
{ |
case evButton: |
Exit(); |
break; |
case evReDraw: |
DefineAndDrawWindow(WIN_X+1,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF); |
DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333); |
DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0); |
GetBackground(); |
break; |
default: |
Exit(); |
} |
} |
} |
stop: |
/programs/cmm/misc/pipet.c |
---|
0,0 → 1,126 |
#define MEMSIZE 1024*20 |
#include "../lib/gui.h" |
#include "../lib/clipboard.h" |
#include "../lib/patterns/rgb.h" |
//===================================================// |
// // |
// DATA // |
// // |
//===================================================// |
dword pick_active = true; |
dword picked_color = 0; |
char picked_color_string[11]; |
#define FORM_W 167 |
#define FORM_H 60 |
#define COLOR_BLOCK_SIZE 42 |
#define COLOR_BLOCK_PADDING FORM_H - COLOR_BLOCK_SIZE / 2 |
#define COLOR_BLOCK_X FORM_W - COLOR_BLOCK_SIZE - COLOR_BLOCK_PADDING |
#define BUTTON_ID_CLOSE 1 |
#define BUTTON_ID_COPY 2 |
#define BUTTON_ID_PICK 3 |
//===================================================// |
// // |
// CODE // |
// // |
//===================================================// |
void main() |
{ |
int btn; |
proc_info Form; |
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE); |
SetWindowLayerBehaviour(-1, ZPOS_ALWAYS_TOP); |
loop() switch(WaitEvent()) |
{ |
case evMouse: |
mouse.get(); |
if (mouse.x>0) && (mouse.x<FORM_W) && (mouse.y>0) && (mouse.y<FORM_H) { |
EventDragWindow(); |
} else if (pick_active) { |
picked_color = GetPixelColorFromScreen(mouse.x + Form.left, mouse.y + Form.top); |
EventUpdateWindowContent(); |
if (mouse.down) && (mouse.key&MOUSE_LEFT) pick_active = false; |
} |
break; |
case evButton: |
btn = GetButtonID(); |
if (btn == BUTTON_ID_CLOSE) ExitProcess(); |
if (btn == BUTTON_ID_COPY) EventCopyHex(); |
if (btn == BUTTON_ID_PICK) pick_active = true; |
break; |
case evKey: |
GetKeys(); |
if (key_scancode == SCAN_CODE_ESC) ExitProcess(); |
if (key_scancode == SCAN_CODE_KEY_C) EventCopyHex(); |
break; |
case evReDraw: |
DefineUnDragableWindow(215, 100, FORM_W, FORM_H); |
GetProcessInfo(#Form, SelfInfo); |
draw_window(); |
break; |
} |
} |
void draw_window() |
{ |
DrawRectangle3D(0, 0, FORM_W, FORM_H, 0xCCCccc, 0x888888); |
DrawRectangle3D(1, 1, FORM_W-2, FORM_H-2, 0xCCCccc, 0x888888); |
DrawBar(2,2,FORM_W-3,FORM_H-3,0xFFFfff); |
DrawRectangle(COLOR_BLOCK_X-2, COLOR_BLOCK_PADDING-2, COLOR_BLOCK_SIZE+3, COLOR_BLOCK_SIZE+3, 0xCBC6C5); |
DefineHiddenButton(COLOR_BLOCK_X-1, COLOR_BLOCK_PADDING-1, COLOR_BLOCK_SIZE+1, COLOR_BLOCK_SIZE+1, BUTTON_ID_PICK); |
DrawCopyButton(67, 11, 35, 14); |
EventUpdateWindowContent(); |
} |
//copy of sprintf() => %A |
void str2col(dword buf, number) |
{ |
byte s; |
strlcpy(buf,"0x00000000",10); |
buf+=10; |
while(number) |
{ |
$dec buf |
s=number&0xF; |
if(s>9)DSBYTE[buf]='A'+s-10; |
else DSBYTE[buf]='0'+s; |
number>>=4; |
} |
} |
void EventUpdateWindowContent() |
{ |
//sprintf(#picked_color_string, "%A", picked_color); |
str2col(#picked_color_string, picked_color); |
rgb.DwordToRgb(picked_color); |
WriteTextWithBg(12,12, 0xD0, 0x000111, #picked_color_string+4, 0xFFFfff); |
WriteNumber(12,33, 0xD0, 0xff0000, 3, rgb.r); |
WriteNumber(44,33, 0xD0, 0x008000, 3, rgb.g); |
WriteNumber(75,33, 0xD0, 0x0000ff, 3, rgb.b); |
DrawBar(COLOR_BLOCK_X, COLOR_BLOCK_PADDING, COLOR_BLOCK_SIZE, COLOR_BLOCK_SIZE, picked_color); |
} |
void DrawCopyButton(dword _x, _y, _w, _h) |
{ |
DefineHiddenButton(_x+1, _y+1, _w-2, _h-2, BUTTON_ID_COPY); |
DrawRectangle(_x, _y, _w, _h, 0x777777); |
WriteText(_x+6, _h-8/2 + _y, 0x80, 0x555555, "Copy"); |
} |
void EventCopyHex() |
{ |
Clipboard__CopyText(#picked_color_string+4); |
} |
/programs/cmm/misc/software_widget.c |
---|
0,0 → 1,295 |
/* |
SOFTWARE CENTER v2.86 |
*/ |
#define MEMSIZE 4096 * 15 |
#include "..\lib\strings.h" |
#include "..\lib\mem.h" |
#include "..\lib\io.h" |
#include "..\lib\gui.h" |
#include "..\lib\obj\libio.h" |
#include "..\lib\obj\libimg.h" |
#include "..\lib\obj\libini.h" |
#include "..\lib\kfont.h" |
#include "..\lib\list_box.h" |
#include "..\lib\collection.h" |
proc_info Form; |
llist list; |
collection app_path_collection; |
bool kolibrios_mounted; |
int window_width, |
window_height; |
int list_pos, |
row, |
col, |
default_icon; |
char window_title[128], |
settings_ini_path[256]; |
bool small_screen = false; |
struct SW_COLORS |
{ |
dword list_bg; |
dword text; |
dword graph; |
dword dark; |
dword light; |
} swc; |
block selection[128]; |
void load_ini_config(dword _ini_path) |
{ |
_ini ini; |
ini.path = _ini_path; |
ini.section = "Config"; |
ini.GetString("title", #window_title, sizeof(window_title), "Software widget"); |
window_width = ini.GetInt("win_width", 690); |
list.item_w = ini.GetInt("cell_w", 73); |
list.item_h = ini.GetInt("cell_h", 71); |
default_icon = ini.GetInt("default_icon", 2); |
} |
void main() |
{ |
dword id; |
kfont.init(DEFAULT_FONT); |
load_dll(libio, #libio_init,1); |
load_dll(libimg, #libimg_init,1); |
load_dll(libini, #lib_init,1); |
kolibrios_mounted = dir_exists("/kolibrios"); |
if (param) { |
strcpy(#settings_ini_path, #param); |
} else { |
strcpy(#settings_ini_path, "/sys/settings/"); |
strcat(#settings_ini_path, I_Path + strrchr(I_Path, '/')); |
strcat(#settings_ini_path, ".ini"); |
} |
load_ini_config(#settings_ini_path); |
list.cur_y = -1; |
list.y = 32; |
DrawList(); |
window_height = row+1*list.item_h + list_pos + skin_height + 15; |
if (window_height>screen.height) { |
window_width = screen.width; |
list.item_h -= 5; |
window_height = row+1*list.item_h + list_pos + skin_height + 15; |
small_screen = true; |
} |
loop() switch(WaitEvent()) |
{ |
case evKey: |
GetKeys(); |
if (SCAN_CODE_LEFT == key_scancode) key_scancode = SCAN_CODE_UP; |
if (SCAN_CODE_RIGHT == key_scancode) key_scancode = SCAN_CODE_DOWN; |
if (list.ProcessKey(key_scancode)) DrawSelection(); |
if (SCAN_CODE_ENTER == key_scancode) EventIconClick(list.cur_y); |
break; |
case evButton: |
id=GetButtonID(); |
if (id==1) ExitProcess(); |
if (id>=100) EventIconClick(id-100); |
break; |
case evReDraw: |
SetAppColors(); |
DefineAndDrawWindow(screen.width-window_width/2,screen.height-window_height/2,window_width,window_height,0x74,sc.work,"",0); |
GetProcessInfo(#Form, SelfInfo); |
if (Form.status_window>2) { |
DrawTitle(#window_title); |
break; |
} |
if (small_screen) { |
DrawTitle(#window_title); |
list.y = 0; |
} else { |
DrawTitle(NULL); |
DrawTopBar(); |
} |
DrawList(); |
DrawBar(0, row +1 * list.item_h + list_pos, Form.cwidth, -row - 1 * list.item_h - list_pos + Form.cheight, swc.list_bg); |
DrawSelection(); |
} |
} |
void SetAppColors() |
{ |
dword bg_col, old_list_bg_color; |
sc.get(); |
old_list_bg_color = swc.list_bg; |
bg_col = sc.work; |
if (skin_is_dark()) |
{ |
//dark colors |
swc.list_bg = sc.work; |
swc.text = sc.work_text; |
swc.dark = sc.work_dark; |
swc.light = sc.work_light; |
} else { |
//light colors |
swc.list_bg = 0xF3F3F3; |
swc.text = 0x000000; |
swc.dark = 0xDCDCDC; |
swc.light = 0xFCFCFC; |
} |
if (swc.list_bg != old_list_bg_color) |
{ |
Libimg_LoadImage(#skin, "/sys/icons32.png"); |
Libimg_FillTransparent(skin.image, skin.w, skin.h, swc.list_bg); |
} |
} |
void DrawList() { |
list.count = 0; |
row = -1; |
app_path_collection.drop(); |
list_pos = list.y; |
list.column_max = window_width - 10 / list.item_w; |
ini_enum_sections stdcall (#settings_ini_path, #process_sections); |
list.visible = list.count; |
} |
byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name) |
{ |
int icon_id = default_icon, |
icon_char_pos; |
int space_pos; |
dword icon_x, icon_y, text_x, text_y; |
//do not show items located in /kolibrios/ if this directory not mounted |
if (!strncmp(key_value, "/kolibrios/", 11)) || (!strncmp(key_value, "/k/", 3)) |
if (!kolibrios_mounted) return true; |
if (col==list.column_max) { |
row++; |
col=0; |
} |
if (col==0) DrawBar(0, row * list.item_h + list_pos, Form.cwidth, list.item_h, swc.list_bg); |
DefineButton(col*list.item_w+6, row*list.item_h + list_pos,list.item_w,list.item_h-3,list.count + 100 + BT_HIDE,0); |
icon_char_pos = strchr(key_value, ','); |
icon_x = col*list.item_w+calc(list.item_w/2)-10; |
icon_y = row*list.item_h+5 + list_pos; |
selection[list.count].x = icon_x-2; |
selection[list.count].y = icon_y-2; |
if (icon_char_pos) ESBYTE[icon_char_pos] = '\0'; //delete icon from string |
app_path_collection.add(key_value); |
text_x = col*list.item_w+5; |
text_y = list.item_h - 40 / 2; |
if (!strchr(key_name, ' ')) {//|| (kfont.getsize(key_name)+30<list.item_w) <== too slow |
kfont.WriteIntoWindowCenter(text_x, row*list.item_h+46 + list_pos, list.item_w,0, swc.list_bg, swc.text, 12, key_name); |
//WriteTextCenter(text_x, row*list.item_h+46 + list_pos+3, list.item_w, swc.text, key_name); |
} else { |
space_pos = strrchr(key_name, ' '); |
ESBYTE[key_name+space_pos-1] = '\0'; |
kfont.WriteIntoWindowCenter(text_x, row*list.item_h+46 + list_pos - 2, list.item_w,0, swc.list_bg, swc.text, 12, key_name); |
kfont.WriteIntoWindowCenter(text_x, row*list.item_h+46 + list_pos + 13, list.item_w,0, swc.list_bg, swc.text, 12, key_name+space_pos); |
//WriteTextCenter(text_x, row*list.item_h+46 + list_pos, list.item_w, swc.text, key_name); |
//WriteTextCenter(text_x, row*list.item_h+46 + list_pos + 10, list.item_w, swc.text, key_name+space_pos); |
} |
if (icon_char_pos) icon_id = atoi(icon_char_pos+1); |
img_draw stdcall(skin.image, icon_x, icon_y, 32, 32, 0, icon_id*32); |
list.count++; |
col++; |
return true; |
} |
int old_row; //to detect empty sections |
byte process_sections(dword sec_name, f_name) |
{ |
int text_len; |
if (!strcmp(sec_name, "Config")) return true; |
if ((col==0) && (row==old_row)) |
{ |
list_pos -= 28; |
} |
else |
{ |
row++; |
} |
col = 0; |
old_row = row; |
if (!small_screen) { |
DrawBar(0, row * list.item_h + list_pos, Form.cwidth , 29, swc.list_bg); |
text_len = kfont.WriteIntoWindow(10, row * list.item_h + 10 + list_pos, swc.list_bg, swc.text, 15, sec_name); |
DrawBar(text_len+20, row * list.item_h + list_pos + 20, Form.cwidth-text_len-20, 1, swc.dark); |
DrawBar(text_len+20, row * list.item_h + list_pos + 21, Form.cwidth-text_len-20, 1, swc.light); |
list_pos += 29; |
} |
ini_enum_keys stdcall (f_name, sec_name, #draw_icons_from_section); |
return true; |
} |
void DrawTopBar() |
{ |
DrawBar(0,0,Form.cwidth, list.y-2, sc.work); |
DrawBar(0,list.y-2, Form.cwidth, 1, MixColors(sc.work, sc.work_graph, 180)); |
DrawBar(0,list.y-1, Form.cwidth, 1, sc.work_graph); |
kfont.WriteIntoWindowCenter(0,5, Form.cwidth, list.y, sc.work, sc.work_text, 16, #window_title); |
} |
void EventIconClick(dword appid) |
{ |
char run_app_path[4096]=0; |
dword app_path = app_path_collection.get(appid); |
dword param_pos = strchr(app_path, '|'); |
if (param_pos) { |
ESBYTE[param_pos] = NULL; |
param_pos++; |
} |
// the next block is created to save some space in ramdisk{ |
// |
// convert relative path to absolute "calc" => "/sys/calc" |
// convert short kolibrios path to full "/k/calc" => "/kolibrios/calc" |
// other copy => as is |
if (ESBYTE[app_path]!='/') { |
strcpy(#run_app_path, "/sys/"); |
} |
else if (!strncmp(app_path, "/k/",3)) { |
strcpy(#run_app_path, "/kolibrios/"); |
app_path+=3; |
} |
strcat(#run_app_path, app_path); |
// }end |
if (file_exists(#run_app_path)) { |
io.run(#run_app_path, param_pos); //0 or offset |
if (param_pos) ESBYTE[param_pos - 1] = '|'; |
} else { |
notify("'Application not found' -E"); |
} |
} |
void DrawSelection() |
{ |
int i; |
dword col; |
for (i=0; i<list.count; i++) { |
if (i==list.cur_y) col=0x0080FF; else col=swc.list_bg; |
DrawWideRectangle(selection[i].x, selection[i].y, 36, 36, 2, col); |
} |
} |
stop: |