cg3600.cpp Mastrini a video
cglib.h Aggiunti vari const agli esercizi cglib02.cpp Aggiunti vari const agli esercizi cg3600a.* Aggiunta maschera mastrini a video git-svn-id: svn://10.65.10.50/trunk@3902 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6f1e1ac7e2
commit
a341853e58
615
cg/cg3600.cpp
615
cg/cg3600.cpp
@ -1,8 +1,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <array.h>
|
#include <applicat.h>
|
||||||
|
#include <colors.h>
|
||||||
|
#include <controls.h>
|
||||||
|
#include <mask.h>
|
||||||
|
#include <urldefid.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
#include "cg3.h"
|
#include "cg3.h"
|
||||||
|
#include "cglib.h"
|
||||||
|
|
||||||
|
#include "cg3600a.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TList
|
// TList
|
||||||
@ -50,6 +58,8 @@ public:
|
|||||||
|
|
||||||
TObject* detach(long pos);
|
TObject* detach(long pos);
|
||||||
bool remove(long pos);
|
bool remove(long pos);
|
||||||
|
|
||||||
|
void choose_step(long expected_size); // Sceglie il passo per gli elemnti
|
||||||
|
|
||||||
TList(long expected_size);
|
TList(long expected_size);
|
||||||
virtual ~TList();
|
virtual ~TList();
|
||||||
@ -58,11 +68,9 @@ public:
|
|||||||
TList::TList(long expected_size)
|
TList::TList(long expected_size)
|
||||||
: _items(0), _current(0)
|
: _items(0), _current(0)
|
||||||
{
|
{
|
||||||
_step = expected_size / MAX_SKIP + 1;
|
|
||||||
_last_skip = 0;
|
|
||||||
|
|
||||||
_skip = new TList_object*[MAX_SKIP];
|
_skip = new TList_object*[MAX_SKIP];
|
||||||
_skip[0] = NULL;
|
_skip[0] = NULL;
|
||||||
|
choose_step(expected_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
TList::~TList()
|
TList::~TList()
|
||||||
@ -149,7 +157,13 @@ void TList::change_step(long step)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TList::choose_step(long expected_size)
|
||||||
|
{
|
||||||
|
long step = expected_size / MAX_SKIP + 1;
|
||||||
|
change_step(step);
|
||||||
|
}
|
||||||
|
|
||||||
long TList::insert(TObject* obj, long index)
|
long TList::insert(TObject* obj, long index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
@ -270,18 +284,587 @@ bool TList::remove(long index)
|
|||||||
return o != NULL;
|
return o != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <time.h>
|
///////////////////////////////////////////////////////////
|
||||||
|
// TGrid_control
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TGrid_control;
|
||||||
|
|
||||||
|
class TGrid_field : public TOperable_field
|
||||||
|
{
|
||||||
|
long _to_select;
|
||||||
|
|
||||||
|
protected: // TMask_field
|
||||||
|
virtual void create(WINDOW parent);
|
||||||
|
virtual void parse_head(TScanner& scanner);
|
||||||
|
virtual bool parse_item(TScanner& scanner);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual long items() const;
|
||||||
|
virtual bool handler(XI_EVENT* ep);
|
||||||
|
|
||||||
|
TGrid_control* grid() const { return (TGrid_control*)_ctl; }
|
||||||
|
|
||||||
|
TGrid_field(TMask* m) : TOperable_field(m) { }
|
||||||
|
virtual ~TGrid_field() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
class TGrid_control : public TControl
|
||||||
|
{
|
||||||
|
enum { FIRST_FIELD = 101, MAX_COL = 128 };
|
||||||
|
|
||||||
|
long _cur_rec;
|
||||||
|
|
||||||
|
// @cmember:(INTERNAL) Tipo di ogni colonna
|
||||||
|
byte _type[MAX_COL];
|
||||||
|
|
||||||
|
TGrid_field* _grid;
|
||||||
|
|
||||||
|
protected: // TControl
|
||||||
|
//@cmember Gestisce gli eventi delle celle
|
||||||
|
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
long items() const { return _grid->items(); }
|
||||||
|
|
||||||
|
int rec2row(long rec) const;
|
||||||
|
long row2rec(int row) const;
|
||||||
|
|
||||||
|
XI_OBJ* find_column(int col) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
long selected() const { return _cur_rec; }
|
||||||
|
void select(long n);
|
||||||
|
void set_focus_rec(long rec);
|
||||||
|
|
||||||
|
int visible_rows() const;
|
||||||
|
|
||||||
|
byte& column_type(int c) { CHECKD(c >= 0 && c < MAX_COL, "Bad column ", c); return _type[c]; }
|
||||||
|
|
||||||
|
void update(long n = -1);
|
||||||
|
|
||||||
|
TGrid_control(WINDOW parent, short cid,
|
||||||
|
short x, short y, short dx, short dy,
|
||||||
|
const char* flags, const char* head,
|
||||||
|
TGrid_field* owner);
|
||||||
|
virtual ~TGrid_control() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
TGrid_control::TGrid_control(
|
||||||
|
WINDOW parent, // @parm Finestra alla quale appartiene lo spreadsheet
|
||||||
|
short cid, // @parm Identificatore
|
||||||
|
short x, // @parm Coordinata x (in caratteri) nel quale posizionare lo spreadsheet
|
||||||
|
short y, // @parm Coordinata y (in caratteri) nel quale posizionare lo spreadsheet
|
||||||
|
short dx, // @parm Larghezza (in caratteri) dello spreasheet
|
||||||
|
short dy, // @parm Lunghezza (in caratteri) dello spreasheet
|
||||||
|
const char* flags, // @parm Flags di abilitazione
|
||||||
|
const char* head, // @parm Titolo delle colonne
|
||||||
|
TGrid_field* owner)
|
||||||
|
: _grid(owner), _cur_rec(0)
|
||||||
|
{
|
||||||
|
const int NUMBER_WIDTH = strchr(flags, 'A') ? 7 : 1;
|
||||||
|
short v_width[MAX_COL];
|
||||||
|
short m_width[MAX_COL];
|
||||||
|
int fixed_columns = 1; // Number of fixed columns
|
||||||
|
int lines_in_header = 1; // Number of header lines
|
||||||
|
const bool multiline = strchr(flags, 'M') != NULL;
|
||||||
|
const int lines_in_cell = multiline ? (int)xi_get_pref(XI_PREF_DEFAULT_MAX_LINES_IN_CELL) : 1;
|
||||||
|
|
||||||
|
// Calcolo larghezza massima tabella
|
||||||
|
TToken_string header(head);
|
||||||
|
TToken_string new_header(256);
|
||||||
|
int i = 0;
|
||||||
|
int f_width = NUMBER_WIDTH; // Stima larghezza colonne fisse
|
||||||
|
int max_width = f_width; // Stima larghezza della colonna piu' grande
|
||||||
|
|
||||||
|
for (const char* h = header.get(); h; h = header.get(), i++)
|
||||||
|
{
|
||||||
|
CHECKD(i < MAX_COL, "Tu meni calumns in scit: ", i);
|
||||||
|
_type[i] = ' ';
|
||||||
|
|
||||||
|
TFixed_string testa(esc(h));
|
||||||
|
const bool multiple = testa.find('\n') > 0;
|
||||||
|
if (multiple)
|
||||||
|
lines_in_header = 2;
|
||||||
|
|
||||||
|
const int at = testa.find('@');
|
||||||
|
int v = testa.len(); // Video width
|
||||||
|
if (at >= 0)
|
||||||
|
{
|
||||||
|
const TString& wi = testa.mid(at+1);
|
||||||
|
const int video = atoi(wi);
|
||||||
|
if (video > 0) v = video;
|
||||||
|
if (wi.find('F') >= 0)
|
||||||
|
{
|
||||||
|
fixed_columns = i+2;
|
||||||
|
f_width += v+1;
|
||||||
|
}
|
||||||
|
if (wi.find('R') >= 0)
|
||||||
|
_type[i] = 'R';
|
||||||
|
|
||||||
|
testa.cut(at);
|
||||||
|
}
|
||||||
|
|
||||||
|
v++;
|
||||||
|
// memory width of column
|
||||||
|
m_width[i] = v * lines_in_cell;
|
||||||
|
if (v > 64) v = 64;
|
||||||
|
v_width[i] = v;
|
||||||
|
if (v_width[i] > max_width) max_width = v_width[i];
|
||||||
|
|
||||||
|
new_header.add(testa);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcola rettangolo massimo per lo sheet
|
||||||
|
XI_RCT rct; coord2rct(parent, x, y, dx, dy, rct);
|
||||||
|
rct.right -= 2*XI_FU_MULTIPLE; // toglie scroll-bar
|
||||||
|
|
||||||
|
// Controlla se ci sono troppe colonne fisse
|
||||||
|
if ((f_width+max_width)*XI_FU_MULTIPLE > rct.right)
|
||||||
|
fixed_columns = 1;
|
||||||
|
|
||||||
|
XI_OBJ* itf = get_interface(parent);
|
||||||
|
|
||||||
|
XI_OBJ_DEF* listdef = xi_add_list_def(NULL, cid,
|
||||||
|
rct.top, rct.left, rct.bottom-rct.top,
|
||||||
|
XI_ATR_ENABLED | XI_ATR_VISIBLE,
|
||||||
|
NORMAL_COLOR, NORMAL_BACK_COLOR, // normal
|
||||||
|
DISABLED_COLOR, DISABLED_BACK_COLOR, // disabled
|
||||||
|
FOCUS_COLOR, // active
|
||||||
|
0);
|
||||||
|
|
||||||
|
listdef->app_data = (long)this;
|
||||||
|
|
||||||
|
XI_LIST_DEF* l = listdef->v.list;
|
||||||
|
l->min_heading_height = xi_button_calc_height_font_id(xvt_default_font()) * lines_in_header;
|
||||||
|
l->sizable_columns = TRUE;
|
||||||
|
l->movable_columns = TRUE;
|
||||||
|
l->fixed_columns = fixed_columns;
|
||||||
|
l->scroll_bar = TRUE;
|
||||||
|
l->scroll_bar_button = TRUE;
|
||||||
|
l->white_space_color = MASK_DARK_COLOR;
|
||||||
|
l->rule_color = MASK_DARK_COLOR;
|
||||||
|
|
||||||
|
// Definizione della prima colonna (numero di riga)
|
||||||
|
const long attr = XI_ATR_VISIBLE | XI_ATR_RJUST | XI_ATR_SELECTABLE;
|
||||||
|
XI_OBJ_DEF* coldef = xi_add_column_def(listdef, FIRST_FIELD+1000-1, attr, 0,
|
||||||
|
NUMBER_WIDTH * XI_FU_MULTIPLE, NUMBER_WIDTH , "");
|
||||||
|
|
||||||
|
coldef->app_data = (long)this;
|
||||||
|
XI_COLUMN_DEF* cd = coldef->v.column;
|
||||||
|
cd->heading_platform = TRUE;
|
||||||
|
cd->column_platform = TRUE;
|
||||||
|
cd->size_rows = multiline;
|
||||||
|
|
||||||
|
for (h = new_header.get(0), i = 0; h; h = new_header.get(), i++)
|
||||||
|
{
|
||||||
|
long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL | XI_ATR_READONLY;
|
||||||
|
if (_type[i] == 'C')
|
||||||
|
attr |= XI_ATR_SELECTABLE;
|
||||||
|
if (_type[i] == 'R')
|
||||||
|
attr |= XI_ATR_RJUST;
|
||||||
|
coldef = xi_add_column_def(listdef, FIRST_FIELD+i+1000, attr, i+1,
|
||||||
|
v_width[i] * XI_FU_MULTIPLE, m_width[i], (char*)h);
|
||||||
|
|
||||||
|
coldef->app_data = (long)this;
|
||||||
|
cd = coldef->v.column;
|
||||||
|
cd->heading_platform = TRUE;
|
||||||
|
cd->center_heading = strchr(h, '\n') == NULL;
|
||||||
|
if (multiline)
|
||||||
|
{
|
||||||
|
cd->size_rows = TRUE;
|
||||||
|
cd->wrap_text = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RCT rd; xi_get_def_rect(listdef, &rd);
|
||||||
|
if ((rd.right - rd.left) > (rct.right - rct.left))
|
||||||
|
l->width = rct.right - rct.left;
|
||||||
|
|
||||||
|
_obj = xi_create(itf, listdef); // Create the whole thing!
|
||||||
|
xi_dequeue(); // Flush events in XOL
|
||||||
|
xi_tree_free(listdef); // Free definitions
|
||||||
|
|
||||||
|
CHECKD(_obj, "Can't create list control ", cid);
|
||||||
|
update_tab_cid();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Converts a row number in the correspondig record number
|
||||||
|
int TGrid_control::rec2row(long record) const
|
||||||
|
{
|
||||||
|
int rows;
|
||||||
|
const long* rec = xi_get_list_info(_obj, &rows);
|
||||||
|
int r = int(record - rec[0]);
|
||||||
|
if (r < 0 || r >= rows)
|
||||||
|
r = -1;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Converts a row number in the correspondig record number
|
||||||
|
long TGrid_control::row2rec(int row) const
|
||||||
|
{
|
||||||
|
int rows;
|
||||||
|
const long* handle = xi_get_list_info(_obj, &rows);
|
||||||
|
|
||||||
|
if (row < 0)
|
||||||
|
row = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (row >= rows)
|
||||||
|
row = rows-1;
|
||||||
|
}
|
||||||
|
const long r = handle[row];
|
||||||
|
CHECKD(r >= 0 && r < items(), "Sheet line out of range: ", row);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TGrid_control::visible_rows() const
|
||||||
|
{
|
||||||
|
return xi_get_visible_rows(_obj, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TGrid_control::update(long n)
|
||||||
|
{
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
const int riga = rec2row(n);
|
||||||
|
if (riga >= 0)
|
||||||
|
{
|
||||||
|
XI_OBJ row;
|
||||||
|
XI_MAKE_ROW(&row, _obj, riga);
|
||||||
|
xi_cell_request(&row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
const long* handle = xi_get_list_info(_obj, &num);
|
||||||
|
|
||||||
|
bool scroll_first = items() == 0;
|
||||||
|
if (!scroll_first)
|
||||||
|
{
|
||||||
|
int first = 0, last = 0;
|
||||||
|
xi_get_visible_rows(_obj, &first, &last);
|
||||||
|
n = handle[first];
|
||||||
|
scroll_first = n > items();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scroll_first)
|
||||||
|
xi_scroll(_obj, XI_SCROLL_FIRST);
|
||||||
|
else
|
||||||
|
xi_scroll_rec(_obj, n, NORMAL_COLOR, XI_ATR_ENABLED, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TGrid_control::select(long rec)
|
||||||
|
{
|
||||||
|
if (rec >= 0 && rec < items())
|
||||||
|
{
|
||||||
|
int rows;
|
||||||
|
const long* handle = xi_get_list_info(_obj, &rows);
|
||||||
|
|
||||||
|
int first = 0, last = 0;
|
||||||
|
xi_get_visible_rows(_obj, &first, &last);
|
||||||
|
|
||||||
|
if (rec < handle[first] || rec > handle[last])
|
||||||
|
xi_scroll_rec(_obj, rec, NORMAL_COLOR, XI_ATR_ENABLED, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TGrid_control::set_focus_rec(long rec)
|
||||||
|
{
|
||||||
|
if (rec < 0)
|
||||||
|
rec = selected();
|
||||||
|
int r = rec2row(rec);
|
||||||
|
if (r < 0)
|
||||||
|
{
|
||||||
|
select(rec);
|
||||||
|
r = rec2row(rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int c = _type[0] == 'C' ? 2 : 1;
|
||||||
|
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, r, c);
|
||||||
|
xi_set_focus(&cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
XI_OBJ* TGrid_control::find_column(
|
||||||
|
int col) const // @parm Indice o identificatore colonna
|
||||||
|
{
|
||||||
|
CHECKD(col >= 0, "Bad column ", col);
|
||||||
|
if (col < FIRST_FIELD) // Se e' un indice trasformalo in identificatore
|
||||||
|
col += FIRST_FIELD + 1000;
|
||||||
|
|
||||||
|
int num;
|
||||||
|
XI_OBJ** columns = xi_get_member_list(_obj, &num);
|
||||||
|
for (int c = num-1; c >= 0; c--)
|
||||||
|
{
|
||||||
|
if (columns[c]->cid == col)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return c >= 0 ? columns[c] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Certified 75%
|
||||||
|
bool TGrid_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||||
|
{
|
||||||
|
BOOLEAN& refused = xiev->refused;
|
||||||
|
|
||||||
|
const bool handled = _grid->handler(xiev);
|
||||||
|
if (handled)
|
||||||
|
return !refused;
|
||||||
|
|
||||||
|
switch (xiev->type)
|
||||||
|
{
|
||||||
|
case XIE_GET_FIRST:
|
||||||
|
if (items() > 0L)
|
||||||
|
{
|
||||||
|
long n = items() * (long)xiev->v.rec_request.percent / 100L;
|
||||||
|
if (n < 0L) n = 0L;
|
||||||
|
xiev->v.rec_request.data_rec = n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
refused = TRUE;
|
||||||
|
break;
|
||||||
|
case XIE_GET_LAST:
|
||||||
|
xiev->v.rec_request.data_rec = items()-1;
|
||||||
|
break;
|
||||||
|
case XIE_GET_PREV:
|
||||||
|
case XIE_GET_NEXT:
|
||||||
|
{
|
||||||
|
const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ;
|
||||||
|
if (n < 0 || n >= items())
|
||||||
|
refused = TRUE;
|
||||||
|
else
|
||||||
|
xiev->v.rec_request.data_rec = n;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XIE_GET_PERCENT:
|
||||||
|
{
|
||||||
|
const long rec = xiev->v.get_percent.record;
|
||||||
|
long n = items(); if (n <= 0) n = 1;
|
||||||
|
xiev->v.get_percent.percent = int(rec * 100L / n);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XIE_COL_MOVE:
|
||||||
|
if (xiev->v.column.in_fixed ||
|
||||||
|
xiev->v.column.col_nbr < xi_get_fixed_columns(xiev->v.column.list))
|
||||||
|
refused = TRUE;
|
||||||
|
break;
|
||||||
|
case XIE_COL_SIZE:
|
||||||
|
break;
|
||||||
|
case XIE_SELECT:
|
||||||
|
xiev->refused = TRUE;
|
||||||
|
break;
|
||||||
|
case XIE_CELL_REQUEST:
|
||||||
|
if (xiev->v.cell_request.col_nbr == 0)
|
||||||
|
{
|
||||||
|
if (xiev->v.cell_request.len > 1)
|
||||||
|
{
|
||||||
|
sprintf(xiev->v.cell_request.s, "%ld", xiev->v.cell_request.rec);
|
||||||
|
xiev->v.cell_request.color = NORMAL_COLOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !refused;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TGrid_field
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TGrid_field::create(WINDOW parent)
|
||||||
|
{
|
||||||
|
_ctl = new TGrid_control(parent, dlg(),
|
||||||
|
_ctl_data._x, _ctl_data._y,
|
||||||
|
_ctl_data._width, _ctl_data._size,
|
||||||
|
_ctl_data._flags, _ctl_data._park,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TGrid_field::parse_head(TScanner& scanner)
|
||||||
|
{
|
||||||
|
_ctl_data._width = scanner.integer();
|
||||||
|
_ctl_data._height = scanner.integer();
|
||||||
|
if (_ctl_data._height == 0)
|
||||||
|
_ctl_data._height = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TGrid_field::parse_item(TScanner& scanner)
|
||||||
|
{
|
||||||
|
if (scanner.key() == "IT")
|
||||||
|
{
|
||||||
|
_ctl_data._park.add(scanner.string());
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return TMask_field::parse_item(scanner);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TGrid_field::handler(XI_EVENT* xiev)
|
||||||
|
{
|
||||||
|
if (xiev->type == XIE_CELL_REQUEST)
|
||||||
|
{
|
||||||
|
const long& rec = xiev->v.cell_request.rec;
|
||||||
|
const short& col = xiev->v.cell_request.col_nbr;
|
||||||
|
|
||||||
|
if (col == 3)
|
||||||
|
{
|
||||||
|
strcpy(xiev->v.cell_request.s,
|
||||||
|
"Questa e' una descrizioncina sgarsolina sgarsolina,"
|
||||||
|
" che non doverebbe stare in una sola righina");
|
||||||
|
|
||||||
|
xiev->v.cell_request.back_color = rec % 7 ? COLOR_YELLOW : COLOR_CYAN;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
long TGrid_field::items() const
|
||||||
|
{
|
||||||
|
return 30000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TGrid_mask
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TGrid_mask : public TMask
|
||||||
|
{
|
||||||
|
TEsercizi_contabili _esercizi;
|
||||||
|
|
||||||
|
protected: // TMask
|
||||||
|
virtual TMask_field* parse_field(TScanner& sc);
|
||||||
|
|
||||||
|
static bool data_handler(TMask_field& f, KEY k);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const TEsercizi_contabili& esercizi() const { return _esercizi; }
|
||||||
|
TEsercizi_contabili& esercizi() { return _esercizi; }
|
||||||
|
|
||||||
|
TGrid_mask(const char* name);
|
||||||
|
virtual ~TGrid_mask() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
TGrid_mask::TGrid_mask(const char* name)
|
||||||
|
{
|
||||||
|
read_mask(name, 0, 0);
|
||||||
|
|
||||||
|
set_handler(F_DADATA, data_handler);
|
||||||
|
set_handler(F_ADATA, data_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
TMask_field* TGrid_mask::parse_field(TScanner& sc)
|
||||||
|
{
|
||||||
|
TMask_field* f;
|
||||||
|
if (sc.key() == "SP")
|
||||||
|
f = new TGrid_field(this);
|
||||||
|
else
|
||||||
|
f = TMask::parse_field(sc);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TGrid_mask::data_handler(TMask_field& f, KEY k)
|
||||||
|
{
|
||||||
|
bool ok = TRUE;
|
||||||
|
if (f.to_check(k) && !f.empty())
|
||||||
|
{
|
||||||
|
const TGrid_mask& gm = (const TGrid_mask&)f.mask();
|
||||||
|
int codice_esercizio = gm.get_int(F_ESERCIZIO);
|
||||||
|
if (codice_esercizio == 0)
|
||||||
|
{
|
||||||
|
const short id_altra_data = f.dlg() == F_DADATA ? F_ADATA : F_DADATA;
|
||||||
|
const TDate d = gm.get(id_altra_data);
|
||||||
|
if (d.ok())
|
||||||
|
codice_esercizio = gm.esercizi().date2esc(d);
|
||||||
|
}
|
||||||
|
const TDate d = f.get();
|
||||||
|
const int esercizio = gm.esercizi().date2esc(d);
|
||||||
|
if (codice_esercizio != 0)
|
||||||
|
{
|
||||||
|
if (esercizio != codice_esercizio)
|
||||||
|
ok = error_box("La data deve appartenere all'esercizio %d", codice_esercizio);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (esercizio == 0)
|
||||||
|
ok = error_box("La data deve appartenere ad un esercizio contabile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TMastrini_video
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TMastrini_video : public TApplication
|
||||||
|
{
|
||||||
|
TGrid_mask* _gm;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool create();
|
||||||
|
virtual bool menu(MENU_TAG);
|
||||||
|
virtual void on_firm_change();
|
||||||
|
};
|
||||||
|
|
||||||
|
bool TMastrini_video::create()
|
||||||
|
{
|
||||||
|
_gm = NULL;
|
||||||
|
dispatch_e_menu(BAR_ITEM(1));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TMastrini_video::on_firm_change()
|
||||||
|
{
|
||||||
|
if (_gm)
|
||||||
|
_gm->esercizi().update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TMastrini_video::menu(MENU_TAG)
|
||||||
|
{
|
||||||
|
_gm = new TGrid_mask("cg3600a");
|
||||||
|
KEY key = 0;
|
||||||
|
while (key != K_QUIT)
|
||||||
|
{
|
||||||
|
if (key == 0)
|
||||||
|
{
|
||||||
|
const TEsercizi_contabili& esercizi = _gm->esercizi();
|
||||||
|
const int codice_ultimo_esercizio = esercizi.last();
|
||||||
|
if (codice_ultimo_esercizio > 0)
|
||||||
|
{
|
||||||
|
const TEsercizio& esercizio = esercizi.esercizio(codice_ultimo_esercizio);
|
||||||
|
_gm->set(F_ESERCIZIO, codice_ultimo_esercizio);
|
||||||
|
_gm->set(F_DADATA, esercizio.inizio());
|
||||||
|
_gm->set(F_ADATA, esercizio.fine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_gm->reset(F_SOTTOCONTO); // Azzera sottoconto
|
||||||
|
_gm->reset(F_CLIENTE); // Azzera cliente
|
||||||
|
_gm->reset(F_FORNITORE); // Azzera fornitore
|
||||||
|
_gm->reset(F_DACAUSALE); // Azzera causali
|
||||||
|
_gm->reset(F_ACAUSALE);
|
||||||
|
}
|
||||||
|
key = _gm->run();
|
||||||
|
}
|
||||||
|
delete _gm;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int cg3600(int argc, char* argv[])
|
int cg3600(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
long max = 100000L;
|
TMastrini_video mv;
|
||||||
TList l(max);
|
mv.run(argc, argv, "Mastrini");
|
||||||
const clock_t start = clock();
|
|
||||||
|
|
||||||
for (long i = 0; i < max; i++)
|
|
||||||
l.add(NULL);
|
|
||||||
|
|
||||||
const clock_t end = clock()-start;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
30
cg/cg3600a.h
Executable file
30
cg/cg3600a.h
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#define F_CODDITTA 101
|
||||||
|
#define F_RAGSOC 102
|
||||||
|
#define F_TIPO 103
|
||||||
|
#define F_GRUPPO 104
|
||||||
|
#define F_DESGRUPPO 105
|
||||||
|
#define F_CONTO 106
|
||||||
|
#define F_DESCONTO 107
|
||||||
|
#define F_SOTTOCONTO 108
|
||||||
|
#define F_DESSOTTOC 109
|
||||||
|
#define F_CLIENTE 206
|
||||||
|
#define F_RAGSOCCLI 207
|
||||||
|
#define F_FORNITORE 306
|
||||||
|
#define F_RAGSOCFOR 307
|
||||||
|
#define F_ESERCIZIO 110
|
||||||
|
#define F_DADATA 111
|
||||||
|
#define F_ADATA 112
|
||||||
|
#define F_DACAUSALE 113
|
||||||
|
#define F_DADESCAUS 114
|
||||||
|
#define F_ACAUSALE 115
|
||||||
|
#define F_ADESCAUS 116
|
||||||
|
#define F_MASTRINI 200
|
||||||
|
#define F_TOTRIG_IMP 201
|
||||||
|
#define F_TOTRIG_DAR 202
|
||||||
|
#define F_TOTRIG_AVE 203
|
||||||
|
#define F_TOTPER_IMP 211
|
||||||
|
#define F_TOTPER_DAR 212
|
||||||
|
#define F_TOTPER_AVE 213
|
||||||
|
#define F_TOTATT_IMP 221
|
||||||
|
#define F_TOTATT_DAR 222
|
||||||
|
#define F_TOTATT_AVE 223
|
305
cg/cg3600a.uml
Executable file
305
cg/cg3600a.uml
Executable file
@ -0,0 +1,305 @@
|
|||||||
|
#include "cg3600a.h"
|
||||||
|
|
||||||
|
TOOLBAR "" 0 21 0 0
|
||||||
|
|
||||||
|
BUTTON DLG_OK 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -14 -11 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_CANCEL 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -24 -11 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_FINDREC 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -34 -11 ""
|
||||||
|
PICTURE BMP_FINDREC
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_QUIT 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -44 -11 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
PAGE "Mastrini" -1 -1 76 20
|
||||||
|
|
||||||
|
NUMBER F_CODDITTA 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 0 "Ditta "
|
||||||
|
FLAGS "DF"
|
||||||
|
USE LF_NDITTE
|
||||||
|
INPUT CODDITTA F_CODDITTA
|
||||||
|
OUTPUT F_RAGSOC RAGSOC
|
||||||
|
CHECKTYPE NORMAL
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_RAGSOC 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 0 ""
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
LIST F_TIPO 10
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 0 "Tipo "
|
||||||
|
ITEM " |Conto" MESSAGE SHOW,1@|HIDE,2@|HIDE,3@
|
||||||
|
ITEM "C|Cliente" MESSAGE HIDE,1@|SHOW,2@|HIDE,3@
|
||||||
|
ITEM "F|Fornitore" MESSAGE HIDE,1@|HIDE,2@|SHOW,3@
|
||||||
|
FLAGS "H"
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_GRUPPO 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Gruppo "
|
||||||
|
USE LF_PCON SELECT (CONTO="")
|
||||||
|
INPUT GRUPPO F_GRUPPO
|
||||||
|
DISPLAY "Gruppo" GRUPPO
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
OUTPUT F_GRUPPO GRUPPO
|
||||||
|
OUTPUT F_DESGRUPPO DESCR
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
ADD RUN cg0 -0
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESGRUPPO 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 1 ""
|
||||||
|
USE LF_PCON KEY 2 SELECT (CONTO="")
|
||||||
|
INPUT DESCR F_DESGRUPPO
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
DISPLAY "Gruppo" GRUPPO
|
||||||
|
COPY OUTPUT F_GRUPPO
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
ADD RUN cg0 -0
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_CONTO 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 2 "Conto "
|
||||||
|
USE LF_PCON SELECT (CONTO!="")&&(SOTTOCONTO="")
|
||||||
|
INPUT GRUPPO F_GRUPPO
|
||||||
|
INPUT CONTO F_CONTO
|
||||||
|
DISPLAY "Gruppo" GRUPPO
|
||||||
|
DISPLAY "Conto" CONTO
|
||||||
|
DISPLAY "Tipo" TMCF
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
OUTPUT F_TIPO TMCF
|
||||||
|
OUTPUT F_GRUPPO GRUPPO
|
||||||
|
OUTPUT F_CONTO CONTO
|
||||||
|
OUTPUT F_DESCONTO DESCR
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
ADD RUN cg0 -0
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESCONTO 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 2 ""
|
||||||
|
USE LF_PCON KEY 2 SELECT (CONTO!="")&&(SOTTOCONTO="")
|
||||||
|
INPUT DESCR F_DESGRUPPO
|
||||||
|
COPY DISPLAY F_GRUPPO
|
||||||
|
DISPLAY "Conto" CONTO
|
||||||
|
DISPLAY "Tipo" TMCF
|
||||||
|
COPY OUTPUT F_CONTO
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
ADD RUN cg0 -0
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_SOTTOCONTO 6
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 3 "Sottoconto "
|
||||||
|
USE LF_PCON SELECT (SOTTOCONTO!="")
|
||||||
|
COPY INPUT F_CONTO
|
||||||
|
INPUT SOTTOCONTO F_SOTTOCONTO
|
||||||
|
DISPLAY "Gruppo" GRUPPO
|
||||||
|
DISPLAY "Conto" CONTO
|
||||||
|
DISPLAY "Sottoconto" SOTTOCONTO
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
OUTPUT F_GRUPPO GRUPPO
|
||||||
|
OUTPUT F_CONTO CONTO
|
||||||
|
OUTPUT F_SOTTOCONTO SOTTOCONTO
|
||||||
|
OUTPUT F_DESSOTTOC DESCR
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 1
|
||||||
|
ADD RUN cg0 -0
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESSOTTOC 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 3 ""
|
||||||
|
USE LF_PCON KEY 2 SELECT (SOTTOCONTO!="")
|
||||||
|
INPUT DESCR F_DESSOTTOC
|
||||||
|
COPY DISPLAY F_DESCONTO
|
||||||
|
DISPLAY "Sottoconto" SOTTOCONTO
|
||||||
|
COPY OUTPUT F_SOTTOCONTO
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 1
|
||||||
|
ADD RUN cg0 -0
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_CLIENTE 6
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 3 "Cliente "
|
||||||
|
USE LF_CLIFO
|
||||||
|
INPUT TIPOCF "C"
|
||||||
|
INPUT CODCF F_CLIENTE
|
||||||
|
DISPLAY "Codice" CODCF
|
||||||
|
DISPLAY "Ragione Sociale@50" RAGSOC
|
||||||
|
OUTPUT F_CLIENTE CODCF
|
||||||
|
OUTPUT F_RAGSOCCLI RAGSOC
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 2
|
||||||
|
ADD RUN cg0 -1 C
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_RAGSOCCLI 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 3 ""
|
||||||
|
USE LF_CLIFO KEY 2
|
||||||
|
INPUT TIPOCF "C"
|
||||||
|
INPUT RAGSOC F_RAGSOCCLI
|
||||||
|
DISPLAY "Ragione Sociale@50" RAGSOC
|
||||||
|
DISPLAY "Codice" CODCF
|
||||||
|
COPY OUTPUT F_CLIENTE
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 2
|
||||||
|
ADD RUN cg0 -1 C
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_FORNITORE 6
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 3 "Fornitore "
|
||||||
|
USE LF_CLIFO
|
||||||
|
INPUT TIPOCF "F"
|
||||||
|
INPUT CODCF F_FORNITORE
|
||||||
|
COPY DISPLAY F_CLIENTE
|
||||||
|
OUTPUT F_FORNITORE CODCF
|
||||||
|
OUTPUT F_RAGSOCFOR RAGSOC
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 3
|
||||||
|
ADD RUN cg0 -1 F
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_RAGSOCFOR 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 3 ""
|
||||||
|
USE LF_CLIFO KEY 2
|
||||||
|
INPUT TIPOCF "F"
|
||||||
|
INPUT RAGSOC F_RAGSOCFOR
|
||||||
|
COPY DISPLAY F_RAGSOCCLI
|
||||||
|
COPY OUTPUT F_FORNITORE
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 3
|
||||||
|
ADD RUN cg0 -1 F
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER F_ESERCIZIO 4
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 4 "Esercizio "
|
||||||
|
USE ESC
|
||||||
|
INPUT CODTAB F_ESERCIZIO
|
||||||
|
DISPLAY "Codice" CODTAB
|
||||||
|
DISPLAY "Inizio esercizio" D0
|
||||||
|
DISPLAY "Fine esercizio" D1
|
||||||
|
OUTPUT F_ESERCIZIO CODTAB
|
||||||
|
ADD NONE
|
||||||
|
END
|
||||||
|
|
||||||
|
DATE F_DADATA
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 4 "Dalla data "
|
||||||
|
END
|
||||||
|
|
||||||
|
DATE F_ADATA
|
||||||
|
BEGIN
|
||||||
|
PROMPT 51 4 "Alla data "
|
||||||
|
VALIDATE DATE_CMP_FUNC >= F_DADATA
|
||||||
|
WARNING "La data finale deve essere maggiore di quella iniziale"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DACAUSALE 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 5 "Da causale "
|
||||||
|
FLAGS "U"
|
||||||
|
USE LF_CAUSALI
|
||||||
|
INPUT CODCAUS F_DACAUSALE
|
||||||
|
DISPLAY "Codice" CODCAUS
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
OUTPUT F_DACAUSALE CODCAUS
|
||||||
|
OUTPUT F_DADESCAUS DESCR
|
||||||
|
STR_EXPR (#F_ACAUSALE="")||(#F_DACAUSALE<=#F_ACAUSALE)
|
||||||
|
WARNING "La causale iniziale deve precedere quella finale"
|
||||||
|
CHECKTYPE SEARCH
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DADESCAUS 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 5 ""
|
||||||
|
USE LF_CAUSALI KEY 2
|
||||||
|
INPUT DESCR F_DADESCAUS
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
DISPLAY "Codice" CODCAUS
|
||||||
|
COPY OUTPUT F_DACAUSALE
|
||||||
|
CHECKTYPE SEARCH
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_ACAUSALE 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 6 "A causale "
|
||||||
|
FLAGS "U"
|
||||||
|
COPY USE F_DACAUSALE
|
||||||
|
INPUT CODCAUS F_ACAUSALE
|
||||||
|
COPY DISPLAY F_DACAUSALE
|
||||||
|
OUTPUT F_ACAUSALE CODCAUS
|
||||||
|
OUTPUT F_ADESCAUS DESCR
|
||||||
|
STR_EXPR (#F_ACAUSALE>=#F_DACAUSALE)
|
||||||
|
WARNING "La causale finale deve seguire quella iniziale"
|
||||||
|
CHECKTYPE SEARCH
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_ADESCAUS 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 6 ""
|
||||||
|
COPY USE F_DADESCAUS
|
||||||
|
INPUT DESCR F_ADESCAUS
|
||||||
|
COPY DISPLAY F_DADESCAUS
|
||||||
|
COPY OUTPUT F_ACAUSALE
|
||||||
|
CHECKTYPE SEARCH
|
||||||
|
END
|
||||||
|
|
||||||
|
SPREADSHEET F_MASTRINI 0 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 7 "Mastrini"
|
||||||
|
FLAGS "M"
|
||||||
|
ITEM "Data Op. \nData Doc.@10"
|
||||||
|
ITEM "C@1"
|
||||||
|
ITEM "Operazione@20F"
|
||||||
|
ITEM "N.Doc. \nN.Prot.@7"
|
||||||
|
ITEM "Importo@18R"
|
||||||
|
ITEM "Saldo@20R"
|
||||||
|
ITEM "Causale@20"
|
||||||
|
ITEM "Dare@18R"
|
||||||
|
ITEM "Avere@18R"
|
||||||
|
END
|
||||||
|
|
||||||
|
TEXT DLG_NULL
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 -3 "Totali all'ultima riga visualizzata "
|
||||||
|
END
|
||||||
|
|
||||||
|
TEXT DLG_NULL
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 -2 "Totali al periodo "
|
||||||
|
END
|
||||||
|
|
||||||
|
TEXT DLG_NULL
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 -1 "Totali attuali "
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
ENDMASK
|
21
cg/cglib.h
21
cg/cglib.h
@ -190,26 +190,25 @@ class TEsercizi_contabili : private TArray
|
|||||||
long _firm;
|
long _firm;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static int ordina_esercizi(const TObject** o1, const TObject** o2);
|
void check() const;
|
||||||
void check();
|
|
||||||
|
|
||||||
const TEsercizio& esc(int i) const
|
const TEsercizio& esc(int i) const
|
||||||
{ return (const TEsercizio&)operator[](i); }
|
{ return (const TEsercizio&)operator[](i); }
|
||||||
|
|
||||||
int date2index(const TDate& d);
|
int date2index(const TDate& d) const;
|
||||||
int esc2index(int codice);
|
int esc2index(int codice) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
const TEsercizio& esercizio(int codice);
|
const TEsercizio& esercizio(int codice) const;
|
||||||
|
|
||||||
int date2esc(const TDate& date);
|
int date2esc(const TDate& date) const;
|
||||||
int pred(int codice);
|
int pred(int codice) const;
|
||||||
int next(int codice);
|
int next(int codice) const;
|
||||||
int first();
|
int first() const;
|
||||||
int last();
|
int last() const;
|
||||||
bool exist(int codice);
|
bool exist(int codice) const;
|
||||||
|
|
||||||
TEsercizi_contabili();
|
TEsercizi_contabili();
|
||||||
virtual ~TEsercizi_contabili() {}
|
virtual ~TEsercizi_contabili() {}
|
||||||
|
@ -356,7 +356,7 @@ void TEsercizi_contabili::update()
|
|||||||
sort();
|
sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEsercizi_contabili::check()
|
void TEsercizi_contabili::check() const
|
||||||
{
|
{
|
||||||
if (_firm != prefix().get_codditta())
|
if (_firm != prefix().get_codditta())
|
||||||
{
|
{
|
||||||
@ -365,11 +365,11 @@ void TEsercizi_contabili::check()
|
|||||||
error_box("Questo programma carinissimo usa gli esercizi,\n"
|
error_box("Questo programma carinissimo usa gli esercizi,\n"
|
||||||
"purtroppo non tiene conto del cambio ditta!");
|
"purtroppo non tiene conto del cambio ditta!");
|
||||||
#endif
|
#endif
|
||||||
update();
|
((TEsercizi_contabili*)this)->update(); // Fool the compiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::date2index(const TDate& d)
|
int TEsercizi_contabili::date2index(const TDate& d) const
|
||||||
{
|
{
|
||||||
check();
|
check();
|
||||||
for (int i = items()-1; i >= 0; i--)
|
for (int i = items()-1; i >= 0; i--)
|
||||||
@ -381,7 +381,7 @@ int TEsercizi_contabili::date2index(const TDate& d)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::esc2index(int codice)
|
int TEsercizi_contabili::esc2index(int codice) const
|
||||||
{
|
{
|
||||||
check();
|
check();
|
||||||
for (int i = items()-1; i >= 0; i--)
|
for (int i = items()-1; i >= 0; i--)
|
||||||
@ -393,43 +393,43 @@ int TEsercizi_contabili::esc2index(int codice)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::date2esc(const TDate& d)
|
int TEsercizi_contabili::date2esc(const TDate& d) const
|
||||||
{
|
{
|
||||||
const int i = date2index(d);
|
const int i = date2index(d);
|
||||||
return i >= 0 ? esc(i).codice() : 0;
|
return i >= 0 ? esc(i).codice() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::first()
|
int TEsercizi_contabili::first() const
|
||||||
{
|
{
|
||||||
check();
|
check();
|
||||||
return items() ? esc(0).codice() : 0;
|
return items() ? esc(0).codice() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::last()
|
int TEsercizi_contabili::last() const
|
||||||
{
|
{
|
||||||
check();
|
check();
|
||||||
return items() ? esc(items()-1).codice() : 0;
|
return items() ? esc(items()-1).codice() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::pred(int codice)
|
int TEsercizi_contabili::pred(int codice) const
|
||||||
{
|
{
|
||||||
const int i = esc2index(codice);
|
const int i = esc2index(codice);
|
||||||
return i > 0 ? esc(i-1).codice() : 0;
|
return i > 0 ? esc(i-1).codice() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TEsercizi_contabili::next(int anno)
|
int TEsercizi_contabili::next(int anno) const
|
||||||
{
|
{
|
||||||
const int i = esc2index(anno);
|
const int i = esc2index(anno);
|
||||||
return i < items()-1 ? esc(i+1).codice() : 0;
|
return i < items()-1 ? esc(i+1).codice() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TEsercizi_contabili::exist(int codice)
|
bool TEsercizi_contabili::exist(int codice) const
|
||||||
{
|
{
|
||||||
const int i = esc2index(codice);
|
const int i = esc2index(codice);
|
||||||
return i >= 0;
|
return i >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TEsercizio& TEsercizi_contabili::esercizio(int codice)
|
const TEsercizio& TEsercizi_contabili::esercizio(int codice) const
|
||||||
{
|
{
|
||||||
const int i = esc2index(codice);
|
const int i = esc2index(codice);
|
||||||
return esc(i);
|
return esc(i);
|
||||||
@ -438,3 +438,5 @@ const TEsercizio& TEsercizi_contabili::esercizio(int codice)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user