browfile.h Stampa background multipli

form.cpp                  "
printer.*                 "
viswin.*                  "
execp.*       Aggiunta fantastica goto_url
isam.cpp      Tolta riga vuota
mask.h        Tolto TMask:: da un metodo
files.h       Tolto include object.h


git-svn-id: svn://10.65.10.50/trunk@5225 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-09-19 08:47:46 +00:00
parent 0a73f4aedc
commit 11d8c5e0b0
11 changed files with 127 additions and 38 deletions

View File

@ -21,11 +21,12 @@ class TBrowsefile_field : public TOperable_field
TViswin* _viswin; TViswin* _viswin;
MASK_LINKHANDLER _lh; MASK_LINKHANDLER _lh;
TArray _links; TArray _links;
TString_array _background;
bool _m_link; bool _m_link;
short _dlg; short _dlg;
WINDOW _parent; WINDOW _parent;
TString_array _background; // Background per usi diversi da anterpima!
protected: protected:
virtual word class_id() const; virtual word class_id() const;
@ -62,7 +63,7 @@ public:
// print background // print background
void set_background(const char* bg); void set_background(const char* bg);
TArray* get_bg_desc() { return &_background; } TString_array& get_bg_desc() { return _background; }
virtual short dlg() const { return _dlg; } virtual short dlg() const { return _dlg; }
// @cmember Ritorna la finestra padre // @cmember Ritorna la finestra padre

View File

@ -5,6 +5,7 @@
#include <xvt.h> #include <xvt.h>
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
#include <shellapi.h>
#include <toolhelp.h> #include <toolhelp.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
@ -152,7 +153,7 @@ word TExternal_app::run(
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (can_run()) if (can_run())
{ {
main_app().begin_wait(); TWait_cursor hourglass;
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
HL_LOGOUT(); HL_LOGOUT();
_exitcode = WinExec((char*)(const char*)path, SW_SHOW); _exitcode = WinExec((char*)(const char*)path, SW_SHOW);
@ -251,7 +252,6 @@ word TExternal_app::run(
else _exitcode = -1; else _exitcode = -1;
#endif #endif
main_app().end_wait();
} else _exitcode = 1; } else _exitcode = 1;
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
@ -361,3 +361,54 @@ TExternal_app::TExternal_app(const char* p)
_error = 0; _error = 0;
_exitcode = 0; _exitcode = 0;
} }
///////////////////////////////////////////////////////////////////////////////
// GotoURL
// Liberamente tradotto da Windows Developer Journal August 1997
///////////////////////////////////////////////////////////////////////////////
static long get_reg_key(HKEY key, const char* subkey, TString& retdata)
{
HKEY hkey;
long retval = RegOpenKey(key, subkey, &hkey);
if (retval == ERROR_SUCCESS)
{
long datasize = retdata.size();
RegQueryValue(hkey, NULL, retdata.get_buffer(), &datasize);
RegCloseKey(hkey);
}
return retval;
}
bool goto_url(const char* url)
{
TString key(MAX_PATH*2);
bool retflag = FALSE;
HINSTANCE hinst = ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
DWORD winst = DWORD((DWORD*)hinst);
UINT error = UINT(winst); // Tutto 'sto giro per evitare un warning
if (error < 32)
{
if (get_reg_key(HKEY_CLASSES_ROOT, ".htm", key) == ERROR_SUCCESS)
{
key << "\\shell\\open\\command";
if (get_reg_key(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS)
{
int pos = key.find("\"%1\"");
if (pos < 0)
pos = key.find("%1");
if (pos > 0)
key.cut(pos);
key << ' ' << url;
error = WinExec(key, SW_SHOWNORMAL);
if (error > 31)
retflag = TRUE;
}
}
}
else
retflag = TRUE;
return retflag;
}

View File

@ -51,4 +51,7 @@ public:
TExternal_app(const char* p); TExternal_app(const char* p);
}; };
// Va ad un URl qualsiasi
bool goto_url(const char* url);
#endif #endif

View File

@ -1,10 +1,6 @@
#ifndef __FILES_H #ifndef __FILES_H
#define __FILES_H #define __FILES_H
#ifndef __OBJECT_H
#include <object.h>
#endif
#ifndef __EXTCTYPE_H #ifndef __EXTCTYPE_H
#include <extctype.h> #include <extctype.h>
#endif #endif

View File

