Migliorata gestione cursore attesa e aggiunta Tab_app

git-svn-id: svn://10.65.10.50/trunk@813 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-01-03 14:19:41 +00:00
parent 9693095752
commit 1071675ff5
12 changed files with 1329 additions and 1158 deletions

View File

@ -10,6 +10,7 @@
#include <modaut.h>
#include <applicat.h>
#include <colors.h>
#include <config.h>
#include <mask.h>
#include <prefix.h>
@ -53,12 +54,7 @@ bool xvt_running() { return _application != NULL; }
HIDDEN long backdrop_eh( WINDOW win, EVENT* ep)
{
#if XVT_OS == XVT_OS_WIN
clear_window( win, COLOR_GRAY );
#else
clear_window( win, COLOR_BLUE );
#endif
clear_window(win, MASK_DARK_COLOR);
return 0L;
}
@ -648,6 +644,27 @@ bool TApplication::config()
return ok;
}
void TApplication::set_cursor(bool w)
{
static _count = 0;
if (w)
{
_count++;
if (_count == 1)
::set_cursor(TASK_WIN, CURSOR_WAIT);
}
else
{
_count--;
#ifdef DBG
if (_count >= 0)
yesnofatal_box("end_wait without matching begin_wait");
#endif
if (_count == 0)
::set_cursor(TASK_WIN, CURSOR_ARROW);
}
}
void TApplication::on_firm_change()
{}

View File

@ -38,6 +38,11 @@ class TApplication
static TString16 _user;
void terminate(); // End of application
void set_cursor(bool w); // Change mouse cursor
bool config(); // Change parameters
void about() const; // About box
protected:
const char* get_module_name() const;
static long task_eh(WINDOW win, EVENT* ep);
@ -58,10 +63,6 @@ protected:
void set_user(const char * user) { _user = user; }
void set_perms();
void terminate();
bool config();
void about() const;
public:
// @FPUB
@ -102,6 +103,9 @@ public:
void wake_up() { _waiting = 0; }
word waiting() const { return _waiting; }
void begin_wait() { set_cursor(TRUE); } // Set CURSOR_WAIT
void end_wait() { set_cursor(FALSE); } // Set CURSOR_ARROW
TApplication();
virtual ~TApplication();
};

View File

@ -94,13 +94,7 @@ END
BOOLEAN MSK_1_ISGRAPHICS
BEGIN
PROMPT 4 8 "Salva configurazione"
HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
END
BOOLEAN MSK_1_ISGRAPHICS
BEGIN
PROMPT 4 9 "Stampa elementi grafici"
PROMPT 4 8 "Stampa elementi grafici"
HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
END

View File

@ -5,8 +5,9 @@
#include <xvt.h>
#endif
extern COLOR MASK_COLOR;
extern COLOR MASK_BACK_COLOR;
extern COLOR MASK_LIGHT_COLOR;
extern COLOR MASK_DARK_COLOR;
extern COLOR NORMAL_COLOR;
extern COLOR NORMAL_BACK_COLOR;
extern COLOR DISABLED_COLOR;
@ -16,6 +17,10 @@ extern COLOR FOCUS_BACK_COLOR;
const COLOR COLOR_DKCYAN = MAKE_COLOR(0,128,128);
const COLOR COLOR_DKYELLOW = MAKE_COLOR(128,128, 0);
const COLOR COLOR_DKGREEN = MAKE_COLOR(0,128, 0);
const COLOR COLOR_DKBLUE = MAKE_COLOR(0,0,128);
const COLOR COLOR_DKRED = MAKE_COLOR(128,0, 0);
const COLOR COLOR_DKMAGENTA = MAKE_COLOR(128,0,128);
#endif

View File

