Patch level : 2.2

Files correlati     : ba0 e ba8
Ricompilazione Demo : [ ]
Commento            :

Reso derivabile il programma di stampa report generici.
Attualmente viene usato da ve1400.cpp per la stampa dei report basati su documenti


git-svn-id: svn://10.65.10.50/trunk@13420 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-10-13 14:50:09 +00:00
parent f6c4a05cb3
commit be76193ce8
3 changed files with 53 additions and 34 deletions

View File

@ -327,18 +327,17 @@ bool TExplorer_mask::stop_run(KEY k)
if (ADVANCED_GRAPHICS) if (ADVANCED_GRAPHICS)
{ {
const int divider = 8; const int divider = 8;
WINDOW window[3]; WINDOW window[3] = {
win(),
((TWindowed_field&)field(DLG_TREE)).win().win(),
((TWindowed_field&)field(DLG_LIST)).win().win()
};
XVT_IMAGE image[3]; XVT_IMAGE image[3];
int i; int i;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
WINDOW w = NULL_WIN; WINDOW& w = window[i];
switch (i)
{
case 1: w = ((TWindowed_field&)field(DLG_TREE)).win().win(); break;
case 2: w = ((TWindowed_field&)field(DLG_LIST)).win().win(); break;
default: w = win(); break;
}
RCT rct; xvt_vobj_get_client_rect(w, &rct); RCT rct; xvt_vobj_get_client_rect(w, &rct);
RCT irct = rct; irct.right /= divider; irct.bottom /= divider; RCT irct = rct; irct.right /= divider; irct.bottom /= divider;
XVT_IMAGE cap = xvt_image_capture(w, &rct); XVT_IMAGE cap = xvt_image_capture(w, &rct);
@ -357,7 +356,6 @@ bool TExplorer_mask::stop_run(KEY k)
xvt_image_set_pixel(img, x, y, MAKE_COLOR(r, g, b)); xvt_image_set_pixel(img, x, y, MAKE_COLOR(r, g, b));
} }
} }
window[i] = w;
image[i] = img; image[i] = img;
} }
for (i = 2; i >= 0; i--) for (i = 2; i >= 0; i--)

View File

@ -6,6 +6,7 @@
#include <reprint.h> #include <reprint.h>
#include "ba8400.h" #include "ba8400.h"
#include "ba8500.h"
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Utility // Utility
@ -13,8 +14,14 @@
bool cod2app(const char* tok, TString& app) bool cod2app(const char* tok, TString& app)
{ {
if (isalpha(tok[0]) && isalpha(tok[1]) && atoi(tok+2) > 1000) if (tok != NULL && isalpha(tok[0]) && isalpha(tok[1]) && atoi(tok+2) > 1000)
{ {
TFilename f;
f.strncpy(tok, 3);
f.ext("exe");
if (!f.custom_path())
return false;
app.strncpy(tok, 3); app.strncpy(tok, 3);
app << " -" << char(tok[3]-1); app << " -" << char(tok[3]-1);
return true; return true;
@ -76,16 +83,7 @@ bool rep2app(const char* name, TString& app, TString& desc)
if (app.not_empty()) if (app.not_empty())
return true; return true;
TToken_string libraries(50, ','); return cod2app(report_name.name(), app);
get_xml_attr(stringona, "libraries", libraries);
FOR_EACH_TOKEN(libraries, tok) if (strlen(tok) == 6)
{
if (cod2app(tok, app))
return true;
}
cod2app(report_name.name(), app);
return true;
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -119,10 +117,10 @@ bool TKlarkKent_mask::on_field_event(TOperable_field& o, TField_event e, long jo
{ {
TFilename name = o.get(); TFilename name = o.get();
TString app, desc; TString app, desc;
const bool ok = rep2app(name, app, desc); rep2app(name, app, desc);
set(F_FORM, desc); set(F_FORM, desc);
set(F_DOC, app); set(F_DOC, app);
enable(DLG_PRINT, ok); enable(DLG_PRINT, desc.not_empty());
} }
break; break;
case DLG_EDIT: case DLG_EDIT:
@ -144,11 +142,12 @@ bool TKlarkKent_mask::on_field_event(TOperable_field& o, TField_event e, long jo
// TKlarkKent_app // TKlarkKent_app
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TKlarkKent_app : public TSkeleton_application TReport* TKlarkKent_app::create_report(const char* name) const
{ {
protected: TReport* r = new TReport;
virtual void main_loop(); r->load(name);
}; return r;
}
void TKlarkKent_app::main_loop() void TKlarkKent_app::main_loop()
{ {
@ -161,6 +160,7 @@ void TKlarkKent_app::main_loop()
bool can_repeat = false; bool can_repeat = false;
do do
{ {
TReport* report = NULL;
TReport_book book; TReport_book book;
FOR_EACH_ARRAY_ROW(arr, r, row) FOR_EACH_ARRAY_ROW(arr, r, row)
{ {
@ -180,8 +180,8 @@ void TKlarkKent_app::main_loop()
} }
TString appname, desc; TString appname, desc;
rep2app(report_name, appname, desc); const bool custom_app = rep2app(report_name, appname, desc);
if (appname.not_empty()) if (custom_app)
{ {
appname << ' ' << report_name; appname << ' ' << report_name;
TExternal_app app(appname); TExternal_app app(appname);
@ -189,23 +189,33 @@ void TKlarkKent_app::main_loop()
} }
else else
{ {
TReport rep; if (report != NULL)
if (rep.load(report_name)) delete report;
report = create_report(report_name);
if (report != NULL)
{ {
const bool ok = book.add(rep); const bool ok = book.add(*report);
if (ok && arr.items() == 1) // Controlla se e' pensabile ripetere la stampa if (ok && arr.items() == 1) // Controlla se e' pensabile ripetere la stampa
{ {
TFilename msk = report_name; TFilename msk = report_name;
msk.ext("msk"); msk.ext("msk");
can_repeat = msk.exist(); // Posso ripetere se ho una maschera collegata can_repeat = msk.custom_path(); // Posso ripetere se ho una maschera collegata
} }
else else
can_repeat = false; can_repeat = false;
} }
} }
} // ciclo sulla lista dei report da stampare
// L'anteprima funziona bene solo se non si distrugge il report corrente
if (report != NULL)
{
if (book.pages() > 0)
book.print_or_preview();
delete report;
report = NULL;
} }
if (book.pages() > 0)
book.print_or_preview();
} while (can_repeat); } while (can_repeat);
} }

11
ba/ba8500.h Executable file
View File

@ -0,0 +1,11 @@
#ifndef __BA8500_H
#define __BA8500_H
class TKlarkKent_app : public TSkeleton_application
{
protected:
virtual TReport* create_report(const char* name) const;
virtual void main_loop();
};
#endif