@ -710,6 +710,11 @@ void TForm_item::send_message(
des.set(""); des.set("");
} else if (cmd == "SHOW") { } else if (cmd == "SHOW") {
des.show(); des.show();
} else if (cmd == "SUB") {
const real n(get());
real r(des.get());
r -= n;
des.set(r.string());
} else if (cmd[0] == '"') { } else if (cmd[0] == '"') {
TString256 val(cmd); TString256 val(cmd);
val.strip("\""); val.strip("\"");
@ -2160,9 +2165,18 @@ TForm_item* TGraphic_section::parse_item(const TString& s)
bool TGraphic_section::update() bool TGraphic_section::update()
{ {
_back = ""; _back.cut(0);
const bool ok = TPrint_section::update(); const bool ok = TPrint_section::update();
printer().setbackground(_back);
int index;
switch(page_type())
{
case even_page: index = 1; break;
case odd_page : index = 2; break;
case last_page: index = 3; break;
default : index = 0; break;
}
printer().setbackground(_back, index);
return ok; return ok;
} }

View File

@ -849,7 +849,6 @@ void TBaseisamfile::set_curr(TRectype * curr)
} }
void TBaseisamfile::setkey(int nkey) void TBaseisamfile::setkey(int nkey)
{ {
CHECKD(nkey > 0 && nkey-1 <= _isamfile->r->NKeys, "Chiave non valida ", nkey); CHECKD(nkey > 0 && nkey-1 <= _isamfile->r->NKeys, "Chiave non valida ", nkey);
NOT_OPEN(); NOT_OPEN();

View File

@ -291,7 +291,7 @@ public:
{ _should_check = FALSE;} { _should_check = FALSE;}
// @cmember Evita che venga chiamata la TWindow // @cmember Evita che venga chiamata la TWindow
virtual void TMask::on_button(short); virtual void on_button(short);
// @cmember Assegna una azione al tasto non standard // @cmember Assegna una azione al tasto non standard
virtual bool on_key(KEY key); virtual bool on_key(KEY key);

View File

@ -270,7 +270,6 @@ HIDDEN int read_int (const char *s, int &n, int &cnt)
return n = atoi (nbuf); return n = atoi (nbuf);
} }
void TPrinter::parse_background(const char* bg_desc, TString_array& background) void TPrinter::parse_background(const char* bg_desc, TString_array& background)
{ {
TString_array pix; TString_array pix;
@ -508,12 +507,28 @@ void TPrinter::parse_background(const char* bg_desc, TString_array& background)
} }
} }
void TPrinter::setbackground(const char* b) void TPrinter::setbackground(const char* b, int index)
{ {
_background.destroy(); CHECK(index >= 0 && index <= 3, "Bad background index");
_backgrounds.destroy(index);
if (b && *b) if (b && *b)
parse_background(b, _background); {
TString_array* bg = new TString_array(formlen());
_backgrounds.add(bg, index);
parse_background(b, *bg);
} }
}
TString_array& TPrinter::getbgdesc(word page) const
{
if (_backgrounds.items() == 0)
((TPrinter*)this)->_backgrounds.add(new TString_array(formlen()));
int index = (page > 0) ? ((page-1) % _backgrounds.items()) : 0;
TString_array* bg = (TString_array*)_backgrounds.objptr(index);
CHECK(bg, "Null printer background");
return *bg;
}
bool printers_on_key(TMask_field & f, KEY key); bool printers_on_key(TMask_field & f, KEY key);
@ -2086,6 +2101,9 @@ void TPrinter::close ()
_finker = NULL; _finker = NULL;
} }
// Dealloca sfondi ormai inutili
_backgrounds.destroy();
freeze (FALSE); freeze (FALSE);
_isopen = FALSE; _isopen = FALSE;
WriteProfileString("windows", "device", defPrinter); WriteProfileString("windows", "device", defPrinter);

View File

