Notes: pre final version

MouseCfg: optimized version (thans, Lev)
RtfRead: fix hotkeys

git-svn-id: svn://kolibrios.org@7434 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-04 20:08:44 +00:00
parent e0615bc762
commit 8bd9dd2363
13 changed files with 153 additions and 106 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,10 +1,11 @@
// Mouse Configuration Utility ver 1.51
// Mouse Configuration Utility ver 1.6
#ifndef AUTOBUILD
#include "lang.h--"
#endif
#define MEMSIZE 0x23E80
#define MEMSIZE 4096*11
#include "..\lib\strings.h"
#include "..\lib\mem.h"
#include "..\lib\fs.h"
@ -34,25 +35,18 @@
?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
?define MADMOUSE "Through screen sides for pointer"
#endif
proc_info Form;
block mouse_frame = { 18, 18, NULL, 130 };
more_less_box pointer_speed = { NULL, 0, 64, POINTER_SPEED };
more_less_box acceleration = { NULL, 0, 64, ACCELERATION_TEXT };
more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 };
checkbox emulation = { MOUSE_EMULATION, NULL };
checkbox madmouse = { MADMOUSE, NULL };
unsigned char panels_img_data[] = FROM "mouse_image.raw";
raw_image panels_img = { 59, 101, #panels_img_data };
:block mouse_frame = { 18, 18, NULL, 130 };
:more_less_box pointer_speed = { NULL, 0, 64, POINTER_SPEED };
:more_less_box acceleration = { NULL, 0, 64, ACCELERATION_TEXT };
:more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 };
:checkbox emulation = { MOUSE_EMULATION, NULL };
:checkbox madmouse = { MADMOUSE, NULL };
_ini ini = { "/sys/settings/system.ini", "mouse" };
dword click_status;
void main() {
proc_info Form;
int id;
load_dll(libini, #lib_init,1);
@ -66,44 +60,36 @@ void main() {
{
case evMouse:
mouse.get();
if (mouse.down) && (click_status==0) && (mouse_frame.hovered()) {
if (mouse.key&MOUSE_LEFT) click_status = 1;
if (mouse.key&MOUSE_RIGHT) click_status = 2;
if (mouse.key&MOUSE_CENTER) click_status = 3;
DrawMouseImage();
}
if (mouse.up) {
click_status=0;
DrawMouseImage();
}
IF (mouse_frame.hovered()) DrawMouseImage(mouse.lkm,mouse.pkm,mouse.mkm, mouse.vert);
IF (mouse.up) DrawMouseImage(0,0,0,0);
break;
case evButton:
CASE evButton:
id = GetButtonID();
if (1 == id) ExitApp();
else if (pointer_speed.click(id)) ApplyCfg();
else if (acceleration.click(id)) ApplyCfg();
else if (double_click_delay.click(id)) ApplyCfg();
else if (emulation.click(id)) {
if (emulation.checked == true) RunProgram("/sys/mousemul", 0);
else KillProcessByName("/sys/mousemul", SINGLE);
IF (1 == id) ExitApp();
else IF (pointer_speed.click(id)) ApplyCfg();
else IF (acceleration.click(id)) ApplyCfg();
else IF (double_click_delay.click(id)) ApplyCfg();
ELSE IF (emulation.click(id)) {
IF (emulation.checked == true) RunProgram("/sys/mousemul", 0);
ELSE KillProcessByName("/sys/mousemul", SINGLE);
break;
}
else if (madmouse.click(id)) {
if (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
else KillProcessByName("/sys/madmouse", SINGLE);
ELSE IF (madmouse.click(id)) {
IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
ELSE KillProcessByName("/sys/madmouse", SINGLE);
break;
}
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitApp();
IF (key_scancode == SCAN_CODE_ESC) ExitApp();
break;
case evReDraw:
system.color.get();
DefineAndDrawWindow(430, 150, 424, 310+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
DefineAndDrawWindow(430, 150, 424, 313+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break;
mouse_frame.w = - mouse_frame.x * 2 + Form.cwidth;
@ -111,15 +97,37 @@ void main() {
mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
WriteText(mouse_frame.x + 110, mouse_frame.y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
WriteText(mouse_frame.x + 110, mouse_frame.y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
DrawMouseImage();
DrawMouseImage(0,0,0,0);
DrawControls();
}
}
:byte panels_img_data[] = FROM "mouse_image.raw";
void DrawMouseImage() {
_PutImage(mouse_frame.x+30, mouse_frame.y + 15, panels_img.w, panels_img.h,
click_status * panels_img.w * panels_img.h * 3 + panels_img.data);
#define red 0xff0000
#define yellow 0xfff600
#define white 0xffffff
#define dgrey 0x2d353d
:struct IMG_PAL{ dword back, shad1, mbody, left, right, middle, white; }
pal = { 0xF0F2F3,0xABB0B2, dgrey, white, white, dgrey, white };
void DrawMouseImage(dword l,r,m,v) {
#define IMG_W 59
#define IMG_H 101
IF (l) pal.left = red;
IF (m) pal.middle = red;
IF (r) pal.right = red;
IF (v) pal.middle = yellow;
PutPaletteImage(#panels_img_data,IMG_W,IMG_H,18+30,18+15,8,#pal);
pal.left = pal.right = white;
pal.middle = dgrey;
if (v) {
pause(10);
DrawMouseImage(0,0,0,0);
}
}
void DrawControls() {

View File

@ -2,7 +2,7 @@
#define CHBOX 12
#define CHECKBOX_ID 50
unsigned char checkbox[sizeof(file "checkbox.raw")]= FROM "checkbox.raw";
unsigned char checkbox[sizeof(file "img/checkbox.raw")]= FROM "img/checkbox.raw";
#define COL_BG_ACTIVE 0xFFF0A9
#define COL_BG_INACTIVE 0xFFFFFF
@ -36,13 +36,13 @@ void NOTE_LINE::Delete()
struct NOTES : llist {
char txt_path[4096];
char txt_data[MAX_LINE_CHARS*LINES_COUNT];
bool txt_file_exists;
NOTE_LINE lines[LINES_COUNT];
char edit_active;
int OpenTxt();
int SaveTxt();
void DeleteNode();
void DrawList();
dword DrawLine(int line_n, draw_h);
} notes;
@ -57,11 +57,13 @@ int NOTES::OpenTxt(dword file_path)
ReadFile(0, 4096, #txt_data, #txt_path);
if (!txt_data) || (strncmp(#txt_data, "notes", 5)!=0)
{
txt_file_exists = false;
notify("'Notes\nData file does not exists or is not valid' -tE");
return 0;
}
else
{
txt_file_exists = true;
i+=5; //skip "notes" indefinier
while (txt_data[i])
{
@ -98,6 +100,7 @@ int NOTES::SaveTxt()
tm = #lines[i].data;
strcat(#txt_data, #lines[i].data);
}
if (!txt_file_exists) CreateFile(0, 0, #txt_path);
WriteFile(0, strlen(#txt_data), #txt_data, #txt_path);
}

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
programs/cmm/notes/notes Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
// Notes v0.8 ALPHA
// Notes v0.9 Beta
#define MEMSIZE 0xDAE80
#include "..\lib\kolibri.h"
@ -32,7 +32,7 @@
#define RED_LINE_X 22
#define COL_RED_LINE 0xF3C9C9
unsigned char edge[sizeof(file "edge.raw")]= FROM "edge.raw"; //292x6
unsigned char edge[sizeof(file "img/edge.raw")]= FROM "img/edge.raw"; //292x6
#define EDGE_H 6
#define TITLE_H 24
#define HEADER_HEIGHT TITLE_H+EDGE_H
@ -47,7 +47,7 @@ unsigned char edge[sizeof(file "edge.raw")]= FROM "edge.raw"; //292x6
#include "engine.h"
dword ed_mouse;
edit_box notebox = {0,999,0,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff,0,
edit_box notebox = {NULL,NULL,NULL,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff,0,
MAX_LINE_CHARS-1,NULL,#ed_mouse,ed_always_focus+ed_focus};
dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 };
@ -63,13 +63,14 @@ block delBtn;
void main()
{
int btn;
bool first_redraw=true;
dword cur_line_offset;
load_dll(boxlib, #box_lib_init,0);
if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt"));
notes.cur_y = -1;
//notes.cur_y = 0;
SetEventMask(0x27);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop() switch(WaitEvent())
{
@ -90,6 +91,7 @@ void main()
if (mouse.key&MOUSE_LEFT)&&(mouse.up)
&& (notes.ProcessMouse(mouse.x, mouse.y)) {
notebox.pos = mouse.x - notebox.left / 6;
EventListRedraw();
EventActivateLine(notes.cur_y);
}
@ -107,14 +109,21 @@ void main()
EventDeleteCurrentNode();
break;
default:
notes.lines[btn-CHECKBOX_ID].state ^= 1;
EventListRedraw();
EventCheckBoxClick(btn-CHECKBOX_ID);
break;
}
break;
case evKey:
GetKeys();
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
{
if (key_scancode == SCAN_CODE_SPACE)
{
EventCheckBoxClick(notes.cur_y);
}
break;
}
switch(key_scancode)
{
case SCAN_CODE_ESC:
@ -137,6 +146,10 @@ void main()
case evReDraw:
draw_window();
if (first_redraw) {
first_redraw = false;
EventActivateLine(0);
}
}
}
@ -172,9 +185,10 @@ void DrawEditBoxN()
{
notebox.width = notes.w-notes.x-8;
notebox.left = notes.x+5;
notebox.pos = notebox.offset = notebox.shift = notebox.shift_old = 0;
notebox.offset = notebox.shift = notebox.shift_old = 0;
notebox.cl_curs_x = notebox.cl_curs_y = 0;
notebox.size = strlen(notebox.text);
if (notebox.pos > notebox.size) notebox.pos = notebox.size;
notebox.top = notes.cur_y*notes.item_h+4+notes.y;
edit_box_draw stdcall(#notebox);
}
@ -212,7 +226,8 @@ void EventDrawDeleteButton()
void EventDeleteCurrentNode()
{
notes.lines[notes.cur_y].Delete();
int t = notes.cur_y;
notes.lines[t].Delete();
EventListRedraw();
}
@ -223,4 +238,10 @@ void EventListRedraw()
notes.DrawList();
}
void EventCheckBoxClick(int id)
{
notes.lines[id].state ^= 1;
EventListRedraw();
}
stop:

View File

@ -2,15 +2,36 @@
* Template C-- program.
*/
#define MEMSIZE 4096*5
#define MEMSIZE 4096*10
#include "../lib/kolibri.h"
#include "../lib/fs.h"
#include "../lib/io.h"
#include "../lib/gui.h"
proc_info Form;
void main()
{
RunProgram("/sys/syspanel", "/sys/settings/games.ini");
word btn;
loop() switch(WaitEvent())
{
case evButton:
btn = GetButtonID();
if (btn == 1) ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
draw_window();
break;
}
}
void draw_window()
{
DefineAndDrawWindow(215, 100, 350, 300, 0x34, 0xEEEeee, "Window title",0);
GetProcessInfo(#Form, SelfInfo);
}

View File

@ -154,20 +154,20 @@ _BGIfont_Prepare:
mov dword[.font],edx ; filename
mov esi,edi ; esi->FontName
mov [.dest],edi ; ptr to load font
mov eax, 70
mov ebx, .fontattr
mcall
test eax, eax
;jnz .fail
dps2 '1'
mov eax, [.fileattr+32]
mov [.fsize], litt_end-litt_file
mov ebx,.fontinfo
mov eax,70
mcall ; ebx - file size
;mov ebx, litt_end-litt_file
;mov edi, litt_file
;mov [.dest],litt_file ; ptr to load font
; mov eax, 70
; mov ebx, .fontattr
; mcall
; test eax, eax
; ;jnz .fail
; dps2 '1'
; mov eax, [.fileattr+32]
;mov [.fsize], litt_end-litt_file
;mov ebx,.fontinfo
;mov eax,70
;mcall ; ebx - file size
mov ebx, litt_end-litt_file
mov edi, litt_file
mov [.dest],litt_file ; ptr to load font
cmp dword[edi],0x08084b50 ; 'PK',8,8
jne .fail

View File

@ -163,8 +163,8 @@ key: ;
mov dh,ah
jmp key
.next: ;]Leency
cmp ah,104 ; HELP
.next:
cmp ah,'h' ; H - help
jne .nohelp
.help:
mov [is_scroll_bar_needed], 0
@ -192,15 +192,15 @@ key: ;
; je still
; jmp prep_load
.nohelp2:
cmp ah,114 ; R - redraw
cmp ah,'r' ; R - redraw
je red
cmp ah,99 ; C - color
cmp ah,'c' ; C - color
jne .nocolor
.color:
xor [mode],RTF_COLORLESS
jmp red
.nocolor:
cmp ah,97 ; A - alignment
cmp ah,'a' ; A - alignment
jne .noalign
.alignment:
xor [mode],RTF_ALIGNLESS
@ -212,12 +212,30 @@ key: ;
dec [pitch]
jmp red
.nopd:
cmp ah,46 ; < - pitch inc
cmp ah,46 ; > - pitch inc
jne .nopi
.incp:
inc [pitch]
jmp red
.nopi:
cmp ah,43 ;zoom+
je .zplus
cmp ah,61 ;zoom=
jne .noplus
.zplus:
fld [FreeFontscale]
fmul [Zoomscale]
.zoom:
fstp [FreeFontscale]
jmp red
.noplus:
cmp ah,45 ;zoom-
jne .home
.zminus:
fld [FreeFontscale]
fdiv [Zoomscale]
jmp .zoom
.home:
cmp ah,180 ; Home
je top_red
@ -307,21 +325,7 @@ key: ;
; je still
jmp red
.noarup:
cmp ah,56 ;zoom+
jne .noplus
.zplus:
fld [FreeFontscale]
fmul [Zoomscale]
.zoom:
fstp [FreeFontscale]
jmp red
.noplus:
cmp ah,54 ;zoom-
jne .nominus
.zminus:
fld [FreeFontscale]
fdiv [Zoomscale]
jmp .zoom
.nominus:
cmp ah,0xB5 ; end
jne .pre_file_open
@ -336,7 +340,7 @@ key: ;
call Set_position
jmp red
.pre_file_open:
cmp ah,108 ; L - load
cmp ah,'l' ; L - load
jne still
.file_open:
;---------------------------------------------------------------------
@ -351,16 +355,6 @@ key: ;
cmp [OpenDialog_data.status],1
je prep_load
jmp still
;---------------------------------------------------------------------
;.sysxtree:
; or [mode],RTF_OPENING
; opendialog draw_window, prep_load, st_1, fname_buf
; st_1:
; and [mode],not RTF_OPENING
; jmp still;red
; stilld:
; jmp still
;---------------------------------------------------------------------
button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
@ -744,7 +738,7 @@ end if
; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
; ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
window_title: db 'RtfRead v1.4',0
window_title: db 'RtfRead v1.5',0
is_scroll_bar_needed dd 0x0
window_width dd 0x0
window_height dd 0x0