Aggiunto Banner iniziale alle applicazioni

git-svn-id: svn://10.65.10.50/trunk@247 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-09-15 10:16:07 +00:00
parent a333152c88
commit 3d2dbf1fe6
8 changed files with 319 additions and 250 deletions

View File

@ -15,17 +15,32 @@
#include <bagn002.h> #include <bagn002.h>
///////////////////////////////////////////////////////////
// Metodi di accesso globali all'applicazione corrente
///////////////////////////////////////////////////////////
HIDDEN XVT_CONFIG cfg; HIDDEN XVT_CONFIG cfg;
HIDDEN TApplication* application = NULL; HIDDEN TApplication* _application = NULL;
HIDDEN long savefirm = 0; HIDDEN long savefirm = 0;
TApplication* MainApp() TApplication* MainApp()
{ {
CHECK(application, "NULL application!"); CHECK(_application, "NULL application!");
return application; return _application;
} }
bool xvt_running() { return application != NULL; } TApplication& main_app()
{
CHECK(_application, "NULL application!");
return *_application;
}
bool xvt_running() { return _application != NULL; }
///////////////////////////////////////////////////////////
// Gestione dello sfondo della finestra principale
///////////////////////////////////////////////////////////
HIDDEN long backdrop_eh( WINDOW win, EVENT* ep) HIDDEN long backdrop_eh( WINDOW win, EVENT* ep)
{ {
@ -59,8 +74,66 @@ HIDDEN void create_backdrop( void )
#endif #endif
} }
///////////////////////////////////////////////////////////
// Gestione del banner iniziale
///////////////////////////////////////////////////////////
class TBanner : public TWindow
{
enum { Y = 6, X = 60 };
protected:
virtual void handler(WINDOW win, EVENT* ep);
public:
TBanner();
~TBanner();
};
TBanner::TBanner()
{
create(-1, -1, X, Y, "BANNER", WSF_NONE, W_PLAIN);
set_font(FF_TIMES, FS_BOLD, 28);
hide_brush();
open_modal();
do_events();
}
TBanner::~TBanner()
{
close_modal();
}
void TBanner::handler(WINDOW win, EVENT* ep)
{
if (ep->type == E_UPDATE)
{
clear(COLOR_LTGRAY);
RCT r; get_client_rect(win, &r);
r.left += CHARY; r.right -= CHARY;
r.top += CHARY; r.bottom -= CHARY;
set_pen(COLOR_BLACK); win_draw_rect(win, &r);
offset_rect(&r, 1, 1);
set_pen(COLOR_WHITE); win_draw_rect(win, &r);
char* t = (char*)(const char*)main_app().title();
const int w = win_get_text_width(win, t, -1);
const int x = (X*CHARX-w)>>1, y = (Y+2)*CHARY>>1;
set_color(COLOR_WHITE, COLOR_LTGRAY);
win_draw_text(win, x+2, y+2, t, -1);
set_color(COLOR_BLACK, COLOR_LTGRAY);
win_draw_text(win, x, y, t, -1);
icon(2, 2);
}
else
TWindow::handler(win, ep);
}
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
///////////////////////////////////////////////////////////
// Gestione dei processi per Windows(R)
///////////////////////////////////////////////////////////
#include <windows.h> #include <windows.h>
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP"); const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
@ -105,10 +178,8 @@ void TApplication::wait_for(const char* command)
set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)waiting_event_hook); set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)waiting_event_hook);
while (waiting_for) do_events(); while (waiting_for) do_events();
/////////////////////////////////////////////////////////// // We need to restore these things
// We need to restore these things customize_controls(TRUE);
///////////////////////////////////////////////////////////
customize_controls(TRUE);
xvt_statbar_refresh(); xvt_statbar_refresh();
} }
@ -121,14 +192,6 @@ void TApplication::wake_up_caller() const
#endif #endif
void TApplication::print()
{
#ifdef DBG
error_box("Non saprei bene cosa stampare!");
#endif
}
long TApplication::task_eh(WINDOW win, EVENT *ep) long TApplication::task_eh(WINDOW win, EVENT *ep)
{ {
switch (ep->type) switch (ep->type)
@ -149,84 +212,82 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
break; break;
} }
return application->handler(win, ep); return _application->handler(win, ep);
} }
void TApplication::about() const
{
#include <prassi.ver>
const TFilename n(__argv[0]);
message_box("PRASSI Versione Beta 1.%g\nProgramma %s\nLibreria del %s",
VERSION, (const char*)n.name(), __DATE__);
}
long TApplication::handler(WINDOW, EVENT* ep) long TApplication::handler(WINDOW, EVENT* ep)
{ {
switch (ep->type) switch (ep->type)
{ {
case E_CREATE: case E_CREATE:
if (create() == FALSE) {
bool ok = FALSE;
{
TBanner banner;
ok = create();
}
if (!ok)
stop_run(); stop_run();
break; }
case E_CHAR: break;
{ case E_CHAR:
{
#ifdef DBG #ifdef DBG
KEY k = e_char_to_key(ep); KEY k = e_char_to_key(ep);
#endif #endif
} }
break; break;
case E_COMMAND: case E_COMMAND:
{
MENU_TAG mt = ep->v.cmd.tag;
switch(mt)
{ {
MENU_TAG mt = ep->v.cmd.tag; case M_FILE_QUIT:
switch(mt)
{
case M_FILE_QUIT:
if (can_close())
stop_run();
break;
case M_FILE_PG_SETUP:
printer().set();
break;
case M_FILE_PRINT:
print();
break;
case M_FILE_NEW:
set_firm();
break;
case M_FILE_REVERT:
config();
break;
case (M_FILE+11) :
about();
break;
default:
if (mt >= BAR_ITEM(1))
{
if(!menu(mt))
stop_run();
}
break;
}
}
break;
case E_CLOSE:
if (can_close()) if (can_close())
stop_run(); stop_run();
break; break;
case E_QUIT: case M_FILE_PG_SETUP:
if (ep->v.query) printer().set();
{ break;
if (can_close()) case M_FILE_PRINT:
quit_OK(); print();
} break;
else case M_FILE_NEW:
stop_run(); set_firm();
break;
case M_FILE_REVERT:
config();
break;
case (M_FILE+11) :
about();
break; break;
default: default:
if (mt >= BAR_ITEM(1))
{
if(!menu(mt))
stop_run();
}
break; break;
} }
return 0L; }
break;
case E_CLOSE:
if (can_close())
stop_run();
break;
case E_QUIT:
if (ep->v.query)
{
if (can_close())
quit_OK();
}
else
stop_run();
break;
default:
break;
}
return 0L;
} }
@ -287,7 +348,7 @@ void TApplication::terminate()
#endif #endif
close_all_dialogs(); close_all_dialogs();
application->destroy(); // Distruzione files e maschere _application->destroy(); // Distruzione files e maschere
do_events(); do_events();
if (_printer) // Distruzione dell'eventuale stampante if (_printer) // Distruzione dell'eventuale stampante
@ -353,17 +414,33 @@ void TApplication::run(int argc, char* argv[], const char* title)
customize_controls(TRUE); customize_controls(TRUE);
application = this; _application = this;
xvt_system(argc, argv, 0L, task_eh, &cfg); xvt_system(argc, argv, 0L, task_eh, &cfg);
} }
// About box: risposta alla opzione Informazioni del menu File
void TApplication::about() const
{
#include <prassi.ver>
const TFilename n(__argv[0]);
message_box("PRASSI Versione Beta 1.%g\nProgramma %s\nLibreria del %s",
VERSION, (const char*)n.name(), __DATE__);
}
// Risposta alla selezione Stampa del menu File
void TApplication::print()
{
#ifdef DBG
error_box("Non saprei bene cosa stampare!");
#endif
}
void TApplication::check_menu_item(MENU_TAG item) void TApplication::check_menu_item(MENU_TAG item)
{ {
win_menu_check(TASK_WIN, item, TRUE); win_menu_check(TASK_WIN, item, TRUE);
win_update_menu_bar(TASK_WIN); win_update_menu_bar(TASK_WIN);
} }
void TApplication::uncheck_menu_item(MENU_TAG item) void TApplication::uncheck_menu_item(MENU_TAG item)
{ {
win_menu_check(TASK_WIN, item, FALSE); win_menu_check(TASK_WIN, item, FALSE);
@ -379,7 +456,6 @@ void TApplication::enable_menu_item(MENU_TAG item, bool on)
void TApplication::dispatch_e_menu(MENU_TAG item) void TApplication::dispatch_e_menu(MENU_TAG item)
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW); HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);

