campo-sirio/ve/ve0400.cpp
alex a0a36d6b33 Patch level : XX.282
Files correlati     :
Ricompilazione Demo : [ ]
Commento            : Riportata la versione 01.05 patch 282


git-svn-id: svn://10.65.10.50/trunk@8019 c028cbd2-c16b-5b4b-a496-9718f37d4682
1999-04-06 15:34:39 +00:00

134 lines
2.9 KiB
C++
Executable File

#include <automask.h>
#include <os_dep.h>
#include <printer.h>
#include <tabapp.h>
#include "vetbnum.h"
///////////////////////////////////////////////////////////
// TVendite_mask
///////////////////////////////////////////////////////////
class TVendite_mask : public TAutomask
{
TString _tab; // Voglio la tabella sempre sotto mano
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
bool is_table(const char* tab) const { return _tab == tab; }
void get_printer_config(TString& name) const;
bool get_printer_name(TString& name) const;
void reset_printer_config() const;
bool on_num_event(TOperable_field& o, TField_event e, long jolly);
public:
TVendite_mask(const char* name);
virtual ~TVendite_mask() { }
};
void TVendite_mask::get_printer_config(TString& config) const
{
config = _tab;
for (TEditable_field* f = get_key_field(1, TRUE); f;
f = get_key_field(1, FALSE)) if (f->shown())
config << f->get();
}
bool TVendite_mask::get_printer_name(TString& name) const
{
TString16 config; get_printer_config(config);
TConfig ini(CONFIG_STAMPE, config);
if (ini.get_int("Type", NULL, -1, -1) >= 0)
{
const int num = ini.get_int("Number");
if (num >= 0)
{
TToken_string pn;
os_get_printer_names(pn);
name = pn.get(num);
}
}
return name.not_empty();
}
void TVendite_mask::reset_printer_config() const
{
TString16 config; get_printer_config(config);
TConfig ini(CONFIG_STAMPE, config);
ini.remove_all();
}
bool TVendite_mask::on_num_event(TOperable_field& o, TField_event e, long jolly)
{
switch(o.dlg())
{
case NUM_DEFPRINTER:
if (e == fe_button && !query_mode())
{
TPrinter& pr = printer();
TString16 config; get_printer_config(config);
pr.read_configuration(config);
pr.set();
e = fe_init;
}
if (e == fe_init)
{
TString name; get_printer_name(name);
o.set(name);
}
if (e == fe_close && o.empty())
reset_printer_config();
break;
default:
break;
}
return TRUE;
}
bool TVendite_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
if (is_table("NUM"))
return on_num_event(o, e, jolly);
return TRUE;
}
TVendite_mask::TVendite_mask(const char* name) : TAutomask(name)
{
const TFixed_string n(name);
_tab = n.mid(4,3);
_tab.upper();
}
///////////////////////////////////////////////////////////
// TVendite_tabapp
///////////////////////////////////////////////////////////
class TVendite_tabapp : public TTable_application
{
protected:
virtual TMask* set_mask(TMask* m);
public:
};
TMask* TVendite_tabapp::set_mask(TMask* m)
{
if (m == NULL)
{
TFilename mn; get_mask_name(mn);
m = new TVendite_mask(mn);
}
return TTable_application::set_mask(m);
}
int ve0400(int argc, char* argv[])
{
TVendite_tabapp vta;
vta.run(argc, argv, "Tabella Vendite");
return 0;
}