forked from KolibriOS/kolibrios
life2: use open dialog, big font in caption
git-svn-id: svn://kolibrios.org@8252 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2e992f24ea
commit
fe0f60a15e
Binary file not shown.
@ -8,7 +8,7 @@
|
||||
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
|
||||
{
|
||||
const char *DebugPrefix = "User program: ";
|
||||
char CommandLine[257];
|
||||
char CommandLine[2048];
|
||||
|
||||
struct TWindowData // Data for drawing a window.
|
||||
{
|
||||
@ -510,31 +510,6 @@ namespace Kolibri
|
||||
}
|
||||
}
|
||||
|
||||
#else // def __KOLIBRI__
|
||||
|
||||
namespace Kolibri
|
||||
{
|
||||
struct TMutex
|
||||
{
|
||||
unsigned int mut;
|
||||
|
||||
TMutex();
|
||||
~TMutex();
|
||||
};
|
||||
#undef KOLIBRI_MUTEX_INIT
|
||||
#define KOLIBRI_MUTEX_INIT TMutex()
|
||||
|
||||
struct TRecMutex
|
||||
{
|
||||
unsigned int mut;
|
||||
|
||||
TRecMutex();
|
||||
~TRecMutex();
|
||||
};
|
||||
#undef KOLIBRI_REC_MUTEX_INIT
|
||||
#define KOLIBRI_REC_MUTEX_INIT TRecMutex()
|
||||
}
|
||||
|
||||
#endif // else: def __KOLIBRI__
|
||||
|
||||
#endif // ndef __KOLIBRI_H_INCLUDED_
|
||||
|
@ -84,9 +84,6 @@ proc @Kolibri@Main$qv
|
||||
cmp esp,eax
|
||||
cmova esp,eax
|
||||
and esp,not 3
|
||||
if defined @Kolibri@CommandLine
|
||||
mov byte [@Kolibri@CommandLine+256], 0
|
||||
end if
|
||||
xor eax,eax
|
||||
cld
|
||||
mov edi,@Kolibri@_ThreadTable
|
||||
@ -389,8 +386,9 @@ proc @Kolibri@Redraw$qippv
|
||||
dec esi
|
||||
jz .window_defined
|
||||
mov eax,SF_DRAW_TEXT
|
||||
mov ebx,0x00070007
|
||||
mov ebx,0x00070005
|
||||
mov ecx,[ebp+KOLIBRI_THREAD_DATA_C_TITLE*4]
|
||||
or ecx,1 shl 28 ;make big font
|
||||
int 0x40
|
||||
.window_defined:
|
||||
.redraw_picture:
|
||||
|
@ -4,12 +4,24 @@ org 0
|
||||
dd 1
|
||||
dd @Kolibri@Main$qv
|
||||
dd I_END
|
||||
dd U_END+STACKSIZE+HEAPSIZE
|
||||
dd U_END+STACKSIZE ;+HEAPSIZE
|
||||
dd U_END+STACKSIZE
|
||||
dd @Kolibri@CommandLine,0
|
||||
if defined @Kolibri@CommandLine
|
||||
dd @Kolibri@CommandLine
|
||||
else
|
||||
dd 0
|
||||
end if
|
||||
if defined @Kolibri@CurrentDirectoryPath
|
||||
dd @Kolibri@CurrentDirectoryPath
|
||||
else
|
||||
dd 0
|
||||
end if
|
||||
|
||||
include "..\..\KOSfuncs.inc"
|
||||
include "..\..\proc32.inc"
|
||||
include "..\..\macros.inc"
|
||||
include "..\..\dll.inc"
|
||||
include "..\..\load_lib.mac"
|
||||
|
||||
ptr equ
|
||||
offset equ
|
||||
|
62
programs/demos/life2/include/l_proc_lib.h
Normal file
62
programs/demos/life2/include/l_proc_lib.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef __L_PROC_LIB_H_INCLUDED_
|
||||
#define __L_PROC_LIB_H_INCLUDED_
|
||||
//
|
||||
// proc_lib.obj
|
||||
//
|
||||
|
||||
struct od_filter
|
||||
{
|
||||
long size; //size = len(#ext) + sizeof(long)
|
||||
char ext[25];
|
||||
};
|
||||
|
||||
struct OpenDialog_data{
|
||||
long type;
|
||||
void* procinfo; //
|
||||
char* com_area_name;
|
||||
void* com_area; //
|
||||
char* opendir_path;
|
||||
char* dir_default_path;
|
||||
char* start_path;
|
||||
void (__stdcall* draw_window)();
|
||||
long status;
|
||||
char* openfile_path;
|
||||
char* filename_area;
|
||||
od_filter* filter_area;
|
||||
short int x_size; // Window X size
|
||||
short int x_start; // Window X position
|
||||
short int y_size; // Window y size
|
||||
short int y_start; // Window Y position
|
||||
};
|
||||
|
||||
struct ColorDialog_data{
|
||||
long type;
|
||||
void* procinfo; //
|
||||
char* com_area_name;
|
||||
void* com_area; //
|
||||
char* start_path;
|
||||
void (__stdcall* draw_window)();
|
||||
long status;
|
||||
short int x_size; // Window X size
|
||||
short int x_start; // Window X position
|
||||
short int y_size; // Window y size
|
||||
short int y_start; // Window Y position
|
||||
long color_type; // 0- RGB, 1 or other - reserved
|
||||
long color; // Selected color
|
||||
};
|
||||
|
||||
//
|
||||
// proc_lib - import table
|
||||
//
|
||||
void (__stdcall* import_proc_lib)() = (void (__stdcall*)())&"lib_init";
|
||||
void (__stdcall* OpenDialog_Init)(OpenDialog_data* odd) = (void (__stdcall*)(OpenDialog_data*))&"OpenDialog_init";
|
||||
void (__stdcall* OpenDialog_Start)(OpenDialog_data* odd) = (void (__stdcall*)(OpenDialog_data*))&"OpenDialog_start";
|
||||
void (__stdcall* OpenDialog_SetFileName)(OpenDialog_data* odd, char* name) = (void (__stdcall*)(OpenDialog_data*, char*))&"OpenDialog_set_file_name";
|
||||
void (__stdcall* OpenDialog_SetFileExt)(OpenDialog_data* odd, char* ext) = (void (__stdcall*)(OpenDialog_data*, char*))&"OpenDialog_set_file_ext";
|
||||
void (__stdcall* ColorDialog_Init)(ColorDialog_data* cdd) = (void (__stdcall*)(ColorDialog_data*))&"ColorDialog_init";
|
||||
void (__stdcall* ColorDialog_Start)(ColorDialog_data* cdd) = (void (__stdcall*)(ColorDialog_data*))&"ColorDialog_start";
|
||||
asm{
|
||||
dd 0,0
|
||||
}
|
||||
|
||||
#endif
|
18
programs/demos/life2/include/load_lib.h
Normal file
18
programs/demos/life2/include/load_lib.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __LOAD_LIB_H_LINCLUDED_
|
||||
#define __LOAD_LIB_H_INCLUDED_
|
||||
|
||||
// macros '@use_library' and 'load_library' defined in file 'load_lib.mac'
|
||||
|
||||
asm{
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
}
|
||||
|
||||
bool LoadLibrary(const char* lib_name, char* lib_path, const char* system_path, void* myimport)
|
||||
{
|
||||
asm{
|
||||
load_library [ebp+8], [ebp+12], [ebp+16], [ebp+20]
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,100 +0,0 @@
|
||||
#ifndef __KOLIBRI_FILE_OPEN_H_INCLUDED_
|
||||
#define __KOLIBRI_FILE_OPEN_H_INCLUDED_
|
||||
|
||||
#include <kolibri.h>
|
||||
|
||||
// Kolibri interface.
|
||||
|
||||
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
|
||||
{
|
||||
struct TOpenFileStruct; // Data for a file open dialog.
|
||||
#define KOLIBRI_OPEN_FILE_INIT {} // Initializer of the file open struct, cat be redefined in a realization of the library
|
||||
|
||||
void OpenFileInit(TOpenFileStruct &ofs);
|
||||
void OpenFileDelete(TOpenFileStruct &ofs);
|
||||
bool OpenFileDialog(TOpenFileStruct &ofs);
|
||||
int OpenFileGetState(const TOpenFileStruct &ofs);
|
||||
bool OpenFileSetState(TOpenFileStruct &ofs, int state);
|
||||
char *OpenFileGetName(const TOpenFileStruct &ofs);
|
||||
bool OpenFileSetName(TOpenFileStruct &ofs, char *name);
|
||||
}
|
||||
|
||||
#ifdef __KOLIBRI__
|
||||
|
||||
namespace Kolibri
|
||||
{
|
||||
// Structures.
|
||||
|
||||
struct TOpenFileStruct
|
||||
{
|
||||
int state;
|
||||
char *name;
|
||||
};
|
||||
#undef KOLIBRI_OPEN_FILE_INIT
|
||||
#define KOLIBRI_OPEN_FILE_INIT {0,0}
|
||||
|
||||
// Inline functions.
|
||||
|
||||
inline void OpenFileInit(TOpenFileStruct &ofs)
|
||||
{
|
||||
ofs.state = 0;
|
||||
ofs.name = 0;
|
||||
}
|
||||
|
||||
inline void OpenFileDelete(TOpenFileStruct &ofs)
|
||||
{
|
||||
if (ofs.name) {Free(ofs.name); ofs.name = 0;}
|
||||
}
|
||||
|
||||
inline int OpenFileGetState(const TOpenFileStruct &ofs)
|
||||
{
|
||||
return ofs.state;
|
||||
}
|
||||
|
||||
inline char *OpenFileGetName(const TOpenFileStruct &ofs)
|
||||
{
|
||||
return ofs.name;
|
||||
}
|
||||
|
||||
// Functions.
|
||||
|
||||
bool OpenFileSetState(TOpenFileStruct &ofs, int state)
|
||||
{
|
||||
if (!ofs.state) return !state;
|
||||
if (ofs.state == state) return true;
|
||||
if (state < 0) return false;
|
||||
ofs.state = state;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenFileSetName(TOpenFileStruct &ofs, char *name)
|
||||
{
|
||||
if (!ofs.name && !name) return true;
|
||||
if (ofs.name) Free(ofs.name);
|
||||
if (!name) {ofs.name = 0; return true;}
|
||||
ofs.name = (char*)Alloc(StrLen(name) + 1);
|
||||
if (!ofs.name) return false;
|
||||
StrCopy(ofs.name, name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#else // else: def __KOLIBRI__
|
||||
|
||||
namespace Kolibri
|
||||
{
|
||||
struct TOpenFileStruct
|
||||
{
|
||||
unsigned int data;
|
||||
|
||||
TOpenFileStruct();
|
||||
~TOpenFileStruct();
|
||||
};
|
||||
#undef KOLIBRI_OPEN_FILE_INIT
|
||||
#define KOLIBRI_OPEN_FILE_INIT TOpenFileStruct()
|
||||
}
|
||||
|
||||
#endif // __KOLIBRI__
|
||||
|
||||
#endif // __KOLIBRI_FILE_OPEN_H_INCLUDED_
|
||||
|
@ -1,167 +0,0 @@
|
||||
proc @Kolibri@OpenFileDialog$qr23Kolibri@TOpenFileStruct uses ebx esi edi ebp
|
||||
call @Kolibri@GetThreadData$qv
|
||||
mov ebp,eax
|
||||
mov ebx,[esp+20]
|
||||
cmp dword [ebx+4],0
|
||||
jnz .open_file_dlg_str
|
||||
mov esi,7
|
||||
jmp .open_file_dlg_alloc
|
||||
.open_file_dlg_str:
|
||||
cld
|
||||
mov edi,[ebx+4]
|
||||
mov ecx,-1
|
||||
xor al,al
|
||||
repnz scas byte [edi]
|
||||
not ecx
|
||||
mov esi,ecx
|
||||
.open_file_dlg_alloc:
|
||||
push esi
|
||||
call @Kolibri@Alloc$qul
|
||||
pop ecx
|
||||
test eax,eax
|
||||
jz .open_file_dlg_ret
|
||||
mov ecx,esi
|
||||
dec ecx
|
||||
push esi
|
||||
push ecx
|
||||
push eax
|
||||
mov dword [ebx],-1
|
||||
cmp dword [ebx+4],0
|
||||
jnz .open_file_dlg_copy
|
||||
mov dword [eax],0x2F64722F
|
||||
mov word [eax+4],0x2F31
|
||||
jmp .open_file_dlg_redraw
|
||||
.open_file_dlg_copy:
|
||||
cld
|
||||
mov ecx,esi
|
||||
mov esi,[ebx+4]
|
||||
mov edi,eax
|
||||
rep movs byte [edi],[esi]
|
||||
.open_file_dlg_redraw:
|
||||
mov eax,12
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
xor eax,eax
|
||||
mov ebx,[ebp+KOLIBRI_THREAD_DATA_X*4]
|
||||
mov ecx,[ebp+KOLIBRI_THREAD_DATA_Y*4]
|
||||
mov edx,[ebp+KOLIBRI_THREAD_DATA_C_WINDOW*4]
|
||||
mov esi,[ebp+KOLIBRI_THREAD_DATA_C_HEADER*4]
|
||||
mov edi,[ebp+KOLIBRI_THREAD_DATA_C_BORDER*4]
|
||||
int 0x40
|
||||
mov eax,4
|
||||
mov ebx,0x00070007
|
||||
mov ecx,[ebp+KOLIBRI_THREAD_DATA_C_TITLE*4]
|
||||
mov edx,Kolibri_open_file_dlg_name
|
||||
mov esi,Kolibri_open_file_dlg_name_end - Kolibri_open_file_dlg_name
|
||||
int 0x40
|
||||
mov eax,4
|
||||
mov ebx,0x000C001E
|
||||
xor ecx,ecx
|
||||
mov edx,[esp]
|
||||
mov esi,[esp+4]
|
||||
int 0x40
|
||||
mov eax,12
|
||||
mov ebx,2
|
||||
int 0x40
|
||||
.open_file_dlg_loop:
|
||||
mov eax,10
|
||||
int 0x40
|
||||
dec eax
|
||||
jz .open_file_dlg_redraw
|
||||
dec eax
|
||||
jz .open_file_dlg_key
|
||||
dec eax
|
||||
jz .open_file_dlg_end
|
||||
jmp .open_file_dlg_loop
|
||||
.open_file_dlg_key:
|
||||
xor edi,edi
|
||||
.open_file_dlg_key_loop:
|
||||
mov eax,2
|
||||
int 0x40
|
||||
test al,al
|
||||
jnz .open_file_dlg_key_end
|
||||
cmp ah,27
|
||||
jz .open_file_dlg_end
|
||||
cmp ah,13
|
||||
jz .open_file_dlg_apply
|
||||
cmp ah,8
|
||||
jz .open_file_dlg_key_bsp
|
||||
cmp ah,32
|
||||
jna .open_file_dlg_key_loop
|
||||
mov ebx,[esp+4]
|
||||
cmp ebx,[esp+8]
|
||||
jb .open_file_dlg_key_any
|
||||
lea esi,[ebx+2*ebx]
|
||||
shr esi,1
|
||||
inc esi
|
||||
push eax
|
||||
push esi
|
||||
push dword [esp+8]
|
||||
call @Kolibri@ReAlloc$qpvul
|
||||
add esp,8
|
||||
mov ecx,eax
|
||||
pop eax
|
||||
test ecx,ecx
|
||||
jz .open_file_dlg_key
|
||||
mov [esp+8],esi
|
||||
mov [esp],ecx
|
||||
.open_file_dlg_key_any:
|
||||
mov esi,ebx
|
||||
add esi,[esp]
|
||||
mov byte [esi],ah
|
||||
inc ebx
|
||||
mov edi,1
|
||||
mov [esp+4],ebx
|
||||
jmp .open_file_dlg_key_loop
|
||||
.open_file_dlg_key_bsp:
|
||||
mov eax,[esp+4]
|
||||
test eax,eax
|
||||
jz .open_file_dlg_key_loop
|
||||
dec eax
|
||||
mov edi,1
|
||||
mov [esp+4],eax
|
||||
jmp .open_file_dlg_key_loop
|
||||
.open_file_dlg_key_end:
|
||||
test edi,edi
|
||||
jnz .open_file_dlg_redraw
|
||||
jmp .open_file_dlg_loop
|
||||
.open_file_dlg_apply:
|
||||
mov eax,[esp+4]
|
||||
inc eax
|
||||
mov [esp+8],eax
|
||||
push eax
|
||||
push dword [esp+4]
|
||||
call @Kolibri@ReAlloc$qpvul
|
||||
add esp,8
|
||||
test eax,eax
|
||||
jz .open_file_dlg_end
|
||||
mov eax,[esp]
|
||||
mov esi,eax
|
||||
add eax,[esp+4]
|
||||
mov byte [eax],0
|
||||
add esp,12
|
||||
mov ebx,[esp+20]
|
||||
mov dword [ebx],2
|
||||
push dword [ebx+4]
|
||||
call @Kolibri@Free$qpv
|
||||
pop ecx
|
||||
mov [ebx+4],esi
|
||||
jmp .open_file_dlg_invalidate
|
||||
.open_file_dlg_end:
|
||||
call @Kolibri@Free$qpv
|
||||
add esp,12
|
||||
mov ebx,[esp+20]
|
||||
mov dword [ebx],1
|
||||
.open_file_dlg_invalidate:
|
||||
push ebp
|
||||
push dword 1
|
||||
call @@Kolibri@Invalidate$qippv
|
||||
add esp,8
|
||||
.open_file_dlg_ret:
|
||||
ret
|
||||
endp
|
||||
|
||||
Kolibri_open_file_dlg_name:
|
||||
db 'Open file'
|
||||
Kolibri_open_file_dlg_name_end:
|
||||
|
@ -1,115 +0,0 @@
|
||||
#include <commdlg.h>
|
||||
|
||||
#include <kolibri.h>
|
||||
#include <kos_heap.h>
|
||||
#include "kos_cdlg.h"
|
||||
|
||||
using namespace Kolibri;
|
||||
|
||||
extern HINSTANCE hInstance;
|
||||
|
||||
struct TThreadDataStruct
|
||||
{
|
||||
void *user;
|
||||
void *stack_begin;
|
||||
TWindowData *win_data;
|
||||
HWND hwnd;
|
||||
int flag;
|
||||
unsigned int win_time, me_time;
|
||||
void *picture;
|
||||
unsigned int picture_width, picture_height;
|
||||
void *keys;
|
||||
unsigned int bmp_data_length;
|
||||
unsigned int *bmp_data;
|
||||
unsigned int mouse_state;
|
||||
};
|
||||
|
||||
struct TOpenFileData
|
||||
{
|
||||
int state;
|
||||
char name[1];
|
||||
};
|
||||
|
||||
namespace Kolibri
|
||||
{
|
||||
TOpenFileStruct::TOpenFileStruct() : data(0) {}
|
||||
|
||||
TOpenFileStruct::~TOpenFileStruct()
|
||||
{
|
||||
if (data) {delete[] (char*)data; data = 0;}
|
||||
}
|
||||
|
||||
void OpenFileInit(TOpenFileStruct &ofs) {ofs.data = 0;}
|
||||
|
||||
void OpenFileDelete(TOpenFileStruct &ofs)
|
||||
{
|
||||
if (ofs.data) {delete[] (char*)ofs.data; ofs.data = 0;}
|
||||
}
|
||||
|
||||
bool OpenFileDialog(TOpenFileStruct &ofs)
|
||||
{
|
||||
char CustomFilter[300], *name;
|
||||
int size;
|
||||
CustomFilter[0] = 0; CustomFilter[1] = 0;
|
||||
if (!OpenFileSetState(ofs, 0)) return false;
|
||||
OPENFILENAME ofn = {sizeof(OPENFILENAME), ((TThreadDataStruct*)GetThreadData())->hwnd,
|
||||
hInstance, "All files (*.*)\0*.*\0",
|
||||
CustomFilter, sizeof(CustomFilter)-1, 1, NULL, 0, NULL, 0, NULL, NULL,
|
||||
OFN_HIDEREADONLY | OFN_EXPLORER, 0, 0, "", 0, NULL, 0};
|
||||
size = 0;
|
||||
if (ofs.data) size = strlen(((TOpenFileData*)ofs.data)->name) + 1;
|
||||
if (size < 10000) size = 10000;
|
||||
name = new char[size + 1];
|
||||
if (!name) return false;
|
||||
if (ofs.data) strcpy(name, ((TOpenFileData*)ofs.data)->name);
|
||||
else name[0] = 0;
|
||||
ofn.lpstrFile = &name[0]; ofn.nMaxFile = size;
|
||||
size = GetOpenFileName(&ofn) == TRUE;
|
||||
if (OpenFileSetName(ofs, name))
|
||||
{
|
||||
((TOpenFileData*)ofs.data)->state = (size ? 2 : 1);
|
||||
}
|
||||
else size = 0;
|
||||
delete[] name;
|
||||
return (bool)size;
|
||||
}
|
||||
|
||||
int OpenFileGetState(const TOpenFileStruct &ofs)
|
||||
{
|
||||
return ofs.data ? ((TOpenFileData*)ofs.data)->state : 0;
|
||||
}
|
||||
|
||||
bool OpenFileSetState(TOpenFileStruct &ofs, int state)
|
||||
{
|
||||
if (!ofs.data || !((TOpenFileData*)ofs.data)->state) return !state;
|
||||
if (((TOpenFileData*)ofs.data)->state == state) return true;
|
||||
if (state < 0) return false;
|
||||
((TOpenFileData*)ofs.data)->state = state;
|
||||
return true;
|
||||
}
|
||||
|
||||
char *OpenFileGetName(const TOpenFileStruct &ofs)
|
||||
{
|
||||
if (!ofs.data) return 0;
|
||||
else return ((TOpenFileData*)ofs.data)->name;
|
||||
}
|
||||
|
||||
bool OpenFileSetName(TOpenFileStruct &ofs, char *name)
|
||||
{
|
||||
if (!ofs.data && !name) return true;
|
||||
int size = (unsigned int)(((TOpenFileData*)0)->name) + 1;
|
||||
int state = 0;
|
||||
if (name) size += strlen(name);
|
||||
if (ofs.data)
|
||||
{
|
||||
state = ((TOpenFileData*)ofs.data)->state;
|
||||
delete[] (char*)ofs.data;
|
||||
}
|
||||
ofs.data = (unsigned int)(new char[size]);
|
||||
if (!ofs.data) return false;
|
||||
((TOpenFileData*)ofs.data)->state = state;
|
||||
if (name) strcpy(((TOpenFileData*)ofs.data)->name, name);
|
||||
else ((TOpenFileData*)ofs.data)->name[0] = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,12 +2,11 @@
|
||||
;//COMPILER// bcc32 -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -Iinclude
|
||||
;//UTIL_PATH// .
|
||||
|
||||
STACKSIZE equ 102400
|
||||
HEAPSIZE equ 102400
|
||||
STACKSIZE equ 8196
|
||||
HEAPSIZE equ 0
|
||||
|
||||
include "include\kos_start.inc"
|
||||
include "include\kos_func.inc"
|
||||
include "include\kos_heap.inc"
|
||||
include "kos_cdlg.inc"
|
||||
include "mmxlife.inc"
|
||||
;include "sse2life.inc"
|
||||
|
@ -1,42 +1,36 @@
|
||||
#include <kolibri.h>
|
||||
#include <kos_heap.h>
|
||||
#include <kos_file.h>
|
||||
#include <load_lib.h>
|
||||
#include <l_proc_lib.h>
|
||||
#include "lifegen.h"
|
||||
#include "life_bmp.h"
|
||||
#include "kos_cdlg.h"
|
||||
|
||||
using namespace Kolibri;
|
||||
|
||||
/***
|
||||
#define StrLen LibbStrLen
|
||||
#define StrCopy LibbStrCopy
|
||||
#define MemCopy LibbMemCopy
|
||||
#define MemSet LibbMemSet
|
||||
#define Floor LibbFloor
|
||||
char library_path[2048];
|
||||
|
||||
unsigned int (*StrLen)(const char *str) = 0;
|
||||
char *(*StrCopy)(char *dest, const char *src) = 0;
|
||||
void *(*MemCopy)(void *dest, const void *src, unsigned int n) = 0;
|
||||
void *(*MemSet)(void *s, char c, unsigned int n) = 0;
|
||||
double (*Floor)(double x) = 0;
|
||||
OpenDialog_data ofd;
|
||||
unsigned char procinfo[1024];
|
||||
char plugin_path[4096], filename_area[256];
|
||||
od_filter filter1 = { 8, "LIF\0\0" };
|
||||
|
||||
void LibbInit()
|
||||
{
|
||||
HINSTANCE hLib = LoadLibrary("Libb.dll");
|
||||
if (!hLib)
|
||||
{
|
||||
DebugPutString("Can't load the library.\n");
|
||||
Kolibri::Abort();
|
||||
}
|
||||
StrLen = (unsigned int(*)(const char *str))GetProcAddress(hLib, "StrLen");
|
||||
StrCopy = (char *(*)(char *dest, const char *src))GetProcAddress(hLib, "StrCopy");
|
||||
MemCopy = (void *(*)(void *dest, const void *src, unsigned int n))GetProcAddress(hLib, "MemCopy");
|
||||
MemSet = (void *(*)(void *s, char c, unsigned int n))GetProcAddress(hLib, "MemSet");
|
||||
Floor = (double (*)(double x))GetProcAddress(hLib, "Floor");
|
||||
namespace Kolibri{
|
||||
char CurrentDirectoryPath[2048];
|
||||
}
|
||||
|
||||
#pragma startup LibbInit
|
||||
/**/
|
||||
void __stdcall DrawWindow()
|
||||
{
|
||||
asm{
|
||||
push ebx
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
}
|
||||
//KolibriOnPaint();
|
||||
asm{
|
||||
mcall SF_REDRAW,SSF_END_DRAW
|
||||
pop ebx
|
||||
}
|
||||
}
|
||||
|
||||
void __stdcall OneGeneration(int w, int h, void *dest, const void *src, int flag);
|
||||
|
||||
@ -107,7 +101,7 @@ AxisParam xpar = {0, 0, 0};
|
||||
AxisParam ypar = {0, 0, 0};
|
||||
MouseParam mpar = {0, 0, 0, 0, 0, MouseParam::HitNull};
|
||||
MenuParam menu;
|
||||
TOpenFileStruct open_file_str = KOLIBRI_OPEN_FILE_INIT;
|
||||
bool open_file_str = false;
|
||||
TimeGeneration timegen[TimeGenLength];
|
||||
int timegenpos = 0;
|
||||
|
||||
@ -1356,11 +1350,9 @@ void LifeScreenPutPicture(const unsigned char *pict, int size, TThreadData th)
|
||||
|
||||
void MenuOpenDialogEnd(TThreadData th)
|
||||
{
|
||||
int state = OpenFileGetState(open_file_str);
|
||||
if (state <= 0) return;
|
||||
OpenFileSetState(open_file_str, 0);
|
||||
if (state != 2) return;
|
||||
char *name = OpenFileGetName(open_file_str);
|
||||
if(!ofd.openfile_path[0] || !open_file_str) return;
|
||||
open_file_str = false;
|
||||
char *name = ofd.openfile_path;
|
||||
if (!name) return;
|
||||
FileInfoBlock* file = FileOpen(name);
|
||||
if (!file) return;
|
||||
@ -1467,8 +1459,9 @@ void MenuMouseClick(int x, int y, int m, TThreadData th)
|
||||
MenuClearClick(th);
|
||||
break;
|
||||
case MenuIOpen:
|
||||
if (OpenFileGetState(open_file_str) < 0) break;
|
||||
OpenFileDialog(open_file_str);
|
||||
ofd.type = 0; // 0 - open
|
||||
OpenDialog_Start(&ofd);
|
||||
if(ofd.status==1) open_file_str = true;
|
||||
break;
|
||||
case MenuIAbout:
|
||||
MenuAboutClick(th);
|
||||
@ -1706,11 +1699,26 @@ bool KolibriOnStart(TStartData &me_start, TThreadData th)
|
||||
me_start.Width = 500; me_start.Height = 400;
|
||||
InitGenerate();
|
||||
InitMenuButton();
|
||||
if (CommandLine[0])
|
||||
if(LoadLibrary("proc_lib.obj", library_path, "/sys/lib/proc_lib.obj", &import_proc_lib))
|
||||
{
|
||||
open_file_str.state = 2;
|
||||
OpenFileSetName(open_file_str, CommandLine);
|
||||
}
|
||||
ofd.procinfo = procinfo;
|
||||
ofd.com_area_name = "FFFFFFFF_open_dialog";
|
||||
ofd.com_area = 0;
|
||||
ofd.opendir_path = plugin_path;
|
||||
ofd.dir_default_path = "/rd/1";
|
||||
ofd.start_path = "/rd/1/File managers/opendial";
|
||||
ofd.draw_window = DrawWindow;
|
||||
ofd.status = 0;
|
||||
ofd.openfile_path = CommandLine;
|
||||
ofd.filename_area = filename_area;
|
||||
ofd.filter_area = &filter1;
|
||||
ofd.x_size = 420;
|
||||
ofd.x_start = 10;
|
||||
ofd.y_size = 320;
|
||||
ofd.y_start = 10;
|
||||
OpenDialog_Init(&ofd);
|
||||
} else return false;
|
||||
if (CommandLine[0]) open_file_str = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1725,7 +1733,7 @@ int KolibriOnIdle(TThreadData th)
|
||||
{
|
||||
static const unsigned int WAIT_TIME = 2, GEN_TIME = 1;
|
||||
int res = -1;
|
||||
if (OpenFileGetState(open_file_str) > 0)
|
||||
if (open_file_str)
|
||||
{
|
||||
MenuOpenDialogEnd(th);
|
||||
res = 0;
|
||||
@ -1826,8 +1834,9 @@ void KolibriOnKeyPress(TThreadData th)
|
||||
break;
|
||||
case 'o':
|
||||
case 'O':
|
||||
if (OpenFileGetState(open_file_str) < 0) break;
|
||||
OpenFileDialog(open_file_str);
|
||||
ofd.type = 0; // 0 - open
|
||||
OpenDialog_Start(&ofd);
|
||||
if(ofd.status==1) open_file_str=true;
|
||||
break;
|
||||
case 'a':
|
||||
case 'A':
|
||||
|
@ -7,13 +7,14 @@ include '../../macros.inc'
|
||||
include '../../proc32.inc'
|
||||
include '../../KOSfuncs.inc'
|
||||
include '../../load_img.inc'
|
||||
include '../../load_lib.mac'
|
||||
include '../../develop/libraries/libs-dev/libimg/libimg.inc'
|
||||
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
|
||||
include 'lang.inc'
|
||||
include 'cnc_editor.inc'
|
||||
include '../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
caption db 'CNC editor 23.05.19',0 ;¯®¤¯¨áì ®ª
|
||||
|
||||
run_file_70 FileInfoBlock
|
||||
@ -2096,39 +2097,12 @@ lib_name_2 db 'buf2d.obj',0
|
||||
system_dir_3 db '/sys/lib/'
|
||||
lib_name_3 db 'box_lib.obj',0
|
||||
|
||||
head_f_i:
|
||||
if lang eq ru
|
||||
head_f_l db '"‘¨á⥬ ï ®è¨¡ª ',0
|
||||
err_message_found_lib_0 db '<27>¥ ©¤¥ ¡¨¡«¨®â¥ª ',39,'proc_lib.obj',39,'" -tE',0
|
||||
err_message_import_0 db 'Žè¨¡ª ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,'" -tW',0
|
||||
err_message_found_lib_1 db '<27>¥ ©¤¥ ¡¨¡«¨®â¥ª ',39,'libimg.obj',39,'" -tE',0
|
||||
err_message_import_1 db 'Žè¨¡ª ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,'" -tW',0
|
||||
err_msg_found_lib_2 db '<27>¥ ©¤¥ ¡¨¡«¨®â¥ª ',39,'buf2d.obj',39,'" -tE',0
|
||||
err_msg_import_2 db 'Žè¨¡ª ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,'" -tW',0
|
||||
err_msg_found_lib_3 db '<27>¥ ©¤¥ ¡¨¡«¨®â¥ª ',39,'box_lib.obj',39,'" -tE',0
|
||||
err_msg_import_3 db 'Žè¨¡ª ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,'" -tW',0
|
||||
else
|
||||
head_f_l db '"System error',0
|
||||
err_message_found_lib_0 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,'" -tE',0
|
||||
err_message_import_0 db 'Error on load import library ',39,'proc_lib.obj',39,'" -tW',0
|
||||
err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,'" -tE',0
|
||||
err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,'" -tW',0
|
||||
err_msg_found_lib_2 db 'Sorry I cannot found library ',39,'buf2d.obj',39,'" -tE',0
|
||||
err_msg_import_2 db 'Error on load import library ',39,'buf2d',39,'" -tW',0
|
||||
err_msg_found_lib_3 db 'Sorry I cannot found library ',39,'box_lib.obj',39,'" -tE',0
|
||||
err_msg_import_3 db 'Error on load import library ',39,'box_lib',39,'" -tW',0
|
||||
end if
|
||||
|
||||
align 4
|
||||
l_libs_start:
|
||||
lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
|
||||
err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
|
||||
lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
|
||||
err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
|
||||
lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
|
||||
err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i
|
||||
lib_3 l_libs lib_name_3, sys_path, file_name, system_dir_3,\
|
||||
err_msg_found_lib_3, head_f_l, import_box_lib,err_msg_import_3,head_f_i
|
||||
lib_0 l_libs lib_name_0, file_name, system_dir_0, import_proclib
|
||||
lib_1 l_libs lib_name_1, file_name, system_dir_1, import_libimg
|
||||
lib_2 l_libs lib_name_2, library_path, system_dir_2, import_buf2d
|
||||
lib_3 l_libs lib_name_3, file_name, system_dir_3, import_box_lib
|
||||
l_libs_end:
|
||||
|
||||
align 4
|
||||
@ -2179,7 +2153,7 @@ import_libimg:
|
||||
aimg_draw db 'img_draw',0
|
||||
|
||||
align 4
|
||||
proclib_import: ;®¯¨á ¨¥ íªá¯®àâ¨à㥬ëå äãªæ¨©
|
||||
import_proclib:
|
||||
OpenDialog_Init dd aOpenDialog_Init
|
||||
OpenDialog_Start dd aOpenDialog_Start
|
||||
OpenDialog_Set_file_name dd aOpenDialog_Set_file_name
|
||||
|
Loading…
Reference in New Issue
Block a user