forked from KolibriOS/kolibrios
CMM new lib: events.h
IconEdit: use event model netcheck: example of event model, can be used for network testing git-svn-id: svn://kolibrios.org@7521 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2650f5831f
commit
babba2a8ce
@ -127,7 +127,12 @@ void main()
|
|||||||
skin.h = 26;
|
skin.h = 26;
|
||||||
wv_progress_bar.progress_color = 0x72B7EB;
|
wv_progress_bar.progress_color = 0x72B7EB;
|
||||||
CreateDir("/tmp0/1/downloads");
|
CreateDir("/tmp0/1/downloads");
|
||||||
if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
|
if (param) && (param[0]=='-') && (param[1]=='d') {
|
||||||
|
strcpy(#downloader_edit, #param+3);
|
||||||
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
|
ExitProcess();
|
||||||
|
}
|
||||||
|
else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
|
||||||
WB1.list.SetFont(8, 14, 10011000b);
|
WB1.list.SetFont(8, 14, 10011000b);
|
||||||
WB1.list.no_selection = true;
|
WB1.list.no_selection = true;
|
||||||
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
||||||
|
@ -19,15 +19,18 @@ DOWNLOADER downloader;
|
|||||||
#endif
|
#endif
|
||||||
char save_to[4096] = "/tmp0/1/Downloads";
|
char save_to[4096] = "/tmp0/1/Downloads";
|
||||||
|
|
||||||
|
#define CONX 15
|
||||||
|
|
||||||
proc_info DL_Form;
|
proc_info DL_Form;
|
||||||
char downloader_edit[10000];
|
char downloader_edit[10000];
|
||||||
char filepath[4096];
|
char filepath[4096];
|
||||||
edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit)-2,#downloader_edit,0,2,19,19};
|
edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit)-2,#downloader_edit,0,2,19,19};
|
||||||
progress_bar pb = {0, 20, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
progress_bar pb = {0, CONX, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
||||||
//progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
//progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F};
|
||||||
//progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color;
|
//progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool downloader_opened;
|
bool downloader_opened;
|
||||||
char downloader_stak[4096];
|
char downloader_stak[4096];
|
||||||
|
|
||||||
@ -106,7 +109,6 @@ void Key_Scan(int id)
|
|||||||
|
|
||||||
void DL_Draw_Window()
|
void DL_Draw_Window()
|
||||||
{
|
{
|
||||||
int cleft = 15;
|
|
||||||
int but_x = 0;
|
int but_x = 0;
|
||||||
int but_y = 58;
|
int but_y = 58;
|
||||||
DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work);
|
DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work);
|
||||||
@ -116,7 +118,7 @@ void DL_Draw_Window()
|
|||||||
DeleteButton(306);
|
DeleteButton(306);
|
||||||
if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED)
|
if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED)
|
||||||
{
|
{
|
||||||
but_x = cleft + DrawStandartCaptButton(cleft, but_y, 301, START_DOWNLOADING);
|
but_x = CONX + DrawStandartCaptButton(CONX, but_y, 301, START_DOWNLOADING);
|
||||||
if (filepath[0])
|
if (filepath[0])
|
||||||
{
|
{
|
||||||
but_x += DrawStandartCaptButton(but_x, but_y, 305, SHOW_IN_FOLDER);
|
but_x += DrawStandartCaptButton(but_x, but_y, 305, SHOW_IN_FOLDER);
|
||||||
@ -128,8 +130,8 @@ void DL_Draw_Window()
|
|||||||
DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING);
|
DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING);
|
||||||
DrawDownloading();
|
DrawDownloading();
|
||||||
}
|
}
|
||||||
WriteText(cleft, ed.top + 4, 0x90, system.color.work_text, "URL:");
|
WriteText(CONX, ed.top + 4, 0x90, system.color.work_text, "URL:");
|
||||||
ed.width = DL_Form.cwidth - ed.left - cleft - 3;
|
ed.width = DL_Form.cwidth - ed.left - CONX - 3;
|
||||||
ed.offset=0;
|
ed.offset=0;
|
||||||
DrawEditBox(#ed);
|
DrawEditBox(#ed);
|
||||||
}
|
}
|
||||||
@ -152,12 +154,40 @@ void StartDownloading()
|
|||||||
DL_Draw_Window();
|
DL_Draw_Window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct TIME
|
||||||
|
{
|
||||||
|
dword old;
|
||||||
|
dword cur;
|
||||||
|
dword gone;
|
||||||
|
} time = {0,0,0};
|
||||||
|
|
||||||
|
dword netdata_received;
|
||||||
|
dword speed;
|
||||||
|
|
||||||
|
void CalculateSpeed()
|
||||||
|
{
|
||||||
|
time.cur = GetStartTime();
|
||||||
|
|
||||||
|
if (time.old) {
|
||||||
|
time.gone = time.cur - time.old;
|
||||||
|
if (time.gone > 200) {
|
||||||
|
speed = downloader.httpd.content_received - netdata_received / time.gone * 100;
|
||||||
|
debugval("speed", speed);
|
||||||
|
debugln(ConvertSizeToKb(speed) );
|
||||||
|
time.old = time.cur;
|
||||||
|
netdata_received = downloader.httpd.content_received;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else time.old = time.cur;
|
||||||
|
}
|
||||||
|
|
||||||
void DrawDownloading()
|
void DrawDownloading()
|
||||||
{
|
{
|
||||||
char bytes_received[70];
|
char bytes_received[70];
|
||||||
sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
|
sprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(downloader.httpd.content_received) );
|
||||||
DrawBar(15, pb.top + 22, strlen(#bytes_received+4)*12, 16, system.color.work);
|
DrawBar(CONX, pb.top + 22, pb.width, 16, system.color.work);
|
||||||
WriteText(15, pb.top + 22, 0x90, system.color.work_text, #bytes_received);
|
WriteText(CONX, pb.top + 22, 0x90, system.color.work_text, #bytes_received);
|
||||||
|
//CalculateSpeed();
|
||||||
progressbar_draw stdcall(#pb);
|
progressbar_draw stdcall(#pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,3 +10,4 @@ tup.rule("rgb.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD
|
|||||||
tup.rule("console.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "console.com")
|
tup.rule("console.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "console.com")
|
||||||
tup.rule("info.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "info.com")
|
tup.rule("info.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "info.com")
|
||||||
tup.rule("pig.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "pig.com")
|
tup.rule("pig.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "pig.com")
|
||||||
|
tup.rule("netcheck.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "netcheck.com")
|
||||||
|
101
programs/cmm/examples/netcheck.c
Normal file
101
programs/cmm/examples/netcheck.c
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Network testing utility
|
||||||
|
* Leency 2018
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MEMSIZE 4096*10
|
||||||
|
|
||||||
|
#include "../lib/fs.h"
|
||||||
|
#include "../lib/gui.h"
|
||||||
|
#include "../lib/events.h"
|
||||||
|
|
||||||
|
//===================================================//
|
||||||
|
// //
|
||||||
|
// DATA //
|
||||||
|
// //
|
||||||
|
//===================================================//
|
||||||
|
|
||||||
|
char download_file[] = "-d http://kolibri-n.org/files/KolibriN9.zip";
|
||||||
|
|
||||||
|
EVENTS button;
|
||||||
|
EVENTS key;
|
||||||
|
|
||||||
|
//===================================================//
|
||||||
|
// //
|
||||||
|
// CODE //
|
||||||
|
// //
|
||||||
|
//===================================================//
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
loop() switch(WaitEvent())
|
||||||
|
{
|
||||||
|
case evButton:
|
||||||
|
button.press( GetButtonID() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case evKey:
|
||||||
|
GetKeys();
|
||||||
|
key.press( key_scancode );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case evReDraw:
|
||||||
|
draw_window();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_window()
|
||||||
|
{
|
||||||
|
system.color.get();
|
||||||
|
DefineAndDrawWindow(215, 100, 350, 300, 0x34, system.color.work, "Network testing utility",0);
|
||||||
|
button.init(10);
|
||||||
|
key.init(10);
|
||||||
|
|
||||||
|
WriteText(10,10, 0x90, system.color.work_text, "Download via:");
|
||||||
|
AddEvent(10, 30, #EventRunAsmDownloader, SCAN_CODE_F1, "ASM Downloader [F1]");
|
||||||
|
AddEvent(10, 60, #EventRunCmmDownloader, SCAN_CODE_F2, "C-- Downloader [F2]");
|
||||||
|
AddEvent(10, 120, #EventRunNetStat, SCAN_CODE_F3, "NetStat [F3]");
|
||||||
|
AddEvent(10, 150, #EventRunNetCfg, SCAN_CODE_F4, "NetCfg [F4]");
|
||||||
|
AddEvent(10, 180, #EventRunBoard, SCAN_CODE_F5, "Board [F5]");
|
||||||
|
button.add_n(1, #ExitProcess);
|
||||||
|
key.add_n(SCAN_CODE_ESC, #ExitProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddEvent(dword bx, by, event, hotkey, text)
|
||||||
|
{
|
||||||
|
DrawStandartCaptButton(bx, by, button.add(event), text);
|
||||||
|
key.add_n(hotkey, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//===================================================//
|
||||||
|
// //
|
||||||
|
// EVENTS //
|
||||||
|
// //
|
||||||
|
//===================================================//
|
||||||
|
|
||||||
|
void EventRunAsmDownloader()
|
||||||
|
{
|
||||||
|
RunProgram("/sys/network/downloader", #download_file+3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventRunCmmDownloader()
|
||||||
|
{
|
||||||
|
RunProgram("/sys/network/webview", #download_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventRunNetStat()
|
||||||
|
{
|
||||||
|
RunProgram("/sys/network/netstat", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventRunNetCfg()
|
||||||
|
{
|
||||||
|
RunProgram("/sys/network/netcfg", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventRunBoard()
|
||||||
|
{
|
||||||
|
RunProgram("/sys/develop/board", NULL);
|
||||||
|
}
|
||||||
|
|
@ -4,13 +4,14 @@
|
|||||||
* Licence: GPL v2
|
* Licence: GPL v2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MEMSIZE 4096*500
|
#define MEMSIZE 1024*2000
|
||||||
|
|
||||||
#include "../lib/gui.h"
|
#include "../lib/gui.h"
|
||||||
#include "../lib/random.h"
|
#include "../lib/random.h"
|
||||||
#include "../lib/mem.h"
|
#include "../lib/mem.h"
|
||||||
#include "../lib/cursor.h"
|
#include "../lib/cursor.h"
|
||||||
#include "../lib/list_box.h"
|
#include "../lib/list_box.h"
|
||||||
|
#include "../lib/events.h"
|
||||||
|
|
||||||
#include "../lib/obj/libimg.h"
|
#include "../lib/obj/libimg.h"
|
||||||
#include "../lib/obj/box_lib.h"
|
#include "../lib/obj/box_lib.h"
|
||||||
@ -36,14 +37,14 @@ char image_menu_items[] =
|
|||||||
‡ ¬¥¨âì ¢á¥ æ¢¥â 1 2";
|
‡ ¬¥¨âì ¢á¥ æ¢¥â 1 2";
|
||||||
?define T_MENU_IMAGE "ˆª®ª "
|
?define T_MENU_IMAGE "ˆª®ª "
|
||||||
?define T_TEST_ICON "<EFBFBD>஢¥à¨âì ¨ª®ªã"
|
?define T_TEST_ICON "<EFBFBD>஢¥à¨âì ¨ª®ªã"
|
||||||
?define T_TITLE "Icon Editor 0.59 Alpha"
|
?define T_TITLE "Icon Editor 0.60 Alpha"
|
||||||
#else
|
#else
|
||||||
char image_menu_items[] =
|
char image_menu_items[] =
|
||||||
"Count colors used
|
"Count colors used
|
||||||
Replace all colors equal to 1 by 2";
|
Replace all colors equal to 1 by 2";
|
||||||
?define T_MENU_IMAGE "Icon"
|
?define T_MENU_IMAGE "Icon"
|
||||||
?define T_TEST_ICON "Test Icon"
|
?define T_TEST_ICON "Test Icon"
|
||||||
?define T_TITLE "<EFBFBD>¥¤ ªâ®à ¨ª®®ª 0.59 Alpha"
|
?define T_TITLE "<EFBFBD>¥¤ ªâ®à ¨ª®®ª 0.60 Alpha"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -81,32 +82,10 @@ signed priorHoverX;
|
|||||||
signed priorHoverY;
|
signed priorHoverY;
|
||||||
bool canvasMouseMoved = false;
|
bool canvasMouseMoved = false;
|
||||||
|
|
||||||
|
EVENTS button;
|
||||||
|
EVENTS key;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BTN_NEW = 40,
|
|
||||||
BTN_OPEN,
|
|
||||||
BTN_SAVE,
|
|
||||||
BTN_MOVE_LEFT,
|
|
||||||
BTN_MOVE_RIGHT,
|
|
||||||
BTN_MOVE_UP,
|
|
||||||
BTN_MOVE_DOWN,
|
|
||||||
BTN_FLIP_HOR,
|
|
||||||
BTN_FLIP_VER,
|
|
||||||
BTN_ROTATE_LEFT,
|
|
||||||
BTN_ROTATE_RIGHT,
|
|
||||||
BTN_TEST_ICON,
|
|
||||||
BTN_PENCIL,
|
|
||||||
BTN_PICK,
|
|
||||||
BTN_FILL,
|
|
||||||
BTN_LINE,
|
|
||||||
BTN_RECT,
|
|
||||||
BTN_BAR,
|
|
||||||
BTN_SELECT,
|
|
||||||
BTN_SCREEN_COPY,
|
|
||||||
BTN_ZOOM_IN,
|
|
||||||
BTN_ZOOM_OUT,
|
|
||||||
BTN_CANVAS_RESIZE,
|
|
||||||
BTN_CROP,
|
|
||||||
BTN_IMAGE_MENU,
|
|
||||||
BTNS_PALETTE_COLOR_MAS = 100,
|
BTNS_PALETTE_COLOR_MAS = 100,
|
||||||
BTNS_LAST_USED_COLORS = 400
|
BTNS_LAST_USED_COLORS = 400
|
||||||
};
|
};
|
||||||
@ -272,116 +251,12 @@ void main()
|
|||||||
|
|
||||||
if (zoom.click(btn)) DrawEditArea();
|
if (zoom.click(btn)) DrawEditArea();
|
||||||
|
|
||||||
switch(btn)
|
button.press(btn);
|
||||||
{
|
|
||||||
case BTN_NEW:
|
|
||||||
EventCreateNewIcon();
|
|
||||||
break;
|
|
||||||
case BTN_OPEN:
|
|
||||||
EventOpenIcon();
|
|
||||||
break;
|
|
||||||
case BTN_SAVE:
|
|
||||||
EventSaveIconToFile();
|
|
||||||
break;
|
|
||||||
case BTN_MOVE_LEFT:
|
|
||||||
EventMove(MOVE_LEFT);
|
|
||||||
break;
|
|
||||||
case BTN_MOVE_RIGHT:
|
|
||||||
EventMove(MOVE_RIGHT);
|
|
||||||
break;
|
|
||||||
case BTN_MOVE_UP:
|
|
||||||
EventMove(MOVE_UP);
|
|
||||||
break;
|
|
||||||
case BTN_MOVE_DOWN:
|
|
||||||
EventMove(MOVE_DOWN);
|
|
||||||
break;
|
|
||||||
case BTN_FLIP_VER:
|
|
||||||
EventMove(FLIP_VER);
|
|
||||||
break;
|
|
||||||
case BTN_FLIP_HOR:
|
|
||||||
EventMove(FLIP_HOR);
|
|
||||||
break;
|
|
||||||
case BTN_ROTATE_LEFT:
|
|
||||||
EventMove(ROTATE_LEFT);
|
|
||||||
break;
|
|
||||||
case BTN_ROTATE_RIGHT:
|
|
||||||
EventMove(ROTATE_RIGHT);
|
|
||||||
break;
|
|
||||||
case BTN_TEST_ICON:
|
|
||||||
EventTestIcon();
|
|
||||||
break;
|
|
||||||
case BTN_PENCIL:
|
|
||||||
setCurrentTool(TOOL_PENCIL);
|
|
||||||
break;
|
|
||||||
case BTN_PICK:
|
|
||||||
setCurrentTool(TOOL_PIPETTE);
|
|
||||||
break;
|
|
||||||
case BTN_FILL:
|
|
||||||
setCurrentTool(TOOL_FILL);
|
|
||||||
break;
|
|
||||||
case BTN_LINE:
|
|
||||||
setCurrentTool(TOOL_LINE);
|
|
||||||
break;
|
|
||||||
case BTN_RECT:
|
|
||||||
setCurrentTool(TOOL_RECT);
|
|
||||||
break;
|
|
||||||
case BTN_BAR:
|
|
||||||
setCurrentTool(TOOL_BAR);
|
|
||||||
break;
|
|
||||||
case BTN_SELECT:
|
|
||||||
setCurrentTool(TOOL_SELECT);
|
|
||||||
break;
|
|
||||||
case BTN_SCREEN_COPY:
|
|
||||||
setCurrentTool(TOOL_SCREEN_COPY);
|
|
||||||
break;
|
|
||||||
case BTN_CANVAS_RESIZE:
|
|
||||||
notify("Sorry, not implemented yet.");
|
|
||||||
break;
|
|
||||||
case BTN_CROP:
|
|
||||||
EventCrop();
|
|
||||||
break;
|
|
||||||
case BTN_IMAGE_MENU:
|
|
||||||
EventShowImageMenu();
|
|
||||||
break;
|
|
||||||
case CLOSE_BTN:
|
|
||||||
EventExitIconEdit();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case evKey:
|
case evKey:
|
||||||
GetKeys();
|
GetKeys();
|
||||||
|
|
||||||
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) key.press(ECTRL + key_scancode);
|
||||||
{
|
|
||||||
switch(key_scancode)
|
|
||||||
{
|
|
||||||
case SCAN_CODE_KEY_S:
|
|
||||||
EventSaveIconToFile();
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_KEY_O:
|
|
||||||
EventOpenIcon();
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_LEFT:
|
|
||||||
EventMove(MOVE_LEFT);
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_RIGHT:
|
|
||||||
EventMove(MOVE_RIGHT);
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_UP:
|
|
||||||
EventMove(MOVE_UP);
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_DOWN:
|
|
||||||
EventMove(MOVE_DOWN);
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_KEY_R:
|
|
||||||
EventMove(BTN_ROTATE_RIGHT);
|
|
||||||
break;
|
|
||||||
case SCAN_CODE_KEY_L:
|
|
||||||
EventMove(BTN_ROTATE_LEFT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
||||||
if (key_scancode == SCAN_CODE_DEL) EventCleanCanvas();
|
if (key_scancode == SCAN_CODE_DEL) EventCleanCanvas();
|
||||||
@ -390,15 +265,7 @@ void main()
|
|||||||
if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0)
|
if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0)
|
||||||
tools[currentTool].onKeyEvent(key_scancode);
|
tools[currentTool].onKeyEvent(key_scancode);
|
||||||
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_P) setCurrentTool(TOOL_PENCIL);
|
key.press(key_scancode);
|
||||||
if (key_scancode == SCAN_CODE_KEY_I) setCurrentTool(TOOL_PIPETTE);
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL);
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_L) setCurrentTool(TOOL_LINE);
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_R) setCurrentTool(TOOL_RECT);
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_B) setCurrentTool(TOOL_BAR);
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_S) setCurrentTool(TOOL_SELECT);
|
|
||||||
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_T) EventTestIcon();
|
|
||||||
|
|
||||||
if (key_scancode == SCAN_CODE_KEY_Z) actionsHistory.undoLastAction();
|
if (key_scancode == SCAN_CODE_KEY_Z) actionsHistory.undoLastAction();
|
||||||
if (key_scancode == SCAN_CODE_KEY_Y) actionsHistory.redoLastAction();
|
if (key_scancode == SCAN_CODE_KEY_Y) actionsHistory.redoLastAction();
|
||||||
@ -416,17 +283,19 @@ void main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTopPanelButton(dword _id, _x, _icon_n)
|
void DrawTopPanelButton(dword _event, _hotkey, _x, _icon_n)
|
||||||
{
|
{
|
||||||
DrawWideRectangle(_x, 4, 22, 22, 3, semi_white);
|
DrawWideRectangle(_x, 4, 22, 22, 3, semi_white);
|
||||||
PutPixel(_x,4,system.color.work);
|
PutPixel(_x,4,system.color.work);
|
||||||
PutPixel(_x,4+21,system.color.work);
|
PutPixel(_x,4+21,system.color.work);
|
||||||
PutPixel(_x+21,4,system.color.work);
|
PutPixel(_x+21,4,system.color.work);
|
||||||
PutPixel(_x+21,4+21,system.color.work);
|
PutPixel(_x+21,4+21,system.color.work);
|
||||||
DefineHiddenButton(_x, 4, 21, 21, _id);
|
DefineHiddenButton(_x, 4, 21, 21, button.add(_event));
|
||||||
img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16);
|
img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16);
|
||||||
|
if (_hotkey) key.add_n(_hotkey, _event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DrawFlatPanelButton(dword _id, _x, _y, _text)
|
int DrawFlatPanelButton(dword _id, _x, _y, _text)
|
||||||
{
|
{
|
||||||
#define P 10
|
#define P 10
|
||||||
@ -441,14 +310,14 @@ int DrawFlatPanelButton(dword _id, _x, _y, _text)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawLeftPanelButton(dword _id, _y, _icon_n)
|
void DrawLeftPanelButton(dword _event, _hotkey, _y, _icon_n)
|
||||||
{
|
{
|
||||||
int x = 5;
|
int x = 5;
|
||||||
DrawRectangle(x, _y, 22-1, 22-1, system.color.work);
|
DrawRectangle(x, _y, 22-1, 22-1, system.color.work);
|
||||||
DefineHiddenButton(x, _y, 21, 21, _id);
|
DefineHiddenButton(x, _y, 21, 21, button.add(_event));
|
||||||
img_draw stdcall(left_icons.image, x+3, _y+3, 16, 16, 0, _icon_n*16);
|
img_draw stdcall(left_icons.image, x+3, _y+3, 16, 16, 0, _icon_n*16);
|
||||||
|
key.add_n(_hotkey, _event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStatusBar()
|
void DrawStatusBar()
|
||||||
{
|
{
|
||||||
zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6);
|
zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6);
|
||||||
@ -459,56 +328,71 @@ void DrawStatusBar()
|
|||||||
zoom.y,
|
zoom.y,
|
||||||
calc(strlen(#param)*8)+6,
|
calc(strlen(#param)*8)+6,
|
||||||
18,
|
18,
|
||||||
BTN_CANVAS_RESIZE,
|
button.add(#EventCanvasResize),
|
||||||
system.color.work_button,
|
system.color.work_button,
|
||||||
system.color.work_button_text,
|
system.color.work_button_text,
|
||||||
#param
|
#param
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawWindow()
|
void DrawWindow()
|
||||||
{
|
{
|
||||||
#define GAP 27
|
#define GAPH 27
|
||||||
|
#define GAPV 28
|
||||||
#define BLOCK_SPACE 10
|
#define BLOCK_SPACE 10
|
||||||
incn tx;
|
incn tx;
|
||||||
|
incn ty;
|
||||||
system.color.get();
|
system.color.get();
|
||||||
DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x73, NULL, T_TITLE, 0);
|
DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x73, NULL, T_TITLE, 0);
|
||||||
GetProcessInfo(#Form, SelfInfo);
|
GetProcessInfo(#Form, SelfInfo);
|
||||||
if (Form.status_window>2) return;
|
if (Form.status_window>2) return;
|
||||||
if (Form.width < 560) { MoveSize(OLD,OLD,560,OLD); return; }
|
if (Form.width < 560) { MoveSize(OLD,OLD,560,OLD); return; }
|
||||||
if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
|
if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
|
||||||
|
button.init(40);
|
||||||
|
key.init(40);
|
||||||
|
|
||||||
right_bar.x = Form.cwidth - right_bar.w;
|
right_bar.x = Form.cwidth - right_bar.w;
|
||||||
b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x;
|
b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x;
|
||||||
DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, system.color.work);
|
DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, system.color.work);
|
||||||
DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, system.color.work_graph);
|
DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, system.color.work_graph);
|
||||||
|
|
||||||
tx.n = 5-GAP;
|
tx.n = 5-GAPH;
|
||||||
DrawTopPanelButton(BTN_NEW, tx.inc(GAP), 2);
|
DrawTopPanelButton(#EventCreateNewIcon, ECTRL + SCAN_CODE_KEY_N, tx.inc(GAPH), 2);
|
||||||
DrawTopPanelButton(BTN_OPEN, tx.inc(GAP), 0); //not implemented
|
DrawTopPanelButton(#EventOpenIcon, ECTRL + SCAN_CODE_KEY_O, tx.inc(GAPH), 0);
|
||||||
DrawTopPanelButton(BTN_SAVE, tx.inc(GAP), 5);
|
DrawTopPanelButton(#EventSaveIconToFile, ECTRL + SCAN_CODE_KEY_S, tx.inc(GAPH), 5);
|
||||||
DrawTopPanelButton(BTN_MOVE_LEFT, tx.inc(GAP+BLOCK_SPACE), 30);
|
DrawTopPanelButton(#EventMoveLeft, ECTRL + SCAN_CODE_LEFT, tx.inc(GAPH+BLOCK_SPACE), 30);
|
||||||
DrawTopPanelButton(BTN_MOVE_RIGHT, tx.inc(GAP), 31);
|
DrawTopPanelButton(#EventMoveRight, ECTRL + SCAN_CODE_RIGHT, tx.inc(GAPH), 31);
|
||||||
DrawTopPanelButton(BTN_MOVE_UP, tx.inc(GAP), 32);
|
DrawTopPanelButton(#EventMoveUp, ECTRL + SCAN_CODE_UP, tx.inc(GAPH), 32);
|
||||||
DrawTopPanelButton(BTN_MOVE_DOWN, tx.inc(GAP), 33);
|
DrawTopPanelButton(#EventMoveDown, ECTRL + SCAN_CODE_DOWN, tx.inc(GAPH), 33);
|
||||||
|
DrawTopPanelButton(#EventFlipHor, 0, tx.inc(GAPH+BLOCK_SPACE), 34);
|
||||||
DrawTopPanelButton(BTN_FLIP_HOR, tx.inc(GAP+BLOCK_SPACE), 34);
|
DrawTopPanelButton(#EventFlipVer, 0, tx.inc(GAPH), 35);
|
||||||
DrawTopPanelButton(BTN_FLIP_VER, tx.inc(GAP), 35);
|
DrawTopPanelButton(#EventRotateLeft, ECTRL + SCAN_CODE_KEY_L, tx.inc(GAPH), 37);
|
||||||
DrawTopPanelButton(BTN_ROTATE_LEFT, tx.inc(GAP), 37);
|
DrawTopPanelButton(#EventRotateRight, ECTRL + SCAN_CODE_KEY_R, tx.inc(GAPH), 36);
|
||||||
DrawTopPanelButton(BTN_ROTATE_RIGHT, tx.inc(GAP), 36);
|
DrawTopPanelButton(#EventTestIcon, ECTRL + SCAN_CODE_KEY_T, tx.inc(GAPH+BLOCK_SPACE), 12);
|
||||||
|
DrawTopPanelButton(#EventCrop, 0, tx.inc(GAPH+BLOCK_SPACE), 46);
|
||||||
DrawTopPanelButton(BTN_TEST_ICON, tx.inc(GAP+BLOCK_SPACE), 12);
|
|
||||||
|
|
||||||
DrawTopPanelButton(BTN_CROP, tx.inc(GAP+BLOCK_SPACE), 46);
|
|
||||||
|
|
||||||
image_menu_btn.x = tx.n;
|
image_menu_btn.x = tx.n;
|
||||||
image_menu_btn.w = DrawFlatPanelButton(BTN_IMAGE_MENU, image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE);
|
image_menu_btn.w = DrawFlatPanelButton(button.add(#EventShowImageMenu), image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE);
|
||||||
//tx.inc(image_menu_btn.w + BLOCK_SPACE);
|
//tx.inc(image_menu_btn.w + BLOCK_SPACE);
|
||||||
|
|
||||||
DrawEditArea();
|
DrawEditArea();
|
||||||
|
|
||||||
DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, system.color.work);
|
DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, system.color.work);
|
||||||
DrawLeftPanel();
|
|
||||||
|
ty.n = right_bar.y - GAPV - 2;
|
||||||
|
|
||||||
|
DrawLeftPanelButton(#EventSelectToolPencil, SCAN_CODE_KEY_P, ty.inc(GAPV), 38);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolPick, SCAN_CODE_KEY_I, ty.inc(GAPV), 39);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolFill, SCAN_CODE_KEY_F, ty.inc(GAPV), 40);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolLine, SCAN_CODE_KEY_L, ty.inc(GAPV), 41);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolRect, SCAN_CODE_KEY_R, ty.inc(GAPV), 42);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolBar, SCAN_CODE_KEY_B, ty.inc(GAPV), 43);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolSelect, SCAN_CODE_KEY_S, ty.inc(GAPV), 44);
|
||||||
|
DrawLeftPanelButton(#EventSelectToolScrCopy,SCAN_CODE_KEY_Q, ty.inc(GAPV), 45);
|
||||||
|
DrawLeftPanelSelection();
|
||||||
|
|
||||||
|
button.add_n(1, #EventExitIconEdit);
|
||||||
|
|
||||||
DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w,
|
DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w,
|
||||||
Form.cheight - TOPBAR_H, system.color.work);
|
Form.cheight - TOPBAR_H, system.color.work);
|
||||||
@ -521,20 +405,10 @@ void DrawWindow()
|
|||||||
DrawStatusBar();
|
DrawStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawLeftPanel()
|
void DrawLeftPanelSelection()
|
||||||
{
|
{
|
||||||
#define GAP 28
|
DrawRectangle3D(5, previousTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, system.color.work, system.color.work);
|
||||||
incn ty;
|
DrawRectangle3D(5, currentTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, 0x333333, 0x777777);
|
||||||
ty.n = right_bar.y - GAP - 2;
|
|
||||||
DrawLeftPanelButton(BTN_PENCIL, ty.inc(GAP), 38);
|
|
||||||
DrawLeftPanelButton(BTN_PICK, ty.inc(GAP), 39);
|
|
||||||
DrawLeftPanelButton(BTN_FILL, ty.inc(GAP), 40);
|
|
||||||
DrawLeftPanelButton(BTN_LINE, ty.inc(GAP), 41);
|
|
||||||
DrawLeftPanelButton(BTN_RECT, ty.inc(GAP), 42);
|
|
||||||
DrawLeftPanelButton(BTN_BAR, ty.inc(GAP), 43);
|
|
||||||
DrawLeftPanelButton(BTN_SELECT, ty.inc(GAP), 44);
|
|
||||||
DrawLeftPanelButton(BTN_SCREEN_COPY, ty.inc(GAP), 45);
|
|
||||||
DrawRectangle3D(5, currentTool*GAP+right_bar.y-2, 16+3+2, 16+3+2, 0x333333, 0x777777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawEditArea()
|
void DrawEditArea()
|
||||||
@ -895,6 +769,31 @@ void EventReplaceImageColors(dword c1, c2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventCanvasResize()
|
||||||
|
{
|
||||||
|
notify("Sorry, not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventMoveLeft() { EventMove(MOVE_LEFT); }
|
||||||
|
void EventMoveRight() { EventMove(MOVE_RIGHT); }
|
||||||
|
void EventMoveUp() { EventMove(MOVE_UP); }
|
||||||
|
void EventMoveDown() { EventMove(MOVE_DOWN); }
|
||||||
|
void EventFlipHor() { EventMove(FLIP_HOR); }
|
||||||
|
void EventFlipVer() { EventMove(FLIP_VER); }
|
||||||
|
void EventRotateLeft() { EventMove(ROTATE_LEFT); }
|
||||||
|
void EventRotateRight() { EventMove(ROTATE_RIGHT); }
|
||||||
|
|
||||||
|
void EventSelectToolPencil() { setCurrentTool(TOOL_PENCIL); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolPick() { setCurrentTool(TOOL_PIPETTE); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolFill() { setCurrentTool(TOOL_FILL); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolLine() { setCurrentTool(TOOL_LINE); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolRect() { setCurrentTool(TOOL_RECT); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolBar() { setCurrentTool(TOOL_BAR); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolSelect() { setCurrentTool(TOOL_SELECT); DrawLeftPanelSelection(); }
|
||||||
|
void EventSelectToolScrCopy() { setCurrentTool(TOOL_SCREEN_COPY); DrawLeftPanelSelection(); }
|
||||||
|
|
||||||
|
char test_icon_stak22[4096];
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
|
|
||||||
char test_icon_stak[4096];
|
char test_icon_stak[4096];
|
||||||
|
@ -107,7 +107,6 @@ void setCurrentTool(int index) {
|
|||||||
|
|
||||||
Cursor.Restore();
|
Cursor.Restore();
|
||||||
if (wrapper.hovered()) SetCursor();
|
if (wrapper.hovered()) SetCursor();
|
||||||
DrawLeftPanel();
|
|
||||||
DrawCanvas();
|
DrawCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// Author: Pavel Iakovlev by. pavelyakov
|
// Author: Pavel Iakovlev by. pavelyakov
|
||||||
|
|
||||||
|
#ifndef INCLUDE_ARRAY_H
|
||||||
|
#define INCLUDE_ARRAY_H
|
||||||
|
|
||||||
// Array memory: [dword key][byte flags][dword left][dword right][dword value] -> 17 bytes = 1 position
|
// Array memory: [dword key][byte flags][dword left][dword right][dword value] -> 17 bytes = 1 position
|
||||||
// If key don't exists then value == 0
|
// If key don't exists then value == 0
|
||||||
@ -162,3 +164,5 @@
|
|||||||
{
|
{
|
||||||
RETURN array.init(size);
|
RETURN array.init(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
46
programs/cmm/lib/events.h
Normal file
46
programs/cmm/lib/events.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
#ifndef INCLUDE_ARRAY_H
|
||||||
|
#include "../lib/array.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ECTRL 300
|
||||||
|
|
||||||
|
struct EVENTS
|
||||||
|
{
|
||||||
|
Array array;
|
||||||
|
int new_id;
|
||||||
|
void init();
|
||||||
|
int add();
|
||||||
|
int add_n();
|
||||||
|
bool press();
|
||||||
|
};
|
||||||
|
|
||||||
|
void EVENTS::init(dword size)
|
||||||
|
{
|
||||||
|
array.init(size);
|
||||||
|
new_id = 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EVENTS::add(dword event1)
|
||||||
|
{
|
||||||
|
new_id++;
|
||||||
|
array.set(new_id, event1);
|
||||||
|
return new_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EVENTS::add_n(dword id, event2)
|
||||||
|
{
|
||||||
|
array.set(id, event2);
|
||||||
|
return new_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EVENTS::press(dword id)
|
||||||
|
{
|
||||||
|
dword event3;
|
||||||
|
if (array.get(id)) {
|
||||||
|
event3 = array.get(id);
|
||||||
|
event3();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
@ -71,6 +71,7 @@
|
|||||||
#define SCAN_CODE_KEY_N 049
|
#define SCAN_CODE_KEY_N 049
|
||||||
#define SCAN_CODE_KEY_O 024
|
#define SCAN_CODE_KEY_O 024
|
||||||
#define SCAN_CODE_KEY_P 025
|
#define SCAN_CODE_KEY_P 025
|
||||||
|
#define SCAN_CODE_KEY_Q 016
|
||||||
#define SCAN_CODE_KEY_R 019
|
#define SCAN_CODE_KEY_R 019
|
||||||
#define SCAN_CODE_KEY_S 031
|
#define SCAN_CODE_KEY_S 031
|
||||||
#define SCAN_CODE_KEY_T 020
|
#define SCAN_CODE_KEY_T 020
|
||||||
|
Loading…
Reference in New Issue
Block a user