View File

@ -9,10 +9,6 @@
#include <printer.h> #include <printer.h>
#endif #endif
#ifndef __MODAUT_H
//#include <modaut.h>
#endif
// @C // @C
// Classe TApplication // Classe TApplication
// @END // @END
@ -88,7 +84,8 @@ public:
virtual ~TApplication(); virtual ~TApplication();
}; };
bool xvt_running(); // xvt is running? bool xvt_running(); // xvt is running?
TApplication* MainApp(); // main application TApplication* MainApp(); // main application (old fashioned: will be removed soon
TApplication& main_app();
#endif // __APPLICATION_H #endif // __APPLICATION_H

View File

@ -1,137 +1,139 @@
#include <assoc.h> #include <assoc.h>
THash_object* TAssoc_array::_lookup(const char* k, bool& isnew, bool insert) THash_object* TAssoc_array::_lookup(const char* k, bool& isnew, bool insert)
{ {
TString key(k); const TFixed_string key(k);
word hv = key.hash() % HASH_SIZE; const word hv = key.hash() % HASH_SIZE;
TArray& arr = _data[hv]; TArray& arr = _data[hv];
THash_object* o = NULL; THash_object* o = NULL;
isnew = FALSE; isnew = FALSE;
for (int i = 0; i < arr.items(); i++) for (int i = 0; i < arr.items(); i++)
{ {
THash_object* ob = (THash_object*)&arr[i]; THash_object* ob = (THash_object*)&arr[i];
if (ob->_key == key) if (ob->_key == key)
{ o = ob; break; } { o = ob; break; }
if (ob->_key > key) if (ob->_key > key)
break; break;
} }
if (o == NULL && insert) if (o == NULL && insert)
{ {
o = new THash_object(key); o = new THash_object(key);
arr.insert(o,i); arr.insert(o,i);
isnew = TRUE; isnew = TRUE;
_cnt++; _cnt++;
} }
return o;
} return o;
}
void TAssoc_array::destroy()
{ void TAssoc_array::destroy()
for (int i = 0; i < HASH_SIZE; i++) {
_data[i].destroy(); for (int i = 0; i < HASH_SIZE; i++)
_cnt = _row = _col = 0; _data[i].destroy();
} _cnt = _row = _col = 0;
}
bool TAssoc_array::add(const char* key, TObject* obj,
bool force) bool TAssoc_array::add(const char* key, TObject* obj,
{ bool force)
bool isnew = FALSE; {
bool isnew = FALSE;
THash_object* o = _lookup(key,isnew,TRUE);
THash_object* o = _lookup(key,isnew,TRUE);
if (!isnew)
{ if (!isnew)
if (force) { o->_obj = obj; } {
return TRUE; if (force) { o->_obj = obj; }
} return TRUE;
o->_obj = obj; }
return FALSE; o->_obj = obj;
} return FALSE;
}
bool TAssoc_array::add(const char* key, const TObject& obj, bool force)
{ bool TAssoc_array::add(const char* key, const TObject& obj, bool force)
return add(key,obj.dup(),force); {
} return add(key,obj.dup(),force);
}
bool TAssoc_array::remove(const char* k)
{ bool TAssoc_array::remove(const char* k)
TString key(k); {
word hv = key.hash() % HASH_SIZE; const TFixed_string key(k);
TArray& arr = _data[hv]; const word hv = key.hash() % HASH_SIZE;
THash_object* o = NULL; TArray& arr = _data[hv];
THash_object* o = NULL;
for (int i = 0; i < arr.items(); i++)
{ for (int i = 0; i < arr.items(); i++)
THash_object* ob = (THash_object*)&arr[i]; {
if (ob->_key == key) THash_object* ob = (THash_object*)&arr[i];
{ o = ob; break; } if (ob->_key == key)
if (ob->_key > key) { o = ob; break; }
break; if (ob->_key > key)
} break;
if (o != NULL) { arr.destroy(i,TRUE); _cnt--; return TRUE; } }
return FALSE; if (o != NULL)
} { arr.destroy(i,TRUE); _cnt--; return TRUE; }
return FALSE;
TObject& TAssoc_array::find(const char* key) }
{
bool isnew = FALSE; TObject& TAssoc_array::find(const char* key)
THash_object* o = _lookup(key, isnew); {
if (o == NULL) error_box("INTERNAL (HASH): Unref key"); bool isnew = FALSE;
if (o->_obj == NULL) return error; THash_object* o = _lookup(key, isnew);
else return *(o->_obj); if (o == NULL) error_box("INTERNAL (HASH): Unref key");
} if (o->_obj == NULL) return error;
else return *(o->_obj);
TObject* TAssoc_array::objptr(const char* key) }
{
bool isnew; TObject* TAssoc_array::objptr(const char* key)
THash_object* o = NULL; {
if ((o = _lookup(key,isnew)) != NULL) bool isnew;
return &(o->obj()); THash_object* o = NULL;
return NULL; if ((o = _lookup(key,isnew)) != NULL)
} return &(o->obj());
return NULL;
bool TAssoc_array::is_key(const char* key) }
{
bool isnew = FALSE; bool TAssoc_array::is_key(const char* key)
THash_object* o = _lookup(key, isnew); {
if (o == NULL) return FALSE; bool isnew = FALSE;
return TRUE; const THash_object* o = _lookup(key, isnew);
} if (o == NULL) return FALSE;
return TRUE;
TObject* TAssoc_array::get() }
{
TArray& arr = _data[_row]; TObject* TAssoc_array::get()
{
for(;_row < HASH_SIZE;) const TArray* arr = &_data[_row];
{
if ((int)_col < arr.items()) for(;_row < HASH_SIZE;)
break; {
arr = _data[++_row]; if ((int)_col < arr->items())
_col = 0; break;
} arr = &_data[++_row];
if (_row == HASH_SIZE) _col = 0;
{ _row = 0; return NULL; } }
if (_row == HASH_SIZE)
THash_object* o = (THash_object*)&arr[_col++]; { _row = 0; return NULL; }
return o->_obj == NULL ? &error : o->_obj;
} THash_object* o = (THash_object*)arr->objptr(_col++);
return (o == NULL || o->_obj == NULL) ? &error : o->_obj;
THash_object* TAssoc_array::get_hashobj() }
{
TArray& arr = _data[_row]; THash_object* TAssoc_array::get_hashobj()
{
for(;_row < HASH_SIZE;) const TArray* arr = &_data[_row];
{
if ((int)_col < arr.items()) for(;_row < HASH_SIZE;)
break; {
arr = _data[++_row]; if ((int)_col < arr->items())
_col = 0; break;
} arr = &_data[++_row];
if (_row == HASH_SIZE) _col = 0;
{ _row = 0; return NULL; } }
if (_row == HASH_SIZE)
return (THash_object*)&arr[_col++]; { _row = 0; return NULL; }
}
return (THash_object*)arr->objptr(_col++);
}

