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 <fstream.h>
#ifdef LINUX
#include "xvt_type.h"
#include "../include/incstr.h"
#else
#include <fstream.h>
#endif
#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/fs_zip.h"
#include "wx/image.h"
#include <wx/snglinst.h>
#include <wx/thread.h>
@ -20,10 +21,16 @@
#include "oswin32.h"
#include <io.h>
#else
#include <errno.h>
#include <unistd.h>
#include "oslinux.h"
#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'
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 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)
{
bool display = (_error_handler == NULL) || (_error_handler(SEV_FATAL, NULL) == FALSE);
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 ";
::wxMessageBox(strMessage, strCaption, wxOK|wxICON_ERROR);
}
@ -135,6 +142,8 @@ wxIcon* GetIconResource(int rid)
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
_nice_icons.Put(rid, icon);
}
else
icon = (wxIcon*)_nice_icons.Get(ICON_RSRC);
}
XVT_ASSERT(icon != NULL);
return icon;
@ -478,7 +487,9 @@ bool TDC::GetClippingBox(RCT* pRct) const
return _clip.right > _clip.left;
}
class TDCMapper : public wxHashTable
WX_DECLARE_HASH_MAP(wxWindow*, TDC*, wxPointerHash, wxPointerEqual, wxTDCHashMap);
class TDCMapper : public wxTDCHashMap
{
wxWindow* _pLastOwner;
TDC* _pLastTDC;
@ -486,29 +497,44 @@ class TDCMapper : public wxHashTable
public:
TDC& GetTDC(wxWindow* owner);
wxDC& GetDC(wxWindow* owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); }
void DestroyDC(wxWindow* owner);
void DestroyTDC(wxWindow* owner);
bool HasValidDC(WINDOW owner) const;
TDCMapper() : _pLastOwner(NULL), _pLastTDC(NULL) { }
} _dc_map;
void TDCMapper::DestroyDC(wxWindow* owner)
{
if (owner)
{
TDC* pTDC = (*this)[owner];
if (pTDC)
pTDC->KillDC();
}
else
clear();
}
void TDCMapper::DestroyTDC(wxWindow* owner)
{
if (owner)
{
wxObject* pDC = Delete((long)owner);
if (pDC)
delete pDC;
TDC* pTDC = (*this)[owner];
if (pTDC)
delete pTDC;
}
else
{
BeginFind();
for (wxNode* node = Next(); node; node = Next())
TDCMapper::iterator it;
for (it = begin(); it != end(); ++it)
{
wxObject* pDC = node->GetData();
delete pDC;
TDC* pTDC = it->second;
if (pTDC)
delete pTDC;
}
Clear();
clear();
}
_pLastOwner = NULL;
}
@ -518,18 +544,18 @@ TDC& TDCMapper::GetTDC(wxWindow* owner)
if (owner == _pLastOwner)
return *_pLastTDC;
TDC* pDC = (TDC*)Get((long)owner);
if (pDC == NULL)
TDC* pTDC = (*this)[owner];
if (pTDC == NULL)
{
if (owner == (wxWindow*)_print_win)
pDC = new TPrintDC(owner);
pTDC = new TPrintDC(owner);
else
pDC = new TDC(owner);
Put((long)owner, pDC);
pTDC = new TDC(owner);
(*this)[owner] = pTDC;
}
_pLastOwner = owner;
_pLastTDC = pDC;
return *pDC;
_pLastTDC = pTDC;
return *pTDC;
}
bool TDCMapper::HasValidDC(WINDOW owner) const
@ -540,8 +566,9 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
if (owner == (WINDOW)_pLastOwner)
return true;
wxObject* pDC = Get(owner);
return pDC != NULL;
CAST_WIN(owner, w);
TDC* pTDC = (*((TDCMapper *) this))[&w];
return pTDC != NULL;
}
///////////////////////////////////////////////////////////
@ -554,19 +581,19 @@ class TwxWindowBase : public wxWindow
{
public:
TwxWindowBase() { }
TwxWindowBase(wxWindow* parent, int id, const wxString& title,
wxPoint pos, wxSize size, long style);
TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint & pos, const wxSize & size, long style);
DECLARE_DYNAMIC_CLASS(TwxWindowBase)
};
IMPLEMENT_DYNAMIC_CLASS(TwxWindowBase, wxWindow)
TwxWindowBase::TwxWindowBase(wxWindow* parent, int id, const wxString& title,
wxPoint pos, wxSize size, long style)
TwxWindowBase::TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, long style)
: wxWindow(parent, id, pos, size, style)
{
SetTitle(title);
SetTitle(title);
}
class TwxWindow : public TwxWindowBase
@ -874,7 +901,7 @@ void TwxWindow::OnPaint(wxPaintEvent& event)
tdc.GetDC(true); // Forza la creazione di un wxPaintDC
DoXvtEvent(e);
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)
@ -991,10 +1018,6 @@ TwxWindow::~TwxWindow()
_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
@ -1089,7 +1112,7 @@ void TTaskWin::SetMenuTree(const MENU_ITEM* tree)
if (pMenu->FindItem(tree->child->tag))
{
bar->Remove(m);
delete pMenu;
// delete pMenu;
break;
}
}
@ -1947,7 +1970,7 @@ bool TFontId::Underline() const
wxFont& TFontId::Font(wxDC* dc) const
{
int nSize = PointSize();
int nSize = PointSize();
if (m_win == _print_win)
{
static wxDC* lastDC = NULL;
@ -2079,10 +2102,10 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const
}
}
#else
const wxImage& img = ((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height);
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
const wxImage& img = (((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height);
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
#endif
}
}
@ -2638,6 +2661,17 @@ void xvt_fsys_get_default_dir(DIRECTORY *dirp)
{
_startup_dir = new wxString;
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)
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)
{
#ifdef WIN32
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
#endif
const wxRect rctDst = NormalizeRCT(dstrctp);
const wxRect rctSrc = NormalizeRCT(srcrctp);
#if 0
@ -2969,7 +3005,9 @@ void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RC
wxMemoryDC dc;
dc.SelectObject( ((TXVT_IMAGE*)dstimage)->Bitmap() );
DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc);
#ifdef WIN32
dst = dc.GetSelectedBitmap();
#endif
dc.SelectObject(wxNullBitmap);
#endif
}
@ -3151,7 +3189,7 @@ void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree)
{
if (win == TASK_WIN)
{
TTaskWin& w = *(TTaskWin*)win;
TTaskWin& w = *(TTaskWin*)win; //occhio
w.SetMenuTree(tree);
}
else
@ -3675,6 +3713,22 @@ BOOLEAN xvt_str_match(const char *mbs, const char *pat, BOOLEAN case_sensitive)
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)
///////////////////////////////////////////////////////////
@ -3812,7 +3866,7 @@ int xvt_sys_get_profile_string(const char* file, const char* paragraph, const ch
#ifdef WIN32
int len = ::GetPrivateProfileString(paragraph, name, defval, value, maxsize, file);
#else
wxFileConfig ini("", "", file);
wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
wxString path;
path << "/" << paragraph;
@ -3840,7 +3894,8 @@ BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, cons
#ifdef WIN32
return ::WritePrivateProfileString(paragraph, name, value, file);
#else
wxFileConfig ini("", "", file);
wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
ini.SetUmask(0x0);
wxString path;
path << "/" << paragraph;
@ -3995,9 +4050,10 @@ void xvt_sys_searchenv(const char * filename, const char * varname, char * pathn
#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)
@ -4098,16 +4154,28 @@ long xvt_vobj_get_attr(WINDOW win, long data)
}
break;
case ATTR_FRAME_WIDTH:
#ifdef LINUX
ret = 8; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_X);
#endif
break;
case ATTR_FRAME_HEIGHT:
#ifdef LINUX
ret = 8; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_Y);
#endif
break;
case ATTR_MENU_HEIGHT:
ret = wxSystemSettings::GetSystemMetric(wxSYS_MENU_Y);
break;
case ATTR_TITLE_HEIGHT:
#ifdef LINUX
ret = 32; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_CAPTION_Y);
#endif
break;
case ATTR_CTL_VERT_SBAR_WIDTH:
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)
{
case W_DOC:
#ifdef WIN32
style |= wxBORDER;
#else
style |= wxRAISED_BORDER;
#endif
if (!caption.IsEmpty())
style |= wxCAPTION | wxSYSTEM_MENU;
style |= (wxCAPTION | wxSYSTEM_MENU);
break;
case W_PLAIN:
// 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
OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC);
#else
OsLinux_SetCaptionStyle((wxWindow*)w, wtype == W_DOC);
#endif
if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID

View File

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