forked from KolibriOS/kolibrios
small refactoring; added rasterwerks (don't use now)
git-svn-id: svn://kolibrios.org@7290 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
fa318e3fad
commit
1489fafd26
@ -24,7 +24,7 @@
|
|||||||
#include "../lib/obj/box_lib.h"
|
#include "../lib/obj/box_lib.h"
|
||||||
#include "../lib/obj/libio.h"
|
#include "../lib/obj/libio.h"
|
||||||
#include "../lib/obj/proc_lib.h"
|
#include "../lib/obj/proc_lib.h"
|
||||||
//#include "../lib/obj/libini.h"
|
#include "../lib/obj/librasterworks.h"
|
||||||
|
|
||||||
#include "../lib/patterns/simple_open_dialog.h"
|
#include "../lib/patterns/simple_open_dialog.h"
|
||||||
|
|
||||||
@ -64,7 +64,8 @@ WebView
|
|||||||
FB2Read
|
FB2Read
|
||||||
HexView";
|
HexView";
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
MENU_ID_FILE=10,
|
MENU_ID_FILE=10,
|
||||||
FILE_SUBMENU_ID_OPEN=10,
|
FILE_SUBMENU_ID_OPEN=10,
|
||||||
FILE_SUBMENU_ID_CLOSE,
|
FILE_SUBMENU_ID_CLOSE,
|
||||||
@ -87,7 +88,7 @@ int menu_encoding_x = NULL;
|
|||||||
int menu_reopen_x = NULL;
|
int menu_reopen_x = NULL;
|
||||||
/*======== MENU END ==========*/
|
/*======== MENU END ==========*/
|
||||||
|
|
||||||
#define TITLE "Calypte v0.37"
|
#define TITLE "Calypte v0.38 dev"
|
||||||
char win_title[4096] = TITLE;
|
char win_title[4096] = TITLE;
|
||||||
|
|
||||||
#define TOPPANELH 23
|
#define TOPPANELH 23
|
||||||
@ -126,6 +127,7 @@ void main()
|
|||||||
//load_dll(libini, #lib_init, 1);
|
//load_dll(libini, #lib_init, 1);
|
||||||
load_dll(iconv_lib, #iconv_open, 0);
|
load_dll(iconv_lib, #iconv_open, 0);
|
||||||
load_dll(Proc_lib, #OpenDialog_init,0);
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
||||||
|
load_dll(librasterworks, #rasterworks_drawText,0);
|
||||||
OpenDialog_init stdcall (#o_dialog);
|
OpenDialog_init stdcall (#o_dialog);
|
||||||
|
|
||||||
if (param)
|
if (param)
|
||||||
@ -145,35 +147,53 @@ void main()
|
|||||||
case evMouse:
|
case evMouse:
|
||||||
mouse.get();
|
mouse.get();
|
||||||
rows.wheel_size = 3;
|
rows.wheel_size = 3;
|
||||||
if (rows.MouseScroll(mouse.vert)) {
|
if (rows.MouseScroll(mouse.vert))
|
||||||
|
{
|
||||||
DrawText();
|
DrawText();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evButton:
|
case evButton:
|
||||||
id=GetButtonID();
|
id=GetButtonID();
|
||||||
if (id==1) ExitProcess();
|
if (id==1)
|
||||||
|
{
|
||||||
|
ExitProcess();
|
||||||
|
}
|
||||||
if (id==MENU_ID_FILE)
|
if (id==MENU_ID_FILE)
|
||||||
|
{
|
||||||
EventShowMenu(menu_file_x, #menu_file_list, MENU_ID_FILE, NULL);
|
EventShowMenu(menu_file_x, #menu_file_list, MENU_ID_FILE, NULL);
|
||||||
|
}
|
||||||
if (id==MENU_ID_ENCODING)
|
if (id==MENU_ID_ENCODING)
|
||||||
|
{
|
||||||
EventShowMenu(menu_encoding_x, #menu_encoding_list, MENU_ID_ENCODING, encoding+1);
|
EventShowMenu(menu_encoding_x, #menu_encoding_list, MENU_ID_ENCODING, encoding+1);
|
||||||
|
}
|
||||||
if (id==MENU_ID_REOPEN)
|
if (id==MENU_ID_REOPEN)
|
||||||
|
{
|
||||||
EventShowMenu(menu_reopen_x, #menu_reopen_list, MENU_ID_REOPEN, NULL);
|
EventShowMenu(menu_reopen_x, #menu_reopen_list, MENU_ID_REOPEN, NULL);
|
||||||
|
}
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (key_scancode == SCAN_CODE_KEY_O) EventOpenFile();
|
if (key_scancode == SCAN_CODE_KEY_O)
|
||||||
|
{
|
||||||
|
EventOpenFile();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rows.ProcessKey(key_scancode)) DrawText();
|
if (rows.ProcessKey(key_scancode))
|
||||||
|
{
|
||||||
|
DrawText();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
if (menu.list.cur_y) EventMenuClick();
|
if (menu.list.cur_y)
|
||||||
|
{
|
||||||
|
EventMenuClick();
|
||||||
|
}
|
||||||
draw_window();
|
draw_window();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -212,7 +232,10 @@ void draw_window()
|
|||||||
rows.SetSizes(0, TOPPANELH, Form.cwidth - SCROLL_SIZE, Form.cheight - TOPPANELH - BOTPANELH, 20);
|
rows.SetSizes(0, TOPPANELH, Form.cwidth - SCROLL_SIZE, Form.cheight - TOPPANELH - BOTPANELH, 20);
|
||||||
rows.column_max = rows.w / rows.font_w;
|
rows.column_max = rows.w / rows.font_w;
|
||||||
|
|
||||||
if (bufpointer) Prepare();
|
if (bufpointer)
|
||||||
|
{
|
||||||
|
Prepare();
|
||||||
|
}
|
||||||
rows.CheckDoesValuesOkey();
|
rows.CheckDoesValuesOkey();
|
||||||
}
|
}
|
||||||
DrawRectangle(rows.x+rows.w-1, rows.y, SCROLL_SIZE, rows.h-1, 0xEEEeee);
|
DrawRectangle(rows.x+rows.w-1, rows.y, SCROLL_SIZE, rows.h-1, 0xEEEeee);
|
||||||
@ -230,19 +253,25 @@ void OpenFile(dword _path)
|
|||||||
{
|
{
|
||||||
bufpointer = mem_Free(bufpointer);
|
bufpointer = mem_Free(bufpointer);
|
||||||
bufpointer = mem_Alloc(bufsize);
|
bufpointer = mem_Alloc(bufsize);
|
||||||
if (ReadFile(0, bufsize, bufpointer, #param) != 0) {
|
if (ReadFile(0, bufsize, bufpointer, #param) != 0)
|
||||||
|
{
|
||||||
bufpointer = 0;
|
bufpointer = 0;
|
||||||
notify("'Error opening file'-E");
|
notify("'Error opening file'-E");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", bufpointer);
|
if (encoding!=CH_CP866)
|
||||||
|
{
|
||||||
|
ChangeCharset(charsets[encoding], "CP866", bufpointer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
PARSE_CALCULATE_ROWS_COUNT,
|
PARSE_CALCULATE_ROWS_COUNT,
|
||||||
PARSE_DRAW_PREPARE,
|
PARSE_DRAW_PREPARE,
|
||||||
};
|
};
|
||||||
|
|
||||||
void Parse(int mode)
|
void Parse(int mode)
|
||||||
{
|
{
|
||||||
int pos=0;
|
int pos=0;
|
||||||
@ -261,22 +290,40 @@ void Parse(int mode)
|
|||||||
do_eof = true;
|
do_eof = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bukva==0x0a) break;
|
if (bukva==0x0a)
|
||||||
else len_str++;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len_str++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (len_str<=rows.column_max)
|
if (len_str<=rows.column_max)
|
||||||
{
|
{
|
||||||
if (mode==PARSE_DRAW_PREPARE) s.addn(bufpointer+pos, len_str);
|
if (mode==PARSE_DRAW_PREPARE)
|
||||||
|
{
|
||||||
|
s.addn(bufpointer+pos, len_str);
|
||||||
|
}
|
||||||
pos += len_str+1;
|
pos += len_str+1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mode==PARSE_DRAW_PREPARE) s.addn(bufpointer+pos, rows.column_max);
|
if (mode==PARSE_DRAW_PREPARE)
|
||||||
|
{
|
||||||
|
s.addn(bufpointer+pos, rows.column_max);
|
||||||
|
}
|
||||||
pos += rows.column_max;
|
pos += rows.column_max;
|
||||||
}
|
}
|
||||||
sub_pos++;
|
sub_pos++;
|
||||||
if (mode==PARSE_CALCULATE_ROWS_COUNT) if (do_eof) break;
|
if (mode==PARSE_CALCULATE_ROWS_COUNT) && (do_eof)
|
||||||
if (mode==PARSE_DRAW_PREPARE) if (pos>=bufsize-1) break;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mode==PARSE_DRAW_PREPARE) && (pos>=bufsize-1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
len_str = 0;
|
len_str = 0;
|
||||||
}
|
}
|
||||||
if (mode == PARSE_CALCULATE_ROWS_COUNT)
|
if (mode == PARSE_CALCULATE_ROWS_COUNT)
|
||||||
@ -295,17 +342,29 @@ void DrawText()
|
|||||||
{
|
{
|
||||||
int i=0, top;
|
int i=0, top;
|
||||||
|
|
||||||
if (rows.count<rows.visible) top = rows.count;
|
if (rows.count<rows.visible)
|
||||||
|
{
|
||||||
|
top = rows.count;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rows.count-rows.first<=rows.visible) top = rows.count-rows.first-1;
|
if (rows.count-rows.first<=rows.visible)
|
||||||
else top = rows.visible;
|
{
|
||||||
|
top = rows.count-rows.first-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
top = rows.visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufpointer) for (i=0; i<top; i++)
|
if (bufpointer)
|
||||||
{
|
{
|
||||||
DrawBar(0, i*rows.item_h+TOPPANELH, rows.w, rows.item_h, 0xFFFFFF);
|
for (i=0; i<top; i++)
|
||||||
WriteText(2, i*rows.item_h+TOPPANELH, 0x90, 0x000000, s.get(i+rows.first));
|
{
|
||||||
|
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);
|
DrawBar(0, i*rows.item_h+rows.y, rows.w, -i*rows.item_h + rows.h, 0xFFFfff);
|
||||||
DrawVerticalScroll();
|
DrawVerticalScroll();
|
||||||
@ -334,19 +393,41 @@ void EventMenuClick()
|
|||||||
switch(menu.list.cur_y)
|
switch(menu.list.cur_y)
|
||||||
{
|
{
|
||||||
//File
|
//File
|
||||||
case FILE_SUBMENU_ID_OPEN: EventOpenFile(); break;
|
case FILE_SUBMENU_ID_OPEN:
|
||||||
case FILE_SUBMENU_ID_CLOSE: EventCloseFile(); break;
|
EventOpenFile();
|
||||||
case FILE_SUBMENU_ID_PROPERTIES: EventShowFileProperties(); break;
|
break;
|
||||||
case FILE_SUBMENU_ID_EXIT: ExitProcess(); break;
|
case FILE_SUBMENU_ID_CLOSE:
|
||||||
|
EventCloseFile();
|
||||||
|
break;
|
||||||
|
case FILE_SUBMENU_ID_PROPERTIES:
|
||||||
|
EventShowFileProperties();
|
||||||
|
break;
|
||||||
|
case FILE_SUBMENU_ID_EXIT:
|
||||||
|
ExitProcess();
|
||||||
|
break;
|
||||||
//Encoding
|
//Encoding
|
||||||
case MENU_ID_ENCODING...MENU_ID_ENCODING+9: EventChangeEncoding(menu.list.cur_y-MENU_ID_ENCODING); break;
|
case MENU_ID_ENCODING...MENU_ID_ENCODING+9:
|
||||||
|
EventChangeEncoding(menu.list.cur_y-MENU_ID_ENCODING);
|
||||||
|
break;
|
||||||
//Reopen
|
//Reopen
|
||||||
case FILE_SUBMENU_ID_TINYPAD: EventOpenFileInAnotherProgram("/sys/tinypad"); break;
|
case FILE_SUBMENU_ID_TINYPAD:
|
||||||
case FILE_SUBMENU_ID_TEXTEDIT: EventOpenFileInAnotherProgram("/sys/develop/t_edit"); break;
|
EventOpenFileInAnotherProgram("/sys/tinypad");
|
||||||
case FILE_SUBMENU_ID_TEXTREAD: EventOpenFileInAnotherProgram("/sys/txtread"); break;
|
break;
|
||||||
case FILE_SUBMENU_ID_WEBVIEW: EventOpenFileInAnotherProgram("/sys/network/webview"); break;
|
case FILE_SUBMENU_ID_TEXTEDIT:
|
||||||
case FILE_SUBMENU_ID_FB2READ: EventOpenFileInAnotherProgram("/sys/fb2read"); break;
|
EventOpenFileInAnotherProgram("/sys/develop/t_edit");
|
||||||
case FILE_SUBMENU_ID_HEXVIEW: EventOpenFileInAnotherProgram("/sys/develop/heed"); break;
|
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;
|
||||||
}
|
}
|
||||||
menu.list.cur_y = 0;
|
menu.list.cur_y = 0;
|
||||||
}
|
}
|
||||||
@ -354,38 +435,39 @@ void EventMenuClick()
|
|||||||
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected)
|
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected)
|
||||||
{
|
{
|
||||||
menu.selected = _selected;
|
menu.selected = _selected;
|
||||||
menu.show(
|
menu.show(Form.left+5 + _menu_item_x, Form.top+skin_height + TOPPANELH, 140, _menu_list, _id);
|
||||||
Form.left+5 + _menu_item_x,
|
|
||||||
Form.top+skin_height + TOPPANELH,
|
|
||||||
140,
|
|
||||||
_menu_list,
|
|
||||||
_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventOpenFile()
|
void EventOpenFile()
|
||||||
{
|
{
|
||||||
OpenDialog_start stdcall (#o_dialog);
|
OpenDialog_start stdcall (#o_dialog);
|
||||||
if (!o_dialog.status) return;
|
if (o_dialog.status)
|
||||||
OpenFile(#openfile_path);
|
{
|
||||||
Prepare();
|
OpenFile(#openfile_path);
|
||||||
draw_window();
|
Prepare();
|
||||||
|
draw_window();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventCloseFile()
|
void EventCloseFile()
|
||||||
{
|
{
|
||||||
if (!bufpointer) return;
|
if (bufpointer)
|
||||||
s.drop();
|
{
|
||||||
bufpointer = mem_Free(bufpointer);
|
s.drop();
|
||||||
strcpy(#win_title, TITLE);
|
bufpointer = mem_Free(bufpointer);
|
||||||
draw_window();
|
strcpy(#win_title, TITLE);
|
||||||
|
draw_window();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventShowFileProperties()
|
void EventShowFileProperties()
|
||||||
{
|
{
|
||||||
char ss_param[4096];
|
char ss_param[4096];
|
||||||
if (!bufpointer) return;
|
if (bufpointer)
|
||||||
sprintf(#ss_param, "-p %s", #param);
|
{
|
||||||
RunProgram("/sys/File managers/Eolite", #ss_param);
|
sprintf(#ss_param, "-p %s", #param);
|
||||||
|
RunProgram("/sys/File managers/Eolite", #ss_param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventChangeEncoding(dword id)
|
void EventChangeEncoding(dword id)
|
||||||
@ -403,4 +485,4 @@ void EventOpenFileInAnotherProgram(dword _app)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
@del lang.h--
|
|
||||||
@echo #define LANG_ENG 1 >lang.h--
|
@echo #define LANG_ENG 1 >lang.h--
|
||||||
|
|
||||||
@del Calypte
|
@del Calypte
|
||||||
@ -7,4 +6,4 @@ c-- Calypte.c
|
|||||||
@rename Calypte.com Calypte
|
@rename Calypte.com Calypte
|
||||||
@del warning.txt
|
@del warning.txt
|
||||||
@del lang.h--
|
@del lang.h--
|
||||||
@pause
|
@pause
|
||||||
|
Loading…
Reference in New Issue
Block a user