View File

@ -231,17 +231,15 @@ long TControl::handler(WINDOW win, EVENT* ep)
break; break;
case E_CHAR: case E_CHAR:
{ {
KEY key = e_char_to_key(ep); const KEY key = e_char_to_key(ep);
switch(key) switch(key)
{ {
case K_SPACE: case K_SPACE:
cc->mouse_up(); cc->mouse_up();
break; break;
default: default:
{ // dispatch_event(get_parent(win), ep);
WINDOW parent = get_parent(win); dispatch_e_char(get_parent(win), key);
dispatch_event(parent, ep);
}
break; break;
} }
} }
@ -974,8 +972,6 @@ WINDOW xvt_create_text(
} }
WINDOW xvt_create_groupbox( WINDOW xvt_create_groupbox(
short left, short top, short right, short bottom, short left, short top, short right, short bottom,
const char* caption, const char* caption,

View File

@ -1 +1 @@
#define VERSION 1.2 #define VERSION 1.3

View File

@ -24,8 +24,8 @@ void TSystem_cursor::mark_deleted(bool deleted)
else else
if (curr().isdeleted()) if (curr().isdeleted())
{ {
curr().recall(); curr().recall();
CWrite(&file()->filehnd()->f, curr().string(), nrec, _nolock); CWrite(&file()->filehnd()->f, curr().string(), nrec, _nolock);
} }
} }
} }
@ -34,16 +34,16 @@ void TSystem_cursor::mark_deleted(bool deleted)
TSystem_cursor::~TSystem_cursor() TSystem_cursor::~TSystem_cursor()
{ {
TLocalisamfile* f = file(); TLocalisamfile* f = file();
const int num = f->num(); const int num = f->num();
f->close();
{
TSystemisamfile s(num);
s.packfile();
}
f->open();
f->close();
{
TSystemisamfile s(num);
s.packfile();
}
f->open();
} }
// *** EOF syscursor.cpp // *** EOF syscursor.cpp

View File

@ -584,6 +584,12 @@ void TWindow::icon(short x0, short y0, int iconid)
#endif #endif
} }
void TWindow::clear(COLOR color)
{ clear_window(win(), color); }
void TWindow::set_mode(DRAW_MODE mode)
{ win_set_draw_mode(win(), mode); }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TTemp_window // TTemp_window
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -747,10 +753,3 @@ bool TScroll_window::on_key(KEY key)
return TWindow::on_key(key); return TWindow::on_key(key);
} }
void TWindow::clear(COLOR color)
{ clear_window(win(), color); }
void TWindow::set_mode(DRAW_MODE mode)
{ win_set_draw_mode(win(), mode); }

View File

@ -43,7 +43,6 @@ struct TPoint
class TWindow class TWindow
{ {
friend class TWindow_manager; friend class TWindow_manager;
// @DPRIV // @DPRIV