@ -300,8 +300,9 @@ class TPrinter : public TObject
// @cmember:(INTERNAL) Nome del paragrafo di configurazione // @cmember:(INTERNAL) Nome del paragrafo di configurazione
TString _config; TString _config;
// @cmember:(INTERNAL) Array di stringhe per la desccrizione del background // @cmember:(INTERNAL) Array di stringhe per la descrizione del background
TString_array _background; TArray _backgrounds;
// @cmember:(INTERNAL) Nomi dei file delle immagini da stampare // @cmember:(INTERNAL) Nomi dei file delle immagini da stampare
TString_array _image_names; TString_array _image_names;
@ -472,13 +473,12 @@ public:
// @cmember Elimina il contenuto del footer // @cmember Elimina il contenuto del footer
void resetfooter(); void resetfooter();
// @cmember Setta il colore del background // @cmember Setta il colore del background
void setbackground(const char* bg); void setbackground(const char* bg, int index = 0);
// @cmember Ritorna l'array con i nomi delle immagini da stampare!!! // @cmember Ritorna l'array con i nomi delle immagini da stampare!!!
TString_array& image_names() TString_array& image_names()
{ return _image_names; } { return _image_names; }
// @cmember Ritorna l'array con i nomi dei colori da stampare!!! // @cmember Ritorna l'array con i nomi dei colori da stampare!!!
TString_array& getbgdesc() TString_array& getbgdesc(word page = 0) const;
{ return _background; }
// @cmember Ritorna l'array con i segalibri settati // @cmember Ritorna l'array con i segalibri settati
TArray& get_bookmarks() TArray& get_bookmarks()
{ return _bookmarks; } { return _bookmarks; }

View File

@ -687,15 +687,23 @@ void TViswin::paint_background(
long j, // @parm Numero della riga di cui stampare il background long j, // @parm Numero della riga di cui stampare il background
int row) // @parm Numero della riga a video sulla quale viene stampato il background int row) // @parm Numero della riga a video sulla quale viene stampato il background
{ {
const bool isbackground = _bg->items() > 0 && printer().isgraphics(); TPrinter& pr = printer();
const bool fink_mode = printer().get_fink_mode();
if (_toplevel)
{
const word page = word((j-1) / pr.formlen() + 1);
_bg = &pr.getbgdesc(page);
}
const bool isbackground = _bg->items() > 0 && pr.isgraphics();
const bool fink_mode = pr.get_fink_mode();
const int rw = (int)(j % (long)_formlen); const int rw = (int)(j % (long)_formlen);
const int ox = (int)origin().x; const int ox = (int)origin().x;
const int mx = ox + columns(); const int mx = ox + columns();
if (!fink_mode) if (!fink_mode)
{ {
const char* line = printer().background_chars(rw); const char* line = pr.background_chars(rw);
set_color (COLOR_BLACK, COLOR_WHITE); set_color (COLOR_BLACK, COLOR_WHITE);
if (line != NULL && (int)strlen(line) > ox) if (line != NULL && (int)strlen(line) > ox)
printat (X_OFFSET, row, "%s", &line[ox]); printat (X_OFFSET, row, "%s", &line[ox]);
@ -704,7 +712,7 @@ void TViswin::paint_background(
if (!isbackground) if (!isbackground)
return; return;
const TString& rwd = (TString &)(*_bg)[rw]; const TString& rwd = _bg->row(rw);
char curcol = 'n'; char curcol = 'n';
char curpen = 'n'; char curpen = 'n';
@ -1057,7 +1065,6 @@ void TViswin::erase_crossbar ()
void TViswin::display_point() void TViswin::display_point()
{ {
if (!_point_displayed) if (!_point_displayed)
paint_point (); paint_point ();
_point_displayed = TRUE; _point_displayed = TRUE;
@ -2590,7 +2597,7 @@ TViswin::TViswin(const char *fname,
_multiple = _toplevel ? (printer ().ismultiplelink()) : _multiple = _toplevel ? (printer ().ismultiplelink()) :
(_brwfld->is_multiple_link()); (_brwfld->is_multiple_link());
_bg = _toplevel ? &(printer().getbgdesc()) : _brwfld->get_bg_desc(); _bg = _toplevel ? &(printer().getbgdesc()) : &_brwfld->get_bg_desc();
_formlen = _toplevel ? printer().formlen() : maxalt; _formlen = _toplevel ? printer().formlen() : maxalt;
_linkID = -1; _linkID = -1;
_inside_linkexec = FALSE; _inside_linkexec = FALSE;

View File

@ -154,7 +154,7 @@ class TViswin : public TScroll_window
TToken_string _multiple_link; TToken_string _multiple_link;
// @cmember:(INTERNAL) Array di colori di background // @cmember:(INTERNAL) Array di colori di background
TArray* _bg; TString_array* _bg;
// @cmember:(INTERNAL) Indica se la stampa e' stata interrotta // @cmember:(INTERNAL) Indica se la stampa e' stata interrotta
bool _frozen; bool _frozen;
// @cmember:(INTERNAL) Finestra in primo piano (se FALSE e un campo di una maschera) // @cmember:(INTERNAL) Finestra in primo piano (se FALSE e un campo di una maschera)