@ -38,20 +38,41 @@ public:
HIDDEN byte COLOR2PIC(COLOR c)
{
byte b;
switch (c)
static unsigned long color[16][2] =
{
case COLOR_DKYELLOW:
b = 0x03; break;
case COLOR_DKCYAN:
b = 0x06; break;
case COLOR_CYAN:
b = 0xF8; break;
case COLOR_YELLOW:
b = 0xFB; break;
default:
b = 0x00; break;
0x000000, 0x00, // BLACK
0x0000FF, 0x04, // BLUE
0x000080, 0x0C, // LTBLUE
0x008000, 0x02, // DKGREEN
0x008080, 0x06, // DKCYAN
0x00FF00, 0xFA, // GREEN
0x00FFFF, 0xFE, // CYAN
0x800000, 0x01, // DKRED
0x800080, 0xFD, // DKMAGENTA
0x808000, 0x03, // DKYELLOW
0x808080, 0xF8, // GRAY
0xC0C0C0, 0x07, // LTGRAY
0xFF0000, 0xF9, // RED
0xFF00FF, 0x05, // MAGENTA
0xFFFF00, 0xFB, // YELLOW
0xFFFFFF, 0xFF, // WHITE
};
int idx, f = 0, l = 15;
c &= 0x00FFFFFF;
while (TRUE)
{
idx = (f+l)>>1;
if (c == color[idx][0]) break;
if (c > color[idx][0]) f = idx+1;
else l = idx-1;
if (f > l)
{
break;
}
}
const byte b = (byte)color[idx][1];
return b;
}
@ -62,25 +83,28 @@ PICTURE xvt_picture_load(short id, bool convert)
if (convert && MASK_BACK_COLOR != COLOR_DKCYAN)
{
const byte newdk = COLOR2PIC(MASK_BACK_COLOR);
const byte newlt = COLOR2PIC(MASK_COLOR);
const byte newba = COLOR2PIC(MASK_BACK_COLOR);
const byte newlt = COLOR2PIC(MASK_LIGHT_COLOR);
const byte newdk = COLOR2PIC(MASK_DARK_COLOR);
const PICTURE old = cpb;
RCT r; cpb_get_picture_size(old, &r);
long size;
char* buf = picture_lock(old, &size);
char huge * buf = picture_lock(old, &size);
CHECK(buf, "Out of memory in picture_load");
cpb = picture_make(buf, size, &r);
const int first = 14;
const int last = first + r.right*r.bottom;
for (int i = first; i < last; i++) switch(buf[i])
const long first = 14;
const long last = first + (long)r.right*r.bottom;
for (long i = first; i < last; i++) switch((byte)buf[i])
{
case 0x06:
buf[i] = newdk; break;
buf[i] = newba; break;
case 0xF8:
buf[i] = newdk; break;
case 0xFE:
buf[i] = newlt; break;
default:
break;
}
cpb = picture_make(buf, size, &r);
picture_unlock(old);
picture_free(old);
}
@ -359,7 +383,7 @@ void TControl::update() const
if (_win != _hdc)
get_geometry(_win);
clear_window(_hdc, MASK_BACK_COLOR);
win_set_fore_color(_hdc, disabled() ? COLOR_GRAY : COLOR_BLACK);
win_set_fore_color(_hdc, disabled() ? DISABLED_COLOR : NORMAL_COLOR);
}
///////////////////////////////////////////////////////////
@ -388,7 +412,7 @@ TText::TText(short left, short top, short right, short bottom,
void TText::update() const
{
TControl::update();
win_set_fore_color(_hdc, COLOR_BLACK);
win_set_fore_color(_hdc, NORMAL_COLOR);
win_draw_text(_hdc, _client.left, _client.top+BASEY, (char*)caption(), -1);
}
@ -440,11 +464,11 @@ void TGroup::update() const
if (multiple())
{
r.left++; r.top++; r.right--; r.bottom--;
draw_round_rect(r, COLOR_BLUE);
draw_round_rect(r, MASK_LIGHT_COLOR);
}
else
{
xvt_draw_rect(_hdc, r, COLOR_GRAY, MASK_COLOR);
xvt_draw_rect(_hdc, r, MASK_DARK_COLOR, MASK_LIGHT_COLOR);
}
}
@ -830,20 +854,21 @@ TTag_button::TTag_button(WINDOW parent, byte p, byte tot)
void TTag_button::update() const
{
get_geometry(win());
clear_window(_hdc, COLOR_GRAY);
clear_window(_hdc, MASK_DARK_COLOR);
for (int i = 0; i < _pages; i++)
{
RCT r; set_rect(&r, width*i, 0, width*(i+1), _client.bottom+4);
CBRUSH b = { PAT_SOLID, (i == _page) ? MASK_BACK_COLOR : COLOR_GRAY };
CBRUSH b = { PAT_SOLID, (i == _page) ? MASK_BACK_COLOR : MASK_DARK_COLOR};
win_set_cbrush(_hdc, &b);
win_set_std_cpen(_hdc, TL_PEN_BLACK);
win_draw_rect(_hdc, &r);
if (i == _page)
xvt_draw_rect(_hdc, r, MASK_COLOR, COLOR_GRAY);
xvt_draw_rect(_hdc, r, MASK_LIGHT_COLOR, MASK_BACK_COLOR);
char n[4]; sprintf(n, "%d", i+1);
win_set_fore_color(_hdc, NORMAL_COLOR);
win_draw_text(_hdc, (width-CHARX)/2 + i*width, BASEY, n, -1);
}
@ -851,7 +876,7 @@ void TTag_button::update() const
pen.width = 1;
pen.pat = PAT_SOLID;
pen.style = P_SOLID;
pen.color = MASK_COLOR;
pen.color = MASK_LIGHT_COLOR;
win_set_cpen(_hdc, &pen);
PNT p = { _client.bottom, 0 };

View File

@ -452,6 +452,7 @@ protected:
virtual void read_from(const TMask& m);
virtual bool parse_item(TScanner&);
virtual bool read();
virtual bool update();
const char* get() const;
@ -462,8 +463,6 @@ protected:
TFieldref& field(int i) const { return (TFieldref&)_field[i]; }
void put_paragraph(const char* s);
bool read();
public:
TForm_string(TPrint_section* section) : TForm_item(section) {}
virtual ~TForm_string() {}
@ -569,6 +568,7 @@ void TForm_string::put_paragraph(const char* s)
bool TForm_string::update()
{
TForm_item::update();
if (read())
{
if (_picture.not_empty())
@ -580,6 +580,7 @@ bool TForm_string::update()
else
put_paragraph(get());
}
return TRUE;
}
@ -632,7 +633,9 @@ class TForm_date : public TForm_string
{
protected:
virtual const char* class_name() const { return "DATA"; }
virtual bool read();
virtual bool set(const char*);
bool set(const TDate& d);
public:
TForm_date(TPrint_section* section);
@ -642,24 +645,30 @@ public:
TForm_date::TForm_date(TPrint_section* section)
: TForm_string(section)
{
if (automagic())
{
TDate oggi(TODAY);
set(oggi.string());
}
}
{}
bool TForm_date::read()
{
bool ok = TForm_string::read();
if ((!ok || !get()[0]) && automagic())
{
set(main_app().printer().getdate());
ok = TRUE;
}
return ok;
}
bool TForm_date::set(const char* s)
{
const TDate d(s);
TForm_string::set(d.string((width() == 8) ? 2 : 4));
#ifdef DBG
return d.ok();
#else
return TRUE;
#endif
}
bool TForm_date::set(const TDate& d)
{
TForm_string::set(d.string((width() == 8) ? 2 : 4));
return TRUE;
}
///////////////////////////////////////////////////////////

View File

@ -118,10 +118,10 @@ void TMask::handler(WINDOW win, EVENT* ep)
if (win != toolwin())
{
clear_window(win, MASK_BACK_COLOR);
RCT r; get_client_rect(win, &r);
xvt_draw_rect(win, r, MASK_COLOR, COLOR_GRAY, 1);
RCT r; get_client_rect(win, &r); r.right--; r.bottom--;
xvt_draw_rect(win, r, MASK_LIGHT_COLOR, MASK_DARK_COLOR, 1);
}
else clear_window(win, COLOR_GRAY);
else clear_window(win, MASK_DARK_COLOR);
#else
clear_window(win, MASK_BACK_COLOR);
#endif

View File

@ -258,6 +258,7 @@ public:
bool print (TPrintrow& rowtoprint);
bool isopen() { return _isopen; }
void setdate(const TDate& d) { _date = d; }
const TDate& getdate() const { return _date; }
TPrtype printtype() { return _printertype; }
void set_printtype(TPrtype dest) { _printertype=dest; }
void set_printerfile(const char * ffile) { _printerfile=ffile; }

View File

@ -462,11 +462,11 @@ bool TSheet::update_row(long n)
if (chk)
{
changed = TRUE;
set_color(MASK_BACK_COLOR, COLOR_LTGRAY);
set_color(MASK_BACK_COLOR, NORMAL_BACK_COLOR);
}
else if (_disabled[n])
{
set_color(COLOR_GRAY, COLOR_LTGRAY);
set_color(DISABLED_COLOR, NORMAL_BACK_COLOR);
changed = TRUE;
}
@ -497,7 +497,7 @@ bool TSheet::update_row(long n)
stringat(x1, y, s);
}
if (changed)
set_color(COLOR_BLACK, COLOR_LTGRAY);
set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
return TRUE;
}
@ -520,9 +520,9 @@ void TSheet::update()
{
if (_last_update < 0)
{
set_color(COLOR_BLACK, COLOR_WHITE);
set_brush(COLOR_WHITE);
set_pen(COLOR_BLACK);
set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
set_pen(NORMAL_COLOR);
set_brush(NORMAL_BACK_COLOR);
set_font(FF_FIXED);
_visible_rows = rows() - reserved_rows() - head_on();
}

75
include/tabapp.cpp Executable file
View File

@ -0,0 +1,75 @@
#include <relapp.h>
#include <stdtypes.h>
#include <tabutil.h>
#include <execp.h>
#include <utility.h>
#include <tabapp.h>
void Tab_application::print()
{
#if XVT_OS == XVT_OS_WIN
TExternal_app stampa(format("ba3a -1 %s", (const char *) _tabname));
#else
TExternal_app stampa(format("ba3 -1 %s", (const char *) _tabname));
#endif
stampa.run();
}
void Tab_application::init_query_mode(TMask& m)
{
m.send_key(K_SHIFT + K_CTRL + 'e', -GR_MODIFY_PROTECTED);
m.send_key(K_SHIFT + K_CTRL + 'e', -GR_RECORD_PROTECTED);
}
void Tab_application::init_modify_mode(TMask& m)
{
m.send_key(K_SHIFT + K_CTRL + 'd', -GR_MODIFY_PROTECTED);
const bool enable = !(_rel->curr().get_bool(FPC));
m.send_key(K_SHIFT + K_CTRL + 'd' + enable, -GR_RECORD_PROTECTED);
}
bool Tab_application::protected_record(TRectype& rec)
{
return rec.get_bool(FPC);
}
bool Tab_application::user_create()
{
if (argc() < 3)
return FALSE;
_tabname = argv(2);
if (_tabname.empty())
return FALSE;
_tabname.upper();
TString16 m, t(_tabname);
if (t[0] == '%') t.ltrim(1);
m << "BATB" << t;
_msk = new TMask(m) ;
for (int i = 0; i < _msk->fields(); i++)
if (_msk->fld(i).in_group(GR_SEARCH))
{
set_search_field(_msk->fld(i).dlg());
break;
}
_rel = new TRelation(_tabname);
set_title(_msk->get_caption());
return TRUE;
}
bool Tab_application::user_destroy()
{
if (_msk) delete _msk;
if (_rel) delete _rel;
return TRUE;
}

38
include/tabapp.h Executable file
View File

@ -0,0 +1,38 @@
#ifndef __TABAPP_H
#define __TABAPP_H
#ifndef __RELAPP_H
#include <relapp.h>
#endif
#define GR_SEARCH 29
#define GR_MODIFY_PROTECTED 30
#define GR_RECORD_PROTECTED 31
#define FPC "FPC"
class Tab_application : public TRelation_application
{
TMask* _msk;
TRelation* _rel;
TString16 _tabname;
protected:
virtual bool protected_record(TRectype& rec);
virtual TMask* get_mask(int mode = NO_MODE) { return _msk;}
virtual bool changing_mask(int mode) { return FALSE;}
virtual TRelation* get_relation() const { return _rel;}
virtual void init_query_mode(TMask& m);
virtual void init_modify_mode(TMask& m);
virtual bool user_create() ;
virtual bool user_destroy() ;
virtual void print();
public:
Tab_application() : _msk(NULL), _rel(NULL) {}
virtual ~Tab_application() {}
const TString& get_tabname() const { return _tabname; }
};
#endif

View File

@ -26,6 +26,7 @@ short BASEY = 8;
short ROWY = 8;
COLOR MASK_BACK_COLOR = COLOR_WHITE;
COLOR MASK_DARK_COLOR = COLOR_BLUE;
COLOR NORMAL_COLOR = COLOR_BLACK;
COLOR NORMAL_BACK_COLOR = COLOR_WHITE;
COLOR DISABLED_COLOR = COLOR_GRAY;
@ -75,8 +76,9 @@ HIDDEN LOGFONT LogFont;
HIDDEN int FontWeight;
COLOR MASK_COLOR = COLOR_CYAN;
COLOR MASK_BACK_COLOR = COLOR_DKCYAN;
COLOR MASK_LIGHT_COLOR = COLOR_CYAN;
COLOR MASK_DARK_COLOR = COLOR_GRAY;
COLOR NORMAL_COLOR = COLOR_BLACK;
COLOR NORMAL_BACK_COLOR = COLOR_LTGRAY;
COLOR DISABLED_COLOR = COLOR_GRAY;
@ -490,8 +492,9 @@ void customize_controls(bool on)
{
TConfig colors(CONFIG_GENERAL, "Colors");
MASK_COLOR = colors.get_color("Mask", NULL, -1, MASK_COLOR);
MASK_BACK_COLOR = colors.get_color("MaskBack", NULL, -1, MASK_BACK_COLOR);
MASK_LIGHT_COLOR = colors.get_color("MaskLight", NULL, -1, MASK_LIGHT_COLOR);
MASK_DARK_COLOR = colors.get_color("MaskDark", NULL, -1, MASK_DARK_COLOR);
NORMAL_COLOR = colors.get_color("Normal", NULL, -1, NORMAL_COLOR);
NORMAL_BACK_COLOR = colors.get_color("NormalBack", NULL, -1, NORMAL_BACK_COLOR);
DISABLED_COLOR = colors.get_color("Disabled", NULL, -1, DISABLED_COLOR);