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>
///////////////////////////////////////////////////////////
// Metodi di accesso globali all'applicazione corrente
///////////////////////////////////////////////////////////
HIDDEN XVT_CONFIG cfg;
HIDDEN TApplication* application = NULL;
HIDDEN TApplication* _application = NULL;
HIDDEN long savefirm = 0;
TApplication* MainApp()
{
CHECK(application, "NULL application!");
return application;
CHECK(_application, "NULL 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)
{
@ -59,8 +74,66 @@ HIDDEN void create_backdrop( void )
#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
///////////////////////////////////////////////////////////
// Gestione dei processi per Windows(R)
///////////////////////////////////////////////////////////
#include <windows.h>
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);
while (waiting_for) do_events();
///////////////////////////////////////////////////////////
// We need to restore these things
///////////////////////////////////////////////////////////
customize_controls(TRUE);
// We need to restore these things
customize_controls(TRUE);
xvt_statbar_refresh();
}
@ -121,14 +192,6 @@ void TApplication::wake_up_caller() const
#endif
void TApplication::print()
{
#ifdef DBG
error_box("Non saprei bene cosa stampare!");
#endif
}
long TApplication::task_eh(WINDOW win, EVENT *ep)
{
switch (ep->type)
@ -149,84 +212,82 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
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)
{
switch (ep->type)
{
case E_CREATE:
if (create() == FALSE)
{
bool ok = FALSE;
{
TBanner banner;
ok = create();
}
if (!ok)
stop_run();
break;
case E_CHAR:
{
}
break;
case E_CHAR:
{
#ifdef DBG
KEY k = e_char_to_key(ep);
KEY k = e_char_to_key(ep);
#endif
}
break;
case E_COMMAND:
}
break;
case E_COMMAND:
{
MENU_TAG mt = ep->v.cmd.tag;
switch(mt)
{
MENU_TAG mt = ep->v.cmd.tag;
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:
case M_FILE_QUIT:
if (can_close())
stop_run();
break;
case E_QUIT:
if (ep->v.query)
{
if (can_close())
quit_OK();
}
else
stop_run();
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;
}
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
close_all_dialogs();
application->destroy(); // Distruzione files e maschere
_application->destroy(); // Distruzione files e maschere
do_events();
if (_printer) // Distruzione dell'eventuale stampante
@ -353,17 +414,33 @@ void TApplication::run(int argc, char* argv[], const char* title)
customize_controls(TRUE);
application = this;
_application = this;
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)
{
win_menu_check(TASK_WIN, item, TRUE);
win_update_menu_bar(TASK_WIN);
}
void TApplication::uncheck_menu_item(MENU_TAG item)
{
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)
{
#if XVT_OS == XVT_OS_WIN
HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);

View File

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

View File

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

View File

@ -231,17 +231,15 @@ long TControl::handler(WINDOW win, EVENT* ep)
break;
case E_CHAR:
{
KEY key = e_char_to_key(ep);
const KEY key = e_char_to_key(ep);
switch(key)
{
case K_SPACE:
cc->mouse_up();
break;
default:
{
WINDOW parent = get_parent(win);
dispatch_event(parent, ep);
}
// dispatch_event(get_parent(win), ep);
dispatch_e_char(get_parent(win), key);
break;
}
}
@ -974,8 +972,6 @@ WINDOW xvt_create_text(
}
WINDOW xvt_create_groupbox(
short left, short top, short right, short bottom,
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
if (curr().isdeleted())
{
curr().recall();
CWrite(&file()->filehnd()->f, curr().string(), nrec, _nolock);
curr().recall();
CWrite(&file()->filehnd()->f, curr().string(), nrec, _nolock);
}
}
}
@ -34,16 +34,16 @@ void TSystem_cursor::mark_deleted(bool deleted)
TSystem_cursor::~TSystem_cursor()
{
TLocalisamfile* f = file();
const int num = f->num();
TLocalisamfile* f = file();
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

View File

@ -584,6 +584,12 @@ void TWindow::icon(short x0, short y0, int iconid)
#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
///////////////////////////////////////////////////////////
@ -747,10 +753,3 @@ bool TScroll_window::on_key(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
{
friend class TWindow_manager;
// @DPRIV