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:
parent
a333152c88
commit
3d2dbf1fe6
@ -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,9 +178,7 @@ 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,25 +212,23 @@ 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;
|
break;
|
||||||
case E_CHAR:
|
case E_CHAR:
|
||||||
{
|
{
|
||||||
@ -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);
|
||||||
|
@ -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
|
||||||
@ -89,6 +85,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
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;
|
||||||
@ -24,6 +24,7 @@ THash_object* TAssoc_array::_lookup(const char* k, bool& isnew, bool insert)
|
|||||||
isnew = TRUE;
|
isnew = TRUE;
|
||||||
_cnt++;
|
_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +58,8 @@ bool TAssoc_array::add(const char* key, const TObject& obj, bool force)
|
|||||||
|
|
||||||
bool TAssoc_array::remove(const char* k)
|
bool TAssoc_array::remove(const char* k)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
@ -70,7 +71,8 @@ bool TAssoc_array::remove(const char* k)
|
|||||||
if (ob->_key > key)
|
if (ob->_key > key)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (o != NULL) { arr.destroy(i,TRUE); _cnt--; return TRUE; }
|
if (o != NULL)
|
||||||
|
{ arr.destroy(i,TRUE); _cnt--; return TRUE; }
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,43 +97,43 @@ TObject* TAssoc_array::objptr(const char* key)
|
|||||||
bool TAssoc_array::is_key(const char* key)
|
bool TAssoc_array::is_key(const char* key)
|
||||||
{
|
{
|
||||||
bool isnew = FALSE;
|
bool isnew = FALSE;
|
||||||
THash_object* o = _lookup(key, isnew);
|
const THash_object* o = _lookup(key, isnew);
|
||||||
if (o == NULL) return FALSE;
|
if (o == NULL) return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TObject* TAssoc_array::get()
|
TObject* TAssoc_array::get()
|
||||||
{
|
{
|
||||||
TArray& arr = _data[_row];
|
const TArray* arr = &_data[_row];
|
||||||
|
|
||||||
for(;_row < HASH_SIZE;)
|
for(;_row < HASH_SIZE;)
|
||||||
{
|
{
|
||||||
if ((int)_col < arr.items())
|
if ((int)_col < arr->items())
|
||||||
break;
|
break;
|
||||||
arr = _data[++_row];
|
arr = &_data[++_row];
|
||||||
_col = 0;
|
_col = 0;
|
||||||
}
|
}
|
||||||
if (_row == HASH_SIZE)
|
if (_row == HASH_SIZE)
|
||||||
{ _row = 0; return NULL; }
|
{ _row = 0; return NULL; }
|
||||||
|
|
||||||
THash_object* o = (THash_object*)&arr[_col++];
|
THash_object* o = (THash_object*)arr->objptr(_col++);
|
||||||
return o->_obj == NULL ? &error : o->_obj;
|
return (o == NULL || o->_obj == NULL) ? &error : o->_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
THash_object* TAssoc_array::get_hashobj()
|
THash_object* TAssoc_array::get_hashobj()
|
||||||
{
|
{
|
||||||
TArray& arr = _data[_row];
|
const TArray* arr = &_data[_row];
|
||||||
|
|
||||||
for(;_row < HASH_SIZE;)
|
for(;_row < HASH_SIZE;)
|
||||||
{
|
{
|
||||||
if ((int)_col < arr.items())
|
if ((int)_col < arr->items())
|
||||||
break;
|
break;
|
||||||
arr = _data[++_row];
|
arr = &_data[++_row];
|
||||||
_col = 0;
|
_col = 0;
|
||||||
}
|
}
|
||||||
if (_row == HASH_SIZE)
|
if (_row == HASH_SIZE)
|
||||||
{ _row = 0; return NULL; }
|
{ _row = 0; return NULL; }
|
||||||
|
|
||||||
return (THash_object*)&arr[_col++];
|
return (THash_object*)arr->objptr(_col++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -1 +1 @@
|
|||||||
#define VERSION 1.2
|
#define VERSION 1.3
|
||||||
|
@ -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); }
|
|
||||||
|
@ -43,7 +43,6 @@ struct TPoint
|
|||||||
|
|
||||||
class TWindow
|
class TWindow
|
||||||
{
|
{
|
||||||
|
|
||||||
friend class TWindow_manager;
|
friend class TWindow_manager;
|
||||||
|
|
||||||
// @DPRIV
|
// @DPRIV
|
||||||
|
Loading…
x
Reference in New Issue
Block a user