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,10 +21,11 @@ class TBrowsefile_field : public TOperable_field
TViswin* _viswin;
MASK_LINKHANDLER _lh;
TArray _links;
TString_array _background;
bool _m_link;
short _dlg;
WINDOW _parent;
TString_array _background; // Background per usi diversi da anterpima!
protected:
virtual word class_id() const;
@ -62,7 +63,7 @@ public:
// print background
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; }
// @cmember Ritorna la finestra padre

View File

@ -5,6 +5,7 @@
#include <xvt.h>
#if XVT_OS == XVT_OS_WIN
#include <shellapi.h>
#include <toolhelp.h>
#include <string.h>
#include <ctype.h>
@ -152,7 +153,7 @@ word TExternal_app::run(
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (can_run())
{
main_app().begin_wait();
TWait_cursor hourglass;
#if XVT_OS == XVT_OS_WIN
HL_LOGOUT();
_exitcode = WinExec((char*)(const char*)path, SW_SHOW);
@ -251,7 +252,6 @@ word TExternal_app::run(
else _exitcode = -1;
#endif
main_app().end_wait();
} else _exitcode = 1;
#if XVT_OS == XVT_OS_WIN
@ -361,3 +361,54 @@ TExternal_app::TExternal_app(const char* p)
_error = 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);
};
// Va ad un URl qualsiasi
bool goto_url(const char* url);
#endif

View File

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

View File

@ -700,7 +700,7 @@ void TForm_item::send_message(
if (val.not_empty()) val << ' ';
val << get();
des.set(val);
} else if (cmd == "DISABLE") {
} else if (cmd == "DISABLE") {
des.disable();
} else if (cmd == "ENABLE") {
des.enable();
@ -710,6 +710,11 @@ void TForm_item::send_message(
des.set("");
} else if (cmd == "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] == '"') {
TString256 val(cmd);
val.strip("\"");
@ -2160,9 +2165,18 @@ TForm_item* TGraphic_section::parse_item(const TString& s)
bool TGraphic_section::update()
{
_back = "";
_back.cut(0);
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;
}

View File

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

View File

@ -291,7 +291,7 @@ public:
{ _should_check = FALSE;}
// @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
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);
}
void TPrinter::parse_background(const char* bg_desc, TString_array& background)
{
TString_array pix;
@ -508,13 +507,29 @@ void TPrinter::parse_background(const char* bg_desc, TString_array& background)
}
}
void TPrinter::setbackground(const char* b)
{
_background.destroy();
void TPrinter::setbackground(const char* b, int index)
{
CHECK(index >= 0 && index <= 3, "Bad background index");
_backgrounds.destroy(index);
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);
// fv support structs for config
@ -2085,6 +2100,9 @@ void TPrinter::close ()
delete _finker;
_finker = NULL;
}
// Dealloca sfondi ormai inutili
_backgrounds.destroy();
freeze (FALSE);
_isopen = FALSE;

View File

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

View File

@ -686,16 +686,24 @@ void TViswin::paint_screen ()
void TViswin::paint_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
{
const bool isbackground = _bg->items() > 0 && printer().isgraphics();
const bool fink_mode = printer().get_fink_mode();
{
TPrinter& pr = printer();
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 ox = (int)origin().x;
const int mx = ox + columns();
if (!fink_mode)
{
const char* line = printer().background_chars(rw);
const char* line = pr.background_chars(rw);
set_color (COLOR_BLACK, COLOR_WHITE);
if (line != NULL && (int)strlen(line) > ox)
printat (X_OFFSET, row, "%s", &line[ox]);
@ -704,7 +712,7 @@ void TViswin::paint_background(
if (!isbackground)
return;
const TString& rwd = (TString &)(*_bg)[rw];
const TString& rwd = _bg->row(rw);
char curcol = 'n';
char curpen = 'n';
@ -1055,15 +1063,14 @@ void TViswin::erase_crossbar ()
_cross_displayed = FALSE;
}
void TViswin::display_point ()
void TViswin::display_point()
{
if (!_point_displayed)
paint_point ();
_point_displayed = TRUE;
}
void TViswin::erase_point ()
void TViswin::erase_point()
{
if (_point_displayed)
paint_point ();
@ -2590,7 +2597,7 @@ TViswin::TViswin(const char *fname,
_multiple = _toplevel ? (printer ().ismultiplelink()) :
(_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;
_linkID = -1;
_inside_linkexec = FALSE;
@ -2745,19 +2752,19 @@ void TBrowsefile_field::disable_link(char fg, char bg)
void TBrowsefile_field::set_background(const char* bg)
{
printer().parse_background(bg, _background);
}
void TBrowsefile_field::add_line(const char* l)
}
void TBrowsefile_field::add_line(const char* l)
{
_viswin->add_line(l);
}
void TBrowsefile_field::close()
void TBrowsefile_field::close()
{
_viswin->close_print();
}
void TBrowsefile_field::goto_pos(long r, long c)
void TBrowsefile_field::goto_pos(long r, long c)
{
_viswin->goto_pos(r,c,TRUE);
}

View File

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