unpack zips in src to better compression
This commit is contained in:
12
sources/z-tools/trunk/ztask/Makefile
Normal file
12
sources/z-tools/trunk/ztask/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
DEBUG = # -DDEBUG
|
||||
STACKSIZE = 64k
|
||||
OPTIMISATION = -O2 -fomit-frame-pointer
|
||||
CPU = -m68020-60
|
||||
LIB = -lwindom -lgem -lldg -lm #-lwout
|
||||
CFLAGS = $(CPU) $(OPTIMISATION) $(DEBUG) -Wall -Wshadow
|
||||
|
||||
OBJ = debug.o gmem.o prefs.o color_selector.o taskman.o pref_panel.o shutdown.o quit.o app.o process.o cpu.o string.o popup.o win.o main.o
|
||||
|
||||
PROGRAM = ztask.app
|
||||
|
||||
include ../common.mak
|
||||
310
sources/z-tools/trunk/ztask/app.c
Normal file
310
sources/z-tools/trunk/ztask/app.c
Normal file
@@ -0,0 +1,310 @@
|
||||
#include "general.h"
|
||||
#include "gmem.h"
|
||||
#include "string.h"
|
||||
|
||||
app_data *root = NULL, *selected = NULL, *old_selected = NULL;
|
||||
int16 app_nbr = 0;
|
||||
|
||||
|
||||
int16 find_top_app_by_window( void)
|
||||
{
|
||||
int16 win_handle, next_win_handle, aes_id, dum;
|
||||
|
||||
if( mt_wind_get( 0, WF_TOP, &win_handle, &aes_id, &next_win_handle, &dum, app.aes_global) == 0)
|
||||
return -1;
|
||||
|
||||
return aes_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* app_data_attach: *
|
||||
* attach a entry in the global application list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* name: The application name. *
|
||||
* name_shown: The name to be shown in the taskbar. *
|
||||
* id: The AES ID of the application. *
|
||||
* name_shown_width: The text width of 'name_shown' in pixel. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* TRUE if all is ok else FALSE *
|
||||
*==================================================================================*/
|
||||
|
||||
int16 app_data_attach( char *name, char *name_shown, int16 id, int16 pid, int16 name_shown_width)
|
||||
{
|
||||
app_data *new = ( app_data *)gmalloc( sizeof(app_data));
|
||||
|
||||
if( !new)
|
||||
return FALSE;
|
||||
|
||||
new -> id = id;
|
||||
new -> pid = pid;
|
||||
new -> next = root;
|
||||
new -> name_shown_width = name_shown_width;
|
||||
|
||||
strcpy( new -> name, name);
|
||||
strcpy( new -> name_shown, name_shown);
|
||||
|
||||
root = new;
|
||||
|
||||
app_nbr++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* app_data_find_parent: *
|
||||
* find the parent( previous) entry in the application list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* child: the function returns the parent of this entry. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* the parent entry else the root entry. *
|
||||
*==================================================================================*/
|
||||
app_data *app_data_find_parent( app_data *child)
|
||||
{
|
||||
app_data *scan = root;
|
||||
|
||||
while( scan)
|
||||
{
|
||||
if( scan->next != child)
|
||||
{
|
||||
scan = scan->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return( scan);
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* app_data_delete: *
|
||||
* Delete an entry in the application list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* id: the AES id of the entry to delete. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void app_data_delete( int16 id)
|
||||
{
|
||||
app_data *scan = root, *parent;
|
||||
|
||||
while( scan)
|
||||
{
|
||||
if( scan->id != id)
|
||||
{
|
||||
scan = scan->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
parent = app_data_find_parent( scan);
|
||||
|
||||
if( parent == NULL)
|
||||
root = scan->next;
|
||||
else
|
||||
parent->next = scan->next;
|
||||
|
||||
gfree( scan);
|
||||
app_nbr--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* app_data_find: *
|
||||
* Find an entry in the application list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* id: the AES id of the entry to find. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* the entry or NULL if not found. *
|
||||
*==================================================================================*/
|
||||
app_data *app_data_find( int16 id)
|
||||
{
|
||||
app_data *scan = root, *result = NULL;
|
||||
|
||||
while( scan)
|
||||
{
|
||||
if( scan->id != id)
|
||||
{
|
||||
scan = scan->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
result = scan;
|
||||
break;
|
||||
}
|
||||
|
||||
return( result);
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* app_have_wind: *
|
||||
* Check if an application owns at least one window. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* id: the AES id of the entry to check. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* 1 if TRUE else 0. *
|
||||
*==================================================================================*/
|
||||
int16 app_have_wind( int16 id)
|
||||
{
|
||||
int16 result = 0, dum, aes_win, next = -1, status, aes_id;
|
||||
|
||||
if( mt_wind_get( 0, WF_OWNER, &aes_id, &status, &aes_win, &dum, app.aes_global) == 0)
|
||||
return result;
|
||||
|
||||
while( aes_win)
|
||||
{
|
||||
if( mt_wind_get( aes_win, WF_OWNER, &aes_id, &status, &next, &dum, app.aes_global) == 0)
|
||||
break;
|
||||
|
||||
if( ( aes_id != id) || ( status == 0))
|
||||
{
|
||||
aes_win = next;
|
||||
continue;
|
||||
}
|
||||
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* app_data_search: *
|
||||
* Make a list of all the loaded application and add it in the global *
|
||||
* application list if necessary. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* -- *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void app_data_search( void)
|
||||
{
|
||||
char name[9], name_shown[MAXNAMLEN];
|
||||
app_data *scan = root, *tmp = NULL;
|
||||
int16 lenght, i, id, pid, type, count = 0, ap_cout, name_shown_width, old_id_by_win, old_id_by_menu;
|
||||
static int16 id_by_win = 0, id_by_menu = 0;
|
||||
|
||||
for( i = 0; mt_appl_search( i, name, &type, &id, app.aes_global); i = 1)
|
||||
{
|
||||
// Is an accessory?
|
||||
if( show_acc == FALSE && ( type & APP_ACCESSORY))
|
||||
continue;
|
||||
|
||||
// Is a system app or zTask itself?
|
||||
if(( type & APP_SYSTEM) || ( id == _AESapid))
|
||||
continue;
|
||||
|
||||
count++;
|
||||
|
||||
// Is already listed?
|
||||
if( app_data_find( id))
|
||||
continue;
|
||||
|
||||
if( mt_appl_control( id, APC_INFO, &ap_cout, app.aes_global) == 0)
|
||||
{
|
||||
count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if it's not a accessory, if the application doesn't own a menu bar and if it doesn't own a window, we skip this id.
|
||||
if(( type != APP_ACCESSORY) && !( ap_cout & APCI_HASMBAR) && !app_have_wind( id))
|
||||
{
|
||||
count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
// We setup the name to show in the case
|
||||
mt_appl_search( -id, name_shown, &type, &pid, app.aes_global);
|
||||
|
||||
trim_start(name_shown);
|
||||
trim_end( name_shown, strlen( name_shown) - 1);
|
||||
|
||||
if( strcmp( "XaSYS", name_shown) == 0)
|
||||
{
|
||||
count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
lenght = strlen( name_shown);
|
||||
|
||||
if( lenght > 4)
|
||||
{
|
||||
char *extention = name_shown + lenght - 4;
|
||||
|
||||
// If the application's name has an extention ( like "xxx.app"), we remove it
|
||||
if( *extention == '.')
|
||||
*extention = '\0';
|
||||
}
|
||||
|
||||
name_shown_width = get_text_width( name_shown);
|
||||
|
||||
if( name_shown_width > ( app_width - 6))
|
||||
name_shown_width = name_shorter( app_width - 6, name_shown);
|
||||
|
||||
app_data_attach( name, name_shown, id, pid, name_shown_width);
|
||||
}
|
||||
|
||||
if( count != app_nbr)
|
||||
{
|
||||
while( scan)
|
||||
{
|
||||
if( mt_appl_find( scan->name, app.aes_global) == -1)
|
||||
{
|
||||
id = scan->id;
|
||||
scan = scan->next;
|
||||
app_data_delete( id);
|
||||
continue;
|
||||
}
|
||||
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
|
||||
old_id_by_win = id_by_win;
|
||||
old_id_by_menu = id_by_menu;
|
||||
|
||||
id_by_win = find_top_app_by_window();
|
||||
id_by_menu = mt_menu_bar( NULL, MENU_INQUIRE, app.aes_global);
|
||||
|
||||
id = 0;
|
||||
|
||||
if(( old_id_by_win != id_by_win) && ( old_id_by_menu == id_by_menu))
|
||||
id = id_by_win;
|
||||
else if(( old_id_by_win == id_by_win) && ( old_id_by_menu != id_by_menu))
|
||||
id = id_by_menu;
|
||||
else if(( old_id_by_win != id_by_win) && ( old_id_by_menu != id_by_menu))
|
||||
id = id_by_menu;
|
||||
|
||||
if( id)
|
||||
{
|
||||
tmp = app_data_find( id);
|
||||
|
||||
if( tmp != selected)
|
||||
{
|
||||
old_selected = selected;
|
||||
selected = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
sources/z-tools/trunk/ztask/app.h
Normal file
9
sources/z-tools/trunk/ztask/app.h
Normal file
@@ -0,0 +1,9 @@
|
||||
extern app_data *root, *selected, *old_selected;
|
||||
extern int16 app_nbr;
|
||||
|
||||
extern int16 app_data_attach( char *name, int16 id);
|
||||
extern void app_data_delete( int16 id);
|
||||
extern app_data *app_data_find( int16 id);
|
||||
extern void app_data_search( void);
|
||||
|
||||
|
||||
192
sources/z-tools/trunk/ztask/color_selector.c
Normal file
192
sources/z-tools/trunk/ztask/color_selector.c
Normal file
@@ -0,0 +1,192 @@
|
||||
#include "general.h"
|
||||
|
||||
static int16 xw, yw, ww, hw, color_by_line;
|
||||
static int16 selected_color;
|
||||
static int16 object_parent;
|
||||
|
||||
extern WINDOW *pref_dialog_win;
|
||||
extern int tmp_button_off_background, tmp_button_off_light_color, tmp_button_off_dark_color,
|
||||
tmp_button_off_text_color, tmp_button_off_text_shadow_color, tmp_button_on_background,
|
||||
tmp_button_on_light_color, tmp_button_on_dark_color, tmp_button_on_text_color,
|
||||
tmp_button_on_text_shadow_color, tmp_geek_area_color, tmp_geek_area_dark_line,
|
||||
tmp_geek_area_light_line, tmp_app_width, tmp_cpu_bar_color,
|
||||
tmp_tt_bar_color, tmp_st_bar_color, tmp_geek_area_text_color;
|
||||
|
||||
static void CDECL timer_function( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
if( !IS_IN( evnt.mx, evnt.my, xw, yw, ww, hw))
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL win_mouse_event( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
int16 x, y, pxy[2];
|
||||
int color = 0;
|
||||
|
||||
for( y = 0, pxy[1] = yw + 1; y < color_by_line; y++, pxy[1] += 11)
|
||||
{
|
||||
for( x = 0, pxy[0] = xw + 1; x < color_by_line; x++, pxy[0] += 11, color++)
|
||||
{
|
||||
if( IS_IN( evnt.mx, evnt.my, pxy[0], pxy[1], 9, 9))
|
||||
{
|
||||
switch( object_parent)
|
||||
{
|
||||
case PREFS_ON_BACK:
|
||||
tmp_button_on_background = color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_LINE1:
|
||||
tmp_button_on_light_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_LINE2:
|
||||
tmp_button_on_dark_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_TEXT1:
|
||||
tmp_button_on_text_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_TEXT2:
|
||||
tmp_button_on_text_shadow_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_BACK:
|
||||
tmp_button_off_background = color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_LINE1:
|
||||
tmp_button_off_light_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_LINE2:
|
||||
tmp_button_off_dark_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_TEXT1:
|
||||
tmp_button_off_text_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_TEXT2:
|
||||
tmp_button_off_text_shadow_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_BACK:
|
||||
tmp_geek_area_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_LINE1:
|
||||
tmp_geek_area_light_line = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_LINE2:
|
||||
tmp_geek_area_dark_line = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_RAM1:
|
||||
tmp_st_bar_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_RAM2:
|
||||
tmp_tt_bar_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_CPU:
|
||||
tmp_cpu_bar_color = color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_TEXT:
|
||||
tmp_geek_area_text_color = color;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
ObjcDraw( OC_FORM, pref_dialog_win, PREFS_PREVIEW, 1);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL win_redraw_event( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
int16 x, y, pxy[4], xy[10], color = 0;
|
||||
|
||||
pxy[0] = xw;
|
||||
pxy[1] = yw;
|
||||
pxy[2] = pxy[0] + ww - 1;
|
||||
pxy[3] = pxy[1] + hw - 1;
|
||||
|
||||
vsf_color( win->graf->handle, WHITE);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
|
||||
for( y = 0, pxy[1] = yw + 1; y < color_by_line; y++, pxy[1] += 11)
|
||||
{
|
||||
for( x = 0, pxy[0] = xw + 1; x < color_by_line; x++, pxy[0] += 11, color++)
|
||||
{
|
||||
pxy[2] = pxy[0] + 9;
|
||||
pxy[3] = pxy[1] + 9;
|
||||
|
||||
vsf_color( win->graf->handle, color);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
xy[0] = pxy[0];
|
||||
xy[1] = pxy[1];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 9;
|
||||
xy[4] = xy[0] + 9;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = xy[1];
|
||||
xy[8] = xy[0];
|
||||
xy[9] = xy[1];
|
||||
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
|
||||
if( color == selected_color)
|
||||
{
|
||||
xy[0] = pxy[0] - 1;
|
||||
xy[1] = pxy[1] - 1;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 11;
|
||||
xy[4] = xy[0] + 11;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = xy[1];
|
||||
xy[8] = xy[0];
|
||||
xy[9] = xy[1];
|
||||
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vdi_color_selector( int16 x, int16 y, int16 color_selected, int16 parent_object)
|
||||
{
|
||||
WINDOW *win = WindCreate( 0, app.x, app.y, app.w, app.h);
|
||||
|
||||
EvntAttach( win, WM_REDRAW, win_redraw_event);
|
||||
EvntAttach( win, WM_XBUTTON, win_mouse_event);
|
||||
|
||||
color_by_line = (( app.nplanes < 8) ? 4 : 16);
|
||||
selected_color = color_selected;
|
||||
object_parent = parent_object;
|
||||
|
||||
if( app.nplanes == 4)
|
||||
WindCalc( WC_BORDER, win, x, y, 45, 45, &xw, &yw, &ww, &hw);
|
||||
else
|
||||
WindCalc( WC_BORDER, win, x, y, 177, 177, &xw, &yw, &ww, &hw);
|
||||
|
||||
WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0);
|
||||
EvntAttach( win, WM_XTIMER, timer_function);
|
||||
WindOpen( win, xw, yw, ww, hw);
|
||||
WindGet( win, WF_WORKXYWH, &xw, &yw, &ww, &hw);
|
||||
}
|
||||
|
||||
151
sources/z-tools/trunk/ztask/cpu.c
Normal file
151
sources/z-tools/trunk/ztask/cpu.c
Normal file
@@ -0,0 +1,151 @@
|
||||
#include "general.h"
|
||||
|
||||
char buf[2048];
|
||||
|
||||
extern uint32 total_stram;
|
||||
extern uint32 total_ttram;
|
||||
|
||||
|
||||
|
||||
/* returns current cpu usage in percent */
|
||||
inline int16 cpu_get_usage( void)
|
||||
{
|
||||
static int32 pre_used = 0, pre_total = 0;
|
||||
int16 usage = 0;
|
||||
int32 mcpu, mnice, msystem, midle, used = 0, total = 0;
|
||||
FILE *fp;
|
||||
|
||||
if ( !( fp = fopen("U:/kern/stat", "r")))
|
||||
return usage;
|
||||
|
||||
fread( buf, 1, 2048, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
sscanf( buf, "%*s %ld %ld %ld %ld", &mcpu, &mnice, &msystem, &midle);
|
||||
|
||||
used = mcpu + msystem + mnice;
|
||||
total = used + midle;
|
||||
|
||||
/* calc CPU usage */
|
||||
if( total - pre_total > 0)
|
||||
usage = ( int16)(( 20 * ( double)( used - pre_used)) / ( double)( total - pre_total));
|
||||
|
||||
if( usage < 0)
|
||||
usage = 0;
|
||||
|
||||
pre_used = used;
|
||||
pre_total = total;
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
||||
|
||||
void get_total_ram( void)
|
||||
{
|
||||
size_t bytes_read;
|
||||
char *match;
|
||||
FILE *fp;
|
||||
|
||||
total_stram = 0;
|
||||
total_ttram = 0;
|
||||
|
||||
if ( !( fp = fopen("U:/kern/meminfo", "r")))
|
||||
return;
|
||||
|
||||
bytes_read = fread( buf, 1, 2048, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if( bytes_read == 0)
|
||||
return;
|
||||
|
||||
match = strstr( buf, "FastTotal");
|
||||
|
||||
if( match == NULL)
|
||||
return;
|
||||
|
||||
sscanf( match, "FastTotal: %ld", &total_ttram);
|
||||
|
||||
match = strstr( buf, "CoreTotal");
|
||||
|
||||
if( match == NULL)
|
||||
return;
|
||||
|
||||
sscanf( match, "CoreTotal: %ld", &total_stram);
|
||||
}
|
||||
|
||||
|
||||
inline void get_free_ram( uint32 *st_ram, uint32 *tt_ram)
|
||||
{
|
||||
size_t bytes_read;
|
||||
uint32 free_ram;
|
||||
char *match;
|
||||
FILE *fp;
|
||||
|
||||
*tt_ram = 0;
|
||||
*st_ram = 0;
|
||||
|
||||
if ( !( fp = fopen("U:/kern/meminfo", "r")))
|
||||
return;
|
||||
|
||||
bytes_read = fread( buf, 1, 2048, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if( bytes_read == 0)
|
||||
return;
|
||||
|
||||
match = strstr( buf, "FastFree");
|
||||
|
||||
if( match == NULL)
|
||||
return;
|
||||
|
||||
sscanf( match, "FastFree: %lu", &free_ram);
|
||||
|
||||
*tt_ram = free_ram;
|
||||
|
||||
match = strstr( buf, "CoreFree");
|
||||
|
||||
if( match == NULL)
|
||||
return;
|
||||
|
||||
sscanf( match, "CoreFree: %lu", &free_ram);
|
||||
|
||||
*st_ram = free_ram;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void get_info_by_pid( int pid, char *name, char *ram_usage, uint32 *cpu_time)
|
||||
{
|
||||
size_t bytes_read;
|
||||
char *s, *t;
|
||||
uint32 user_time, system_time;
|
||||
int32 ram;
|
||||
|
||||
FILE *fp;
|
||||
|
||||
sprintf( buf, "U:/kern/%d/stat", pid);
|
||||
|
||||
if ( !( fp = fopen( buf, "r")))
|
||||
return;
|
||||
|
||||
bytes_read = fread( buf, 1, 2048, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if( bytes_read == 0)
|
||||
return;
|
||||
|
||||
s = strchr ( buf, '(') + 1;
|
||||
t = strchr ( buf, ')');
|
||||
strncpy( name, s, t - s);
|
||||
name[t - s] = '\0';
|
||||
|
||||
sscanf( t + 2, "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %lu %lu %*d %*d %*d %*d %*u %*d %*u %*u %ld", &user_time, &system_time, &ram);
|
||||
|
||||
sprintf( ram_usage, "%ld kB", ram >> 10);
|
||||
|
||||
*cpu_time = user_time + system_time;
|
||||
}
|
||||
9
sources/z-tools/trunk/ztask/cpu.h
Normal file
9
sources/z-tools/trunk/ztask/cpu.h
Normal file
@@ -0,0 +1,9 @@
|
||||
extern inline int16 cpu_get_usage( void);
|
||||
extern void get_total_ram( void);
|
||||
extern inline void get_info_by_pid( int pid, char *name, char *ram_usage, uint32 *cpu_time);
|
||||
extern inline void get_free_ram( uint32 *st_Ram, uint32 *tt_ram);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
32
sources/z-tools/trunk/ztask/debug.c
Normal file
32
sources/z-tools/trunk/ztask/debug.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "general.h"
|
||||
#ifdef DEBUG
|
||||
#include <windom/wout.h>
|
||||
#endif
|
||||
|
||||
/*==================================================================================*
|
||||
* void zdebug: *
|
||||
* print debug information in 'wout' window. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* ... -> text and parameter are the same that sandard "printf" function. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void zdebug( const char *format, ...)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
va_list args;
|
||||
char fo_buff[255], *p;
|
||||
|
||||
va_start( args, format);
|
||||
vsprintf( fo_buff, format, args);
|
||||
p = fo_buff;
|
||||
va_end( args);
|
||||
|
||||
wout_printf("%s\n", p);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
154
sources/z-tools/trunk/ztask/font_8.h
Normal file
154
sources/z-tools/trunk/ztask/font_8.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/* MY_FONT8: Fonte 8*8 'non monospac<61>e'. */
|
||||
/* Version 1.0 (c) Eric Reboux 1997. */
|
||||
|
||||
static short ofwf[256] = /* tableau espacements des caract<63>res */
|
||||
{
|
||||
0, 7, 7, 7, 7, 8, 8, 8, 7, 8, 7, 7, 7, 7, 6, 7,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7,
|
||||
3, 3, 5, 7, 6, 6, 7, 3, 4, 4, 6, 6, 3, 6, 2, 5,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 4, 5, 4, 6,
|
||||
7, 6, 6, 6, 6, 5, 5, 6, 6, 2, 5, 6, 5, 7, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 3, 5, 3, 6, 6,
|
||||
3, 5, 5, 5, 5, 5, 3, 5, 5, 4, 4, 5, 4, 8, 5, 5,
|
||||
5, 5, 4, 5, 3, 5, 5, 6, 6, 5, 6, 5, 2, 5, 7, 6,
|
||||
6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 6, 6,
|
||||
5, 8, 8, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5,
|
||||
5, 4, 5, 5, 5, 6, 5, 5, 6, 7, 7, 8, 8, 3, 7, 7,
|
||||
5, 5, 8, 7, 8, 8, 6, 6, 6, 6, 5, 4, 8, 8, 8, 8,
|
||||
6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 6, 8,
|
||||
7, 6, 6, 8, 7, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 8, 8, 6, 7, 5, 5, 4, 7, 5, 5, 5, 6
|
||||
};
|
||||
|
||||
static short my_font_8[1280] = /* Tableau des donn<6E>es de la fonte */
|
||||
{
|
||||
0x0018, 0x3C7E, 0x1818, 0x1800, 0x0018, 0x1818, 0x7E3C, 0x1800,
|
||||
0x0008, 0x0C7E, 0x7E0C, 0x0800, 0x0010, 0x307E, 0x7E30, 0x1000,
|
||||
0x3C99, 0xC3E7, 0xC399, 0x3C00, 0xFFFF, 0xFEFC, 0xF9F3, 0xE700,
|
||||
0xE7C3, 0x993C, 0x99C3, 0xE700, 0x0002, 0x068C, 0xD870, 0x2000,
|
||||
0x7EC3, 0x9195, 0x9981, 0xC37E, 0x183C, 0x3C3C, 0x7E10, 0x3810,
|
||||
0x000E, 0x0B08, 0x0838, 0x7830, 0xF080, 0xDC90, 0x9810, 0x1000,
|
||||
0x6080, 0x9C92, 0x7C12, 0x1200, 0x0A0A, 0x0A1A, 0x1A32, 0xF2E2,
|
||||
0xA0A0, 0xA0B0, 0xB098, 0x9E8E, 0x3844, 0x4400, 0x4444, 0x3800,
|
||||
0x0404, 0x0400, 0x0404, 0x0400, 0x3804, 0x0438, 0x4040, 0x3800,
|
||||
0x7008, 0x0870, 0x0808, 0x7000, 0x4444, 0x4438, 0x0404, 0x0400,
|
||||
0x3840, 0x4038, 0x0404, 0x3800, 0x3840, 0x4038, 0x4444, 0x3800,
|
||||
0x7008, 0x0800, 0x0808, 0x0800, 0x3844, 0x4438, 0x4444, 0x3800,
|
||||
0x3844, 0x4438, 0x0404, 0x3800, 0x0000, 0x7804, 0x7844, 0x3800,
|
||||
0x7040, 0x7040, 0x7C10, 0x1C00, 0x0F1F, 0x3F30, 0x3020, 0x3C2E,
|
||||
0xE0F0, 0xD808, 0x0808, 0x78A8, 0x2216, 0x1B0C, 0x0F5C, 0x7370,
|
||||
0x0850, 0xB050, 0xA020, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x4040, 0x4040, 0x4000, 0x4000, 0x4848, 0x0000, 0x0000, 0x0000,
|
||||
0x0024, 0x7E24, 0x247E, 0x2400, 0x103C, 0x5038, 0x1478, 0x1000,
|
||||
0x0048, 0x0810, 0x1020, 0x2400, 0x1824, 0x1830, 0x4A44, 0x3A00,
|
||||
0x2020, 0x4000, 0x0000, 0x0000, 0x1020, 0x4040, 0x4040, 0x2010,
|
||||
0x4020, 0x1010, 0x1010, 0x2040, 0x0028, 0x107C, 0x1028, 0x0000,
|
||||
0x0010, 0x107C, 0x1010, 0x0000, 0x0000, 0x0000, 0x0020, 0x2040,
|
||||
0x0000, 0x007C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000,
|
||||
0x0808, 0x1010, 0x2020, 0x4040, 0x3844, 0x4444, 0x4444, 0x3800,
|
||||
0x1030, 0x1010, 0x1010, 0x3800, 0x3844, 0x0408, 0x1020, 0x7C00,
|
||||
0x7C08, 0x1038, 0x0444, 0x3800, 0x0818, 0x2848, 0x7C08, 0x0800,
|
||||
0x7C40, 0x7804, 0x0444, 0x3800, 0x1820, 0x4078, 0x4444, 0x3800,
|
||||
0x7C04, 0x0408, 0x1010, 0x1000, 0x3844, 0x4438, 0x4444, 0x3800,
|
||||
0x3844, 0x443C, 0x0408, 0x3000, 0x0000, 0x4000, 0x0040, 0x0000,
|
||||
0x0000, 0x2000, 0x0020, 0x2040, 0x0010, 0x2040, 0x2010, 0x0000,
|
||||
0x0000, 0x7800, 0x7800, 0x0000, 0x0040, 0x2010, 0x2040, 0x0000,
|
||||
0x3844, 0x0408, 0x1000, 0x1000, 0x3C42, 0x5A52, 0x5C40, 0x3E00,
|
||||
0x1028, 0x4444, 0x7C44, 0x4400, 0x7844, 0x4478, 0x4444, 0x7800,
|
||||
0x3844, 0x4040, 0x4044, 0x3800, 0x7048, 0x4444, 0x4448, 0x7000,
|
||||
0x7840, 0x4070, 0x4040, 0x7800, 0x7840, 0x4070, 0x4040, 0x4000,
|
||||
0x3844, 0x404C, 0x4444, 0x3800, 0x4444, 0x447C, 0x4444, 0x4400,
|
||||
0x4040, 0x4040, 0x4040, 0x4000, 0x0808, 0x0808, 0x0848, 0x3000,
|
||||
0x4448, 0x5060, 0x5048, 0x4400, 0x4040, 0x4040, 0x4040, 0x7800,
|
||||
0x4266, 0x5A42, 0x4242, 0x4200, 0x4464, 0x544C, 0x4444, 0x4400,
|
||||
0x3844, 0x4444, 0x4444, 0x3800, 0x7844, 0x4478, 0x4040, 0x4000,
|
||||
0x3844, 0x4444, 0x5448, 0x3400, 0x7844, 0x4478, 0x5048, 0x4400,
|
||||
0x3844, 0x4038, 0x0444, 0x3800, 0x7C10, 0x1010, 0x1010, 0x1000,
|
||||
0x4444, 0x4444, 0x4444, 0x3800, 0x4444, 0x4444, 0x2828, 0x1000,
|
||||
0x4141, 0x4149, 0x2A2A, 0x1400, 0x4444, 0x2810, 0x2844, 0x4400,
|
||||
0x4444, 0x4428, 0x1010, 0x1000, 0x7C04, 0x0810, 0x2040, 0x7C00,
|
||||
0x6040, 0x4040, 0x4040, 0x6000, 0x4040, 0x2020, 0x1010, 0x0808,
|
||||
0x6020, 0x2020, 0x2020, 0x6000, 0x1028, 0x4400, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x7C00, 0x4040, 0x2000, 0x0000, 0x0000,
|
||||
0x0000, 0x3008, 0x3848, 0x3800, 0x4040, 0x7048, 0x4848, 0x7000,
|
||||
0x0000, 0x3048, 0x4048, 0x3000, 0x0808, 0x3848, 0x4848, 0x3800,
|
||||
0x0000, 0x3048, 0x7840, 0x3800, 0x3040, 0x4060, 0x4040, 0x4000,
|
||||
0x0000, 0x3848, 0x4838, 0x0870, 0x4040, 0x7048, 0x4848, 0x4800,
|
||||
0x2000, 0x6020, 0x2020, 0x7000, 0x1000, 0x1010, 0x1010, 0x5020,
|
||||
0x4040, 0x4850, 0x6050, 0x4800, 0x6020, 0x2020, 0x2020, 0x7000,
|
||||
0x0000, 0x7649, 0x4949, 0x4900, 0x0000, 0x7048, 0x4848, 0x4800,
|
||||
0x0000, 0x3048, 0x4848, 0x3000, 0x0000, 0x7048, 0x4848, 0x7040,
|
||||
0x0000, 0x3848, 0x4848, 0x3808, 0x0000, 0x5060, 0x4040, 0x4000,
|
||||
0x0000, 0x3840, 0x3008, 0x7000, 0x4040, 0x6040, 0x4040, 0x2000,
|
||||
0x0000, 0x4848, 0x4848, 0x3800, 0x0000, 0x4848, 0x4850, 0x2000,
|
||||
0x0000, 0x4444, 0x5438, 0x2800, 0x0000, 0x4428, 0x1028, 0x4400,
|
||||
0x0000, 0x4848, 0x4838, 0x0870, 0x0000, 0x7C08, 0x1020, 0x7C00,
|
||||
0x1820, 0x2040, 0x2020, 0x1800, 0x4040, 0x4040, 0x4040, 0x4040,
|
||||
0x6010, 0x1008, 0x1010, 0x6000, 0x0020, 0x724E, 0x0400, 0x0000,
|
||||
0x0010, 0x2828, 0x447C, 0x0000, 0x3844, 0x4040, 0x4438, 0x1020,
|
||||
0x4800, 0x4848, 0x4848, 0x3800, 0x1020, 0x3048, 0x7840, 0x3800,
|
||||
0x3048, 0x3008, 0x3848, 0x3800, 0x2800, 0x3008, 0x3848, 0x3800,
|
||||
0x1008, 0x3008, 0x3848, 0x3800, 0x1010, 0x3008, 0x3848, 0x3800,
|
||||
0x0030, 0x4840, 0x4830, 0x1060, 0x1028, 0x3048, 0x7840, 0x3800,
|
||||
0x2800, 0x3048, 0x7840, 0x3800, 0x2010, 0x3048, 0x7840, 0x3800,
|
||||
0x5000, 0x6020, 0x2020, 0x7000, 0x2050, 0x6020, 0x2020, 0x7000,
|
||||
0x2010, 0x6020, 0x2020, 0x7000, 0x2800, 0x1028, 0x447C, 0x4400,
|
||||
0x1000, 0x1028, 0x447C, 0x4400, 0x1020, 0x7840, 0x7040, 0x7800,
|
||||
0x0000, 0x3E09, 0x3F48, 0x3E00, 0x1F38, 0x484E, 0x7848, 0x4F00,
|
||||
0x3048, 0x3048, 0x4848, 0x3000, 0x4800, 0x3048, 0x4848, 0x3000,
|
||||
0x2010, 0x3048, 0x4848, 0x3000, 0x3048, 0x0048, 0x4848, 0x3800,
|
||||
0x2010, 0x0048, 0x4848, 0x3800, 0x4800, 0x4848, 0x4838, 0x0870,
|
||||
0x2800, 0x3844, 0x4444, 0x3800, 0x4400, 0x4444, 0x4444, 0x3800,
|
||||
0x1038, 0x5450, 0x5438, 0x1000, 0x1824, 0x2078, 0x2020, 0x7800,
|
||||
0x4444, 0x3810, 0x7C10, 0x1000, 0x1824, 0x4478, 0x4444, 0x7840,
|
||||
0x1820, 0x2070, 0x2020, 0x4000, 0x1020, 0x3008, 0x3848, 0x3800,
|
||||
0x2040, 0x0060, 0x2020, 0x7000, 0x1020, 0x0030, 0x4848, 0x3000,
|
||||
0x1020, 0x0048, 0x4848, 0x3800, 0x2850, 0x0070, 0x4848, 0x4800,
|
||||
0x3458, 0x0064, 0x544C, 0x4400, 0x0030, 0x0838, 0x4838, 0x0078,
|
||||
0x0030, 0x4848, 0x4830, 0x0078, 0x1000, 0x1020, 0x4044, 0x3800,
|
||||
0x0000, 0x0000, 0x1E10, 0x1000, 0x0000, 0x0000, 0x7808, 0x0800,
|
||||
0x4244, 0x4816, 0x2142, 0x0700, 0x4244, 0x4816, 0x2A4F, 0x0200,
|
||||
0x0040, 0x0040, 0x4040, 0x4040, 0x0012, 0x2448, 0x2412, 0x0000,
|
||||
0x0048, 0x2412, 0x2448, 0x0000, 0x2850, 0x0030, 0x0878, 0x3800,
|
||||
0x2850, 0x0030, 0x4848, 0x3000, 0x1D22, 0x262A, 0x3222, 0x5C00,
|
||||
0x0000, 0x1A24, 0x3C24, 0x5800, 0x0000, 0x3E49, 0x4F48, 0x3E00,
|
||||
0x3F48, 0x484E, 0x4848, 0x3F00, 0x1008, 0x1028, 0x447C, 0x4400,
|
||||
0x3458, 0x1028, 0x447C, 0x4400, 0x3458, 0x0038, 0x4444, 0x3800,
|
||||
0x2400, 0x0000, 0x0000, 0x0000, 0x1020, 0x4000, 0x0000, 0x0000,
|
||||
0x2070, 0x2020, 0x0000, 0x0000, 0x3A4A, 0x4A4A, 0x3A0A, 0x0A0A,
|
||||
0x3C42, 0x99A1, 0xA199, 0x423C, 0x3C42, 0xB9A5, 0xB9A5, 0x423C,
|
||||
0xEA4E, 0x4A4A, 0x0000, 0x0000, 0x2400, 0x6424, 0x2474, 0x0418,
|
||||
0x7424, 0x2424, 0x2474, 0x0418, 0x0000, 0x1038, 0x7C10, 0x1010,
|
||||
0x1010, 0x107C, 0x3810, 0x0000, 0x0010, 0x18FC, 0x1810, 0x0000,
|
||||
0x0008, 0x183F, 0x1808, 0x0000, 0x1010, 0x101F, 0x0000, 0x0000,
|
||||
0x0000, 0x00F0, 0x1010, 0x1010, 0x1010, 0x10F0, 0x0000, 0x0000,
|
||||
0x0000, 0x001F, 0x1010, 0x1010, 0x0000, 0x00FF, 0x0000, 0x0000,
|
||||
0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x10FF, 0x1010, 0x1010,
|
||||
0x1010, 0x101F, 0x1010, 0x1010, 0x0000, 0x00FF, 0x1010, 0x1010,
|
||||
0x1010, 0x10F0, 0x1010, 0x1010, 0x1010, 0x10FF, 0x0000, 0x0000,
|
||||
0x0010, 0x181C, 0x1C18, 0x1000, 0x0008, 0x1838, 0x3818, 0x0800,
|
||||
0x0024, 0x343C, 0x3C34, 0x2400, 0x0024, 0x2C3C, 0x3C2C, 0x2400,
|
||||
0x0048, 0x6C7E, 0x7E6C, 0x4800, 0x0012, 0x367E, 0x7E36, 0x1200,
|
||||
0x0010, 0x387C, 0x007C, 0x0000, 0x007C, 0x7C7C, 0x7C7C, 0x0000,
|
||||
0x0038, 0x7C7C, 0x7C38, 0x0000, 0x3C42, 0x8181, 0x8250, 0x3810,
|
||||
0x1054, 0x9282, 0x8244, 0x3800, 0x0004, 0x0404, 0x247C, 0x2000,
|
||||
0x0609, 0x1C22, 0x221C, 0x4830, 0x0000, 0x1028, 0x4400, 0x0000,
|
||||
0x0036, 0x4949, 0x3600, 0x0000, 0x0000, 0x324C, 0x484C, 0x3200,
|
||||
0x1824, 0x4478, 0x4444, 0x7840, 0x7C24, 0x2020, 0x2020, 0x7000,
|
||||
0x0001, 0x3E54, 0x1414, 0x1400, 0x7E22, 0x1008, 0x1022, 0x7E00,
|
||||
0x001C, 0x3048, 0x4848, 0x3000, 0x0000, 0x2424, 0x2424, 0x3A40,
|
||||
0x0004, 0x3850, 0x1010, 0x1000, 0x3810, 0x3844, 0x4438, 0x1038,
|
||||
0x0038, 0x447C, 0x4444, 0x3800, 0x0038, 0x4444, 0x4428, 0x6C00,
|
||||
0x3020, 0x1038, 0x4444, 0x3800, 0x0408, 0x3854, 0x5438, 0x2040,
|
||||
0x1038, 0x5454, 0x5438, 0x1000, 0x3C60, 0x407C, 0x4060, 0x3C00,
|
||||
0x386C, 0x4444, 0x4444, 0x4400, 0x007C, 0x007C, 0x007C, 0x0000,
|
||||
0x0010, 0x107C, 0x1010, 0x007C, 0x0020, 0x1008, 0x1020, 0x007C,
|
||||
0x0008, 0x1020, 0x1008, 0x007C, 0x0609, 0x0808, 0x0808, 0x0808,
|
||||
0x0808, 0x0808, 0x0808, 0x4830, 0x0010, 0x007C, 0x0010, 0x0000,
|
||||
0x0032, 0x4C00, 0x324C, 0x0000, 0x3048, 0x4830, 0x0000, 0x0000,
|
||||
0x3078, 0x7830, 0x0000, 0x0000, 0x0000, 0x0000, 0x3030, 0x0000,
|
||||
0x0006, 0x0808, 0x6828, 0x1000, 0x3048, 0x4848, 0x0000, 0x0000,
|
||||
0x3048, 0x1020, 0x7800, 0x0000, 0x7008, 0x3008, 0x7000, 0x0000,
|
||||
0xFE00, 0x0000, 0x0000, 0x0000
|
||||
};
|
||||
120
sources/z-tools/trunk/ztask/general.h
Normal file
120
sources/z-tools/trunk/ztask/general.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* zbar.
|
||||
* Copyright (c) 2005 Zorro ( zorro270@yahoo.fr)
|
||||
*
|
||||
* This application is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <osbind.h>
|
||||
#include <mintbind.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <windom.h>
|
||||
#include <ldg.h>
|
||||
#include <scancode.h>
|
||||
#include "types2b.h"
|
||||
#include "prefs.h"
|
||||
#include "ztask.rsh"
|
||||
|
||||
/* Option */
|
||||
|
||||
#ifndef MAXNAMLEN
|
||||
#define MAXNAMLEN 255
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 1024
|
||||
#endif
|
||||
|
||||
/* xfont text attrib. */
|
||||
#define BOLD 0x01
|
||||
#define LIGHT 0x02
|
||||
#define ITALIC 0x04
|
||||
#define ULINE 0x08
|
||||
#define INVERSE 0x10
|
||||
#define SHADOW 0x20
|
||||
#define MONOSPACE 0x40
|
||||
|
||||
#define POPUP_ITEM 64
|
||||
|
||||
#define BOLD 0x01
|
||||
#define LIGHT 0x02
|
||||
#define ITALIC 0x04
|
||||
#define ULINE 0x08
|
||||
#define INVERSE 0x10
|
||||
#define SHADOW 0x20
|
||||
#define MONOSPACE 0x40
|
||||
|
||||
#define F_HIDE 1
|
||||
#define F_QUIT 2
|
||||
#define F_KILL 3
|
||||
#define F_TASKMANAGER 4
|
||||
#define F_PREFERENCES 5
|
||||
#define F_SHUTDOWN 6
|
||||
#define F_QUIT_ZBAR 7
|
||||
|
||||
typedef struct _app_data
|
||||
{
|
||||
int16 id, pid;
|
||||
char name[9];
|
||||
char name_shown[MAXNAMLEN];
|
||||
int16 name_shown_width;
|
||||
int16 x_pos, y_pos;
|
||||
struct _app_data *next;
|
||||
} app_data;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char item_name[POPUP_ITEM][64];
|
||||
RECT16 item_pos[POPUP_ITEM];
|
||||
int16 icon[POPUP_ITEM];
|
||||
int16 selectable[POPUP_ITEM];
|
||||
int16 function[POPUP_ITEM];
|
||||
int16 item_nbr;
|
||||
int16 selected, old_selected;
|
||||
int16 x_pos, y_pos, w_pos, h_pos;
|
||||
app_data *entry;
|
||||
WINDOW *win;
|
||||
} popup_data;
|
||||
|
||||
|
||||
typedef struct _process
|
||||
{
|
||||
int pid;
|
||||
char cpu_usage[5];
|
||||
char ram_usage[30];
|
||||
char name[MAXNAMLEN];
|
||||
uint32 cpu_time;
|
||||
int16 ram_usage_txt_width;
|
||||
int16 y_pos;
|
||||
struct _process *next;
|
||||
} process;
|
||||
|
||||
|
||||
extern void zdebug( const char *format, ...);
|
||||
extern OBJECT *get_tree( int16 obj_index);
|
||||
extern char *get_string( int16 str_index);
|
||||
extern void shutdown_dialog( void);
|
||||
extern void quit_dialog( void);
|
||||
extern void pref_dialog( void);
|
||||
|
||||
|
||||
|
||||
247
sources/z-tools/trunk/ztask/gmem.c
Normal file
247
sources/z-tools/trunk/ztask/gmem.c
Normal file
@@ -0,0 +1,247 @@
|
||||
#include "general.h"
|
||||
#include "gmem.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
typedef struct _GMemHdr
|
||||
{
|
||||
int size;
|
||||
int index;
|
||||
struct _GMemHdr *next;
|
||||
} GMemHdr;
|
||||
|
||||
#define gMemHdrSize (( sizeof(GMemHdr) + 7) & ~7)
|
||||
#define gMemTrlSize 4
|
||||
#define gMemDeadVal 0xFFFFFFFFUL
|
||||
|
||||
/* round data size so trailer will be aligned */
|
||||
#define gMemDataSize(size) ((((size) + gMemTrlSize - 1) / gMemTrlSize) * gMemTrlSize)
|
||||
|
||||
#define gMemNLists 64
|
||||
#define gMemListShift 4
|
||||
#define gMemListMask (gMemNLists - 1)
|
||||
static GMemHdr *gMemList[gMemNLists] = {
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static int gMemIndex = 0;
|
||||
static int gMemAlloc = 0;
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
void *gmalloc(int size)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
int size1;
|
||||
char *mem;
|
||||
GMemHdr *hdr;
|
||||
void *data;
|
||||
int lst;
|
||||
unsigned long *trl, *p;
|
||||
|
||||
if (size <= 0)
|
||||
return NULL;
|
||||
|
||||
size1 = gMemDataSize(size);
|
||||
|
||||
mem = (char *)malloc(size1 + gMemHdrSize + gMemTrlSize);
|
||||
|
||||
if ( mem == NULL)
|
||||
{
|
||||
zdebug( "Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hdr = (GMemHdr *)mem;
|
||||
data = (void *)(mem + gMemHdrSize);
|
||||
trl = (unsigned long *)(mem + gMemHdrSize + size1);
|
||||
hdr->size = size;
|
||||
hdr->index = gMemIndex++;
|
||||
lst = ((int)hdr >> gMemListShift) & gMemListMask;
|
||||
hdr->next = gMemList[lst];
|
||||
gMemList[lst] = hdr;
|
||||
++gMemAlloc;
|
||||
|
||||
for (p = (unsigned long *)data; p <= trl; ++p)
|
||||
*p = gMemDeadVal;
|
||||
|
||||
return data;
|
||||
#else
|
||||
void *p;
|
||||
|
||||
if (size <= 0)
|
||||
return NULL;
|
||||
|
||||
p = malloc(size);
|
||||
|
||||
if ( p == NULL)
|
||||
{
|
||||
zdebug( "Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *grealloc(void *p, int size)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
GMemHdr *hdr;
|
||||
void *q;
|
||||
int oldSize;
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
if (p)
|
||||
gfree(p);
|
||||
return NULL;
|
||||
}
|
||||
if (p)
|
||||
{
|
||||
hdr = (GMemHdr *)((char *)p - gMemHdrSize);
|
||||
oldSize = hdr->size;
|
||||
q = gmalloc(size);
|
||||
memcpy(q, p, size < oldSize ? size : oldSize);
|
||||
gfree(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
q = gmalloc(size);
|
||||
}
|
||||
return q;
|
||||
#else
|
||||
void *q;
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
if (p)
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (p)
|
||||
q = realloc( p, size);
|
||||
else
|
||||
q = malloc(size);
|
||||
|
||||
if (!q)
|
||||
{
|
||||
zdebug( "Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
return q;
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfree(void *p)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
int size;
|
||||
GMemHdr *hdr;
|
||||
GMemHdr *prevHdr, *q;
|
||||
int lst;
|
||||
unsigned long *trl, *clr;
|
||||
|
||||
if (p)
|
||||
{
|
||||
hdr = (GMemHdr *)((char *)p - gMemHdrSize);
|
||||
lst = ((int)hdr >> gMemListShift) & gMemListMask;
|
||||
|
||||
for (prevHdr = NULL, q = gMemList[lst]; q; prevHdr = q, q = q->next)
|
||||
{
|
||||
if ( q == hdr)
|
||||
break;
|
||||
}
|
||||
|
||||
if( q)
|
||||
{
|
||||
if (prevHdr)
|
||||
prevHdr->next = hdr->next;
|
||||
else
|
||||
gMemList[lst] = hdr->next;
|
||||
|
||||
--gMemAlloc;
|
||||
size = gMemDataSize(hdr->size);
|
||||
trl = (unsigned long *)((char *)hdr + gMemHdrSize + size);
|
||||
|
||||
if (*trl != gMemDeadVal)
|
||||
{
|
||||
zdebug( "Overwrite past end of block %d at address %p", hdr->index, p);
|
||||
}
|
||||
|
||||
for (clr = (unsigned long *)hdr; clr <= trl; ++clr)
|
||||
*clr = gMemDeadVal;
|
||||
|
||||
free(hdr);
|
||||
}
|
||||
else
|
||||
{
|
||||
zdebug( "Attempted to free bad address %p", p);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (p)
|
||||
free(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
void gMemReport( void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
FILE *inffile;
|
||||
GMemHdr *p;
|
||||
int lst;
|
||||
|
||||
if (( inffile = fopen( "C:\\ztkdebug.txt", "wb+")) == NULL)
|
||||
return;
|
||||
|
||||
fprintf( inffile, "%d memory allocations in all\n", gMemIndex);
|
||||
|
||||
if( gMemAlloc > 0)
|
||||
{
|
||||
fprintf( inffile, "%d memory blocks left allocated:\n", gMemAlloc);
|
||||
fprintf( inffile, " index size\n");
|
||||
fprintf( inffile, "-------- --------\n");
|
||||
|
||||
for (lst = 0; lst < gMemNLists; ++lst)
|
||||
{
|
||||
for (p = gMemList[lst]; p; p = p->next)
|
||||
fprintf( inffile, "%8d %8d\n", p->index, p->size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( inffile, "No memory blocks left allocated\n");
|
||||
}
|
||||
|
||||
fprintf( inffile, "--= End =--");
|
||||
|
||||
fclose( inffile);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char *copyString(char *s)
|
||||
{
|
||||
char *s1;
|
||||
|
||||
s1 = (char *)gmalloc(strlen(s) + 1);
|
||||
strcpy(s1, s);
|
||||
return s1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
19
sources/z-tools/trunk/ztask/gmem.h
Normal file
19
sources/z-tools/trunk/ztask/gmem.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef GMEM_H
|
||||
#define GMEM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void *gmalloc(int size);
|
||||
extern void *grealloc(void *p, int size);
|
||||
extern void gfree(void *p);
|
||||
extern void gMemReport( void);
|
||||
char *copyString(char *s);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
22
sources/z-tools/trunk/ztask/history.txt
Normal file
22
sources/z-tools/trunk/ztask/history.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
22 March 2006: BETA2
|
||||
====================
|
||||
|
||||
News:
|
||||
-----
|
||||
- Preference panel added.
|
||||
- With Xaaes, "XaSys" is not more listed as a GEM process.
|
||||
|
||||
|
||||
Bugs fixes:
|
||||
-----------
|
||||
- The first drawn of the process list in the Task Manager
|
||||
was corrupted.
|
||||
- Some littles bugs fixed.
|
||||
|
||||
|
||||
|
||||
|
||||
14 March 2006: BETA1
|
||||
======================
|
||||
|
||||
- First public release.
|
||||
125
sources/z-tools/trunk/ztask/main.c
Normal file
125
sources/z-tools/trunk/ztask/main.c
Normal file
@@ -0,0 +1,125 @@
|
||||
#include "general.h"
|
||||
#include "gmem.h"
|
||||
#include "app.h"
|
||||
#include "cpu.h"
|
||||
#include "process.h"
|
||||
#include <mint/cookie.h>
|
||||
|
||||
extern int16 cpu_history[100];
|
||||
extern void main_win( void);
|
||||
|
||||
OBJECT *get_tree( int16 obj_index)
|
||||
{
|
||||
OBJECT *tree;
|
||||
RsrcGaddr( NULL, 0, obj_index, &tree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
||||
char *get_string( int16 str_index)
|
||||
{
|
||||
char *txt;
|
||||
rsrc_gaddr( 5, str_index, &txt);
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
||||
void applexit( WINDOW *w, short buff[8])
|
||||
{
|
||||
WINDOW *last_closed = NULL;
|
||||
|
||||
if( EvntFind( NULL, WM_XTIMER))
|
||||
EvntDelete( NULL, WM_XTIMER);
|
||||
|
||||
/* Close all windows */
|
||||
while( wglb.first)
|
||||
{
|
||||
if (last_closed != wglb.first)
|
||||
{
|
||||
ApplWrite( _AESapid, WM_DESTROY, wglb.first->handle, 0, 0, 0, 0);
|
||||
last_closed = wglb.first; /* to prevent sending toons of WM_CLOSED messages to each window */
|
||||
}
|
||||
|
||||
if( EvntWindom( MU_MESAG | MU_TIMER) & MU_TIMER) /* MU_TIMER event catched ? */
|
||||
last_closed = NULL; /* then WM_CLOSED message has been lost ! it should be resent */
|
||||
}
|
||||
|
||||
prefs_write();
|
||||
|
||||
while( root != NULL)
|
||||
app_data_delete( root->id);
|
||||
|
||||
while( process_root != NULL)
|
||||
process_delete( process_root->pid);
|
||||
|
||||
RsrcXtype( 0, NULL, 0);
|
||||
RsrcFree();
|
||||
|
||||
ApplExit();
|
||||
gMemReport();
|
||||
exit( 0);
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[])
|
||||
{
|
||||
int16 i, dum, app_long_name;
|
||||
int32 mint = 0;
|
||||
|
||||
ApplInit();
|
||||
|
||||
if( app.nplanes < 4)
|
||||
{
|
||||
( void)FormAlert( 1 , "[1][Sorry, zTask needs minimum a 16 colors display][Quit]");
|
||||
ApplExit();
|
||||
exit( 0);
|
||||
}
|
||||
|
||||
if( Getcookie( C_MiNT, ( long*)&mint) != 0)
|
||||
{
|
||||
( void)FormAlert( 1 , "[1][Sorry, zTask works only with MiNT][Quit]");
|
||||
ApplExit();
|
||||
exit( 0);
|
||||
}
|
||||
|
||||
mt_appl_getinfo( AES_EXTENDED, &dum, &dum, &app_long_name, &dum, app.aes_global);
|
||||
|
||||
if( app_long_name <= 0)
|
||||
{
|
||||
( void)FormAlert( 1 , "[1][AES 4.x needed!][Quit]");
|
||||
ApplExit();
|
||||
exit( 0);
|
||||
}
|
||||
|
||||
if( !RsrcLoad( "ztask.rsc"))
|
||||
{
|
||||
( void)FormAlert( 1 , "[1][ztask.rsc not found!][Quit]");
|
||||
ApplExit();
|
||||
exit( 0);
|
||||
}
|
||||
|
||||
RsrcXtype( RSRC_XTYPE, NULL, 0);
|
||||
|
||||
prefs_read();
|
||||
|
||||
get_total_ram();
|
||||
|
||||
evnt.timer = 20L;
|
||||
evnt.bclick = 258;
|
||||
evnt.bmask = 3;
|
||||
evnt.bstate = 0;
|
||||
|
||||
EvntAttach( NULL, AP_TERM, applexit);
|
||||
|
||||
for( i = 0; i < 101;)
|
||||
cpu_history[i++] = 100;
|
||||
|
||||
main_win();
|
||||
|
||||
for(;;)
|
||||
EvntWindom( MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON);
|
||||
|
||||
// applexit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
233
sources/z-tools/trunk/ztask/popup.c
Normal file
233
sources/z-tools/trunk/ztask/popup.c
Normal file
@@ -0,0 +1,233 @@
|
||||
#include "general.h"
|
||||
#include "app.h"
|
||||
#include "string.h"
|
||||
#include "win.h"
|
||||
#include "taskman.h"
|
||||
#include <signal.h>
|
||||
|
||||
popup_data popup;
|
||||
extern WINDOW *app_bar;
|
||||
|
||||
|
||||
void CDECL popup_delete( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
WindDelete( win);
|
||||
popup.win = NULL;
|
||||
|
||||
if( menu_enabled == TRUE)
|
||||
{
|
||||
menu_enabled = FALSE;
|
||||
draw_page( app_bar, root->x_pos - 24, root->y_pos, 24, 23);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void process_popup_item( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
if( popup.selected < 0)
|
||||
return;
|
||||
|
||||
switch( popup.function[popup.selected])
|
||||
{
|
||||
case F_SHUTDOWN:
|
||||
shutdown_dialog();
|
||||
break;
|
||||
|
||||
case F_TASKMANAGER:
|
||||
taskman_dialog();
|
||||
break;
|
||||
|
||||
case F_QUIT_ZBAR:
|
||||
quit_dialog();
|
||||
break;
|
||||
|
||||
case F_KILL:
|
||||
Pkill( popup.entry->pid, SIGKILL);
|
||||
mt_evnt_timer( 100L, app.aes_global);
|
||||
break;
|
||||
|
||||
case F_PREFERENCES:
|
||||
pref_dialog();
|
||||
break;
|
||||
|
||||
case F_QUIT:
|
||||
ApplWrite( popup.entry->id, AP_TERM, 0, 0, 0, 0, 0);
|
||||
mt_evnt_timer( 100L, app.aes_global);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
popup_delete( win, buff);
|
||||
}
|
||||
|
||||
|
||||
int16 popup_item_under_mouse( void)
|
||||
{
|
||||
int16 i, ok, result = -1;
|
||||
|
||||
for( i = 0; i < popup.item_nbr; i++)
|
||||
{
|
||||
ok = IS_IN( evnt.mx, evnt.my, popup.item_pos[i].x1, popup.item_pos[i].y1, popup.item_pos[i].x2, popup.item_pos[i].y2);
|
||||
|
||||
if( ok)
|
||||
{
|
||||
if( popup.selectable[i] == TRUE)
|
||||
result = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void CDECL popup_redraw( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
int16 pxy[6], i, y, title_color, title_shadow;
|
||||
|
||||
pxy[0] = popup.x_pos;
|
||||
pxy[1] = popup.y_pos;
|
||||
pxy[2] = pxy[0] + popup.w_pos - 1;
|
||||
pxy[3] = pxy[1] + popup.h_pos - 1;
|
||||
|
||||
vsf_color( win->graf->handle, button_off_background);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
pxy[5] = pxy[1];
|
||||
pxy[1] = pxy[3];
|
||||
pxy[4] = pxy[2];
|
||||
|
||||
vsl_color( win->graf->handle, button_off_dark_color);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
pxy[4] = pxy[2];
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = popup.y_pos;
|
||||
pxy[5] = pxy[3];
|
||||
|
||||
vsl_color( win->graf->handle, button_off_light_color);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
pxy[0] = popup.x_pos + 1;
|
||||
pxy[1] = popup.y_pos + 1;
|
||||
pxy[2] = pxy[0] + popup.w_pos - 3;
|
||||
|
||||
for( i = 0, y = popup.y_pos + 7; i < popup.item_nbr; i++, y += 18, pxy[1] += 18)
|
||||
{
|
||||
popup.item_pos[i].x1 = pxy[0];
|
||||
popup.item_pos[i].x2 = popup.w_pos;
|
||||
popup.item_pos[i].y1 = pxy[1];
|
||||
|
||||
if( popup.item_name[i][0] == '\0')
|
||||
{
|
||||
int16 xy[4] = { pxy[0] + 1, pxy[1] + 5, pxy[2] - 1, pxy[1] + 5};
|
||||
|
||||
v_pline( win->graf->handle, 2, xy);
|
||||
|
||||
xy[1]--;
|
||||
xy[3]--;
|
||||
|
||||
vsl_color( win->graf->handle, button_off_dark_color);
|
||||
v_pline( win->graf->handle, 2, xy);
|
||||
|
||||
y -= 9;
|
||||
pxy[1] -= 9;
|
||||
popup.item_pos[i].y2 = 9;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
popup.item_pos[i].y2 = 18;
|
||||
|
||||
if( i == popup.selected)
|
||||
{
|
||||
pxy[3] = pxy[1] + 17;
|
||||
vsf_color( win->graf->handle, button_on_background);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
title_color = button_on_text_color;
|
||||
title_shadow = button_on_text_shadow_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
title_color = button_off_text_color;
|
||||
title_shadow = button_off_text_shadow_color;
|
||||
}
|
||||
|
||||
if( popup.icon[i] > -1)
|
||||
{
|
||||
icons[popup.icon[i]].ob_x = popup.x_pos + x_space;
|
||||
icons[popup.icon[i]].ob_y = pxy[1] + 2;
|
||||
|
||||
mt_objc_draw( icons, popup.icon[i], 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global);
|
||||
|
||||
draw_text( win->graf->handle, icons[popup.icon[i]].ob_x + 17 + x_space, y + 1, title_shadow, popup.item_name[i]);
|
||||
draw_text( win->graf->handle, icons[popup.icon[i]].ob_x + 16 + x_space, y, title_color, popup.item_name[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_text( win->graf->handle, popup.x_pos + x_space + 1, y + 1, title_shadow, popup.item_name[i]);
|
||||
draw_text( win->graf->handle, popup.x_pos + x_space, y, title_color, popup.item_name[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void open_popup( app_data *entry)
|
||||
{
|
||||
int16 i, lenght, zbarx, zbary, dum;
|
||||
|
||||
WindGet( app_bar, WF_CURRXYWH, &zbarx, &zbary, &dum, &dum);
|
||||
|
||||
if( entry)
|
||||
popup.x_pos = entry->x_pos - 1;
|
||||
else
|
||||
popup.x_pos = zbarx;
|
||||
|
||||
popup.h_pos = 5;
|
||||
popup.selected = -1;
|
||||
popup.old_selected = -1;
|
||||
|
||||
for( popup.w_pos = 0, i = 0; i < popup.item_nbr; i++)
|
||||
{
|
||||
if( popup.item_name[i][0] == '\0')
|
||||
{
|
||||
popup.h_pos += 9;
|
||||
continue;
|
||||
}
|
||||
|
||||
lenght = get_text_width( popup.item_name[i]);
|
||||
|
||||
if( popup.icon[i] > -1)
|
||||
lenght += 16 + x_space;
|
||||
|
||||
if( lenght > popup.w_pos)
|
||||
popup.w_pos = lenght;
|
||||
|
||||
popup.h_pos += 18;
|
||||
}
|
||||
|
||||
popup.w_pos += ( x_space * 3);
|
||||
popup.w_pos = MAX( popup.w_pos, app_width + 1);
|
||||
|
||||
while( popup.x_pos + popup.w_pos > app.x + app.w)
|
||||
popup.x_pos--;
|
||||
|
||||
popup.entry = entry;
|
||||
popup.win = WindCreate( 0, app.x, app.y, app.w, app.h);
|
||||
|
||||
EvntAttach( popup.win, WM_DESTROY, popup_delete);
|
||||
EvntAttach( popup.win, WM_REDRAW, popup_redraw);
|
||||
EvntAttach( popup.win, WM_XBUTTON, process_popup_item);
|
||||
|
||||
popup.y_pos = zbary - popup.h_pos + 1;
|
||||
|
||||
WindOpen( popup.win, popup.x_pos, popup.y_pos, popup.w_pos, popup.h_pos);
|
||||
// WindSet( popup.win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0);
|
||||
WindGet( popup.win, WF_WORKXYWH, &popup.x_pos, &popup.y_pos, &popup.w_pos, &popup.h_pos);
|
||||
}
|
||||
|
||||
|
||||
8
sources/z-tools/trunk/ztask/popup.h
Normal file
8
sources/z-tools/trunk/ztask/popup.h
Normal file
@@ -0,0 +1,8 @@
|
||||
extern popup_data popup;
|
||||
extern void open_popup( app_data *entry);
|
||||
extern int16 popup_item_under_mouse( void);
|
||||
extern void popup_delete( WINDOW *win);
|
||||
|
||||
|
||||
|
||||
|
||||
614
sources/z-tools/trunk/ztask/pref_panel.c
Normal file
614
sources/z-tools/trunk/ztask/pref_panel.c
Normal file
@@ -0,0 +1,614 @@
|
||||
#include "general.h"
|
||||
#include "win.h"
|
||||
#include "string.h"
|
||||
#include "app.h"
|
||||
|
||||
int tmp_button_off_background, tmp_button_off_light_color, tmp_button_off_dark_color,
|
||||
tmp_button_off_text_color, tmp_button_off_text_shadow_color, tmp_button_on_background,
|
||||
tmp_button_on_light_color, tmp_button_on_dark_color, tmp_button_on_text_color,
|
||||
tmp_button_on_text_shadow_color, tmp_geek_area_color, tmp_geek_area_dark_line,
|
||||
tmp_geek_area_light_line, tmp_app_width, tmp_cpu_bar_color,
|
||||
tmp_tt_bar_color, tmp_st_bar_color, tmp_show_clock, tmp_clock_us,
|
||||
tmp_show_system_info, tmp_show_acc, tmp_geek_area_text_color;
|
||||
static void *thumb = NULL;
|
||||
int *tmp;
|
||||
static int16 xy[10], tmp_cpu_x, tmp_tt_x, tmp_st_x, tmp_clock_x, tmp_geek_area_width, tmp_y_text_pos,
|
||||
tmp_x_pos, tmp_y_pos, tmp_w_pos, tmp_geek_area_x, text_width, x;
|
||||
static OBJECT *dial = NULL;
|
||||
WINDOW *pref_dialog_win = NULL;
|
||||
|
||||
extern void vdi_color_selector( int16 xw, int16 yw, int16 color_selected, int16 parent_object);
|
||||
|
||||
|
||||
static void CDECL pref_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
pref_dialog_win = NULL;
|
||||
}
|
||||
|
||||
static void CDECL pref_dialog_ok_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
pref_dialog_win = NULL;
|
||||
|
||||
button_off_background = tmp_button_off_background;
|
||||
button_off_light_color = tmp_button_off_light_color;
|
||||
button_off_dark_color = tmp_button_off_dark_color;
|
||||
button_off_text_color = tmp_button_off_text_color;
|
||||
button_off_text_shadow_color = tmp_button_off_text_shadow_color;
|
||||
button_on_background = tmp_button_on_background;
|
||||
button_on_light_color = tmp_button_on_light_color;
|
||||
button_on_dark_color = tmp_button_on_dark_color;
|
||||
button_on_text_color = tmp_button_on_text_color;
|
||||
button_on_text_shadow_color = tmp_button_on_text_shadow_color;
|
||||
geek_area_text_color = tmp_geek_area_text_color;
|
||||
geek_area_color = tmp_geek_area_color;
|
||||
geek_area_dark_line = tmp_geek_area_dark_line;
|
||||
geek_area_light_line = tmp_geek_area_light_line;
|
||||
app_width = tmp_app_width;
|
||||
cpu_bar_color = tmp_cpu_bar_color;
|
||||
tt_bar_color = tmp_tt_bar_color;
|
||||
st_bar_color = tmp_st_bar_color;
|
||||
show_clock = tmp_show_clock;
|
||||
clock_us = tmp_clock_us;
|
||||
show_system_info = tmp_show_system_info;
|
||||
|
||||
|
||||
if( show_acc != tmp_show_acc)
|
||||
{
|
||||
while( root != NULL)
|
||||
app_data_delete( root->id);
|
||||
|
||||
show_acc = tmp_show_acc;
|
||||
app_data_search();
|
||||
}
|
||||
else
|
||||
show_acc = tmp_show_acc;
|
||||
|
||||
set_component_position();
|
||||
|
||||
w_pos = geek_area_width + ( app_nbr * app_width) + 24;
|
||||
|
||||
while( w_pos > app.w)
|
||||
w_pos -= app_width;
|
||||
|
||||
x_pos = app.x + ( app.w - w_pos);
|
||||
w_pos -= 1;
|
||||
|
||||
WindSet( app_bar, WF_WORKXYWH, x_pos, y_pos, w_pos, h_pos);
|
||||
|
||||
// Xaaes bug... with this AES, WindSet( win, WF_CURRXYWH,... doesn't redraw the taskbar.
|
||||
draw_page( app_bar, x_pos, y_pos, w_pos, h_pos);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL click_on_color( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
int16 y, color_selection_width, selected_color = 0;
|
||||
|
||||
switch( obj)
|
||||
{
|
||||
case PREFS_ON_BACK:
|
||||
selected_color = ( int16)tmp_button_on_background;
|
||||
break;
|
||||
|
||||
case PREFS_ON_LINE1:
|
||||
selected_color = ( int16)tmp_button_on_light_color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_LINE2:
|
||||
selected_color = ( int16)tmp_button_on_dark_color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_TEXT1:
|
||||
selected_color = ( int16)tmp_button_on_text_color;
|
||||
break;
|
||||
|
||||
case PREFS_ON_TEXT2:
|
||||
selected_color = ( int16)tmp_button_on_text_shadow_color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_BACK:
|
||||
selected_color = ( int16)tmp_button_off_background;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_LINE1:
|
||||
selected_color = ( int16)tmp_button_off_light_color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_LINE2:
|
||||
selected_color = ( int16)tmp_button_off_dark_color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_TEXT1:
|
||||
selected_color = ( int16)tmp_button_off_text_color;
|
||||
break;
|
||||
|
||||
case PREFS_OFF_TEXT2:
|
||||
selected_color = ( int16)tmp_button_off_text_shadow_color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_BACK:
|
||||
selected_color = ( int16)tmp_geek_area_color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_LINE1:
|
||||
selected_color = ( int16)tmp_geek_area_light_line;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_LINE2:
|
||||
selected_color = ( int16)tmp_geek_area_dark_line;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_RAM1:
|
||||
selected_color = ( int16)tmp_st_bar_color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_RAM2:
|
||||
selected_color = ( int16)tmp_tt_bar_color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_CPU:
|
||||
selected_color = ( int16)tmp_cpu_bar_color;
|
||||
break;
|
||||
|
||||
case PREFS_GEEK_TEXT:
|
||||
selected_color = ( int16)tmp_geek_area_text_color;
|
||||
break;
|
||||
}
|
||||
|
||||
mt_objc_offset( dial, obj, &x, &y, app.aes_global);
|
||||
|
||||
if( app.nplanes == 4)
|
||||
color_selection_width = 45;
|
||||
else
|
||||
color_selection_width = 177;
|
||||
|
||||
while( x + color_selection_width + 2 > app.w)
|
||||
x--;
|
||||
|
||||
while( y + color_selection_width + 2 > app.h)
|
||||
y--;
|
||||
|
||||
vdi_color_selector( x, y, selected_color, ( int16)obj);
|
||||
}
|
||||
|
||||
static void CDECL pref_dialog_default_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
if( app.nplanes < 8)
|
||||
{
|
||||
tmp_button_off_light_color = WHITE;
|
||||
tmp_button_off_dark_color = LBLACK;
|
||||
tmp_button_off_text_color = BLACK;
|
||||
tmp_button_off_text_shadow_color = WHITE;
|
||||
tmp_button_on_background = LBLACK;
|
||||
tmp_button_on_light_color = LWHITE;
|
||||
tmp_button_on_dark_color = BLACK;
|
||||
tmp_button_on_text_color = BLACK;
|
||||
tmp_button_on_text_shadow_color = LWHITE;
|
||||
tmp_geek_area_text_color = BLACK;
|
||||
tmp_geek_area_color = LWHITE;
|
||||
tmp_geek_area_dark_line = LBLACK;
|
||||
tmp_geek_area_light_line = WHITE;
|
||||
tmp_cpu_bar_color = CYAN;
|
||||
tmp_tt_bar_color = BLUE;
|
||||
tmp_st_bar_color = RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_button_off_background = 8;
|
||||
tmp_button_off_light_color = 250;
|
||||
tmp_button_off_dark_color = 252;
|
||||
tmp_button_off_text_color = 255;
|
||||
tmp_button_off_text_shadow_color = 250;
|
||||
tmp_button_on_background = 252;
|
||||
tmp_button_on_light_color = 8;
|
||||
tmp_button_on_dark_color = 144;
|
||||
tmp_button_on_text_color = 1;
|
||||
tmp_button_on_text_shadow_color = 251;
|
||||
tmp_geek_area_text_color = 1;
|
||||
tmp_geek_area_color = 252;
|
||||
tmp_geek_area_dark_line = 144;
|
||||
tmp_geek_area_light_line = 250;
|
||||
tmp_app_width = 72;
|
||||
tmp_cpu_bar_color = 146;
|
||||
tmp_tt_bar_color = 73;
|
||||
tmp_st_bar_color = 106;
|
||||
}
|
||||
|
||||
if( FormThbGet( thumb, 0) == PREFS_COLOR)
|
||||
{
|
||||
ObjcDraw( OC_FORM, win, PREFS_PANEL1, 3);
|
||||
ObjcDraw( OC_FORM, win, PREFS_COLOR, 1);
|
||||
}
|
||||
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL draw_preview( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[3] = pblk->pb_y + pblk->pb_h - 1;
|
||||
|
||||
vsf_color( win->graf->handle, LCYAN);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = pblk->pb_x;
|
||||
xy[3] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[4] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = pblk->pb_y;
|
||||
xy[8] = pblk->pb_x;
|
||||
xy[9] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
|
||||
x = x_space + 2;
|
||||
|
||||
if( tmp_show_system_info)
|
||||
{
|
||||
tmp_cpu_x = x;
|
||||
x += ( bar_width + 2);
|
||||
|
||||
tmp_st_x = x;
|
||||
x += ( bar_width + 2);
|
||||
|
||||
tmp_tt_x = x;
|
||||
x += ( bar_width + x_space);
|
||||
}
|
||||
|
||||
if( tmp_show_clock == TRUE)
|
||||
{
|
||||
tmp_clock_x = x;
|
||||
|
||||
if( tmp_clock_us == FALSE)
|
||||
text_width = get_text_width( "22:37:05");
|
||||
else
|
||||
text_width = get_text_width( "10:37:05 PM");
|
||||
|
||||
x += ( text_width + x_space);
|
||||
}
|
||||
|
||||
tmp_geek_area_width = x + 1;
|
||||
|
||||
tmp_y_text_pos = pblk->pb_y + pblk->pb_h - 15;
|
||||
|
||||
tmp_w_pos = tmp_geek_area_width + ( 2 * tmp_app_width) + 23;
|
||||
tmp_x_pos = pblk->pb_x + ( pblk->pb_w - tmp_w_pos) - 1;
|
||||
tmp_y_pos = pblk->pb_y + pblk->pb_h - 22;
|
||||
|
||||
|
||||
tmp_geek_area_x = tmp_x_pos + tmp_w_pos - tmp_geek_area_width;
|
||||
|
||||
/* we draw the menu area */
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0] + 23;
|
||||
xy[3] = xy[1] + 20;
|
||||
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_button_off_background);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[1] = xy[3];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos;
|
||||
xy[4] = xy[0] + 22;
|
||||
xy[5] = tmp_y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = xy[4] + 1;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = tmp_x_pos;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
// icons[ICONS_MENU].ob_x = xw + 4;
|
||||
// icons[ICONS_MENU].ob_y = y_pos + 2;
|
||||
|
||||
// mt_objc_draw( icons, ICONS_MENU, 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global);
|
||||
|
||||
tmp_x_pos += 24;
|
||||
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0] + tmp_app_width - 1;
|
||||
xy[3] = xy[1] + 20;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_button_on_background);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[1] = xy[3];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos;
|
||||
xy[4] = xy[0] + tmp_app_width - 2;
|
||||
xy[5] = tmp_y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_on_dark_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = xy[4] + 1;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = tmp_x_pos;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_on_light_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_on_text_shadow_color, "Dummy");
|
||||
draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_on_text_color, "Dummy");
|
||||
|
||||
tmp_x_pos += tmp_app_width;
|
||||
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0] + tmp_app_width - 1;
|
||||
xy[3] = xy[1] + 20;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_button_off_background);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[1] = xy[3];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos;
|
||||
xy[4] = xy[0] + tmp_app_width - 2;
|
||||
xy[5] = tmp_y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = xy[4] + 1;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = tmp_x_pos;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_off_text_shadow_color, "Dummy");
|
||||
draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_off_text_color, "Dummy");
|
||||
|
||||
tmp_x_pos += tmp_app_width;
|
||||
|
||||
|
||||
|
||||
/* draw the "geek" area */
|
||||
xy[0] = tmp_x_pos + 2;
|
||||
xy[1] = tmp_y_pos + 2;
|
||||
xy[2] = xy[0] + tmp_geek_area_width - 6;
|
||||
xy[3] = xy[1] + 16;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_geek_area_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = xy[2] + tmp_geek_area_width - 2;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = xy[1];
|
||||
xy[8] = xy[0];
|
||||
xy[9] = xy[1];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_background);
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
|
||||
xy[0]++;
|
||||
xy[1] = xy[3] - 1;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos + 1;
|
||||
xy[4]--;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_geek_area_dark_line);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[2] = xy[4];
|
||||
xy[3] = xy[1];
|
||||
xy[5] = tmp_y_pos + 2;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_geek_area_light_line);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
|
||||
/* draw the cpu % in the "geek" area */
|
||||
if( tmp_show_system_info)
|
||||
{
|
||||
/* the CPU usage */
|
||||
xy[0] = tmp_cpu_x + tmp_geek_area_x;
|
||||
xy[1] = tmp_y_pos + 3;
|
||||
xy[2] = xy[0] + bar_width - 1;
|
||||
xy[3] = xy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = xy[0] + 1;
|
||||
xy[2] = xy[2] - 1;
|
||||
xy[3] = tmp_y_pos + 16;
|
||||
xy[1] = tmp_y_pos + 9;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_cpu_bar_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
/* the STRAM usage */
|
||||
xy[0] = tmp_st_x + tmp_geek_area_x;
|
||||
xy[1] = tmp_y_pos + 3;
|
||||
xy[2] = xy[0] + bar_width - 1;
|
||||
xy[3] = xy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = xy[0] + 1;
|
||||
xy[2] = xy[2] - 1;
|
||||
xy[3] = tmp_y_pos + 16;
|
||||
xy[1] = tmp_y_pos + 9;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_st_bar_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = tmp_tt_x + tmp_geek_area_x;
|
||||
xy[1] = tmp_y_pos + 3;
|
||||
xy[2] = xy[0] + bar_width - 1;
|
||||
xy[3] = xy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
|
||||
xy[0] = xy[0] + 1;
|
||||
xy[2] = xy[2] - 1;
|
||||
xy[3] = tmp_y_pos + 16;
|
||||
xy[1] = tmp_y_pos + 9;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_tt_bar_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
}
|
||||
|
||||
if( tmp_show_clock == TRUE)
|
||||
{
|
||||
if( tmp_clock_us == FALSE)
|
||||
draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, (int16)tmp_geek_area_text_color, "22:37:05");
|
||||
else
|
||||
draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, (int16)tmp_geek_area_text_color, "10:37:05 PM");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CDECL draw_color_case( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
tmp = ( int*)data;
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = xy[0] + 127;
|
||||
xy[3] = xy[1] + 127;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)*tmp);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = pblk->pb_x;
|
||||
xy[3] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[4] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = pblk->pb_y;
|
||||
xy[8] = pblk->pb_x;
|
||||
xy[9] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
}
|
||||
|
||||
|
||||
void pref_dialog( void)
|
||||
{
|
||||
int frms[] = { PREFS_PANEL1, PREFS_PANEL2};
|
||||
int buts[] = { PREFS_COLOR, PREFS_MISC};
|
||||
|
||||
if( pref_dialog_win != NULL)
|
||||
return;
|
||||
|
||||
dial = get_tree( PREFS);
|
||||
|
||||
tmp_button_off_background = button_off_background;
|
||||
tmp_button_off_light_color = button_off_light_color;
|
||||
tmp_button_off_dark_color = button_off_dark_color;
|
||||
tmp_button_off_text_color = button_off_text_color;
|
||||
tmp_button_off_text_shadow_color = button_off_text_shadow_color;
|
||||
tmp_button_on_background = button_on_background;
|
||||
tmp_button_on_light_color = button_on_light_color;
|
||||
tmp_button_on_dark_color = button_on_dark_color;
|
||||
tmp_button_on_text_color = button_on_text_color;
|
||||
tmp_button_on_text_shadow_color = button_on_text_shadow_color;
|
||||
tmp_geek_area_text_color = geek_area_text_color;
|
||||
tmp_geek_area_color = geek_area_color;
|
||||
tmp_geek_area_dark_line = geek_area_dark_line;
|
||||
tmp_geek_area_light_line = geek_area_light_line;
|
||||
tmp_app_width = app_width;
|
||||
tmp_cpu_bar_color = cpu_bar_color;
|
||||
tmp_tt_bar_color = tt_bar_color;
|
||||
tmp_st_bar_color = st_bar_color;
|
||||
tmp_show_clock = show_clock;
|
||||
tmp_clock_us = clock_us;
|
||||
tmp_show_system_info = show_system_info;
|
||||
tmp_show_acc = show_acc;
|
||||
|
||||
|
||||
if( ( pref_dialog_win = FormCreate( dial, NAME|MOVER, NULL, "Preferences", NULL, TRUE, FALSE)) == NULL)
|
||||
return;
|
||||
|
||||
dial = FORM( pref_dialog_win);
|
||||
|
||||
thumb = FormThumb( pref_dialog_win, frms, buts, 2);
|
||||
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_BACK, draw_color_case, &tmp_button_on_background);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_LINE1, draw_color_case, &tmp_button_on_light_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_LINE2, draw_color_case, &tmp_button_on_dark_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_TEXT1, draw_color_case, &tmp_button_on_text_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_TEXT2, draw_color_case, &tmp_button_on_text_shadow_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_BACK, draw_color_case, &tmp_button_off_background);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_LINE1, draw_color_case, &tmp_button_off_light_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_LINE2, draw_color_case, &tmp_button_off_dark_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_TEXT1, draw_color_case, &tmp_button_off_text_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_TEXT2, draw_color_case, &tmp_button_off_text_shadow_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_BACK, draw_color_case, &tmp_geek_area_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_LINE1, draw_color_case, &tmp_geek_area_light_line);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_LINE2, draw_color_case, &tmp_geek_area_dark_line);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_RAM1, draw_color_case, &tmp_st_bar_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_RAM2, draw_color_case, &tmp_tt_bar_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_CPU, draw_color_case, &tmp_cpu_bar_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_TEXT, draw_color_case, &tmp_geek_area_text_color);
|
||||
RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_PREVIEW, draw_preview, NULL);
|
||||
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_OK, pref_dialog_ok_event, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_CANCEL, pref_dialog_cancel_event, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_DEFAULT, pref_dialog_default_event, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_BACK, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_LINE1, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_LINE2, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_TEXT1, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_TEXT2, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_BACK, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_LINE1, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_LINE2, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_TEXT1, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_TEXT2, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_BACK, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_LINE1, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_LINE2, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_RAM1, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_RAM2, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_CPU, click_on_color, NULL);
|
||||
ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_TEXT, click_on_color, NULL);
|
||||
|
||||
ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SHOW_US_CLOCK, &tmp_clock_us, 1);
|
||||
ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SHOW_ACC, &tmp_show_acc, 1);
|
||||
ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SYSTEM_INFO, &tmp_show_system_info, 1);
|
||||
ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SHOW_CLOCK, &tmp_show_clock, 1);
|
||||
}
|
||||
|
||||
392
sources/z-tools/trunk/ztask/preference.c
Normal file
392
sources/z-tools/trunk/ztask/preference.c
Normal file
@@ -0,0 +1,392 @@
|
||||
#include "general.h"
|
||||
#include "win.h"
|
||||
#include "string.h"
|
||||
|
||||
int tmp_button_off_background, tmp_button_off_light_color, tmp_button_off_dark_color,
|
||||
tmp_button_off_text_color, tmp_button_off_text_shadow_color, tmp_button_on_background,
|
||||
tmp_button_on_light_color, tmp_button_on_dark_color, tmp_button_on_text_color,
|
||||
tmp_button_on_text_shadow_color, tmp_geek_area_color, tmp_geek_area_dark_line,
|
||||
tmp_geek_area_light_line, tmp_app_width, tmp_cpu_bar_color,
|
||||
tmp_tt_bar_color, tmp_st_bar_color, tmp_show_clock, tmp_clock_us,
|
||||
tmp_show_system_info, tmp_show_acc;
|
||||
|
||||
int *tmp;
|
||||
static int16 xy[10], tmp_cpu_x, tmp_tt_x, tmp_st_x, tmp_clock_x, tmp_geek_area_width, tmp_y_text_pos,
|
||||
tmp_x_pos, tmp_y_pos, tmp_w_pos, tmp_geek_area_x, text_width, x;
|
||||
static OBJECT *dial = NULL;
|
||||
|
||||
|
||||
static void CDECL pref_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
}
|
||||
|
||||
static void CDECL pref_dialog_ok_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL draw_preview( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[3] = pblk->pb_y + pblk->pb_h - 1;
|
||||
|
||||
vsf_color( win->graf->handle, LCYAN);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = pblk->pb_x;
|
||||
xy[3] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[4] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = pblk->pb_y;
|
||||
xy[8] = pblk->pb_x;
|
||||
xy[9] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
|
||||
x = x_space + 2;
|
||||
|
||||
if( tmp_show_system_info)
|
||||
{
|
||||
tmp_cpu_x = x;
|
||||
x += ( bar_width + 2);
|
||||
|
||||
tmp_st_x = x;
|
||||
x += ( bar_width + 2);
|
||||
|
||||
tmp_tt_x = x;
|
||||
x += ( bar_width + x_space);
|
||||
}
|
||||
|
||||
if( tmp_show_clock == TRUE)
|
||||
{
|
||||
tmp_clock_x = x;
|
||||
|
||||
if( tmp_clock_us == FALSE)
|
||||
text_width = get_text_width( "22:37:05");
|
||||
else
|
||||
text_width = get_text_width( "10:37:05 PM");
|
||||
|
||||
x += ( text_width + x_space);
|
||||
}
|
||||
|
||||
tmp_geek_area_width = x + 1;
|
||||
|
||||
tmp_y_text_pos = pblk->pb_y + pblk->pb_h - 15;
|
||||
|
||||
tmp_w_pos = tmp_geek_area_width + ( 2 * tmp_app_width) + 23;
|
||||
tmp_x_pos = pblk->pb_x + ( pblk->pb_w - tmp_w_pos) - 1;
|
||||
tmp_y_pos = pblk->pb_y + pblk->pb_h - 22;
|
||||
|
||||
|
||||
tmp_geek_area_x = tmp_x_pos + tmp_w_pos - tmp_geek_area_width;
|
||||
|
||||
/* we draw the menu area */
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0] + 23;
|
||||
xy[3] = xy[1] + 20;
|
||||
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_button_off_background);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[1] = xy[3];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos;
|
||||
xy[4] = xy[0] + 22;
|
||||
xy[5] = tmp_y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = xy[4] + 1;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = tmp_x_pos;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
// icons[ICONS_MENU].ob_x = xw + 4;
|
||||
// icons[ICONS_MENU].ob_y = y_pos + 2;
|
||||
|
||||
// mt_objc_draw( icons, ICONS_MENU, 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global);
|
||||
|
||||
tmp_x_pos += 24;
|
||||
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0] + tmp_app_width - 1;
|
||||
xy[3] = xy[1] + 20;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_button_on_background);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[1] = xy[3];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos;
|
||||
xy[4] = xy[0] + tmp_app_width - 2;
|
||||
xy[5] = tmp_y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_on_dark_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = xy[4] + 1;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = tmp_x_pos;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_on_light_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_on_text_shadow_color, "Dummy");
|
||||
draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_on_text_color, "Dummy");
|
||||
|
||||
tmp_x_pos += tmp_app_width;
|
||||
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0] + tmp_app_width - 1;
|
||||
xy[3] = xy[1] + 20;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_button_off_background);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[1] = xy[3];
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos;
|
||||
xy[4] = xy[0] + tmp_app_width - 2;
|
||||
xy[5] = tmp_y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = xy[4] + 1;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = tmp_x_pos;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_off_text_shadow_color, "Dummy");
|
||||
draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_off_text_color, "Dummy");
|
||||
|
||||
tmp_x_pos += tmp_app_width;
|
||||
|
||||
|
||||
|
||||
/* draw the "geek" area */
|
||||
xy[0] = tmp_x_pos + 2;
|
||||
xy[1] = tmp_y_pos + 2;
|
||||
xy[2] = xy[0] + tmp_geek_area_width - 6;
|
||||
xy[3] = xy[1] + 16;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_geek_area_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = tmp_x_pos;
|
||||
xy[1] = tmp_y_pos;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = xy[1] + 20;
|
||||
xy[4] = xy[2] + tmp_geek_area_width - 2;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = xy[1];
|
||||
xy[8] = xy[0];
|
||||
xy[9] = xy[1];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_button_off_background);
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
|
||||
xy[0]++;
|
||||
xy[1] = xy[3] - 1;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = tmp_y_pos + 1;
|
||||
xy[4]--;
|
||||
xy[5] = xy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_geek_area_dark_line);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[2] = xy[4];
|
||||
xy[3] = xy[1];
|
||||
xy[5] = tmp_y_pos + 2;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)tmp_geek_area_light_line);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
|
||||
/* draw the cpu % in the "geek" area */
|
||||
if( tmp_show_system_info)
|
||||
{
|
||||
/* the CPU usage */
|
||||
xy[0] = tmp_cpu_x + tmp_geek_area_x;
|
||||
xy[1] = tmp_y_pos + 3;
|
||||
xy[2] = xy[0] + bar_width - 1;
|
||||
xy[3] = xy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = xy[0] + 1;
|
||||
xy[2] = xy[2] - 1;
|
||||
xy[3] = tmp_y_pos + 16;
|
||||
xy[1] = tmp_y_pos + 9;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_cpu_bar_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
/* the STRAM usage */
|
||||
xy[0] = tmp_st_x + tmp_geek_area_x;
|
||||
xy[1] = tmp_y_pos + 3;
|
||||
xy[2] = xy[0] + bar_width - 1;
|
||||
xy[3] = xy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = xy[0] + 1;
|
||||
xy[2] = xy[2] - 1;
|
||||
xy[3] = tmp_y_pos + 16;
|
||||
xy[1] = tmp_y_pos + 9;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_st_bar_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = tmp_tt_x + tmp_geek_area_x;
|
||||
xy[1] = tmp_y_pos + 3;
|
||||
xy[2] = xy[0] + bar_width - 1;
|
||||
xy[3] = xy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
|
||||
xy[0] = xy[0] + 1;
|
||||
xy[2] = xy[2] - 1;
|
||||
xy[3] = tmp_y_pos + 16;
|
||||
xy[1] = tmp_y_pos + 9;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tmp_tt_bar_color);
|
||||
v_bar( win->graf->handle, xy);
|
||||
}
|
||||
|
||||
if( tmp_show_clock == TRUE)
|
||||
{
|
||||
if( tmp_clock_us == FALSE)
|
||||
draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, BLACK, "22:37:05");
|
||||
else
|
||||
draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, BLACK, "10:37:05 PM");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CDECL draw_color_case( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
tmp = ( int*)data;
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = xy[0] + 127;
|
||||
xy[3] = xy[1] + 127;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)*tmp);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = pblk->pb_x;
|
||||
xy[3] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[4] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[5] = xy[3];
|
||||
xy[6] = xy[4];
|
||||
xy[7] = pblk->pb_y;
|
||||
xy[8] = pblk->pb_x;
|
||||
xy[9] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 5, xy);
|
||||
}
|
||||
|
||||
|
||||
void pref_dialog( void)
|
||||
{
|
||||
WINDOW *win;
|
||||
int frms[] = { PREFS_PANEL1, PREFS_PANEL2};
|
||||
int buts[] = { PREFS_COLOR, PREFS_MISC};
|
||||
|
||||
dial = get_tree( PREFS);
|
||||
|
||||
tmp_button_off_background = button_off_background;
|
||||
tmp_button_off_light_color = button_off_light_color;
|
||||
tmp_button_off_dark_color = button_off_dark_color;
|
||||
tmp_button_off_text_color = button_off_text_color;
|
||||
tmp_button_off_text_shadow_color = button_off_text_shadow_color;
|
||||
tmp_button_on_background = button_on_background;
|
||||
tmp_button_on_light_color = button_on_light_color;
|
||||
tmp_button_on_dark_color = button_on_dark_color;
|
||||
tmp_button_on_text_color = button_on_text_color;
|
||||
tmp_button_on_text_shadow_color = button_on_text_shadow_color;
|
||||
tmp_geek_area_color = geek_area_color;
|
||||
tmp_geek_area_dark_line = geek_area_dark_line;
|
||||
tmp_geek_area_light_line = geek_area_light_line;
|
||||
tmp_app_width = app_width;
|
||||
tmp_cpu_bar_color = cpu_bar_color;
|
||||
tmp_tt_bar_color = tt_bar_color;
|
||||
tmp_st_bar_color = st_bar_color;
|
||||
tmp_show_clock = show_clock;
|
||||
tmp_clock_us = clock_us;
|
||||
tmp_show_system_info = show_system_info;
|
||||
tmp_show_acc = show_acc;
|
||||
|
||||
|
||||
if( ( win = FormCreate( dial, NAME|MOVER, NULL, "Preferences", NULL, TRUE, FALSE)) == NULL)
|
||||
return;
|
||||
|
||||
dial = FORM( win);
|
||||
|
||||
FormThumb( win, frms, buts, 2);
|
||||
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_ON_BACK, draw_color_case, &tmp_button_on_background);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_ON_LINE1, draw_color_case, &tmp_button_on_light_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_ON_LINE2, draw_color_case, &tmp_button_on_dark_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_ON_TEXT1, draw_color_case, &tmp_button_on_text_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_ON_TEXT2, draw_color_case, &tmp_button_on_text_shadow_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_OFF_BACK, draw_color_case, &tmp_button_off_background);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_OFF_LINE1, draw_color_case, &tmp_button_off_light_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_OFF_LINE2, draw_color_case, &tmp_button_off_dark_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_OFF_TEXT1, draw_color_case, &tmp_button_off_text_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_OFF_TEXT2, draw_color_case, &tmp_button_off_text_shadow_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_GEEK_BACK, draw_color_case, &tmp_geek_area_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_GEEK_LINE1, draw_color_case, &tmp_geek_area_light_line);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_GEEK_LINE2, draw_color_case, &tmp_geek_area_dark_line);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_GEEK_RAM1, draw_color_case, &tmp_st_bar_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_GEEK_RAM2, draw_color_case, &tmp_tt_bar_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_GEEK_CPU, draw_color_case, &tmp_cpu_bar_color);
|
||||
RsrcUserDraw( OC_FORM, win, PREFS_PREVIEW, draw_preview, NULL);
|
||||
|
||||
WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0);
|
||||
ObjcAttachFormFunc( win, PREFS_OK, pref_dialog_ok_event, NULL);
|
||||
ObjcAttachFormFunc( win, PREFS_CANCEL, pref_dialog_cancel_event, NULL);
|
||||
ObjcAttachVar( OC_FORM, win, PREFS_SHOW_US_CLOCK, &tmp_clock_us, 1);
|
||||
ObjcAttachVar( OC_FORM, win, PREFS_SHOW_ACC, &tmp_show_acc, 1);
|
||||
ObjcAttachVar( OC_FORM, win, PREFS_SYSTEM_INFO, &tmp_show_system_info, 1);
|
||||
ObjcAttachVar( OC_FORM, win, PREFS_SHOW_CLOCK, &tmp_show_clock, 1);
|
||||
}
|
||||
|
||||
354
sources/z-tools/trunk/ztask/prefs.c
Normal file
354
sources/z-tools/trunk/ztask/prefs.c
Normal file
@@ -0,0 +1,354 @@
|
||||
#include "general.h"
|
||||
|
||||
int button_off_background = 8;
|
||||
int button_off_light_color = 250;
|
||||
int button_off_dark_color = 252;
|
||||
int button_off_text_color = 255;
|
||||
int button_off_text_shadow_color = 250;
|
||||
int button_on_background = 252;
|
||||
int button_on_light_color = 8;
|
||||
int button_on_dark_color = 144;
|
||||
int button_on_text_color = 1;
|
||||
int button_on_text_shadow_color = 251;
|
||||
int geek_area_text_color = 1;
|
||||
int geek_area_color = 252;
|
||||
int geek_area_dark_line = 144;
|
||||
int geek_area_light_line = 250;
|
||||
int app_width = 72;
|
||||
int cpu_bar_color = 146;
|
||||
int tt_bar_color = 73;
|
||||
int st_bar_color = 106;
|
||||
int show_clock = TRUE;
|
||||
int clock_us = FALSE;
|
||||
int show_system_info = TRUE;
|
||||
int show_acc = TRUE;
|
||||
|
||||
/* Prototype */
|
||||
int prefs_read( void);
|
||||
int prefs_write( void);
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* prefs_read: *
|
||||
* Reads the content of the INF file an put it in the preference global variables. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: 0 if error *
|
||||
*==================================================================================*/
|
||||
int prefs_read( void)
|
||||
{
|
||||
char filename[256] = "";
|
||||
char unknown_s[256] = "";
|
||||
FILE *inffile;
|
||||
int32 filepos;
|
||||
char *env_home;
|
||||
int16 len;
|
||||
boolean valid_entry_found;
|
||||
|
||||
shel_envrn( &env_home, "HOME=");
|
||||
|
||||
/* Home directory exist? */
|
||||
if ( env_home != NULL)
|
||||
{
|
||||
strcpy( filename, env_home);
|
||||
len = ( int16)strlen( filename);
|
||||
|
||||
if ((filename[len - 1] != '\\') && (filename[len - 1] != '/'))
|
||||
{
|
||||
strcat( filename, "\\");
|
||||
}
|
||||
|
||||
strcat( filename, "ztask.inf");
|
||||
|
||||
if (( inffile = fopen( filename, "rb+")) != NULL)
|
||||
goto loop;
|
||||
|
||||
}
|
||||
|
||||
/* With ftell, we MUST open the file in binary mode and not in text mode !!! */
|
||||
if (( inffile = fopen( "ztask.inf", "rb+")) == NULL)
|
||||
{
|
||||
if( app.nplanes < 8)
|
||||
{
|
||||
button_off_light_color = WHITE;
|
||||
button_off_dark_color = LBLACK;
|
||||
button_off_text_color = BLACK;
|
||||
button_off_text_shadow_color = WHITE;
|
||||
button_on_background = LBLACK;
|
||||
button_on_light_color = LWHITE;
|
||||
button_on_dark_color = BLACK;
|
||||
button_on_text_color = BLACK;
|
||||
button_on_text_shadow_color = LWHITE;
|
||||
geek_area_color = LWHITE;
|
||||
geek_area_dark_line = LBLACK;
|
||||
geek_area_light_line = WHITE;
|
||||
cpu_bar_color = CYAN;
|
||||
tt_bar_color = BLUE;
|
||||
st_bar_color = RED;
|
||||
}
|
||||
|
||||
return( 0);
|
||||
}
|
||||
|
||||
loop:
|
||||
|
||||
do
|
||||
{
|
||||
valid_entry_found = FALSE;
|
||||
|
||||
filepos = ftell( inffile);
|
||||
|
||||
if ( fscanf( inffile, "button_off_background=%d ", &button_off_background) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if (fscanf( inffile, "button_off_light_color=%d ", &button_off_light_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "button_off_dark_color=%d ", &button_off_dark_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if (fscanf( inffile, "button_off_text_color=%d ", &button_off_text_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "button_off_text_shadow_color=%d ", &button_off_text_shadow_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "button_on_background=%d ", &button_on_background) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if (fscanf( inffile, "button_on_light_color=%d ", &button_on_light_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "button_on_dark_color=%d ", &button_on_dark_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if (fscanf( inffile, "button_on_text_color=%d ", &button_on_text_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "button_on_text_shadow_color=%d ", &button_on_text_shadow_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "geek_area_text_color=%d ", &geek_area_text_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
|
||||
if ( fscanf( inffile, "geek_area_color=%d ", &geek_area_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
|
||||
if ( fscanf( inffile, "geek_area_dark_line=%d ", &geek_area_dark_line) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "geek_area_light_line=%d ", &geek_area_light_line) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "app_width=%d ", &app_width) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
|
||||
if ( fscanf( inffile, "cpu_bar_color=%d ", &cpu_bar_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
|
||||
if ( fscanf( inffile, "tt_bar_color=%d ", &tt_bar_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "st_bar_color=%d ", &st_bar_color) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "show_clock=%d ", &show_clock) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "clock_us=%d ", &clock_us) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "show_system_info=%d ", &show_system_info) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "show_acc=%d ", &show_acc) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
if ( fscanf( inffile, "%s ", unknown_s) == 1)
|
||||
{
|
||||
valid_entry_found = TRUE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
fseek( inffile, filepos, SEEK_SET);
|
||||
|
||||
} while ( valid_entry_found);
|
||||
|
||||
fclose( inffile);
|
||||
|
||||
return( 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* prefs_write: *
|
||||
* Writes the preference variables in the preference file. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: 0 if error *
|
||||
*==================================================================================*/
|
||||
int prefs_write( void)
|
||||
{
|
||||
char filename[256] = "ztask.inf";
|
||||
FILE *inffile;
|
||||
char *env_home;
|
||||
int16 len;
|
||||
|
||||
shel_envrn( &env_home, "HOME=");
|
||||
|
||||
/* Home directory exist? */
|
||||
if ( env_home != NULL)
|
||||
{
|
||||
strcpy( filename, env_home);
|
||||
|
||||
len = ( int16)strlen( filename);
|
||||
|
||||
if ((filename[len - 1] != '\\') && (filename[len - 1] != '/'))
|
||||
strcat( filename, "\\");
|
||||
|
||||
strcat( filename, "ztask.inf");
|
||||
}
|
||||
|
||||
/* With ftell, we MUST open the file in binary mode and not in text mode !!! */
|
||||
if (( inffile = fopen( filename, "wb+")) == NULL)
|
||||
return( 0);
|
||||
|
||||
fprintf( inffile, "button_off_background=%d\r\n", button_off_background);
|
||||
fprintf( inffile, "button_off_light_color=%d\r\n", button_off_light_color);
|
||||
fprintf( inffile, "button_off_dark_color=%d\r\n", button_off_dark_color);
|
||||
fprintf( inffile, "button_off_text_color=%d\r\n", button_off_text_color);
|
||||
fprintf( inffile, "button_off_text_shadow_color=%d\r\n", button_off_text_shadow_color);
|
||||
fprintf( inffile, "button_on_background=%d\r\n", button_on_background);
|
||||
fprintf( inffile, "button_on_light_color=%d\r\n", button_on_light_color);
|
||||
fprintf( inffile, "button_on_dark_color=%d\r\n", button_on_dark_color);
|
||||
fprintf( inffile, "button_on_text_color=%d\r\n", button_on_text_color);
|
||||
fprintf( inffile, "button_on_text_shadow_color=%d\r\n", button_on_text_shadow_color);
|
||||
fprintf( inffile, "geek_area_text_color=%d\r\n", geek_area_text_color);
|
||||
fprintf( inffile, "geek_area_color=%d\r\n", geek_area_color);
|
||||
fprintf( inffile, "geek_area_dark_line=%d\r\n", geek_area_dark_line);
|
||||
fprintf( inffile, "geek_area_light_line=%d\r\n", geek_area_light_line);
|
||||
fprintf( inffile, "app_width=%d\r\n", app_width);
|
||||
fprintf( inffile, "cpu_bar_color=%d\r\n", cpu_bar_color);
|
||||
fprintf( inffile, "tt_bar_color=%d\r\n", tt_bar_color);
|
||||
fprintf( inffile, "st_bar_color=%d\r\n", st_bar_color);
|
||||
fprintf( inffile, "show_clock=%d\r\n", show_clock);
|
||||
fprintf( inffile, "clock_us=%d\r\n", clock_us);
|
||||
fprintf( inffile, "show_system_info=%d\r\n", show_system_info);
|
||||
fprintf( inffile, "show_acc=%d\r\n", show_acc);
|
||||
fclose( inffile);
|
||||
|
||||
return( 1);
|
||||
}
|
||||
30
sources/z-tools/trunk/ztask/prefs.h
Normal file
30
sources/z-tools/trunk/ztask/prefs.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Global variable */
|
||||
extern int button_off_background;
|
||||
extern int button_on_background;
|
||||
extern int button_on_light_color;
|
||||
extern int button_off_light_color;
|
||||
extern int button_on_dark_color;
|
||||
extern int button_off_dark_color;
|
||||
extern int button_on_text_color;
|
||||
extern int button_on_text_shadow_color;
|
||||
extern int button_off_text_color;
|
||||
extern int button_off_text_shadow_color;
|
||||
extern int geek_area_text_color;
|
||||
extern int geek_area_color;
|
||||
extern int geek_area_dark_line;
|
||||
extern int geek_area_light_line;
|
||||
extern int app_width;
|
||||
extern int cpu_bar_color;
|
||||
extern int tt_bar_color;
|
||||
extern int st_bar_color;
|
||||
extern int show_clock;
|
||||
extern int clock_us;
|
||||
extern int show_system_info;
|
||||
extern int show_acc;
|
||||
|
||||
|
||||
/* Function */
|
||||
extern int prefs_read( void);
|
||||
extern int prefs_write( void);
|
||||
|
||||
|
||||
230
sources/z-tools/trunk/ztask/process.c
Normal file
230
sources/z-tools/trunk/ztask/process.c
Normal file
@@ -0,0 +1,230 @@
|
||||
#include "general.h"
|
||||
#include "gmem.h"
|
||||
#include "string.h"
|
||||
#include "cpu.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
process *process_root = NULL;
|
||||
int process_nbr = 0;
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* process_attach: *
|
||||
* attach a entry in the global process list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* pid: The PID of the application. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* the processe created or NULL *
|
||||
*==================================================================================*/
|
||||
|
||||
process *process_attach( int pid)
|
||||
{
|
||||
process *new = ( process *)gmalloc( sizeof(process));
|
||||
|
||||
if( !new)
|
||||
return NULL;
|
||||
|
||||
new -> pid = pid;
|
||||
new -> next = process_root;
|
||||
new->cpu_time = 0;
|
||||
|
||||
process_root = new;
|
||||
|
||||
process_nbr++;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* process_find_parent: *
|
||||
* find the parent( previous) entry in the process list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* child: the function returns the parent of this entry. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* the parent entry else the root entry. *
|
||||
*==================================================================================*/
|
||||
process *process_find_parent( process *child)
|
||||
{
|
||||
process *scan = process_root;
|
||||
|
||||
while( scan)
|
||||
{
|
||||
if( scan->next != child)
|
||||
{
|
||||
scan = scan->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return( scan);
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* process_delete: *
|
||||
* Delete an entry in the process list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* pid: the pid of the entry to delete. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void process_delete( int pid)
|
||||
{
|
||||
process *scan = process_root, *parent;
|
||||
|
||||
while( scan)
|
||||
{
|
||||
if( scan->pid != pid)
|
||||
{
|
||||
scan = scan->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
parent = process_find_parent( scan);
|
||||
|
||||
if( parent == NULL)
|
||||
process_root = scan->next;
|
||||
else
|
||||
parent->next = scan->next;
|
||||
|
||||
gfree( scan);
|
||||
process_nbr--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* process_find: *
|
||||
* Find an entry in the process list. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* id: the pid of the entry to find. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* the entry or NULL if not found. *
|
||||
*==================================================================================*/
|
||||
process *process_find( int pid)
|
||||
{
|
||||
process *scan = process_root, *result = NULL;
|
||||
|
||||
while( scan)
|
||||
{
|
||||
if( scan->pid != pid)
|
||||
{
|
||||
scan = scan->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
result = scan;
|
||||
break;
|
||||
}
|
||||
|
||||
return( result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* scan_process: *
|
||||
* Make a list of all the process and add it in the global process list if *
|
||||
* necessary. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* -- *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void scan_process( void)
|
||||
{
|
||||
int pid, count = 0;
|
||||
uint32 old_cpu_time;
|
||||
DIR *dir;
|
||||
char *dirname;
|
||||
char buf[128];
|
||||
struct dirent *de;
|
||||
process *current_process = NULL, *scan;
|
||||
clock_t current_t, relative_t;
|
||||
static clock_t old_t = 0;
|
||||
|
||||
current_t = clock();
|
||||
|
||||
relative_t = current_t - old_t;
|
||||
|
||||
old_t = current_t;
|
||||
|
||||
if (( dir = opendir( "U:/kern")) == NULL)
|
||||
return;
|
||||
|
||||
while(( de = readdir( dir)) != NULL)
|
||||
{
|
||||
dirname = de->d_name;
|
||||
|
||||
if( dirname[0] != '1' && dirname[0] != '2' && dirname[0] != '3' && dirname[0] != '4' && dirname[0] != '5'
|
||||
&& dirname[0] != '6' && dirname[0] != '7' && dirname[0] != '8' && dirname[0] != '9')
|
||||
continue;
|
||||
|
||||
count++;
|
||||
|
||||
pid = atoi( dirname);
|
||||
|
||||
current_process = process_find( pid);
|
||||
|
||||
// Is already listed?
|
||||
if( current_process == NULL)
|
||||
current_process = process_attach( pid);
|
||||
|
||||
old_cpu_time = current_process->cpu_time;
|
||||
|
||||
get_info_by_pid( pid, current_process->name, current_process->ram_usage, ¤t_process->cpu_time);
|
||||
|
||||
sprintf( current_process->cpu_usage, "%lu", ((current_process->cpu_time - old_cpu_time) * 20) / relative_t);
|
||||
|
||||
current_process->ram_usage_txt_width = get_text_width( current_process->ram_usage);
|
||||
}
|
||||
|
||||
closedir( dir);
|
||||
|
||||
if( count != process_nbr)
|
||||
{
|
||||
scan = process_root;
|
||||
|
||||
while( scan != NULL)
|
||||
{
|
||||
sprintf( buf, "U:/kern/%d", scan->pid);
|
||||
|
||||
if (( dir = opendir( buf)) == NULL)
|
||||
{
|
||||
pid = scan->pid;
|
||||
scan = scan->next;
|
||||
process_delete( pid);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
closedir( dir);
|
||||
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
sources/z-tools/trunk/ztask/process.h
Normal file
4
sources/z-tools/trunk/ztask/process.h
Normal file
@@ -0,0 +1,4 @@
|
||||
extern process *process_root;
|
||||
extern int process_nbr;
|
||||
extern void process_delete( int pid);
|
||||
extern void scan_process( void);
|
||||
26
sources/z-tools/trunk/ztask/quit.c
Normal file
26
sources/z-tools/trunk/ztask/quit.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "general.h"
|
||||
|
||||
static void quit_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void quit_dialog_ok_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, AP_TERM, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void quit_dialog( void)
|
||||
{
|
||||
WINDOW *win;
|
||||
|
||||
if( ( win = FormCreate( get_tree( QUIT), NAME|MOVER, NULL, "", NULL, TRUE, FALSE)) == NULL)
|
||||
return;
|
||||
|
||||
WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0);
|
||||
ObjcAttachFormFunc( win, QUIT_YES, quit_dialog_ok_event, NULL);
|
||||
ObjcAttachFormFunc( win, QUIT_NO, quit_dialog_cancel_event, NULL);
|
||||
}
|
||||
34
sources/z-tools/trunk/ztask/shutdown.c
Normal file
34
sources/z-tools/trunk/ztask/shutdown.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "general.h"
|
||||
|
||||
static int shutdown_mode = SHUTDOWN_DIAL_HALT;
|
||||
|
||||
|
||||
static void shutdown_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void shutdown_dialog_ok_event( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
Shutdown(( long)shutdown_mode);
|
||||
}
|
||||
|
||||
|
||||
void shutdown_dialog( void)
|
||||
{
|
||||
WINDOW *win;
|
||||
|
||||
if( ( win = FormCreate( get_tree( SHUTDOWN_DIAL), NAME|MOVER, NULL, get_string( S_SHUTDOWN), NULL, TRUE, FALSE)) == NULL)
|
||||
return;
|
||||
|
||||
ObjcAttachVar( OC_FORM, win, SHUTDOWN_DIAL_WARN, &shutdown_mode, 1);
|
||||
ObjcAttachVar( OC_FORM, win, SHUTDOWN_DIAL_COLD, &shutdown_mode, 2);
|
||||
ObjcAttachVar( OC_FORM, win, SHUTDOWN_DIAL_HALT, &shutdown_mode, 0);
|
||||
|
||||
ObjcAttachFormFunc( win, SHUTDOWN_DIAL_OK, shutdown_dialog_ok_event, NULL);
|
||||
ObjcAttachFormFunc( win, SHUTDOWN_DIAL_CANCEL, shutdown_dialog_cancel_event, NULL);
|
||||
}
|
||||
|
||||
180
sources/z-tools/trunk/ztask/string.c
Normal file
180
sources/z-tools/trunk/ztask/string.c
Normal file
@@ -0,0 +1,180 @@
|
||||
#include "general.h"
|
||||
#include "font_8.h"
|
||||
|
||||
void trim_start( char *name)
|
||||
{
|
||||
while( name[0] == ' ')
|
||||
// memcpy( name, name + 1, strlen( name));
|
||||
strcpy( name, name + 1);
|
||||
}
|
||||
|
||||
|
||||
void trim_end( char *name, int16 len)
|
||||
{
|
||||
while( name[len] == ' ')
|
||||
name[len--] = '\0';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* zstrncpy: *
|
||||
* Copy <n> bytes from <src> to <dst>, including the terminating \0'-byte. * *
|
||||
* If <src> is longer than <n-1>, it will be truncated with a '\0'-byte at *
|
||||
* position n-1. *
|
||||
* Example: zstrncpy(b, "string", 1) would put a '\0'-byte at b[0] and *
|
||||
* return. *
|
||||
* Basically, think of the <n> as a limiter on the number of bytes at <dst> *
|
||||
* we're allowed to touch, and then fit a string-copying idea on top of that. *
|
||||
* Works for me, and a lot better than the standard strncpy(), too. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: <dst> *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* dst: Pointer to destination text. *
|
||||
* src: Pointer to source text. *
|
||||
* n: Limiter on the number of bytes at <dst> *
|
||||
*==================================================================================*/
|
||||
char *zstrncpy( char *dst, const char *src, size_t n)
|
||||
{
|
||||
register const char *source = src;
|
||||
register char *dest = dst;
|
||||
register size_t count = n;
|
||||
|
||||
if( dest && !source && count)
|
||||
*dest = '\0';
|
||||
else if( dest && source && (count >= 1))
|
||||
{
|
||||
for( count--; count > 0 && *source != '\0'; count--)
|
||||
*dest++ = *source++;
|
||||
*dest = '\0';
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void draw_text_to_buffer( int16 xf, int16 yf, int32 src_line_octets, const char *str, MFDB *bm)
|
||||
{
|
||||
int16 c, character_pixel_skip = 0;
|
||||
int32 src_line_word = src_line_octets >> 1;
|
||||
|
||||
while ( (c = *str++) != 0)
|
||||
{
|
||||
int xpos = xf + character_pixel_skip;
|
||||
int xpos_octet = xpos >> 3;
|
||||
register int pixel_shift = xpos - ( xpos_octet << 3);
|
||||
register char *character = (char*)&my_font_8[(c - 1) << 2];
|
||||
register int i;
|
||||
|
||||
if( pixel_shift == 0)
|
||||
{
|
||||
register char *dest = bm->fd_addr + ( yf * src_line_octets) + xpos_octet;
|
||||
|
||||
for( i = 0; i < 8; i++)
|
||||
{
|
||||
*dest = *character++;
|
||||
dest += src_line_octets;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
register short *dest = ( short*)( bm->fd_addr + ( yf * src_line_octets) + xpos_octet);
|
||||
|
||||
for( i = 0; i < 8; i++)
|
||||
{
|
||||
*dest |= (( *character++) << 8) >> pixel_shift;
|
||||
dest += src_line_word;
|
||||
}
|
||||
}
|
||||
|
||||
character_pixel_skip += ofwf[c];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void draw_text( int16 vdih, int16 xf, int16 yf, int16 color, const char *str)
|
||||
{
|
||||
MFDB pic, screen = {0};
|
||||
short fx_mem[16], sys_pxy[8] = { 0, 0, 0, 7, xf, yf, 0, yf + 7}, c, char_width, tcolor[2] = { color, WHITE};
|
||||
|
||||
pic.fd_addr = fx_mem;
|
||||
pic.fd_w = 16;
|
||||
pic.fd_h = 8;
|
||||
pic.fd_wdwidth = 1;
|
||||
pic.fd_stand = 0;
|
||||
pic.fd_nplanes = 1;
|
||||
|
||||
while ( (c = *str++) != 0)
|
||||
{
|
||||
register char *model = (char*)&my_font_8[(c - 1) << 2] ;
|
||||
register char *dest = (char*)fx_mem;
|
||||
|
||||
char_width = ofwf[c];
|
||||
|
||||
memset( fx_mem, 0, 20);
|
||||
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model++;
|
||||
dest += 2;
|
||||
*dest = *model;
|
||||
|
||||
sys_pxy[2] = char_width - 1;
|
||||
sys_pxy[6] = sys_pxy[4] + sys_pxy[2];
|
||||
|
||||
/*vdi*/
|
||||
vrt_cpyfm( vdih, 2, sys_pxy, &pic, &screen, tcolor);
|
||||
|
||||
sys_pxy[4] += char_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline int16 get_text_width( const char *str)
|
||||
{
|
||||
register int16 c, text_width = 0;
|
||||
|
||||
while ( (c = *str++) != 0)
|
||||
{
|
||||
text_width += ofwf[c];
|
||||
}
|
||||
|
||||
return text_width;
|
||||
}
|
||||
|
||||
|
||||
int16 name_shorter( int16 max_size, char *str)
|
||||
{
|
||||
int16 len, current_len;
|
||||
|
||||
len = ( int16) strlen( str) - 1;
|
||||
|
||||
do
|
||||
{
|
||||
str[len - 3] = '.';
|
||||
str[len - 2] = '.';
|
||||
str[len - 1] = '.';
|
||||
str[len] = '\0';
|
||||
|
||||
len--;
|
||||
|
||||
current_len = get_text_width( str);
|
||||
|
||||
} while ( ( current_len >= max_size) && ( len > 0));
|
||||
|
||||
return current_len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
11
sources/z-tools/trunk/ztask/string.h
Normal file
11
sources/z-tools/trunk/ztask/string.h
Normal file
@@ -0,0 +1,11 @@
|
||||
extern void draw_text( int16 vdih, int16 xf, int16 yf, int16 color, const char *str);
|
||||
extern inline void draw_text_to_buffer( int16 xf, int16 yf, int32 src_line_octets, const char *str, MFDB *bm);
|
||||
extern inline int16 get_text_width( const char *str);
|
||||
extern int16 name_shorter( int16 max_size, char *str);
|
||||
extern char *zstrncpy( char *dst, const char *src, size_t n);
|
||||
extern void trim_start( char *name);
|
||||
extern void trim_end( char *name, int16 len);
|
||||
|
||||
|
||||
|
||||
|
||||
612
sources/z-tools/trunk/ztask/taskman.c
Normal file
612
sources/z-tools/trunk/ztask/taskman.c
Normal file
@@ -0,0 +1,612 @@
|
||||
#include "general.h"
|
||||
#include "win.h"
|
||||
#include "process.h"
|
||||
#include "gmem.h"
|
||||
#include "string.h"
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
|
||||
WINDOW *taskman_win = NULL;
|
||||
static void *thumb = NULL;
|
||||
process *process_loop, *process_selected = NULL;
|
||||
MFDB cpu_average_background = {0}, process_list_buffer = {0};
|
||||
static int16 wanted_color[2] = { BLACK, LGREEN}, txt_color[2] = { BLACK, WHITE}, selected_txt_color[2] = { BLACK, LWHITE}, xy[8], x, i, ii, dum, res, cpu_history_point[202];
|
||||
static OBJECT *dial = NULL;
|
||||
uint32 old_stram, old_ttram, process_list_buffer_lenght;
|
||||
int32 uptime, loadaverage[3], updays, tmpdays, uphours, tmphours, upmins, upsecs, ypos, ypos_max;
|
||||
static MFDB screen = {0};
|
||||
float slider_pos = 0.0, slider_step = 0.0;
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* int16 init_mfdb: *
|
||||
* fit a MFDB with the parameters suppplied. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* bm -> The MFDB to fit. *
|
||||
* width -> Image's width. *
|
||||
* height -> Image's height. *
|
||||
* planes -> Screen planes or 1 if the image is monochrome. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* '0' if error or the memory size allocated. *
|
||||
*==================================================================================*/
|
||||
uint32 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes)
|
||||
{
|
||||
uint32 length;
|
||||
|
||||
bm->fd_w = width;
|
||||
bm->fd_h = height;
|
||||
bm->fd_wdwidth = ( width >> 4) + (( width % 16) != 0);
|
||||
bm->fd_stand = 0;
|
||||
bm->fd_nplanes = planes;
|
||||
bm->fd_r1 = 0;
|
||||
bm->fd_r2 = 0;
|
||||
bm->fd_r3 = 0;
|
||||
|
||||
length = (( (( uint32)bm->fd_wdwidth << 1 ) * ( uint32)bm->fd_nplanes) * ( uint32)bm->fd_h) + 256L;
|
||||
bm->fd_addr = gmalloc( length);
|
||||
|
||||
if( bm->fd_addr)
|
||||
return( length - 256);
|
||||
|
||||
bm->fd_addr = NULL;
|
||||
|
||||
return ( 0);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL taskman_win_mouse_event( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
int16 ob_x, ob_y;
|
||||
|
||||
if( FormThbGet( thumb, 0) != TASK_PROCESS)
|
||||
return;
|
||||
|
||||
mt_objc_offset( FORM( win), TASK_PROCESS_LIST, &ob_x, &ob_y, app.aes_global);
|
||||
|
||||
if( !IS_IN( evnt.mx, evnt.my, ob_x, ob_y, dial[TASK_PROCESS_LIST].ob_width, dial[TASK_PROCESS_LIST].ob_height))
|
||||
return;
|
||||
|
||||
evnt.my -= ( ob_y + 15);
|
||||
|
||||
process_loop = process_root;
|
||||
|
||||
while( process_loop != NULL)
|
||||
{
|
||||
if(( process_loop->y_pos > evnt.my) && ( process_loop->y_pos < evnt.my + 13))
|
||||
{
|
||||
process_selected = process_loop;
|
||||
break;
|
||||
}
|
||||
|
||||
process_loop = process_loop->next;
|
||||
}
|
||||
|
||||
if( process_selected)
|
||||
{
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, 1);
|
||||
|
||||
if( dial[TASK_KILL].ob_state & DISABLED)
|
||||
{
|
||||
ObjcChange( OC_FORM, win, TASK_KILL, ~DISABLED, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDECL draw_process_list( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
memset( process_list_buffer.fd_addr, 0, process_list_buffer_lenght);
|
||||
|
||||
i = 0;
|
||||
process_loop = process_root;
|
||||
|
||||
|
||||
while( process_loop != NULL)
|
||||
{
|
||||
process_loop->y_pos = i - ( ypos * 13);
|
||||
|
||||
if(( process_loop->y_pos >= pblk->pb_h - 12) || ( process_loop->y_pos < 0))
|
||||
{
|
||||
process_loop = process_loop->next;
|
||||
i += 13;
|
||||
continue;
|
||||
}
|
||||
|
||||
draw_text_to_buffer( 2, process_loop->y_pos + 3, process_list_buffer.fd_wdwidth << 1, process_loop->name, &process_list_buffer);
|
||||
draw_text_to_buffer( 183, process_loop->y_pos + 3, process_list_buffer.fd_wdwidth << 1, process_loop->cpu_usage, &process_list_buffer);
|
||||
draw_text_to_buffer( pblk->pb_w - ( process_loop->ram_usage_txt_width + 4), process_loop->y_pos + 3, process_list_buffer.fd_wdwidth << 1, process_loop->ram_usage, &process_list_buffer);
|
||||
|
||||
i += 13;
|
||||
|
||||
process_loop = process_loop->next;
|
||||
}
|
||||
|
||||
xy[0] = 0;
|
||||
xy[1] = 0;
|
||||
xy[2] = pblk->pb_w - 1;
|
||||
xy[3] = pblk->pb_h - 1;
|
||||
xy[4] = pblk->pb_x;
|
||||
xy[5] = pblk->pb_y;
|
||||
xy[6] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[7] = pblk->pb_y + pblk->pb_h - 1;
|
||||
|
||||
vrt_cpyfm( win->graf->handle, MD_REPLACE, xy, &process_list_buffer, &screen, txt_color);
|
||||
|
||||
if( process_selected != NULL)
|
||||
{
|
||||
if(( process_selected->y_pos >= pblk->pb_h - 12) || ( process_selected->y_pos < 0))
|
||||
return;
|
||||
|
||||
xy[0] = 0;
|
||||
xy[1] = process_selected->y_pos;
|
||||
xy[2] = pblk->pb_w - 1;
|
||||
xy[3] = xy[1] + 12;
|
||||
xy[4] = pblk->pb_x;
|
||||
xy[5] = pblk->pb_y + process_selected->y_pos;
|
||||
xy[6] = pblk->pb_x + pblk->pb_w - 1;
|
||||
xy[7] = xy[5] + 12;
|
||||
vrt_cpyfm( win->graf->handle, MD_REPLACE, xy, &process_list_buffer, &screen, selected_txt_color);
|
||||
}
|
||||
}
|
||||
|
||||
static void calc_process_slider( WINDOW *win)
|
||||
{
|
||||
int16 max_mover_size;
|
||||
int16 full_win_size = ypos_max * 13;
|
||||
|
||||
max_mover_size = dial[TASK_VBACK].ob_height;
|
||||
|
||||
dial[TASK_VMOVER].ob_y = 0;
|
||||
dial[TASK_VMOVER].ob_height = max_mover_size;
|
||||
|
||||
if ( dial[TASK_PROCESS_LIST].ob_height < full_win_size)
|
||||
{
|
||||
float factor = ( float)dial[TASK_PROCESS_LIST].ob_height / ( float)full_win_size;
|
||||
float mover_size = MAX(( float)max_mover_size * factor, 6L);
|
||||
|
||||
slider_pos = 0;
|
||||
slider_step = ( float)max_mover_size / ( float)ypos_max;
|
||||
dial[TASK_VMOVER].ob_height = ( int16)( mover_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void CDECL taskman_dialog_kill( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
if( process_selected == NULL)
|
||||
return;
|
||||
|
||||
Pkill( process_selected->pid, SIGKILL);
|
||||
ObjcChange( mode, win, obj, ~SELECTED, TRUE);
|
||||
ObjcChange( mode, win, obj, DISABLED, TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void CDECL slid_up( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( mode, win, obj, SELECTED, TRUE);
|
||||
|
||||
do
|
||||
{
|
||||
if ( ypos > 0L)
|
||||
{
|
||||
ypos--;
|
||||
ObjcDraw( OC_FORM, win, TASK_PROCESS_LIST, 1);
|
||||
slider_pos -= slider_step;
|
||||
dial[TASK_VMOVER].ob_y = MAX( 0, ( int16)floor( slider_pos));
|
||||
ObjcDraw( OC_FORM, win, TASK_VBACK, 2);
|
||||
mt_evnt_timer( 100L, app.aes_global);
|
||||
}
|
||||
graf_mkstate( &dum, &dum, &res, &dum);
|
||||
|
||||
} while( res);
|
||||
|
||||
ObjcChange( mode, win, obj, ~SELECTED, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL slid_down( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
ObjcChange( mode, win, obj, SELECTED, TRUE);
|
||||
|
||||
do
|
||||
{
|
||||
if (( ypos < ( ypos_max - dial[TASK_PROCESS_LIST].ob_height / 13)) && ( ypos_max > dial[TASK_PROCESS_LIST].ob_height / 13))
|
||||
{
|
||||
ypos ++;
|
||||
ObjcDraw( OC_FORM, win, TASK_PROCESS_LIST, 1);
|
||||
slider_pos += slider_step;
|
||||
dial[TASK_VMOVER].ob_y = ( int16)floor( slider_pos);
|
||||
ObjcDraw( OC_FORM, win, TASK_VBACK, 2);
|
||||
mt_evnt_timer( 100L, app.aes_global);
|
||||
}
|
||||
graf_mkstate( &dum, &dum, &res, &dum);
|
||||
|
||||
} while( res);
|
||||
|
||||
ObjcChange( mode, win, obj, ~SELECTED, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void CDECL slid_vmover( WINDOW *win, int obj, int mode, void *data)
|
||||
{
|
||||
int32 old_ypos = ypos;
|
||||
|
||||
ObjcChange( mode, win, obj, SELECTED, TRUE);
|
||||
|
||||
graf_mouse( FLAT_HAND, NULL);
|
||||
|
||||
while( !wind_update( BEG_MCTRL));
|
||||
|
||||
res = graf_slidebox( dial, TASK_VBACK, TASK_VMOVER, 1);
|
||||
|
||||
wind_update( END_MCTRL);
|
||||
|
||||
ypos = MAX( 0, ( ypos_max - dial[TASK_PROCESS_LIST].ob_height / 13) * res / 1000L);
|
||||
|
||||
if( old_ypos != ypos)
|
||||
{
|
||||
slider_pos = ypos * slider_step;
|
||||
dial[TASK_VMOVER].ob_y = ( int16)floor( slider_pos);
|
||||
ObjcDraw( OC_FORM, win, TASK_VBACK, 2);
|
||||
ObjcDraw( OC_FORM, win, TASK_PROCESS_LIST, 1);
|
||||
}
|
||||
|
||||
graf_mouse( ARROW, NULL);
|
||||
|
||||
ObjcChange( mode, win, obj, ~SELECTED, TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void CDECL draw_cpu_average( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
xy[0] = xy[1] = 0;
|
||||
xy[2] = 300;
|
||||
xy[3] = 100;
|
||||
xy[4] = pblk->pb_x;
|
||||
xy[5] = pblk->pb_y;
|
||||
xy[6] = xy[4] + 300;
|
||||
xy[7] = xy[5] + 100;
|
||||
|
||||
vrt_cpyfm( win->graf->handle, MD_REPLACE, xy, &cpu_average_background, &screen, wanted_color);
|
||||
|
||||
x = pblk->pb_x;
|
||||
|
||||
for( i = 0, ii = 0; i < 101; x += 3)
|
||||
{
|
||||
cpu_history_point[ii++] = x;
|
||||
cpu_history_point[ii++] = pblk->pb_y + cpu_history[i++];
|
||||
}
|
||||
|
||||
vsl_color( win->graf->handle, CYAN);
|
||||
v_pline( win->graf->handle, 101, cpu_history_point);
|
||||
}
|
||||
|
||||
static void CDECL draw_name_button( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1] + pblk->pb_h - 1;
|
||||
|
||||
vsf_color( win->graf->handle, LWHITE);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1];
|
||||
xy[4] = xy[2];
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 2;
|
||||
xy[2] = xy[0] + pblk->pb_w - 2;
|
||||
xy[3] = xy[1];
|
||||
xy[4] = xy[2];
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, LBLACK);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 2;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = pblk->pb_y;
|
||||
xy[4] = xy[0] + pblk->pb_w - 2;
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, WHITE);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, pblk->pb_x + 5, pblk->pb_y + 3, BLACK, "Process name");
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void CDECL draw_cpu_button( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1] + pblk->pb_h - 1;
|
||||
|
||||
vsf_color( win->graf->handle, LWHITE);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1];
|
||||
xy[4] = xy[2];
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 2;
|
||||
xy[2] = xy[0] + pblk->pb_w - 2;
|
||||
xy[3] = xy[1];
|
||||
xy[4] = xy[2];
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, LBLACK);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 2;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = pblk->pb_y;
|
||||
xy[4] = xy[0] + pblk->pb_w - 2;
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, WHITE);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, pblk->pb_x + 25, pblk->pb_y + 3, BLACK, "CPU");
|
||||
|
||||
}
|
||||
|
||||
static void CDECL draw_ram_button( WINDOW *win, PARMBLK *pblk, void *data)
|
||||
{
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1] + pblk->pb_h - 1;
|
||||
|
||||
vsf_color( win->graf->handle, LWHITE);
|
||||
v_bar( win->graf->handle, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 1;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1];
|
||||
// xy[4] = xy[2];
|
||||
// xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, BLACK);
|
||||
v_pline( win->graf->handle, 2, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 2;
|
||||
xy[2] = xy[0] + pblk->pb_w - 1;
|
||||
xy[3] = xy[1];
|
||||
xy[4] = xy[2];
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, LBLACK);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
xy[0] = pblk->pb_x;
|
||||
xy[1] = pblk->pb_y + pblk->pb_h - 2;
|
||||
xy[2] = xy[0];
|
||||
xy[3] = pblk->pb_y;
|
||||
xy[4] = xy[0] + pblk->pb_w - 2;
|
||||
xy[5] = pblk->pb_y;
|
||||
|
||||
vsl_color( win->graf->handle, WHITE);
|
||||
v_pline( win->graf->handle, 3, xy);
|
||||
|
||||
draw_text( win->graf->handle, pblk->pb_x + 33, pblk->pb_y + 3, BLACK, "Memory Usage");
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void CDECL taskman_dialog_close( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0);
|
||||
|
||||
// zdebug( "close");
|
||||
}
|
||||
|
||||
static void CDECL taskman_dialog_free_ressource( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
while( process_root != NULL)
|
||||
process_delete( process_root->pid);
|
||||
|
||||
if( process_list_buffer.fd_addr)
|
||||
{
|
||||
gfree( process_list_buffer.fd_addr);
|
||||
process_list_buffer.fd_addr = NULL;
|
||||
}
|
||||
|
||||
// zdebug( "destroy");
|
||||
|
||||
taskman_win = NULL;
|
||||
thumb = NULL;
|
||||
}
|
||||
|
||||
void taskman_timer( void)
|
||||
{
|
||||
int old_process_nbr;
|
||||
|
||||
|
||||
switch( FormThbGet( thumb, 0))
|
||||
{
|
||||
case TASK_SYSTEM:
|
||||
if( old_stram != stram)
|
||||
{
|
||||
old_stram = stram;
|
||||
sprintf( ObjcString( dial, TASK_ST_FREE, NULL), "%ld", stram);
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_ST_FREE, 1);
|
||||
}
|
||||
|
||||
if( old_ttram != ttram)
|
||||
{
|
||||
old_ttram = ttram;
|
||||
sprintf( ObjcString( dial, TASK_TT_FREE, NULL), "%ld", ttram);
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_TT_FREE, 1);
|
||||
}
|
||||
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_CPU_AVERAGE, 1);
|
||||
|
||||
|
||||
Suptime( &uptime, loadaverage);
|
||||
updays = uptime / 86400;
|
||||
tmpdays = updays * 86400;
|
||||
uphours = (uptime - tmpdays) / 3600;
|
||||
tmphours = uphours * 3600;
|
||||
upmins = (uptime - tmpdays - tmphours) / 60;
|
||||
upsecs = (uptime - tmpdays - tmphours - ( upmins * 60));
|
||||
|
||||
sprintf( ObjcString( dial, TASK_UPTIME, NULL), "%ld days %ld hours %ld minutes %ld secs", updays, uphours, upmins, upsecs);
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_UPTIME, 1);
|
||||
break;
|
||||
|
||||
|
||||
case TASK_PROCESS:
|
||||
old_process_nbr = process_nbr;
|
||||
scan_process();
|
||||
|
||||
if( old_process_nbr != process_nbr)
|
||||
{
|
||||
ypos = 0;
|
||||
ypos_max = process_nbr;
|
||||
calc_process_slider( taskman_win);
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, 1);
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_VBACK, 2);
|
||||
}
|
||||
else
|
||||
ObjcDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, 1);
|
||||
|
||||
if( dial[TASK_LED1].ob_state & SELECTED)
|
||||
{
|
||||
ObjcChange( OC_FORM, taskman_win, TASK_LED1, NORMAL, 1);
|
||||
ObjcChange( OC_FORM, taskman_win, TASK_LED2, SELECTED, 1);
|
||||
}
|
||||
else if( dial[TASK_LED2].ob_state & SELECTED)
|
||||
{
|
||||
ObjcChange( OC_FORM, taskman_win, TASK_LED2, NORMAL, 1);
|
||||
ObjcChange( OC_FORM, taskman_win, TASK_LED3, SELECTED, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjcChange( OC_FORM, taskman_win, TASK_LED1, SELECTED, 1);
|
||||
ObjcChange( OC_FORM, taskman_win, TASK_LED3, NORMAL, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void taskman_dialog( void)
|
||||
{
|
||||
BITBLK *image;
|
||||
|
||||
int frms[] = { TASK_PANEL1, TASK_PANEL2, TASK_PANEL3};
|
||||
int buts[] = { TASK_PROCESS, TASK_SYSTEM, TASK_NETWORK};
|
||||
|
||||
if( taskman_win != NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
process_selected = NULL;
|
||||
|
||||
dial = get_tree( TASK);
|
||||
|
||||
sprintf( ObjcString( dial, TASK_ST_TOTAL, NULL), "%ld", total_stram);
|
||||
sprintf( ObjcString( dial, TASK_TT_TOTAL, NULL), "%ld", total_ttram);
|
||||
sprintf( ObjcString( dial, TASK_ST_FREE, NULL), "%ld", stram);
|
||||
sprintf( ObjcString( dial, TASK_TT_FREE, NULL), "%ld", ttram);
|
||||
|
||||
old_stram = stram;
|
||||
old_ttram = ttram;
|
||||
|
||||
Suptime( &uptime, loadaverage);
|
||||
updays = uptime / 86400;
|
||||
tmpdays = updays * 86400;
|
||||
uphours = (uptime - tmpdays) / 3600;
|
||||
tmphours = uphours * 3600;
|
||||
upmins = (uptime - tmpdays - tmphours) / 60;
|
||||
upsecs = (uptime - tmpdays - tmphours - ( upmins * 60));
|
||||
sprintf( ObjcString( dial, TASK_UPTIME, NULL), "%ld days %ld hours %ld minutes %ld secs", updays, uphours, upmins, upsecs);
|
||||
|
||||
dial[TASK_NETWORK].ob_flags |= HIDETREE;
|
||||
dial[TASK_KILL].ob_state |= DISABLED;
|
||||
|
||||
if( ( taskman_win = FormCreate( dial, NAME|MOVER|CLOSER, NULL, get_string( S_TASKMAN), NULL, TRUE, FALSE)) == NULL)
|
||||
return;
|
||||
|
||||
dial = FORM( taskman_win);
|
||||
|
||||
scan_process();
|
||||
|
||||
{
|
||||
ypos = 0;
|
||||
ypos_max = process_nbr;
|
||||
taskman_win->h_u = 13;
|
||||
|
||||
calc_process_slider( taskman_win);
|
||||
|
||||
ObjcAttachFormFunc( taskman_win, TASK_UP, slid_up, NULL);
|
||||
ObjcAttachFormFunc( taskman_win, TASK_DOWN, slid_down, NULL);
|
||||
ObjcAttachFormFunc( taskman_win, TASK_VMOVER, slid_vmover, NULL);
|
||||
}
|
||||
|
||||
thumb = FormThumb( taskman_win, frms, buts, 3);
|
||||
|
||||
|
||||
process_list_buffer_lenght = init_mfdb( &process_list_buffer, dial[TASK_PROCESS_LIST].ob_width, dial[TASK_PROCESS_LIST].ob_height, 1);
|
||||
|
||||
rsrc_gaddr( R_IMAGEDATA, CPU_AVERAGE, &image);
|
||||
|
||||
cpu_average_background.fd_w = 304;
|
||||
cpu_average_background.fd_h = 101;
|
||||
cpu_average_background.fd_wdwidth = ( 304 >> 4) + (( 304 % 16) != 0);
|
||||
cpu_average_background.fd_stand = 0;
|
||||
cpu_average_background.fd_nplanes = 1;
|
||||
cpu_average_background.fd_r1 = 0;
|
||||
cpu_average_background.fd_r2 = 0;
|
||||
cpu_average_background.fd_r3 = 0;
|
||||
cpu_average_background.fd_addr = (void*)image->bi_pdata;
|
||||
|
||||
|
||||
RsrcUserDraw( OC_FORM, taskman_win, TASK_CPU_AVERAGE, draw_cpu_average, NULL);
|
||||
RsrcUserDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, draw_process_list, NULL);
|
||||
RsrcUserDraw( OC_FORM, taskman_win, TASK_C_NAME, draw_name_button, NULL);
|
||||
RsrcUserDraw( OC_FORM, taskman_win, TASK_C_CPU, draw_cpu_button, NULL);
|
||||
RsrcUserDraw( OC_FORM, taskman_win, TASK_C_RAM, draw_ram_button, NULL);
|
||||
|
||||
EvntAttach( taskman_win, WM_CLOSED, taskman_dialog_close);
|
||||
EvntAdd( taskman_win, WM_XBUTTON, taskman_win_mouse_event, EV_BOT);
|
||||
EvntAdd( taskman_win, WM_DESTROY, taskman_dialog_free_ressource, EV_TOP);
|
||||
|
||||
ObjcAttachFormFunc( taskman_win, TASK_KILL, taskman_dialog_kill, NULL);
|
||||
}
|
||||
|
||||
7
sources/z-tools/trunk/ztask/taskman.h
Normal file
7
sources/z-tools/trunk/ztask/taskman.h
Normal file
@@ -0,0 +1,7 @@
|
||||
extern void taskman_dialog( void);
|
||||
extern void taskman_timer( void);
|
||||
extern WINDOW *taskman_win;
|
||||
|
||||
|
||||
|
||||
|
||||
43
sources/z-tools/trunk/ztask/types2b.h
Normal file
43
sources/z-tools/trunk/ztask/types2b.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef __2B_UNIVERSAL_TYPES__
|
||||
#define __2B_UNIVERSAL_TYPES__
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef signed long int32;
|
||||
typedef unsigned long uint32;
|
||||
typedef int32 fix31;
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef signed short int16;
|
||||
typedef unsigned short uint16;
|
||||
#define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */
|
||||
typedef signed long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
#else /* Compiler doesn't support 64 Bit Integers */
|
||||
typedef signed int int16;
|
||||
typedef unsigned int uint16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32 hi;
|
||||
uint32 lo;
|
||||
} int64;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32 hi;
|
||||
uint32 lo;
|
||||
} loff_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 hi;
|
||||
uint32 lo;
|
||||
} uint64;
|
||||
#endif
|
||||
|
||||
|
||||
typedef int32 boolean;
|
||||
|
||||
|
||||
#endif /* __2B_UNIVERSAL_TYPES__ */
|
||||
672
sources/z-tools/trunk/ztask/win.c
Normal file
672
sources/z-tools/trunk/ztask/win.c
Normal file
@@ -0,0 +1,672 @@
|
||||
#include "general.h"
|
||||
#include "app.h"
|
||||
#include "cpu.h"
|
||||
#include "popup.h"
|
||||
#include "string.h"
|
||||
#include "taskman.h"
|
||||
|
||||
static clock_t chrono_value, update_time = ( clock_t)( 100L);
|
||||
int16 cpu_usage = 0;
|
||||
int32 total_stram = 0;
|
||||
int32 total_ttram = 0;
|
||||
uint32 stram = 0;
|
||||
uint32 ttram = 0;
|
||||
int16 stram_percent = 0;
|
||||
int16 ttram_percent = 0;
|
||||
int16 bar_width = 6;
|
||||
int16 geek_area_width = 64;
|
||||
int16 cpu_history[101];
|
||||
int16 x_pos, w_pos, y_pos, h_pos, geek_area_x, clock_x, cpu_x, st_x, tt_x;
|
||||
int16 hcell = 8, dum, y_text_pos, x_space = 5, menu_enabled = FALSE;
|
||||
char xbios_time[15];
|
||||
|
||||
WINDOW *app_bar;
|
||||
OBJECT *icons = NULL;
|
||||
static void win_mouse_event( WINDOW *win, int16 buff[8]);
|
||||
static void win_redraw_event( WINDOW *win, int16 buff[8]);
|
||||
|
||||
|
||||
static void CDECL timer_function( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
app_data *tmp;
|
||||
clock_t current_t;
|
||||
clock_t relative_t;
|
||||
time_t curtime;
|
||||
struct tm *loctime;
|
||||
int16 old_app_nbr = app_nbr;
|
||||
static int skip = 0;
|
||||
|
||||
if( popup.win)
|
||||
{
|
||||
if( IS_IN( evnt.mx, evnt.my, popup.x_pos, popup.y_pos, popup.w_pos, popup.h_pos + 2))
|
||||
{
|
||||
popup.selected = popup_item_under_mouse();
|
||||
|
||||
if( popup.selected != popup.old_selected)
|
||||
{
|
||||
if( popup.selected >= 0)
|
||||
draw_page( popup.win, popup.item_pos[popup.selected].x1, popup.item_pos[popup.selected].y1, popup.item_pos[popup.selected].x2, popup.item_pos[popup.selected].y2);
|
||||
|
||||
if( popup.old_selected >= 0)
|
||||
draw_page( popup.win, popup.item_pos[popup.old_selected].x1, popup.item_pos[popup.old_selected].y1, popup.item_pos[popup.old_selected].x2, popup.item_pos[popup.old_selected].y2);
|
||||
|
||||
popup.old_selected = popup.selected;
|
||||
}
|
||||
}
|
||||
else if( menu_enabled == TRUE)
|
||||
{
|
||||
if( !IS_IN( evnt.mx, evnt.my, root->x_pos - 24, root->y_pos, 24, 23))
|
||||
popup_delete( popup.win);
|
||||
}
|
||||
else if( !IS_IN( evnt.mx, evnt.my, popup.entry->x_pos, popup.entry->y_pos, app_width, 23))
|
||||
popup_delete( popup.win);
|
||||
}
|
||||
|
||||
current_t = clock();
|
||||
|
||||
relative_t = current_t - chrono_value;
|
||||
|
||||
if( relative_t < update_time)
|
||||
return;
|
||||
|
||||
chrono_value = current_t;
|
||||
|
||||
cpu_usage = cpu_get_usage();
|
||||
|
||||
if( skip == 0)
|
||||
{
|
||||
memcpy( cpu_history, &cpu_history[1], 200);
|
||||
cpu_history[100] = 100 - cpu_usage;
|
||||
|
||||
if( show_clock == TRUE)
|
||||
{
|
||||
curtime = time( NULL);
|
||||
loctime = localtime( &curtime);
|
||||
|
||||
if( clock_us == TRUE)
|
||||
strftime( xbios_time, 12, "%I:%M:%S %p", loctime);
|
||||
else
|
||||
strftime( xbios_time, 12, "%H:%M:%S", loctime);
|
||||
}
|
||||
|
||||
if( show_system_info)
|
||||
{
|
||||
get_free_ram( &stram, &ttram);
|
||||
stram_percent = (int16)(( 100 * stram) / total_stram);
|
||||
|
||||
if( total_ttram != 0)
|
||||
ttram_percent = (int16)(( 100 * ttram) / total_ttram);
|
||||
|
||||
}
|
||||
|
||||
skip = 1;
|
||||
|
||||
tmp = selected;
|
||||
|
||||
app_data_search();
|
||||
|
||||
if( old_app_nbr == app_nbr)
|
||||
{
|
||||
draw_page( win, geek_area_x + 4, app.y + app.h - 19, geek_area_width - 9, 15);
|
||||
|
||||
if( selected != tmp)
|
||||
{
|
||||
if( selected != NULL)
|
||||
draw_page( win, selected->x_pos, selected->y_pos, app_width, h_pos);
|
||||
|
||||
if( old_selected != NULL)
|
||||
draw_page( win, old_selected->x_pos, old_selected->y_pos, app_width, h_pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
w_pos = geek_area_width + ( app_nbr * app_width) + 24;
|
||||
|
||||
while( w_pos > app.w)
|
||||
w_pos -= app_width;
|
||||
|
||||
x_pos = app.x + ( app.w - w_pos);
|
||||
w_pos -= 1;
|
||||
|
||||
WindSet( win, WF_WORKXYWH, x_pos, y_pos, w_pos, h_pos);
|
||||
|
||||
// Xaaes bug... with this AES, WindSet( win, WF_CURRXYWH,... doesn't redraw the taskbar.
|
||||
draw_page( win, x_pos, y_pos, w_pos, h_pos);
|
||||
}
|
||||
|
||||
if( taskman_win != NULL)
|
||||
taskman_timer();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_page( win, geek_area_x + 4, app.y + app.h - 19, geek_area_width - 9, 15);
|
||||
skip = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void CDECL win_mouse_event( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
app_data *scan = root, *tmp = NULL;
|
||||
|
||||
// evnt.nb_click = 0;
|
||||
|
||||
while( scan != NULL)
|
||||
{
|
||||
if( scan->x_pos == -1)
|
||||
continue;
|
||||
|
||||
if( IS_IN( evnt.mx, evnt.my, scan->x_pos, scan->y_pos, app_width, h_pos))
|
||||
{
|
||||
tmp = scan;
|
||||
break;
|
||||
}
|
||||
|
||||
scan = scan->next;
|
||||
}
|
||||
|
||||
|
||||
if( tmp != NULL)
|
||||
{
|
||||
int16 ap_cout;
|
||||
|
||||
old_selected = selected;
|
||||
selected = tmp;
|
||||
|
||||
if( old_selected != selected)
|
||||
{
|
||||
mt_appl_control( selected->id, APC_INFO, &ap_cout, app.aes_global);
|
||||
|
||||
if( ap_cout & APCI_HIDDEN)
|
||||
mt_appl_control( selected->id, APC_SHOW, &ap_cout, app.aes_global);
|
||||
|
||||
mt_appl_control( selected->id, APC_TOP, &ap_cout, app.aes_global);
|
||||
|
||||
draw_page( win, selected->x_pos, selected->y_pos, app_width, h_pos);
|
||||
|
||||
if( old_selected != NULL)
|
||||
draw_page( win, old_selected->x_pos, old_selected->y_pos, app_width, h_pos);
|
||||
}
|
||||
}
|
||||
|
||||
if( popup.win)
|
||||
return;
|
||||
|
||||
/* if we are on the menu icon or on an application item, we open a popup */
|
||||
if(( tmp != NULL) && ( evnt.mbut == 2))
|
||||
{
|
||||
char dummy[MAXNAMLEN];
|
||||
uint32 dummy_var;
|
||||
|
||||
popup.item_nbr = 0;
|
||||
|
||||
get_info_by_pid((int)tmp->pid, dummy, popup.item_name[popup.item_nbr], &dummy_var);
|
||||
|
||||
popup.selectable[popup.item_nbr] = FALSE;
|
||||
popup.function[popup.item_nbr] = 0;
|
||||
popup.icon[popup.item_nbr++] = ICONS_MEM;
|
||||
|
||||
popup.selectable[popup.item_nbr] = FALSE;
|
||||
popup.function[popup.item_nbr] = 0;
|
||||
popup.item_name[popup.item_nbr][0] = '\0';
|
||||
popup.icon[popup.item_nbr++] = -1;
|
||||
|
||||
/* popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_HIDE;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_HIDE));
|
||||
popup.icon[popup.item_nbr++] = -1;
|
||||
*/
|
||||
popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_QUIT;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_QUIT));
|
||||
popup.icon[popup.item_nbr++] = -1;
|
||||
|
||||
popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_KILL;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_KILL));
|
||||
popup.icon[popup.item_nbr++] = -1;
|
||||
|
||||
open_popup( tmp);
|
||||
}
|
||||
else if(( tmp == NULL) && ( evnt.mx < root->x_pos) && ( evnt.mbut == 1))
|
||||
{
|
||||
int16 x, y;
|
||||
|
||||
popup.item_nbr = 0;
|
||||
|
||||
popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_TASKMANAGER;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_TASKMAN));
|
||||
popup.icon[popup.item_nbr++] = ICONS_TASK;
|
||||
|
||||
popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_PREFERENCES;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_PREFS));
|
||||
popup.icon[popup.item_nbr++] = ICONS_CONFIGURE;
|
||||
|
||||
popup.selectable[popup.item_nbr] = FALSE;
|
||||
popup.function[popup.item_nbr] = 0;
|
||||
popup.item_name[popup.item_nbr][0] = '\0';
|
||||
popup.icon[popup.item_nbr++] = -1;
|
||||
|
||||
popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_QUIT_ZBAR;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_QUIT));
|
||||
popup.icon[popup.item_nbr++] = ICONS_ARROW;
|
||||
|
||||
popup.selectable[popup.item_nbr] = TRUE;
|
||||
popup.function[popup.item_nbr] = F_SHUTDOWN;
|
||||
strcpy( popup.item_name[popup.item_nbr], get_string( S_SHUTDOWN));
|
||||
popup.icon[popup.item_nbr++] = ICONS_SHUTDOWN;
|
||||
|
||||
menu_enabled = TRUE;
|
||||
WindGet( win, WF_WORKXYWH, &x, &y, &dum, &dum);
|
||||
draw_page( win, x, y, 25, 24);
|
||||
|
||||
open_popup( tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CDECL win_redraw_event( WINDOW *win, int16 buff[8])
|
||||
{
|
||||
int16 x_text_pos, xw, pxy[10], background, top_line, lower_line, title_shadow, title_color;
|
||||
app_data *scan = root;
|
||||
|
||||
xw = x_pos;
|
||||
|
||||
geek_area_x = xw + w_pos - geek_area_width;
|
||||
|
||||
/* we draw the menu area */
|
||||
pxy[0] = xw;
|
||||
pxy[1] = y_pos;
|
||||
pxy[2] = pxy[0] + 23;
|
||||
pxy[3] = pxy[1] + h_pos - 1;
|
||||
|
||||
if( menu_enabled == TRUE)
|
||||
{
|
||||
background = ( int16)button_on_background;
|
||||
top_line = ( int16)button_on_dark_color;
|
||||
lower_line = ( int16)button_on_light_color;
|
||||
title_color = ( int16)button_on_text_color;
|
||||
title_shadow = ( int16)button_on_text_shadow_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
background = ( int16)button_off_background;
|
||||
top_line = ( int16)button_off_light_color;
|
||||
lower_line = ( int16)button_off_dark_color;
|
||||
title_color = ( int16)button_off_text_color;
|
||||
title_shadow = ( int16)button_off_text_shadow_color;
|
||||
}
|
||||
|
||||
vsf_color( win->graf->handle, background);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
pxy[1] = pxy[3];
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = y_pos;
|
||||
pxy[4] = pxy[0] + 22;
|
||||
pxy[5] = y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, top_line);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
pxy[0] = pxy[4] + 1;
|
||||
pxy[1] = y_pos;
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = pxy[1] + h_pos - 1;
|
||||
pxy[4] = xw;
|
||||
pxy[5] = pxy[3];
|
||||
|
||||
vsl_color( win->graf->handle, lower_line);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
icons[ICONS_MENU].ob_x = xw + 4;
|
||||
icons[ICONS_MENU].ob_y = y_pos + 2;
|
||||
|
||||
mt_objc_draw( icons, ICONS_MENU, 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global);
|
||||
|
||||
xw += 24;
|
||||
|
||||
|
||||
/* We draw the application list */
|
||||
while( scan != NULL)
|
||||
{
|
||||
if(( pxy[0] + app_width - 2) > geek_area_x)
|
||||
{
|
||||
scan->x_pos = -1;
|
||||
scan->y_pos = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
scan->x_pos = xw;
|
||||
scan->y_pos = y_pos;
|
||||
xw += app_width;
|
||||
|
||||
pxy[0] = scan->x_pos;
|
||||
pxy[1] = y_pos;
|
||||
pxy[2] = pxy[0] + app_width - 1;
|
||||
pxy[3] = pxy[1] + h_pos - 1;
|
||||
|
||||
if( scan == selected)
|
||||
{
|
||||
background = ( int16)button_on_background;
|
||||
top_line = ( int16)button_on_dark_color;
|
||||
lower_line = ( int16)button_on_light_color;
|
||||
title_color = ( int16)button_on_text_color;
|
||||
title_shadow = ( int16)button_on_text_shadow_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
background = ( int16)button_off_background;
|
||||
top_line = ( int16)button_off_light_color;
|
||||
lower_line = ( int16)button_off_dark_color;
|
||||
title_color = ( int16)button_off_text_color;
|
||||
title_shadow = ( int16)button_off_text_shadow_color;
|
||||
}
|
||||
|
||||
vsf_color( win->graf->handle, background);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
pxy[1] = pxy[3];
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = y_pos;
|
||||
pxy[4] = pxy[0] + app_width - 2;
|
||||
pxy[5] = y_pos;
|
||||
|
||||
vsl_color( win->graf->handle, top_line);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
pxy[0] = pxy[4] + 1;
|
||||
pxy[1] = y_pos;
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = pxy[1] + h_pos - 1;
|
||||
pxy[4] = scan->x_pos;
|
||||
pxy[5] = pxy[3];
|
||||
|
||||
vsl_color( win->graf->handle, lower_line);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
x_text_pos = scan->x_pos + (( app_width - scan->name_shown_width) >> 1);
|
||||
|
||||
draw_text( win->graf->handle, x_text_pos + 1, y_text_pos + 1, ( int16)title_shadow, scan->name_shown);
|
||||
draw_text( win->graf->handle, x_text_pos, y_text_pos, ( int16)title_color, scan->name_shown);
|
||||
|
||||
}
|
||||
|
||||
scan = scan->next;
|
||||
}
|
||||
|
||||
/* draw the "geek" area */
|
||||
pxy[0] = xw + 2;
|
||||
pxy[1] = y_pos + 2;
|
||||
pxy[2] = pxy[0] + geek_area_width - 6;
|
||||
pxy[3] = pxy[1] + h_pos - 5;
|
||||
|
||||
vsf_color( win->graf->handle, geek_area_color);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
pxy[0] = xw;
|
||||
pxy[1] = y_pos;
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = pxy[1] + h_pos - 1;
|
||||
pxy[4] = pxy[2] + geek_area_width - 2;
|
||||
pxy[5] = pxy[3];
|
||||
pxy[6] = pxy[4];
|
||||
pxy[7] = pxy[1];
|
||||
pxy[8] = pxy[0];
|
||||
pxy[9] = pxy[1];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)button_off_background);
|
||||
v_pline( win->graf->handle, 5, pxy);
|
||||
|
||||
pxy[0]++;
|
||||
pxy[1] = pxy[3] - 1;
|
||||
pxy[2] = pxy[0];
|
||||
pxy[3] = y_pos + 1;
|
||||
pxy[4]--;
|
||||
pxy[5] = pxy[3];
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)geek_area_dark_line);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
pxy[2] = pxy[4];
|
||||
pxy[3] = pxy[1];
|
||||
pxy[5] = y_pos + 2;
|
||||
|
||||
vsl_color( win->graf->handle, ( int16)geek_area_light_line);
|
||||
v_pline( win->graf->handle, 3, pxy);
|
||||
|
||||
|
||||
/* draw the cpu % in the "geek" area */
|
||||
if( show_system_info)
|
||||
{
|
||||
/* the CPU usage */
|
||||
pxy[0] = cpu_x + geek_area_x;
|
||||
pxy[1] = y_pos + 3;
|
||||
pxy[2] = pxy[0] + bar_width - 1;
|
||||
pxy[3] = pxy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
pxy[0] = pxy[0] + 1;
|
||||
pxy[2] = pxy[2] - 1;
|
||||
pxy[3] = y_pos + 16;
|
||||
|
||||
if( cpu_usage >= 8)
|
||||
{
|
||||
if( cpu_usage >= 99)
|
||||
pxy[1] = y_pos + 4;
|
||||
else if( cpu_usage >= 91)
|
||||
pxy[1] = y_pos + 5;
|
||||
else if( cpu_usage >= 83)
|
||||
pxy[1] = y_pos + 6;
|
||||
else if( cpu_usage >= 75)
|
||||
pxy[1] = y_pos + 7;
|
||||
else if( cpu_usage >= 66)
|
||||
pxy[1] = y_pos + 8;
|
||||
else if( cpu_usage >= 58)
|
||||
pxy[1] = y_pos + 9;
|
||||
else if( cpu_usage >= 50)
|
||||
pxy[1] = y_pos + 10;
|
||||
else if( cpu_usage >= 41)
|
||||
pxy[1] = y_pos + 11;
|
||||
else if( cpu_usage >= 33)
|
||||
pxy[1] = y_pos + 12;
|
||||
else if( cpu_usage >= 25)
|
||||
pxy[1] = y_pos + 13;
|
||||
else if( cpu_usage >= 16)
|
||||
pxy[1] = y_pos + 14;
|
||||
else
|
||||
pxy[1] = y_pos + 15;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)cpu_bar_color);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
}
|
||||
|
||||
/* the STRAM usage */
|
||||
pxy[0] = st_x + geek_area_x;
|
||||
pxy[1] = y_pos + 3;
|
||||
pxy[2] = pxy[0] + bar_width - 1;
|
||||
pxy[3] = pxy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
|
||||
pxy[0] = pxy[0] + 1;
|
||||
pxy[2] = pxy[2] - 1;
|
||||
pxy[3] = y_pos + 16;
|
||||
|
||||
if( stram_percent >= 8)
|
||||
{
|
||||
if( stram_percent >= 99)
|
||||
pxy[1] = y_pos + 4;
|
||||
else if( stram_percent >= 91)
|
||||
pxy[1] = y_pos + 5;
|
||||
else if( stram_percent >= 83)
|
||||
pxy[1] = y_pos + 6;
|
||||
else if( stram_percent >= 75)
|
||||
pxy[1] = y_pos + 7;
|
||||
else if( stram_percent >= 66)
|
||||
pxy[1] = y_pos + 8;
|
||||
else if( stram_percent >= 58)
|
||||
pxy[1] = y_pos + 9;
|
||||
else if( stram_percent >= 50)
|
||||
pxy[1] = y_pos + 10;
|
||||
else if( stram_percent >= 41)
|
||||
pxy[1] = y_pos + 11;
|
||||
else if( stram_percent >= 33)
|
||||
pxy[1] = y_pos + 12;
|
||||
else if( stram_percent >= 25)
|
||||
pxy[1] = y_pos + 13;
|
||||
else if( stram_percent >= 16)
|
||||
pxy[1] = y_pos + 14;
|
||||
else
|
||||
pxy[1] = y_pos + 15;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)st_bar_color);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
}
|
||||
|
||||
/* the TTRAM usage */
|
||||
|
||||
if( total_ttram != 0)
|
||||
{
|
||||
pxy[0] = tt_x + geek_area_x;
|
||||
pxy[1] = y_pos + 3;
|
||||
pxy[2] = pxy[0] + bar_width - 1;
|
||||
pxy[3] = pxy[1] + 14;
|
||||
|
||||
vsf_color( win->graf->handle, BLACK);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
|
||||
|
||||
pxy[0] = pxy[0] + 1;
|
||||
pxy[2] = pxy[2] - 1;
|
||||
pxy[3] = y_pos + 16;
|
||||
|
||||
if( ttram_percent >= 8)
|
||||
{
|
||||
if( ttram_percent >= 99)
|
||||
pxy[1] = y_pos + 4;
|
||||
else if( ttram_percent >= 91)
|
||||
pxy[1] = y_pos + 5;
|
||||
else if( ttram_percent >= 83)
|
||||
pxy[1] = y_pos + 6;
|
||||
else if( ttram_percent >= 75)
|
||||
pxy[1] = y_pos + 7;
|
||||
else if( ttram_percent >= 66)
|
||||
pxy[1] = y_pos + 8;
|
||||
else if( ttram_percent >= 58)
|
||||
pxy[1] = y_pos + 9;
|
||||
else if( ttram_percent >= 50)
|
||||
pxy[1] = y_pos + 10;
|
||||
else if( ttram_percent >= 41)
|
||||
pxy[1] = y_pos + 11;
|
||||
else if( ttram_percent >= 33)
|
||||
pxy[1] = y_pos + 12;
|
||||
else if( ttram_percent >= 25)
|
||||
pxy[1] = y_pos + 13;
|
||||
else if( ttram_percent >= 16)
|
||||
pxy[1] = y_pos + 14;
|
||||
else
|
||||
pxy[1] = y_pos + 15;
|
||||
|
||||
vsf_color( win->graf->handle, ( int16)tt_bar_color);
|
||||
v_bar( win->graf->handle, pxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* draw the clock in the "geek" area */
|
||||
if( show_clock == TRUE)
|
||||
{
|
||||
draw_text( win->graf->handle, clock_x + geek_area_x, y_text_pos, (int16)geek_area_text_color, xbios_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void set_component_position( void)
|
||||
{
|
||||
int16 text_width, x = x_space + 2;
|
||||
|
||||
if( show_system_info)
|
||||
{
|
||||
cpu_x = x;
|
||||
x += ( bar_width + 2);
|
||||
|
||||
if( total_ttram != 0)
|
||||
{
|
||||
st_x = x;
|
||||
x += ( bar_width + 2);
|
||||
|
||||
tt_x = x;
|
||||
x += ( bar_width + x_space);
|
||||
}
|
||||
else
|
||||
{
|
||||
st_x = x;
|
||||
x += ( bar_width + x_space);
|
||||
|
||||
tt_x = x;
|
||||
}
|
||||
}
|
||||
|
||||
if( show_clock == TRUE)
|
||||
{
|
||||
clock_x = x;
|
||||
|
||||
if( clock_us == FALSE)
|
||||
text_width = get_text_width( "00:00:00");
|
||||
else
|
||||
text_width = get_text_width( "00:00:00 PM");
|
||||
|
||||
x += ( text_width + x_space);
|
||||
}
|
||||
|
||||
geek_area_width = x + 1;
|
||||
y_text_pos = app.y + app.h - 14;
|
||||
}
|
||||
|
||||
|
||||
void main_win( void)
|
||||
{
|
||||
chrono_value = clock();
|
||||
|
||||
rsrc_gaddr( 0, ICONS, &icons);
|
||||
popup.win = NULL;
|
||||
|
||||
app_bar = WindCreate( 0, app.x, app.y, app.w, app.h);
|
||||
|
||||
EvntAttach( app_bar, WM_REDRAW, win_redraw_event);
|
||||
EvntAttach( app_bar, WM_XBUTTON, win_mouse_event);
|
||||
|
||||
set_component_position();
|
||||
app_data_search();
|
||||
|
||||
w_pos = geek_area_width + ( app_nbr * app_width) + 24;
|
||||
|
||||
while( w_pos > app.w)
|
||||
w_pos -= app_width;
|
||||
|
||||
x_pos = app.x + ( app.w - w_pos);
|
||||
w_pos -= 1;
|
||||
y_pos = app.y + app.h - 21;
|
||||
|
||||
|
||||
WindCalc( WC_BORDER, app_bar, x_pos, y_pos, w_pos, 22, &x_pos, &y_pos, &w_pos, &h_pos);
|
||||
|
||||
WindSet( app_bar, WF_BEVENT, BEVENT_WORK, 0, 0, 0);
|
||||
WindOpen( app_bar, x_pos, y_pos, w_pos, h_pos);
|
||||
EvntAttach( app_bar, WM_XTIMER, timer_function);
|
||||
WindGet( app_bar, WF_WORKXYWH, &x_pos, &y_pos, &w_pos, &h_pos);
|
||||
|
||||
h_pos = 21;
|
||||
}
|
||||
|
||||
20
sources/z-tools/trunk/ztask/win.h
Normal file
20
sources/z-tools/trunk/ztask/win.h
Normal file
@@ -0,0 +1,20 @@
|
||||
extern int16 cpu_usage;
|
||||
extern int32 total_stram;
|
||||
extern int32 total_ttram;
|
||||
extern uint32 stram;
|
||||
extern uint32 ttram;
|
||||
extern int16 bar_width;
|
||||
extern int16 geek_area_width;
|
||||
extern int16 geek_area_border_width;
|
||||
extern int16 hcell, x_space;
|
||||
extern int16 x_pos, w_pos, y_pos, h_pos;
|
||||
|
||||
extern WINDOW *app_bar;
|
||||
extern OBJECT *icons;
|
||||
extern int16 x_space, menu_enabled;
|
||||
extern int16 cpu_history[100];
|
||||
|
||||
extern void set_component_position( void);
|
||||
|
||||
|
||||
|
||||
BIN
sources/z-tools/trunk/ztask/ztask.hrd
Normal file
BIN
sources/z-tools/trunk/ztask/ztask.hrd
Normal file
Binary file not shown.
BIN
sources/z-tools/trunk/ztask/ztask.rsc
Normal file
BIN
sources/z-tools/trunk/ztask/ztask.rsc
Normal file
Binary file not shown.
102
sources/z-tools/trunk/ztask/ztask.rsh
Normal file
102
sources/z-tools/trunk/ztask/ztask.rsh
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Resource C-Header-File v1.95 f<>r ResourceMaster ab v2.06 by ARDISOFT */
|
||||
|
||||
#define ICONS 0 /* form/dial */
|
||||
#define ICONS_CPU 3 /* CICON in tree ICONS */
|
||||
#define ICONS_MEM 4 /* CICON in tree ICONS */
|
||||
#define ICONS_ARROW 5 /* CICON in tree ICONS */
|
||||
#define ICONS_NET 6 /* CICON in tree ICONS */
|
||||
#define ICONS_LED 7 /* CICON in tree ICONS */
|
||||
#define ICONS_MENU 8 /* CICON in tree ICONS */
|
||||
#define ICONS_SHUTDOWN 9 /* CICON in tree ICONS */
|
||||
#define ICONS_CONFIGURE 1 /* CICON in tree ICONS */
|
||||
#define ICONS_TASK 2 /* CICON in tree ICONS */
|
||||
|
||||
#define SHUTDOWN_DIAL 1 /* form/dial */
|
||||
#define SHUTDOWN_DIAL_OK 1 /* BUTTON in tree SHUTDOWN_DIAL */
|
||||
#define SHUTDOWN_DIAL_WARN 3 /* BUTTON in tree SHUTDOWN_DIAL */
|
||||
#define SHUTDOWN_DIAL_COLD 4 /* BUTTON in tree SHUTDOWN_DIAL */
|
||||
#define SHUTDOWN_DIAL_HALT 5 /* BUTTON in tree SHUTDOWN_DIAL */
|
||||
#define SHUTDOWN_DIAL_CANCEL 6 /* BUTTON in tree SHUTDOWN_DIAL */
|
||||
|
||||
#define TASK 2 /* form/dial */
|
||||
#define TASK_PANEL3 1 /* BUTTON in tree TASK */
|
||||
#define TASK_PANEL2 3 /* BUTTON in tree TASK */
|
||||
#define TASK_CPU_AVERAGE 5 /* BOX in tree TASK */
|
||||
#define TASK_CPU 6 /* CICON in tree TASK */
|
||||
#define TASK_ST_TOTAL 9 /* TEXT in tree TASK */
|
||||
#define TASK_TT_TOTAL 11 /* TEXT in tree TASK */
|
||||
#define TASK_ST_FREE 13 /* TEXT in tree TASK */
|
||||
#define TASK_TT_FREE 15 /* TEXT in tree TASK */
|
||||
#define TASK_UPTIME 17 /* BOXTEXT in tree TASK */
|
||||
#define TASK_MEM 18 /* CICON in tree TASK */
|
||||
#define TASK_SHUTDOWN 19 /* CICON in tree TASK */
|
||||
#define TASK_PANEL1 20 /* BUTTON in tree TASK */
|
||||
#define TASK_BOX_00 21 /* BOX in tree TASK */
|
||||
#define TASK_UP 22 /* CICON in tree TASK */
|
||||
#define TASK_DOWN 23 /* CICON in tree TASK */
|
||||
#define TASK_VBACK 24 /* BOX in tree TASK */
|
||||
#define TASK_VMOVER 25 /* BOX in tree TASK */
|
||||
#define TASK_KILL 26 /* BUTTON in tree TASK */
|
||||
#define TASK_PROCESS_LIST 28 /* BOX in tree TASK */
|
||||
#define TASK_C_NAME 32 /* BOX in tree TASK */
|
||||
#define TASK_C_CPU 33 /* BOX in tree TASK */
|
||||
#define TASK_C_RAM 34 /* BOX in tree TASK */
|
||||
#define TASK_LED1 35 /* CICON in tree TASK */
|
||||
#define TASK_LED2 36 /* CICON in tree TASK */
|
||||
#define TASK_LED3 37 /* CICON in tree TASK */
|
||||
#define TASK_PROCESS 29 /* BUTTON in tree TASK */
|
||||
#define TASK_SYSTEM 30 /* BUTTON in tree TASK */
|
||||
#define TASK_NETWORK 31 /* BUTTON in tree TASK */
|
||||
|
||||
#define QUIT 3 /* form/dial */
|
||||
#define QUIT_NO 4 /* BUTTON in tree QUIT */
|
||||
#define QUIT_YES 5 /* BUTTON in tree QUIT */
|
||||
|
||||
#define PREFS 4 /* form/dial */
|
||||
#define PREFS_PANEL2 1 /* BUTTON in tree PREFS */
|
||||
#define PREFS_SYSTEM_INFO 2 /* BUTTON in tree PREFS */
|
||||
#define PREFS_SHOW_ACC 3 /* BUTTON in tree PREFS */
|
||||
#define PREFS_SHOW_US_CLOCK 10 /* BUTTON in tree PREFS */
|
||||
#define PREFS_SHOW_CLOCK 11 /* BUTTON in tree PREFS */
|
||||
#define PREFS_PANEL1 12 /* BUTTON in tree PREFS */
|
||||
#define PREFS_PREVIEW 14 /* BOX in tree PREFS */
|
||||
#define PREFS_OFF_BACK 17 /* BOX in tree PREFS */
|
||||
#define PREFS_OFF_LINE2 19 /* BOX in tree PREFS */
|
||||
#define PREFS_OFF_LINE1 20 /* BOX in tree PREFS */
|
||||
#define PREFS_OFF_TEXT1 22 /* BOX in tree PREFS */
|
||||
#define PREFS_OFF_TEXT2 23 /* BOX in tree PREFS */
|
||||
#define PREFS_ON_BACK 26 /* BOX in tree PREFS */
|
||||
#define PREFS_ON_LINE2 28 /* BOX in tree PREFS */
|
||||
#define PREFS_ON_LINE1 29 /* BOX in tree PREFS */
|
||||
#define PREFS_ON_TEXT1 31 /* BOX in tree PREFS */
|
||||
#define PREFS_ON_TEXT2 32 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_BACK 35 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_LINE2 37 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_LINE1 38 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_RAM1 40 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_CPU 41 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_RAM2 43 /* BOX in tree PREFS */
|
||||
#define PREFS_GEEK_TEXT 50 /* BOX in tree PREFS */
|
||||
#define PREFS_COLOR 44 /* BUTTON in tree PREFS */
|
||||
#define PREFS_MISC 45 /* BUTTON in tree PREFS */
|
||||
#define PREFS_OK 46 /* BUTTON in tree PREFS */
|
||||
#define PREFS_CANCEL 47 /* BUTTON in tree PREFS */
|
||||
#define PREFS_DEFAULT 48 /* BUTTON in tree PREFS */
|
||||
|
||||
#define S_SHUTDOWN 0 /* Free string */
|
||||
|
||||
#define S_PREFS 1 /* Free string */
|
||||
|
||||
#define S_TASKMAN 2 /* Free string */
|
||||
|
||||
#define S_KILL 3 /* Free string */
|
||||
|
||||
#define S_QUIT 4 /* Free string */
|
||||
|
||||
#define S_HIDE 5 /* Free string */
|
||||
|
||||
#define S_SCREENSHOT 6 /* Free string */
|
||||
|
||||
#define F_SHOW 7 /* Free string */
|
||||
|
||||
#define CPU_AVERAGE 0 /* Free image */
|
||||
95
sources/z-tools/trunk/ztask/ztask.rsm
Normal file
95
sources/z-tools/trunk/ztask/ztask.rsm
Normal file
@@ -0,0 +1,95 @@
|
||||
ResourceMaster v3.5
|
||||
#C 5@8@1@0@
|
||||
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
|
||||
#FoHRD@rsm2out@HRD@hrd@@@[HRD-File@0@
|
||||
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
|
||||
#R 0@0@3@1@3@1@
|
||||
#M 2001011@0@7728@580@
|
||||
#T 0@2@ICONS@@10@@
|
||||
#O 3@33@CPU@@
|
||||
#O 4@33@MEM@@
|
||||
#O 5@33@ARROW@@
|
||||
#O 6@33@NET@@
|
||||
#O 7@33@LED@@
|
||||
#O 8@33@MENU@@
|
||||
#O 9@33@SHUTDOWN@@
|
||||
#O 1@33@CONFIGURE@@
|
||||
#O 2@33@TASK@@
|
||||
#T 1@2@SHUTDOWN_DIAL@@7@@
|
||||
#O 1@26@OK@@
|
||||
#O 3@26@WARN@@
|
||||
#O 4@26@COLD@@
|
||||
#O 5@26@HALT@@
|
||||
#O 6@26@CANCEL@@
|
||||
#T 2@2@TASK@@38@@
|
||||
#O 1@26@PANEL3@@
|
||||
#O 3@26@PANEL2@@
|
||||
#O 5@20@CPU_AVERAGE@@
|
||||
#O 6@33@CPU@@
|
||||
#O 9@21@ST_TOTAL@@
|
||||
#O 11@21@TT_TOTAL@@
|
||||
#O 13@21@ST_FREE@@
|
||||
#O 15@21@TT_FREE@@
|
||||
#O 17@22@UPTIME@@
|
||||
#O 18@33@MEM@@
|
||||
#O 19@33@SHUTDOWN@@
|
||||
#O 20@26@PANEL1@@
|
||||
#O 21@20@BOX_00@@
|
||||
#O 22@33@UP@@
|
||||
#O 23@33@DOWN@@
|
||||
#O 24@20@VBACK@@
|
||||
#O 25@20@VMOVER@@
|
||||
#O 26@26@KILL@@
|
||||
#O 28@20@PROCESS_LIST@@
|
||||
#O 32@20@C_NAME@@
|
||||
#O 33@20@C_CPU@@
|
||||
#O 34@20@C_RAM@@
|
||||
#O 35@33@LED1@@
|
||||
#O 36@33@LED2@@
|
||||
#O 37@33@LED3@@
|
||||
#O 29@26@PROCESS@@
|
||||
#O 30@26@SYSTEM@@
|
||||
#O 31@26@NETWORK@@
|
||||
#T 3@2@QUIT@@6@@
|
||||
#O 4@26@NO@@
|
||||
#O 5@26@YES@@
|
||||
#T 4@2@PREFS@@51@@
|
||||
#O 1@26@PANEL2@@
|
||||
#O 2@26@SYSTEM_INFO@@
|
||||
#O 3@26@SHOW_ACC@@
|
||||
#O 10@26@SHOW_US_CLOCK@@
|
||||
#O 11@26@SHOW_CLOCK@@
|
||||
#O 12@26@PANEL1@@
|
||||
#O 14@20@PREVIEW@@
|
||||
#O 17@20@OFF_BACK@@
|
||||
#O 19@20@OFF_LINE2@@
|
||||
#O 20@20@OFF_LINE1@@
|
||||
#O 22@20@OFF_TEXT1@@
|
||||
#O 23@20@OFF_TEXT2@@
|
||||
#O 26@20@ON_BACK@@
|
||||
#O 28@20@ON_LINE2@@
|
||||
#O 29@20@ON_LINE1@@
|
||||
#O 31@20@ON_TEXT1@@
|
||||
#O 32@20@ON_TEXT2@@
|
||||
#O 35@20@GEEK_BACK@@
|
||||
#O 37@20@GEEK_LINE2@@
|
||||
#O 38@20@GEEK_LINE1@@
|
||||
#O 40@20@GEEK_RAM1@@
|
||||
#O 41@20@GEEK_CPU@@
|
||||
#O 43@20@GEEK_RAM2@@
|
||||
#O 50@20@GEEK_TEXT@@
|
||||
#O 44@26@COLOR@@
|
||||
#O 45@26@MISC@@
|
||||
#O 46@26@OK@@
|
||||
#O 47@26@CANCEL@@
|
||||
#O 48@26@DEFAULT@@
|
||||
#S 0@5@S_SHUTDOWN@@
|
||||
#S 1@5@S_PREFS@@
|
||||
#S 2@5@S_TASKMAN@@
|
||||
#S 3@5@S_KILL@@
|
||||
#S 4@5@S_QUIT@@
|
||||
#S 5@5@S_HIDE@@
|
||||
#S 6@5@S_SCREENSHOT@@
|
||||
#S 7@5@F_SHOW@@
|
||||
#I 0@6@CPU_AVERAGE@@
|
||||
#c 8983@
|
||||
Reference in New Issue
Block a user