Modifiche dalla versione Linux sulla 2.1

git-svn-id: svn://10.65.10.50/trunk@11839 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2004-03-12 14:21:37 +00:00
parent d054341657
commit 2902fa494a
4 changed files with 136 additions and 46 deletions

View File

@ -1,8 +1,10 @@
#include "wxinc.h" #include "wxinc.h"
#include <fstream.h>
#ifdef LINUX #ifdef LINUX
#include "xvt_type.h" #include "xvt_type.h"
#include "../include/incstr.h"
#else
#include <fstream.h>
#endif #endif
#include "agasys.h" #include "agasys.h"

13
xvaga/incstr.h Executable file
View File

@ -0,0 +1,13 @@
#ifndef __INCSTR_H
#define __INCRSTR_H
#ifdef WIN32
#ifndef _INC_FSTREAM
#include <fstream.h>
#endif
#include <strstrea.h>
#else
#include <fstream>
#include <sstream>
using namespace std;
#endif
#endif

View File

@ -7,6 +7,7 @@
#include "wx/fontdlg.h" #include "wx/fontdlg.h"
#include "wx/fs_zip.h" #include "wx/fs_zip.h"
#include "wx/image.h" #include "wx/image.h"
#include <wx/snglinst.h> #include <wx/snglinst.h>
#include <wx/thread.h> #include <wx/thread.h>
@ -20,10 +21,16 @@
#include "oswin32.h" #include "oswin32.h"
#include <io.h> #include <io.h>
#else #else
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include "oslinux.h" #include "oslinux.h"
#endif #endif
#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win
#define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w);
#define CAST_TDC(win,dc) XVT_ASSERT(win != NULL_WIN); TDC& dc = _dc_map.GetTDC((TwxWindow*)win);
#define CAST_DC(win,dc) XVT_ASSERT(win != NULL_WIN); wxDC& dc = _dc_map.GetDC((TwxWindow*)win);
// Funzione interna di utilita' // Funzione interna di utilita'
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m); MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m);
@ -40,16 +47,16 @@ static wxHashTable _nice_icons;
static EVENT_HANDLER _task_win_handler = NULL; static EVENT_HANDLER _task_win_handler = NULL;
static XVT_ERRMSG_HANDLER _error_handler = NULL; static XVT_ERRMSG_HANDLER _error_handler = NULL;
#define XVT_ASSERT(test) assert_box((test), __LINE__) #define XVT_ASSERT(test) assert_box((test), __LINE__, __FILE__ )
void assert_box(bool test, int line) void assert_box(bool test, int line, const char * file)
{ {
if (!test) if (!test)
{ {
bool display = (_error_handler == NULL) || (_error_handler(SEV_FATAL, NULL) == FALSE); bool display = (_error_handler == NULL) || (_error_handler(SEV_FATAL, NULL) == FALSE);
if (display) if (display)
{ {
const wxString strMessage = wxString::Format("Sorry, the application passed some invalid parameters on line %d.", line); const wxString strMessage = wxString::Format("Sorry, the application passed some invalid parameters on line %d file %s.", line, file);
const wxString strCaption = "Emulated XVT Error "; const wxString strCaption = "Emulated XVT Error ";
::wxMessageBox(strMessage, strCaption, wxOK|wxICON_ERROR); ::wxMessageBox(strMessage, strCaption, wxOK|wxICON_ERROR);
} }
@ -135,6 +142,8 @@ wxIcon* GetIconResource(int rid)
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO); icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
_nice_icons.Put(rid, icon); _nice_icons.Put(rid, icon);
} }
else
icon = (wxIcon*)_nice_icons.Get(ICON_RSRC);
} }
XVT_ASSERT(icon != NULL); XVT_ASSERT(icon != NULL);
return icon; return icon;
@ -478,7 +487,9 @@ bool TDC::GetClippingBox(RCT* pRct) const
return _clip.right > _clip.left; return _clip.right > _clip.left;
} }
class TDCMapper : public wxHashTable WX_DECLARE_HASH_MAP(wxWindow*, TDC*, wxPointerHash, wxPointerEqual, wxTDCHashMap);
class TDCMapper : public wxTDCHashMap
{ {
wxWindow* _pLastOwner; wxWindow* _pLastOwner;
TDC* _pLastTDC; TDC* _pLastTDC;
@ -486,29 +497,44 @@ class TDCMapper : public wxHashTable
public: public:
TDC& GetTDC(wxWindow* owner); TDC& GetTDC(wxWindow* owner);
wxDC& GetDC(wxWindow* owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); } wxDC& GetDC(wxWindow* owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); }
void DestroyDC(wxWindow* owner);
void DestroyTDC(wxWindow* owner); void DestroyTDC(wxWindow* owner);
bool HasValidDC(WINDOW owner) const; bool HasValidDC(WINDOW owner) const;
TDCMapper() : _pLastOwner(NULL), _pLastTDC(NULL) { } TDCMapper() : _pLastOwner(NULL), _pLastTDC(NULL) { }
} _dc_map; } _dc_map;
void TDCMapper::DestroyDC(wxWindow* owner)
{
if (owner)
{
TDC* pTDC = (*this)[owner];
if (pTDC)
pTDC->KillDC();
}
else
clear();
}
void TDCMapper::DestroyTDC(wxWindow* owner) void TDCMapper::DestroyTDC(wxWindow* owner)
{ {
if (owner) if (owner)
{ {
wxObject* pDC = Delete((long)owner); TDC* pTDC = (*this)[owner];
if (pDC) if (pTDC)
delete pDC; delete pTDC;
} }
else else
{ {
BeginFind(); TDCMapper::iterator it;
for (wxNode* node = Next(); node; node = Next())
for (it = begin(); it != end(); ++it)
{ {
wxObject* pDC = node->GetData(); TDC* pTDC = it->second;
delete pDC; if (pTDC)
delete pTDC;
} }
Clear(); clear();
} }
_pLastOwner = NULL; _pLastOwner = NULL;
} }
@ -518,18 +544,18 @@ TDC& TDCMapper::GetTDC(wxWindow* owner)
if (owner == _pLastOwner) if (owner == _pLastOwner)
return *_pLastTDC; return *_pLastTDC;
TDC* pDC = (TDC*)Get((long)owner); TDC* pTDC = (*this)[owner];
if (pDC == NULL) if (pTDC == NULL)
{ {
if (owner == (wxWindow*)_print_win) if (owner == (wxWindow*)_print_win)
pDC = new TPrintDC(owner); pTDC = new TPrintDC(owner);
else else
pDC = new TDC(owner); pTDC = new TDC(owner);
Put((long)owner, pDC); (*this)[owner] = pTDC;
} }
_pLastOwner = owner; _pLastOwner = owner;
_pLastTDC = pDC; _pLastTDC = pTDC;
return *pDC; return *pTDC;
} }
bool TDCMapper::HasValidDC(WINDOW owner) const bool TDCMapper::HasValidDC(WINDOW owner) const
@ -540,8 +566,9 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
if (owner == (WINDOW)_pLastOwner) if (owner == (WINDOW)_pLastOwner)
return true; return true;
wxObject* pDC = Get(owner); CAST_WIN(owner, w);
return pDC != NULL; TDC* pTDC = (*((TDCMapper *) this))[&w];
return pTDC != NULL;
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -554,19 +581,19 @@ class TwxWindowBase : public wxWindow
{ {
public: public:
TwxWindowBase() { } TwxWindowBase() { }
TwxWindowBase(wxWindow* parent, int id, const wxString& title, TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
wxPoint pos, wxSize size, long style); const wxPoint & pos, const wxSize & size, long style);
DECLARE_DYNAMIC_CLASS(TwxWindowBase) DECLARE_DYNAMIC_CLASS(TwxWindowBase)
}; };
IMPLEMENT_DYNAMIC_CLASS(TwxWindowBase, wxWindow) IMPLEMENT_DYNAMIC_CLASS(TwxWindowBase, wxWindow)
TwxWindowBase::TwxWindowBase(wxWindow* parent, int id, const wxString& title, TwxWindowBase::TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
wxPoint pos, wxSize size, long style) const wxPoint &pos, const wxSize &size, long style)
: wxWindow(parent, id, pos, size, style) : wxWindow(parent, id, pos, size, style)
{ {
SetTitle(title); SetTitle(title);
} }
class TwxWindow : public TwxWindowBase class TwxWindow : public TwxWindowBase
@ -874,7 +901,7 @@ void TwxWindow::OnPaint(wxPaintEvent& event)
tdc.GetDC(true); // Forza la creazione di un wxPaintDC tdc.GetDC(true); // Forza la creazione di un wxPaintDC
DoXvtEvent(e); DoXvtEvent(e);
tdc.KillDC(); // Distrugge il wxPaintDC tdc.KillDC(); // Distrugge il wxPaintDC
_dc_map.DestroyTDC(NULL); // Distrugge tutti i wxClientDC residui (risolve molte "porcate" del video) _dc_map.DestroyDC(NULL); // Distrugge davvero tutti i wxClientDC residui (risolve molte "porcate" del video)
} }
static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et) static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et)
@ -991,10 +1018,6 @@ TwxWindow::~TwxWindow()
_nice_windows.Delete((WINDOW)this); _nice_windows.Delete((WINDOW)this);
} }
#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win
#define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w);
#define CAST_TDC(win,dc) XVT_ASSERT(win != NULL_WIN); TDC& dc = _dc_map.GetTDC((TwxWindow*)win);
#define CAST_DC(win,dc) XVT_ASSERT(win != NULL_WIN); wxDC& dc = _dc_map.GetDC((TwxWindow*)win);
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Main application = TASK_WIN functions // Main application = TASK_WIN functions
@ -1089,7 +1112,7 @@ void TTaskWin::SetMenuTree(const MENU_ITEM* tree)
if (pMenu->FindItem(tree->child->tag)) if (pMenu->FindItem(tree->child->tag))
{ {
bar->Remove(m); bar->Remove(m);
delete pMenu; // delete pMenu;
break; break;
} }
} }
@ -1947,7 +1970,7 @@ bool TFontId::Underline() const
wxFont& TFontId::Font(wxDC* dc) const wxFont& TFontId::Font(wxDC* dc) const
{ {
int nSize = PointSize(); int nSize = PointSize();
if (m_win == _print_win) if (m_win == _print_win)
{ {
static wxDC* lastDC = NULL; static wxDC* lastDC = NULL;
@ -2079,10 +2102,10 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const
} }
} }
#else #else
const wxImage& img = ((TXVT_IMAGE*)image)->Image()); const wxImage& img = (((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src); wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height); sub.Rescale(dst.width, dst.height);
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition()); dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
#endif #endif
} }
} }
@ -2638,6 +2661,17 @@ void xvt_fsys_get_default_dir(DIRECTORY *dirp)
{ {
_startup_dir = new wxString; _startup_dir = new wxString;
wxFileName::SplitPath(wxTheApp->argv[0], _startup_dir, NULL, NULL); wxFileName::SplitPath(wxTheApp->argv[0], _startup_dir, NULL, NULL);
#ifdef LINUX
if (*_startup_dir == ".")
*_startup_dir = "";
#endif
if (_startup_dir->IsEmpty())
{
char exedir[_MAX_PATH];
xvt_fsys_get_dir(dirp);
xvt_fsys_convert_dir_to_str(dirp, exedir, sizeof(exedir));
*_startup_dir = exedir;
}
} }
if (dirp != NULL) if (dirp != NULL)
xvt_fsys_convert_str_to_dir(*_startup_dir, dirp); xvt_fsys_convert_str_to_dir(*_startup_dir, dirp);
@ -2953,7 +2987,9 @@ void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color)
void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp) void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp)
{ {
#ifdef WIN32
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image(); wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
#endif
const wxRect rctDst = NormalizeRCT(dstrctp); const wxRect rctDst = NormalizeRCT(dstrctp);
const wxRect rctSrc = NormalizeRCT(srcrctp); const wxRect rctSrc = NormalizeRCT(srcrctp);
#if 0 #if 0
@ -2969,7 +3005,9 @@ void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RC
wxMemoryDC dc; wxMemoryDC dc;
dc.SelectObject( ((TXVT_IMAGE*)dstimage)->Bitmap() ); dc.SelectObject( ((TXVT_IMAGE*)dstimage)->Bitmap() );
DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc); DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc);
#ifdef WIN32
dst = dc.GetSelectedBitmap(); dst = dc.GetSelectedBitmap();
#endif
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
#endif #endif
} }
@ -3151,7 +3189,7 @@ void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree)
{ {
if (win == TASK_WIN) if (win == TASK_WIN)
{ {
TTaskWin& w = *(TTaskWin*)win; TTaskWin& w = *(TTaskWin*)win; //occhio
w.SetMenuTree(tree); w.SetMenuTree(tree);
} }
else else
@ -3675,6 +3713,22 @@ BOOLEAN xvt_str_match(const char *mbs, const char *pat, BOOLEAN case_sensitive)
return text.Matches(pattern); return text.Matches(pattern);
} }
void xvt_str_make_upper(char* str)
{
#ifdef WIN32
_strupr(str);
#else
for (char * s = str; *s; s++)
*s = toupper(*s);
#endif
}
void xvt_str_make_lower(char* str)
{
for (char * s = str; *s; s++)
*s = tolower(*s);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// XVT system calls (added by Guy) // XVT system calls (added by Guy)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -3812,7 +3866,7 @@ int xvt_sys_get_profile_string(const char* file, const char* paragraph, const ch
#ifdef WIN32 #ifdef WIN32
int len = ::GetPrivateProfileString(paragraph, name, defval, value, maxsize, file); int len = ::GetPrivateProfileString(paragraph, name, defval, value, maxsize, file);
#else #else
wxFileConfig ini("", "", file); wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
wxString path; wxString path;
path << "/" << paragraph; path << "/" << paragraph;
@ -3840,7 +3894,8 @@ BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, cons
#ifdef WIN32 #ifdef WIN32
return ::WritePrivateProfileString(paragraph, name, value, file); return ::WritePrivateProfileString(paragraph, name, value, file);
#else #else
wxFileConfig ini("", "", file); wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
ini.SetUmask(0x0);
wxString path; wxString path;
path << "/" << paragraph; path << "/" << paragraph;
@ -3995,9 +4050,10 @@ void xvt_sys_searchenv(const char * filename, const char * varname, char * pathn
#endif #endif
} }
BOOLEAN xvt_fsys_access(const char *pathname, int mode) int xvt_fsys_access(const char *pathname, int mode)
{ {
return access(pathname, mode); wxString str = ::wxGetCwd();
return access(pathname, mode) == -1 ? errno : 0;
} }
BOOLEAN xvt_fsys_file_exists(const char *pathname) BOOLEAN xvt_fsys_file_exists(const char *pathname)
@ -4098,16 +4154,28 @@ long xvt_vobj_get_attr(WINDOW win, long data)
} }
break; break;
case ATTR_FRAME_WIDTH: case ATTR_FRAME_WIDTH:
#ifdef LINUX
ret = 8; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_X); ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_X);
#endif
break; break;
case ATTR_FRAME_HEIGHT: case ATTR_FRAME_HEIGHT:
#ifdef LINUX
ret = 8; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_Y); ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_Y);
#endif
break; break;
case ATTR_MENU_HEIGHT: case ATTR_MENU_HEIGHT:
ret = wxSystemSettings::GetSystemMetric(wxSYS_MENU_Y); ret = wxSystemSettings::GetSystemMetric(wxSYS_MENU_Y);
break; break;
case ATTR_TITLE_HEIGHT: case ATTR_TITLE_HEIGHT:
#ifdef LINUX
ret = 32; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_CAPTION_Y); ret = wxSystemSettings::GetSystemMetric(wxSYS_CAPTION_Y);
#endif
break; break;
case ATTR_CTL_VERT_SBAR_WIDTH: case ATTR_CTL_VERT_SBAR_WIDTH:
ret = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X); ret = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
@ -4358,9 +4426,13 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
switch (wtype) switch (wtype)
{ {
case W_DOC: case W_DOC:
#ifdef WIN32
style |= wxBORDER; style |= wxBORDER;
#else
style |= wxRAISED_BORDER;
#endif
if (!caption.IsEmpty()) if (!caption.IsEmpty())
style |= wxCAPTION | wxSYSTEM_MENU; style |= (wxCAPTION | wxSYSTEM_MENU);
break; break;
case W_PLAIN: case W_PLAIN:
// style |= wxBORDER; // Non attivare MAI il bordo! // style |= wxBORDER; // Non attivare MAI il bordo!
@ -4380,6 +4452,8 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
#ifdef WIN32 #ifdef WIN32
OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC); OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC);
#else
OsLinux_SetCaptionStyle((wxWindow*)w, wtype == W_DOC);
#endif #endif
if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID

View File

@ -7,7 +7,7 @@
#include "oswin32.h" #include "oswin32.h"
#else #else
#include "oslinux.h" #include "oslinux.h"
#include <fstream.h> #include "incstr.h"
#endif #endif
#include "xvintern.h" #include "xvintern.h"
@ -768,10 +768,11 @@ const char* xvt_fsys_get_campo_ini()
if (prawin == NULL) if (prawin == NULL)
{ {
BOOLEAN bFound = FALSE; BOOLEAN bFound = FALSE;
char exedir[_MAX_PATH], path[_MAX_PATH];
#ifdef WIN32 #ifdef WIN32
// Nelle installazioni sfigate con programmi in rete cerca di stabilire il percorso locale di Campo.ini // Nelle installazioni sfigate con programmi in rete cerca di stabilire il percorso locale di Campo.ini
DIRECTORY dir; DIRECTORY dir;
char exedir[_MAX_PATH], path[_MAX_PATH];
xvt_fsys_get_default_dir(&dir); xvt_fsys_get_default_dir(&dir);
xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir)); xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir));
if (xvt_fsys_is_network_drive(exedir)) if (xvt_fsys_is_network_drive(exedir))