2002-02-28 14:26:23 +00:00
|
|
|
|
#include "wxinc.h"
|
|
|
|
|
|
|
|
|
|
#include "wx/clipbrd.h"
|
2003-03-24 16:22:11 +00:00
|
|
|
|
#include "wx/colordlg.h"
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#include "wx/confbase.h"
|
|
|
|
|
#include "wx/fileconf.h"
|
|
|
|
|
#include "wx/fontdlg.h"
|
|
|
|
|
#include "wx/image.h"
|
2003-05-16 09:25:11 +00:00
|
|
|
|
#include <wx/snglinst.h>
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#include "wx/fs_zip.h"
|
2002-10-24 10:47:49 +00:00
|
|
|
|
#include "wx/html/helpctrl.h"
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#include "xvt.h"
|
|
|
|
|
#include "statbar.h"
|
|
|
|
|
|
|
|
|
|
#include "xvintern.h"
|
|
|
|
|
#include "agasys.h"
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#include "oswin32.h"
|
2003-06-06 13:50:22 +00:00
|
|
|
|
#include <io.h>
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include "oslinux.h"
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
// Funzione interna di utilita'
|
|
|
|
|
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_CONFIG* _config_ = NULL;
|
|
|
|
|
wxWindow* _task_win = NULL;
|
|
|
|
|
wxWindow* _mouse_trapper = NULL;
|
2003-03-27 12:15:57 +00:00
|
|
|
|
RCT _startup_rect = { 0,0,0,0 };
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxString _startup_dir;
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
static wxHashTable _nice_windows;
|
|
|
|
|
static wxHashTable _nice_icons;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
static EVENT_HANDLER _task_win_handler = NULL;
|
|
|
|
|
static XVT_ERRMSG_HANDLER _error_handler = NULL;
|
|
|
|
|
|
2003-02-05 14:26:24 +00:00
|
|
|
|
#define XVT_ASSERT(test) assert_box((test), __LINE__)
|
|
|
|
|
|
|
|
|
|
void assert_box(bool test, int line)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
if (!test)
|
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
|
bool display = (_error_handler == NULL) || (_error_handler(SEV_FATAL, NULL) == FALSE);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (display)
|
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
|
const wxString strMessage = wxString::Format("Sorry, the application passed some invalid parameters on line %d.", line);
|
|
|
|
|
const wxString strCaption = "Emulated XVT Error ";
|
2002-07-03 14:53:33 +00:00
|
|
|
|
::wxMessageBox(strMessage, strCaption, wxOK|wxICON_ERROR);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sys_sorry_box(const char * file,int line)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
static wxHashTable sorry;
|
|
|
|
|
if (sorry.Get(line) == NULL)
|
|
|
|
|
{
|
|
|
|
|
sorry.Put(line, &sorry); // Dummy
|
2003-05-22 15:25:25 +00:00
|
|
|
|
const wxString strMessage = wxString::Format("Function in file %s at line %d not implemented", file, line);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
::wxMessageBox(strMessage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win
|
|
|
|
|
|
|
|
|
|
static bool RectIntersect(const wxRect &rect1, const wxRect &rect2)
|
|
|
|
|
{
|
|
|
|
|
if (rect1.GetRight() < rect2.GetLeft())
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return false;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (rect2.GetRight() < rect1.GetLeft())
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return false;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (rect1.GetBottom() < rect2.GetTop())
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return false;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (rect2.GetBottom() < rect1.GetTop())
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return false;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxRect NormalizeRCT(const RCT* prct)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(prct != NULL);
|
|
|
|
|
wxRect rct;
|
|
|
|
|
rct.x = min(prct->left, prct->right);
|
|
|
|
|
rct.y = min(prct->top, prct->bottom);
|
|
|
|
|
rct.width = abs(prct->right - prct->left);
|
|
|
|
|
rct.height = abs(prct->bottom - prct->top);
|
|
|
|
|
return rct;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxString GetResourceName(const char* type, int rid)
|
|
|
|
|
{
|
|
|
|
|
wxString strName;
|
|
|
|
|
strName = _startup_dir;
|
|
|
|
|
strName += "/res/resource.ini";
|
|
|
|
|
wxFileConfig ini("", "", strName);
|
|
|
|
|
|
|
|
|
|
strName = "/"; strName += type; strName += "s";
|
|
|
|
|
ini.SetPath(strName);
|
|
|
|
|
|
|
|
|
|
wxString val;
|
|
|
|
|
if (ini.Read(wxString::Format("%d", rid), &val))
|
|
|
|
|
{
|
|
|
|
|
strName = _startup_dir;
|
|
|
|
|
strName += "/res/";
|
|
|
|
|
strName += val;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strName.Empty();
|
|
|
|
|
return strName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxIcon* GetIconResource(int rid)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
wxIcon* icon = (wxIcon*)_nice_icons.Get(rid);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (icon == NULL)
|
|
|
|
|
{
|
|
|
|
|
wxString strName = ::GetResourceName("Icon", rid);
|
|
|
|
|
if (::wxFileExists(strName))
|
|
|
|
|
{
|
|
|
|
|
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
_nice_icons.Put(rid, icon);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
XVT_ASSERT(icon != NULL);
|
|
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxCursor* GetCursorResource(int rid)
|
|
|
|
|
{
|
|
|
|
|
static wxHashTable cursors;
|
|
|
|
|
wxCursor* cursor = (wxCursor*)cursors.Get(rid);
|
|
|
|
|
if (cursor == NULL)
|
|
|
|
|
{
|
|
|
|
|
switch (rid)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
case CURSOR_CROSS: cursor = new wxCursor(wxCURSOR_CROSS); break;
|
|
|
|
|
case CURSOR_IBEAM: cursor = new wxCursor(wxCURSOR_IBEAM); break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
wxString strName = ::GetResourceName("Cursor", rid);
|
|
|
|
|
if (::wxFileExists(strName))
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#ifdef WIN32
|
2002-02-28 14:26:23 +00:00
|
|
|
|
cursor = new wxCursor(strName, wxBITMAP_TYPE_CUR);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
cursor = wxSTANDARD_CURSOR;
|
|
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (!cursor->Ok())
|
|
|
|
|
{
|
|
|
|
|
delete cursor;
|
|
|
|
|
cursor = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (cursor == NULL)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(false);
|
|
|
|
|
cursor = wxSTANDARD_CURSOR;
|
|
|
|
|
}
|
|
|
|
|
cursors.Put(rid, cursor);
|
|
|
|
|
}
|
|
|
|
|
return cursor;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Caret emulation
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TwxCaret : private wxTimer
|
|
|
|
|
{
|
|
|
|
|
WINDOW _owner;
|
|
|
|
|
PNT _pos;
|
|
|
|
|
wxSize _size;
|
|
|
|
|
bool _visible;
|
|
|
|
|
bool _drawn;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void Toggle();
|
|
|
|
|
virtual void Notify() { Toggle(); }
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void SetPos(int x, int y) { _pos.h = x; _pos.v = y; }
|
|
|
|
|
void SetSize(int x, int y) { _size.x = x; _size.y = y; }
|
|
|
|
|
void Show(WINDOW w, bool on = true);
|
|
|
|
|
void Hide() { Show(false); }
|
|
|
|
|
bool IsVisible() const { return _visible; }
|
|
|
|
|
WINDOW Owner() const { return _owner; }
|
|
|
|
|
void Kill();
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TwxCaret() : _owner(NULL_WIN), _visible(false) { }
|
2002-07-03 14:53:33 +00:00
|
|
|
|
virtual ~TwxCaret() { Kill(); }
|
|
|
|
|
} _TheCaret;
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void TwxCaret::Kill()
|
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
_owner = NULL_WIN;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-07-03 14:53:33 +00:00
|
|
|
|
|
|
|
|
|
void TwxCaret::Show(WINDOW w, bool on)
|
|
|
|
|
{
|
|
|
|
|
if (_visible && _drawn)
|
|
|
|
|
Toggle(); // Lo cancella
|
|
|
|
|
|
|
|
|
|
_visible = on;
|
|
|
|
|
if (on)
|
|
|
|
|
{
|
|
|
|
|
_owner = w;
|
|
|
|
|
Toggle();
|
|
|
|
|
wxTimer::Start(500); // Lampeggia ogni mezzo secondo
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (w == _owner)
|
|
|
|
|
Kill();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxCaret::Toggle()
|
|
|
|
|
{
|
|
|
|
|
if (!_visible || _owner == NULL_WIN)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_drawn = !_drawn;
|
|
|
|
|
|
|
|
|
|
DRAW_CTOOLS dct;
|
|
|
|
|
xvt_dwin_get_draw_ctools(_owner, &dct);
|
|
|
|
|
|
|
|
|
|
CPEN pen;
|
|
|
|
|
pen.width = _size.x;
|
|
|
|
|
pen.pat = PAT_SOLID;
|
|
|
|
|
pen.style = P_SOLID;
|
|
|
|
|
pen.color = _drawn ? dct.fore_color : dct.back_color;
|
|
|
|
|
xvt_dwin_set_cpen(_owner, &pen);
|
|
|
|
|
xvt_dwin_set_draw_mode(_owner, M_COPY);
|
|
|
|
|
xvt_dwin_draw_set_pos(_owner, _pos);
|
2002-07-30 14:11:47 +00:00
|
|
|
|
PNT p = _pos; p.v -= _size.y-1;
|
2002-07-03 14:53:33 +00:00
|
|
|
|
|
|
|
|
|
xvt_dwin_set_clip(_owner, NULL); // Non si mai!
|
|
|
|
|
xvt_dwin_draw_line(_owner, p);
|
|
|
|
|
xvt_dwin_set_draw_ctools(_owner, &dct);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Generic Display context
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#define CAST_COLOR(xc, wc) wxColour wc((xc>>16)&0xFF, (xc>>8)&0xFF, xc&0xFF)
|
2002-10-24 10:47:49 +00:00
|
|
|
|
#define MAKE_XVT_COLOR(wc) MAKE_COLOR(wc.Red(), wc.Green(), wc.Blue())
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
TDC::TDC(wxWindow* owner) : _dc(NULL)
|
|
|
|
|
{
|
|
|
|
|
_owner = owner;
|
|
|
|
|
|
|
|
|
|
memset(&_dct, 0, sizeof(_dct));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
_dct.pen.width = 0;
|
|
|
|
|
_dct.pen.pat = PAT_SOLID;
|
|
|
|
|
_dct.pen.style = P_SOLID;
|
|
|
|
|
_dct.pen.color = COLOR_BLACK;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_dct.brush.pat = PAT_HOLLOW;
|
|
|
|
|
_dct.brush.color = COLOR_WHITE;
|
|
|
|
|
_dct.mode = M_COPY;
|
|
|
|
|
_dct.fore_color = COLOR_BLACK;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
_dct.back_color = COLOR_WHITE;
|
|
|
|
|
_dct.opaque_text = FALSE;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
_font.SetPointSize(9); // Default font
|
2003-05-22 15:07:21 +00:00
|
|
|
|
_deltaf = 0;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-01-07 12:20:49 +00:00
|
|
|
|
SetClippingBox(NULL); // Reset clip area
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
_dirty = -1; // Absolutely force setting
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TDC::~TDC()
|
|
|
|
|
{
|
|
|
|
|
KillDC();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-05 14:26:24 +00:00
|
|
|
|
void TDC::SetDirty(int d)
|
|
|
|
|
{
|
|
|
|
|
if (_dirty >= 0)
|
|
|
|
|
_dirty = d;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
static int PatternToStyle(PAT_STYLE pat)
|
|
|
|
|
{
|
|
|
|
|
int style;
|
|
|
|
|
switch (pat)
|
|
|
|
|
{
|
|
|
|
|
case PAT_NONE:
|
|
|
|
|
case PAT_HOLLOW: style = wxTRANSPARENT; break;
|
|
|
|
|
case PAT_SOLID: style = wxSOLID; break;
|
|
|
|
|
case PAT_HORZ: style = wxHORIZONTAL_HATCH; break;
|
|
|
|
|
case PAT_VERT: style = wxVERTICAL_HATCH; break;
|
|
|
|
|
case PAT_FDIAG: style = wxFDIAGONAL_HATCH; break;
|
|
|
|
|
case PAT_BDIAG: style = wxBDIAGONAL_HATCH; break;
|
|
|
|
|
case PAT_CROSS: style = wxCROSS_HATCH; break;
|
|
|
|
|
case PAT_DIAGCROSS: style = wxCROSSDIAG_HATCH; break;
|
|
|
|
|
case PAT_RUBBER:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case PAT_SPECIAL:
|
|
|
|
|
default: style = wxSOLID; SORRY_BOX(); break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
return style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int PenStyleToStyle(PEN_STYLE s, PAT_STYLE p)
|
|
|
|
|
{
|
|
|
|
|
int style;
|
|
|
|
|
if (p != PAT_HOLLOW)
|
|
|
|
|
{
|
|
|
|
|
switch (s)
|
|
|
|
|
{
|
|
|
|
|
case P_DOT: style = wxDOT; break;
|
|
|
|
|
case P_DASH: style = wxSHORT_DASH; break;
|
|
|
|
|
case P_SOLID:
|
|
|
|
|
default: style = wxSOLID; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
style = wxTRANSPARENT;
|
|
|
|
|
|
|
|
|
|
return style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDC::PenChanged() const
|
|
|
|
|
{
|
|
|
|
|
const int diff = memcmp(&_dct.pen, &_real_dct.pen, sizeof(_dct.pen));
|
|
|
|
|
return diff != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDC::BrushChanged() const
|
|
|
|
|
{
|
|
|
|
|
const int diff = memcmp(&_dct.brush, &_real_dct.brush, sizeof(_dct.brush));
|
|
|
|
|
return diff != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDC::FontChanged() const
|
|
|
|
|
{
|
|
|
|
|
return _font != _real_font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxDC& TDC::GetDC(bool bPaint)
|
|
|
|
|
{
|
|
|
|
|
if (bPaint)
|
|
|
|
|
{
|
|
|
|
|
KillDC();
|
|
|
|
|
_dc = new wxPaintDC(_owner);
|
|
|
|
|
_dirty = -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_dc == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dc = new wxClientDC(_owner);
|
|
|
|
|
_dirty = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty)
|
|
|
|
|
{
|
|
|
|
|
if (_dirty < 0 || PenChanged())
|
|
|
|
|
{
|
|
|
|
|
CAST_COLOR(_dct.pen.color, pen_color);
|
|
|
|
|
wxPen* pen = wxThePenList->FindOrCreatePen(pen_color, _dct.pen.width, PenStyleToStyle(_dct.pen.style, _dct.pen.pat));
|
|
|
|
|
_dc->SetPen(*pen);
|
|
|
|
|
_real_dct.pen = _dct.pen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty < 0 || BrushChanged())
|
|
|
|
|
{
|
|
|
|
|
CAST_COLOR(_dct.brush.color, brush_color);
|
|
|
|
|
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(brush_color, PatternToStyle(_dct.brush.pat));
|
|
|
|
|
_dc->SetBrush(*brush);
|
|
|
|
|
_real_dct.brush = _dct.brush;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty < 0 || _dct.mode != _real_dct.mode)
|
|
|
|
|
{
|
|
|
|
|
switch(_dct.mode)
|
|
|
|
|
{
|
|
|
|
|
case M_COPY: _dc->SetLogicalFunction(wxCOPY); break;
|
|
|
|
|
case M_OR: _dc->SetLogicalFunction(wxOR); break;
|
|
|
|
|
case M_XOR: _dc->SetLogicalFunction(wxXOR); break;
|
|
|
|
|
case M_CLEAR: _dc->SetLogicalFunction(wxCLEAR); break;
|
|
|
|
|
case M_NOT_COPY: _dc->SetLogicalFunction(wxSRC_INVERT); break;
|
|
|
|
|
case M_NOT_OR: _dc->SetLogicalFunction(wxNOR); break;
|
|
|
|
|
case M_NOT_XOR:
|
|
|
|
|
case M_NOT_CLEAR:
|
|
|
|
|
default: SORRY_BOX();
|
|
|
|
|
}
|
|
|
|
|
_real_dct.mode = _dct.mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty < 0 || _dct.fore_color != _real_dct.fore_color)
|
|
|
|
|
{
|
|
|
|
|
CAST_COLOR(_dct.fore_color, fore_color);
|
|
|
|
|
_dc->SetTextForeground(fore_color);
|
|
|
|
|
_real_dct.fore_color = _dct.fore_color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty < 0 || _dct.back_color != _real_dct.back_color)
|
|
|
|
|
{
|
|
|
|
|
CAST_COLOR(_dct.back_color, back_color);
|
|
|
|
|
_dc->SetTextBackground(back_color);
|
|
|
|
|
_real_dct.back_color = _dct.back_color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty < 0 || _dct.opaque_text != _real_dct.opaque_text)
|
|
|
|
|
{
|
|
|
|
|
_dc->SetBackgroundMode(_dct.opaque_text ? wxSOLID : wxTRANSPARENT);
|
|
|
|
|
_real_dct.opaque_text = _dct.opaque_text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dirty < 0 || FontChanged())
|
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
|
_dc->SetFont(_font.Font(_dc));
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_real_font = _font;
|
2003-05-22 15:07:21 +00:00
|
|
|
|
|
|
|
|
|
int height, desc, lead;
|
|
|
|
|
_dc->GetTextExtent("Campo", NULL, &height, &desc, &lead);
|
|
|
|
|
_deltaf = height-desc;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dirty = false;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return *_dc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDC::KillDC()
|
|
|
|
|
{
|
2002-04-22 15:08:56 +00:00
|
|
|
|
if (_dc != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
SetClippingBox(NULL);
|
|
|
|
|
delete _dc;
|
2002-04-22 15:08:56 +00:00
|
|
|
|
_dc = NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDC::SetClippingBox(const RCT* pRct)
|
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
|
#if wxCHECK_VERSION(2,3,0)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (_dc != NULL)
|
2003-04-01 07:34:53 +00:00
|
|
|
|
_dc->DestroyClippingRegion();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#endif
|
2003-04-01 07:34:53 +00:00
|
|
|
|
if (pRct)
|
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
wxRect rct = NormalizeRCT(pRct);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
GetDC().SetClippingRegion(rct);
|
|
|
|
|
_clip = *pRct;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
|
_clip.left = _clip.top = 0;
|
|
|
|
|
_clip.right = _clip.bottom = 32000;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDC::GetClippingBox(RCT* pRct) const
|
|
|
|
|
{
|
|
|
|
|
*pRct = _clip;
|
|
|
|
|
return _clip.right > _clip.left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TDCMapper : public wxHashTable
|
|
|
|
|
{
|
|
|
|
|
wxWindow* _pLastOwner;
|
|
|
|
|
TDC* _pLastTDC;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TDC& GetTDC(wxWindow* owner);
|
|
|
|
|
wxDC& GetDC(wxWindow* owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); }
|
|
|
|
|
void DestroyTDC(wxWindow* owner);
|
|
|
|
|
bool HasValidDC(WINDOW owner) const;
|
|
|
|
|
|
|
|
|
|
TDCMapper() : _pLastOwner(NULL), _pLastTDC(NULL) { }
|
|
|
|
|
} _dc_map;
|
|
|
|
|
|
|
|
|
|
void TDCMapper::DestroyTDC(wxWindow* owner)
|
|
|
|
|
{
|
|
|
|
|
if (owner)
|
|
|
|
|
{
|
|
|
|
|
wxObject* pDC = Delete((long)owner);
|
|
|
|
|
if (pDC)
|
|
|
|
|
delete pDC;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BeginFind();
|
|
|
|
|
for (wxNode* node = Next(); node; node = Next())
|
|
|
|
|
{
|
|
|
|
|
wxObject* pDC = node->GetData();
|
|
|
|
|
delete pDC;
|
|
|
|
|
}
|
|
|
|
|
Clear();
|
|
|
|
|
}
|
|
|
|
|
_pLastOwner = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDC& TDCMapper::GetTDC(wxWindow* owner)
|
|
|
|
|
{
|
|
|
|
|
if (owner == _pLastOwner)
|
|
|
|
|
return *_pLastTDC;
|
|
|
|
|
|
|
|
|
|
TDC* pDC = (TDC*)Get((long)owner);
|
|
|
|
|
if (pDC == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (owner == (wxWindow*)_print_win)
|
|
|
|
|
pDC = new TPrintDC(owner);
|
|
|
|
|
else
|
|
|
|
|
pDC = new TDC(owner);
|
|
|
|
|
Put((long)owner, pDC);
|
|
|
|
|
}
|
|
|
|
|
_pLastOwner = owner;
|
|
|
|
|
_pLastTDC = pDC;
|
|
|
|
|
return *pDC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDCMapper::HasValidDC(WINDOW owner) const
|
|
|
|
|
{
|
|
|
|
|
if (owner == NULL_WIN)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (owner == (WINDOW)_pLastOwner)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
wxObject* pDC = Get(owner);
|
|
|
|
|
return pDC != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Generic window class
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#define TIMER_ID 1
|
|
|
|
|
|
|
|
|
|
class TwxWindowBase : public wxWindow
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TwxWindowBase() { }
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TwxWindowBase(wxWindow* parent, int id, const wxString& title,
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxPoint pos, wxSize size, long style);
|
|
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(TwxWindowBase)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(TwxWindowBase, wxWindow)
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TwxWindowBase::TwxWindowBase(wxWindow* parent, int id, const wxString& title,
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxPoint pos, wxSize size, long style)
|
|
|
|
|
: wxWindow(parent, id, pos, size, style)
|
|
|
|
|
{
|
|
|
|
|
SetTitle(title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TwxWindow : public TwxWindowBase
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* m_menu;
|
|
|
|
|
|
|
|
|
|
protected:
|
2002-07-03 14:53:33 +00:00
|
|
|
|
virtual void OnChar(wxKeyEvent& e);
|
2003-03-28 15:33:49 +00:00
|
|
|
|
virtual void OnClose(wxCloseEvent& e);
|
2003-05-09 13:49:07 +00:00
|
|
|
|
virtual void OnKeyDown(wxKeyEvent& e);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
virtual void OnKillFocus(wxFocusEvent& e);
|
|
|
|
|
virtual void OnMenu(wxCommandEvent& event);
|
|
|
|
|
virtual void OnMouseDouble(wxMouseEvent& e);
|
|
|
|
|
virtual void OnMouseDown(wxMouseEvent& e);
|
|
|
|
|
virtual void OnMouseMove(wxMouseEvent& e);
|
|
|
|
|
virtual void OnMouseUp(wxMouseEvent& e);
|
|
|
|
|
virtual void OnScroll(wxScrollEvent& e);
|
|
|
|
|
virtual void OnScrollWin(wxScrollWinEvent& e);
|
|
|
|
|
virtual void OnSetFocus(wxFocusEvent& e);
|
|
|
|
|
virtual void OnSize(wxSizeEvent& e);
|
|
|
|
|
virtual void OnTimer(wxTimerEvent& e);
|
|
|
|
|
|
|
|
|
|
public:
|
2003-03-28 15:33:49 +00:00
|
|
|
|
void DoXvtEvent(EVENT& e);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
virtual void OnPaint(wxPaintEvent& event);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
WIN_TYPE _type;
|
|
|
|
|
EVENT_HANDLER _eh;
|
|
|
|
|
long _app_data;
|
|
|
|
|
wxTimer* _timer;
|
|
|
|
|
|
|
|
|
|
void SetMenuTree(const MENU_ITEM* menu);
|
|
|
|
|
MENU_ITEM* GetMenuTree() const { return m_menu; }
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
|
|
|
|
TwxWindow() : m_menu(NULL), _type(W_DOC), _eh(NULL), _app_data(0L), _timer(NULL) { }
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title,
|
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0);
|
|
|
|
|
virtual ~TwxWindow();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
DECLARE_DYNAMIC_CLASS(TwxWindow);
|
|
|
|
|
DECLARE_EVENT_TABLE();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TTaskWin : public wxFrame
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* m_menu;
|
|
|
|
|
|
|
|
|
|
wxMenuBar* m_pOldBar;
|
|
|
|
|
wxWindow* m_MenuOwner;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void OnClose(wxCloseEvent& event);
|
|
|
|
|
virtual void OnMenu(wxCommandEvent& event);
|
|
|
|
|
virtual void OnSize(wxSizeEvent& event);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void OnPaint();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void SetMenuTree(const MENU_ITEM* tree);
|
|
|
|
|
const MENU_ITEM* GetMenuTree() const { return m_menu; }
|
|
|
|
|
void PushMenuTree(const MENU_ITEM* tree, wxWindow* owner);
|
|
|
|
|
void PopMenuTree();
|
|
|
|
|
|
|
|
|
|
TTaskWin() : wxFrame(), m_menu(NULL), m_pOldBar(NULL) { }
|
|
|
|
|
TTaskWin(wxWindow *parent, wxWindowID id, const wxString& title,
|
|
|
|
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE);
|
|
|
|
|
~TTaskWin();
|
|
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(TTaskWin);
|
|
|
|
|
DECLARE_EVENT_TABLE();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(TwxWindow, TwxWindowBase)
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(TwxWindow, TwxWindowBase)
|
2002-07-03 14:53:33 +00:00
|
|
|
|
EVT_CHAR(TwxWindow::OnChar)
|
2003-05-09 13:49:07 +00:00
|
|
|
|
EVT_KEY_DOWN(TwxWindow::OnKeyDown)
|
2003-03-28 15:33:49 +00:00
|
|
|
|
EVT_CLOSE(TwxWindow::OnClose)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
EVT_KILL_FOCUS(TwxWindow::OnKillFocus)
|
|
|
|
|
EVT_LEFT_DCLICK(TwxWindow::OnMouseDouble)
|
|
|
|
|
EVT_LEFT_DOWN(TwxWindow::OnMouseDown)
|
|
|
|
|
EVT_LEFT_UP(TwxWindow::OnMouseUp)
|
|
|
|
|
EVT_MENU_RANGE(1000, 32766, TwxWindow::OnMenu)
|
|
|
|
|
EVT_MOTION(TwxWindow::OnMouseMove)
|
|
|
|
|
EVT_PAINT(TwxWindow::OnPaint)
|
|
|
|
|
EVT_RIGHT_DOWN(TwxWindow::OnMouseDown)
|
|
|
|
|
EVT_RIGHT_UP(TwxWindow::OnMouseUp)
|
|
|
|
|
EVT_SCROLL(TwxWindow::OnScroll)
|
|
|
|
|
EVT_SCROLLWIN(TwxWindow::OnScrollWin)
|
|
|
|
|
EVT_SET_FOCUS(TwxWindow::OnSetFocus)
|
|
|
|
|
EVT_SIZE(TwxWindow::OnSize)
|
|
|
|
|
EVT_TIMER(TIMER_ID, TwxWindow::OnTimer)
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
void TwxWindow::DoXvtEvent(EVENT& e)
|
|
|
|
|
{
|
|
|
|
|
if (this != NULL && _eh != NULL)
|
|
|
|
|
_eh((WINDOW)this, &e);
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
|
void TwxWindow::OnChar(wxKeyEvent& event)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
|
static bool bSkipNextDotKey = FALSE;
|
2002-07-30 14:11:47 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_CHAR;
|
|
|
|
|
int k = event.GetKeyCode();
|
|
|
|
|
|
2002-09-13 14:56:23 +00:00
|
|
|
|
if (bSkipNextDotKey)
|
|
|
|
|
{
|
|
|
|
|
bSkipNextDotKey = FALSE;
|
|
|
|
|
if (k == '.')
|
|
|
|
|
{
|
|
|
|
|
event.Skip();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
switch (k)
|
|
|
|
|
{
|
|
|
|
|
case WXK_ALT:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case WXK_MENU:
|
2002-07-30 14:11:47 +00:00
|
|
|
|
case WXK_NUMPAD0:
|
|
|
|
|
case WXK_NUMPAD1:
|
|
|
|
|
case WXK_NUMPAD2:
|
|
|
|
|
case WXK_NUMPAD3:
|
|
|
|
|
case WXK_NUMPAD4:
|
|
|
|
|
case WXK_NUMPAD5:
|
|
|
|
|
case WXK_NUMPAD6:
|
|
|
|
|
case WXK_NUMPAD7:
|
|
|
|
|
case WXK_NUMPAD8:
|
|
|
|
|
case WXK_NUMPAD9:
|
|
|
|
|
event.Skip();
|
|
|
|
|
return;
|
2002-04-22 15:08:56 +00:00
|
|
|
|
case WXK_NUMPAD_DECIMAL: // ??? Non arriva mai
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case WXK_DECIMAL: // ??? Arriva sia '.' sia WXK_DECIMAL=340
|
2003-05-09 13:49:07 +00:00
|
|
|
|
k = ','; // Trasformo il punto in virgola
|
2002-09-13 14:56:23 +00:00
|
|
|
|
bSkipNextDotKey = TRUE;
|
|
|
|
|
break;
|
2003-05-09 13:49:07 +00:00
|
|
|
|
case WXK_NUMPAD_ADD: k = '+'; break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case WXK_DOWN : k = K_DOWN; break;
|
2003-05-09 13:49:07 +00:00
|
|
|
|
case WXK_END: k = K_LEND; break;
|
|
|
|
|
case WXK_HOME: k = K_LHOME; break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case WXK_LEFT : k = K_LEFT; break;
|
|
|
|
|
case WXK_NEXT : k = K_NEXT; break;
|
|
|
|
|
case WXK_PRIOR: k = K_PREV; break;
|
|
|
|
|
case WXK_RIGHT: k = K_RIGHT; break;
|
|
|
|
|
case WXK_UP : k = K_UP; break;
|
|
|
|
|
case WXK_TAB:
|
|
|
|
|
if (event.ShiftDown())
|
|
|
|
|
k = K_BTAB;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (k >= WXK_F1 && k <= WXK_F24)
|
|
|
|
|
k = K_F1 + k - WXK_F1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.v.chr.shift = event.ShiftDown();
|
|
|
|
|
e.v.chr.control = event.ControlDown();
|
|
|
|
|
if (event.AltDown())
|
|
|
|
|
{
|
|
|
|
|
e.v.chr.control = TRUE;
|
|
|
|
|
if (k >= 'a' && k <= 'z')
|
|
|
|
|
k = toupper(k);
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-03-20 10:30:21 +00:00
|
|
|
|
if (strchr("+-", k) == NULL) // Aggiungere qui vari testi eventuali
|
|
|
|
|
{
|
|
|
|
|
event.Skip();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
e.v.chr.ch = k;
|
|
|
|
|
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-09 13:49:07 +00:00
|
|
|
|
void TwxWindow::OnKeyDown(wxKeyEvent& event)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
// Triste necessita' per gestire corretamente Alt+'+' del tasterino
|
|
|
|
|
const int k = event.GetKeyCode();
|
|
|
|
|
if (k == WXK_NUMPAD_ADD)
|
|
|
|
|
{
|
|
|
|
|
if (event.AltDown())
|
|
|
|
|
{
|
|
|
|
|
OnChar(event);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
event.Skip();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-28 15:33:49 +00:00
|
|
|
|
void TwxWindow::OnClose(wxCloseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_DESTROY;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
Destroy();
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
void TwxWindow::OnKillFocus(wxFocusEvent& event)
|
|
|
|
|
{
|
|
|
|
|
if (_TheCaret.Owner() == (WINDOW)this)
|
|
|
|
|
_TheCaret.Hide();
|
|
|
|
|
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_FOCUS;
|
|
|
|
|
e.v.active = 0;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnMenu(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_COMMAND;
|
|
|
|
|
e.v.cmd.control = 0; e.v.cmd.shift = 0;
|
|
|
|
|
e.v.cmd.tag = event.GetId();
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnMouseDouble(wxMouseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_MOUSE_DBL;
|
|
|
|
|
e.v.mouse.button = 0;
|
|
|
|
|
e.v.mouse.control = event.ControlDown();
|
|
|
|
|
e.v.mouse.shift = event.ShiftDown();
|
|
|
|
|
int x, y; event.GetPosition(&x, &y);
|
|
|
|
|
e.v.mouse.where.h = x;
|
|
|
|
|
e.v.mouse.where.v = y;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnMouseDown(wxMouseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_MOUSE_DOWN;
|
|
|
|
|
e.v.mouse.button = event.RightDown() ? 1 : 0;
|
|
|
|
|
e.v.mouse.control = event.ControlDown();
|
|
|
|
|
e.v.mouse.shift = event.ShiftDown();
|
2002-09-13 14:56:23 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
int x, y; event.GetPosition(&x, &y);
|
|
|
|
|
e.v.mouse.where.h = x;
|
|
|
|
|
e.v.mouse.where.v = y;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnMouseMove(wxMouseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_MOUSE_MOVE;
|
|
|
|
|
int x, y; event.GetPosition(&x, &y);
|
|
|
|
|
e.v.mouse.where.h = x;
|
|
|
|
|
e.v.mouse.where.v = y;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnMouseUp(wxMouseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_MOUSE_UP;
|
|
|
|
|
e.v.mouse.button = event.RightUp() ? 1 : 0;
|
|
|
|
|
e.v.mouse.control = event.ControlDown();
|
|
|
|
|
e.v.mouse.shift = event.ShiftDown();
|
|
|
|
|
int x, y; event.GetPosition(&x, &y);
|
|
|
|
|
e.v.mouse.where.h = x;
|
|
|
|
|
e.v.mouse.where.v = y;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnPaint(wxPaintEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_UPDATE;
|
|
|
|
|
|
|
|
|
|
RCT& rct = e.v.update.rct;
|
|
|
|
|
|
|
|
|
|
wxRect rctDamaged = GetUpdateRegion().GetBox();
|
|
|
|
|
rct.left = rctDamaged.x;
|
|
|
|
|
rct.top = rctDamaged.y;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
rct.right = rctDamaged.GetRight()+1;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
rct.bottom = rctDamaged.GetBottom()+1;
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TDC& tdc = _dc_map.GetTDC(this);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et)
|
|
|
|
|
{
|
|
|
|
|
if (et == wxEVT_SCROLL_TOP)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return SC_THUMB; // Meglio di niente
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (et == wxEVT_SCROLL_BOTTOM)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return SC_THUMB; // Meglio di niente
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (et == wxEVT_SCROLL_LINEUP)
|
|
|
|
|
return SC_LINE_UP;
|
|
|
|
|
if (et == wxEVT_SCROLL_LINEDOWN)
|
|
|
|
|
return SC_LINE_DOWN;
|
|
|
|
|
if (et == wxEVT_SCROLL_PAGEUP)
|
|
|
|
|
return SC_PAGE_UP;
|
|
|
|
|
if (et == wxEVT_SCROLL_PAGEDOWN)
|
|
|
|
|
return SC_PAGE_DOWN;
|
|
|
|
|
if (et == wxEVT_SCROLL_THUMBTRACK)
|
|
|
|
|
return SC_THUMBTRACK;
|
|
|
|
|
if (et == wxEVT_SCROLL_THUMBRELEASE)
|
|
|
|
|
return SC_THUMB;
|
|
|
|
|
return SC_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnScroll(wxScrollEvent& event)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
SCROLL_CONTROL sc = ConvertScrollToXVT(event.GetEventType());
|
2003-03-17 11:29:38 +00:00
|
|
|
|
if (sc != SC_NONE)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-03-17 11:29:38 +00:00
|
|
|
|
const wxScrollBar* sb = (wxScrollBar*)event.GetEventObject();
|
|
|
|
|
const wxSize sz = sb->GetSize();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-03-17 11:29:38 +00:00
|
|
|
|
e.type = E_CONTROL;
|
|
|
|
|
e.v.ctl.id = event.GetId();
|
|
|
|
|
e.v.ctl.ci.type = sz.x > sz.y ? WC_HSCROLL : WC_VSCROLL;
|
|
|
|
|
e.v.ctl.ci.win = (WINDOW)sb;
|
|
|
|
|
e.v.ctl.ci.v.scroll.pos = event.GetPosition();
|
|
|
|
|
e.v.ctl.ci.v.scroll.what = sc;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnScrollWin(wxScrollWinEvent& event)
|
|
|
|
|
{
|
|
|
|
|
wxEventType et = event.GetEventType();
|
|
|
|
|
et -= (wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP);
|
2003-03-17 11:29:38 +00:00
|
|
|
|
const SCROLL_CONTROL sc = ConvertScrollToXVT(et);
|
|
|
|
|
if (sc != SC_NONE)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = event.GetOrientation() == wxHORIZONTAL ? E_HSCROLL : E_VSCROLL;
|
|
|
|
|
e.v.scroll.pos = event.GetPosition();
|
|
|
|
|
e.v.scroll.what = sc;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnSetFocus(wxFocusEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_FOCUS;
|
|
|
|
|
e.v.active = 1;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnSize(wxSizeEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_SIZE;
|
|
|
|
|
e.v.size.height = event.GetSize().x;
|
|
|
|
|
e.v.size.width = event.GetSize().y;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::OnTimer(wxTimerEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_TIMER;
|
|
|
|
|
e.v.timer.id = (WINDOW)this;
|
|
|
|
|
DoXvtEvent(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TwxWindow::SetMenuTree(const MENU_ITEM* tree)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(tree != NULL);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
if (tree != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
if (m_menu)
|
|
|
|
|
xvt_res_free_menu_tree(m_menu);
|
|
|
|
|
m_menu = xvt_menu_duplicate_tree(tree);
|
|
|
|
|
((TTaskWin*)_task_win)->PushMenuTree(tree, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TwxWindow::TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title,
|
|
|
|
|
const wxPoint& pos, const wxSize& size, long style)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
: TwxWindowBase(parent, id, title, pos, size, style),
|
2003-06-06 13:50:22 +00:00
|
|
|
|
m_menu(NULL), _eh(NULL), _timer(NULL)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
_nice_windows.Put((WINDOW)this, this);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
TwxWindow::~TwxWindow()
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (_timer)
|
|
|
|
|
delete _timer;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (m_menu)
|
|
|
|
|
{
|
|
|
|
|
xvt_res_free_menu_tree(m_menu);
|
|
|
|
|
((TTaskWin*)_task_win)->PopMenuTree();
|
|
|
|
|
}
|
2003-04-16 15:50:37 +00:00
|
|
|
|
|
|
|
|
|
_nice_windows.Delete((WINDOW)this);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(TTaskWin, wxFrame)
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(TTaskWin, wxFrame)
|
|
|
|
|
EVT_CLOSE(TTaskWin::OnClose)
|
|
|
|
|
EVT_MENU_RANGE(1000, 32766, TTaskWin::OnMenu)
|
|
|
|
|
EVT_PAINT(TTaskWin::OnPaint)
|
|
|
|
|
EVT_SIZE(TTaskWin::OnSize)
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
void TTaskWin::OnClose(wxCloseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
if (event.CanVeto())
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_CLOSE;
|
|
|
|
|
int veto = _task_win_handler((WINDOW)this, &e);
|
|
|
|
|
event.Veto(veto != 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
event.Skip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTaskWin::OnMenu(wxCommandEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_COMMAND;
|
|
|
|
|
e.v.cmd.control = 0; e.v.cmd.shift = 0;
|
|
|
|
|
e.v.cmd.tag = event.GetId();
|
|
|
|
|
|
|
|
|
|
if (m_MenuOwner == NULL || m_MenuOwner == this)
|
|
|
|
|
_task_win_handler((WINDOW)this, &e);
|
|
|
|
|
else
|
|
|
|
|
((TwxWindow*)m_MenuOwner)->_eh((WINDOW)m_MenuOwner, &e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTaskWin::OnPaint()
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_UPDATE;
|
|
|
|
|
RCT& rct = e.v.update.rct;
|
2002-07-03 14:53:33 +00:00
|
|
|
|
|
|
|
|
|
wxRect rctDamaged = GetUpdateRegion().GetBox();
|
|
|
|
|
rct.left = rctDamaged.x;
|
|
|
|
|
rct.top = rctDamaged.y;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
rct.right = rctDamaged.GetRight()+1;
|
2002-07-03 14:53:33 +00:00
|
|
|
|
rct.bottom = rctDamaged.GetBottom()+1;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TDC& dc = _dc_map.GetTDC(this);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
dc.GetDC(true); // Forza la creazione di un wxPaintDC
|
|
|
|
|
_task_win_handler((WINDOW)this, &e);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
dc.KillDC();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTaskWin::OnSize(wxSizeEvent& event)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_SIZE;
|
|
|
|
|
e.v.size.height = event.GetSize().x;
|
|
|
|
|
e.v.size.width = event.GetSize().y;
|
|
|
|
|
_task_win_handler((WINDOW)this, &e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTaskWin::SetMenuTree(const MENU_ITEM* tree)
|
|
|
|
|
{
|
|
|
|
|
if (m_menu)
|
|
|
|
|
xvt_res_free_menu_tree(m_menu);
|
|
|
|
|
m_menu = xvt_menu_duplicate_tree(tree);
|
|
|
|
|
|
|
|
|
|
wxMenuBar* bar = GetMenuBar();
|
|
|
|
|
for ( ; tree != NULL && tree->tag != 0; tree++)
|
|
|
|
|
{
|
|
|
|
|
wxMenu* pMenu = new wxMenu;
|
|
|
|
|
for (MENU_ITEM* mi = tree->child; mi != NULL && mi->tag != 0; mi++)
|
|
|
|
|
{
|
|
|
|
|
wxMenuItem* item = NULL;
|
|
|
|
|
if (mi->separator)
|
|
|
|
|
item = new wxMenuItem(pMenu, wxID_SEPARATOR);
|
|
|
|
|
else
|
|
|
|
|
item = new wxMenuItem(pMenu, mi->tag, mi->text, wxEmptyString, mi->checkable);
|
|
|
|
|
pMenu->DoAppend(item);
|
|
|
|
|
}
|
|
|
|
|
const int nLast = bar->GetMenuCount()-1;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int m;
|
|
|
|
|
for (m = 2; m < nLast; m++)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
wxMenu* pMenu = bar->GetMenu(m);
|
|
|
|
|
if (pMenu->FindItem(tree->child->tag))
|
|
|
|
|
{
|
|
|
|
|
bar->Remove(m);
|
|
|
|
|
delete pMenu;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bar->Insert(m, pMenu, tree->text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTaskWin::PushMenuTree(const MENU_ITEM* tree, wxWindow* owner)
|
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
if(m_pOldBar != NULL)
|
|
|
|
|
PopMenuTree();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
m_pOldBar = GetMenuBar();
|
|
|
|
|
|
|
|
|
|
wxMenuBar* pBar = new wxMenuBar;
|
|
|
|
|
for (; tree && tree->tag != 0; tree++)
|
|
|
|
|
{
|
|
|
|
|
wxMenu* pMenu = new wxMenu;
|
|
|
|
|
for (MENU_ITEM* mi = tree->child; mi != NULL && mi->tag != 0; mi++)
|
|
|
|
|
{
|
|
|
|
|
wxMenuItem* item = NULL;
|
|
|
|
|
if (mi->separator)
|
|
|
|
|
item = new wxMenuItem(pMenu, wxID_SEPARATOR);
|
|
|
|
|
else
|
|
|
|
|
item = new wxMenuItem(pMenu, mi->tag, mi->text, wxEmptyString, mi->checkable);
|
|
|
|
|
pMenu->DoAppend(item);
|
|
|
|
|
}
|
|
|
|
|
pBar->Append(pMenu, tree->text);
|
|
|
|
|
}
|
|
|
|
|
SetMenuBar(pBar);
|
|
|
|
|
m_MenuOwner = owner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTaskWin::PopMenuTree()
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(m_pOldBar != NULL);
|
|
|
|
|
wxMenuBar* pBar = GetMenuBar();
|
|
|
|
|
SetMenuBar(m_pOldBar);
|
|
|
|
|
delete pBar;
|
|
|
|
|
m_pOldBar = NULL;
|
|
|
|
|
m_MenuOwner = NULL; // = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTaskWin::TTaskWin(wxWindow *parent, wxWindowID id,
|
|
|
|
|
const wxString& title, const wxPoint& pos,
|
|
|
|
|
const wxSize& size, long style)
|
|
|
|
|
: wxFrame(parent, id, title, pos, size, style), m_menu(NULL), m_pOldBar(NULL), m_MenuOwner(NULL)
|
|
|
|
|
{
|
|
|
|
|
wxIcon* ico = ::GetIconResource(ICON_RSRC);
|
|
|
|
|
if (ico)
|
|
|
|
|
SetIcon(*ico);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
_nice_windows.Put((WINDOW)this, this);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTaskWin::~TTaskWin()
|
|
|
|
|
{
|
|
|
|
|
if (m_menu)
|
|
|
|
|
{
|
|
|
|
|
xvt_res_free_menu_tree(m_menu);
|
|
|
|
|
m_menu = NULL;
|
|
|
|
|
}
|
2003-04-16 15:50:37 +00:00
|
|
|
|
_nice_windows.Delete((WINDOW)this);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// XVT
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void xvt_app_allow_quit(void)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2003-04-30 15:43:51 +00:00
|
|
|
|
wxTheApp->ExitMainLoop(); // Gi<47> lo fa la destroy
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_app_create(int argc, char **argv, unsigned long flags,
|
2002-02-28 14:26:23 +00:00
|
|
|
|
EVENT_HANDLER eh, XVT_CONFIG *config)
|
|
|
|
|
{
|
2003-04-30 15:43:51 +00:00
|
|
|
|
::wxInitAllImageHandlers();
|
2003-06-06 10:13:43 +00:00
|
|
|
|
xvt_fsys_get_default_dir(NULL); // Init Startup Directory
|
2003-04-30 15:43:51 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_task_win_handler = eh;
|
|
|
|
|
_config_ = config;
|
|
|
|
|
|
2003-04-30 15:43:51 +00:00
|
|
|
|
const wxString title = config->taskwin_title;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
wxPoint pos = wxDefaultPosition;
|
|
|
|
|
wxSize size = wxDefaultSize;
|
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE;
|
|
|
|
|
|
2003-03-27 12:15:57 +00:00
|
|
|
|
if (_startup_rect.right > _startup_rect.left)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2003-03-27 12:15:57 +00:00
|
|
|
|
pos.x = _startup_rect.left;
|
|
|
|
|
pos.y = _startup_rect.top;
|
|
|
|
|
size.x = _startup_rect.right - _startup_rect.left;
|
|
|
|
|
size.y = _startup_rect.bottom - _startup_rect.top;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
style |= wxMAXIMIZE;
|
|
|
|
|
|
|
|
|
|
_task_win = new TTaskWin(NULL, ICON_RSRC, title, pos, size, style);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
_nice_windows.Put((long)_task_win, _task_win);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
wxMenu* Menus[3];
|
|
|
|
|
wxString Title[3];
|
|
|
|
|
Title[0] = "&File";
|
|
|
|
|
Menus[0] = new wxMenu;
|
|
|
|
|
Menus[0]->Append(M_FILE_NEW, "Scelta &Ditta...");
|
|
|
|
|
Menus[0]->AppendSeparator();
|
|
|
|
|
Menus[0]->Append(M_FILE_PG_SETUP, "&Impostazione Stampante...");
|
|
|
|
|
Menus[0]->Append(M_FILE_PRINT, "&Stampa");
|
|
|
|
|
Menus[0]->AppendSeparator();
|
|
|
|
|
Menus[0]->Append(M_FILE_QUIT, "&Fine");
|
|
|
|
|
Title[1] = "&Modifica";
|
|
|
|
|
Menus[1] = new wxMenu;
|
|
|
|
|
Menus[1]->Append(M_EDIT_CUT, "&Taglia\tCtrl+X");
|
|
|
|
|
Menus[1]->Append(M_EDIT_COPY, "&Copia\tCtrl+C");
|
|
|
|
|
Menus[1]->Append(M_EDIT_PASTE, "&Incolla\tCtrl+V");
|
2003-04-16 15:50:37 +00:00
|
|
|
|
Menus[1]->Append(M_EDIT_CLEAR, "&Elimina\tCanc");
|
2002-02-28 14:26:23 +00:00
|
|
|
|
Title[2] = "&Help";
|
|
|
|
|
Menus[2] = new wxMenu;
|
|
|
|
|
Menus[2]->Append(M_HELP_CONTENTS, "&Sommario");
|
|
|
|
|
Menus[2]->Append(M_HELP_SEARCH, "&Cerca argomento");
|
|
|
|
|
Menus[2]->Append(M_HELP_HELPONHELP, "&Uso della guida");
|
|
|
|
|
Menus[2]->AppendSeparator();
|
|
|
|
|
Menus[2]->Append(M_FILE_ABOUT+1, "&Informazioni");
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
wxMenuBar* pMenubar = new wxMenuBar(3, Menus, Title);
|
|
|
|
|
#else
|
|
|
|
|
wxMenuBar* pMenubar = new wxMenuBar();
|
|
|
|
|
|
|
|
|
|
for (int i= 0; i < 3; i++)
|
|
|
|
|
pMenubar->Append(Menus[i], Title[i]);
|
|
|
|
|
#endif
|
2003-05-22 15:47:31 +00:00
|
|
|
|
((wxFrame*)_task_win)->SetMenuBar(pMenubar);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
_task_win->Show();
|
|
|
|
|
if (style & wxMAXIMIZE)
|
|
|
|
|
((wxFrame*)_task_win)->Maximize();
|
|
|
|
|
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(e));
|
|
|
|
|
e.type = E_CREATE;
|
|
|
|
|
long ret = _task_win_handler((WINDOW)_task_win, &e);
|
|
|
|
|
if (ret != 0)
|
2003-04-30 15:43:51 +00:00
|
|
|
|
wxTheApp->MainLoop();
|
|
|
|
|
wxTheApp->ExitMainLoop(); // Non entrare nel main loop di xwWindows
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_app_destroy(void)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2003-04-30 15:43:51 +00:00
|
|
|
|
wxTheApp->ExitMainLoop();
|
2003-03-28 15:33:49 +00:00
|
|
|
|
_task_win->Destroy();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2002-04-26 10:50:41 +00:00
|
|
|
|
DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS *ct)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(ct != NULL);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
TDC dc(NULL);
|
2002-04-26 10:50:41 +00:00
|
|
|
|
memcpy(ct, &dc._dct, sizeof(DRAW_CTOOLS));
|
|
|
|
|
return ct;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_app_process_pending_events(void)
|
|
|
|
|
{
|
2003-04-30 15:43:51 +00:00
|
|
|
|
if (wxTheApp != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (int m = 0; m < 4 && wxTheApp->Pending(); m++)
|
|
|
|
|
wxTheApp->Dispatch();
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Clipboard functions
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
static DATA_PTR ptrClipboardData = NULL;
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
char* xvt_cb_alloc_data(long size)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
xvt_cb_free_data();
|
|
|
|
|
if (size > 0)
|
|
|
|
|
ptrClipboardData = xvt_mem_zalloc(size+1);
|
|
|
|
|
return ptrClipboardData;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_cb_close(void)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxTheClipboard->Close();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_cb_free_data(void)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (ptrClipboardData != NULL)
|
|
|
|
|
{
|
|
|
|
|
xvt_mem_free(ptrClipboardData);
|
|
|
|
|
ptrClipboardData = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* xvt_cb_get_data(CB_FORMAT cbfmt, char *name, long *sizep)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (xvt_cb_has_format(cbfmt, name))
|
|
|
|
|
{
|
|
|
|
|
wxTextDataObject data;
|
|
|
|
|
wxTheClipboard->GetData(data);
|
|
|
|
|
*sizep = data.GetDataSize();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (*sizep > 0)
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
xvt_cb_alloc_data(*sizep);
|
|
|
|
|
memcpy(ptrClipboardData, data.GetText(), *sizep);
|
|
|
|
|
(*sizep)--; // Elimino lo '/0' finale che non piace a XI
|
|
|
|
|
return ptrClipboardData;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
sizep = 0;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_cb_has_format(CB_FORMAT fmt, char *name)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
BOOLEAN ok = fmt == CB_TEXT && wxTheClipboard->IsSupported(wxDF_TEXT);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_cb_open(BOOLEAN writing)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxTheClipboard->Open();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return TRUE;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_cb_put_data(CB_FORMAT cbfmt, char *name, long size, PICTURE pic)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
BOOLEAN ok = cbfmt == CB_TEXT && ptrClipboardData != NULL;
|
|
|
|
|
if (ok)
|
|
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(ptrClipboardData));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Controls functions (NOT used)
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ SORRY_BOX(); } // Ignored
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
WINDOW win = NULL_WIN;
|
|
|
|
|
switch (win_def_p->wtype)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case WC_HSCROLL: /* horizontal scrollbar control */
|
|
|
|
|
case WC_VSCROLL: /* vertical scrollbar control */
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
const wxRect rct = NormalizeRCT(&win_def_p->rct);
|
|
|
|
|
long style = win_def_p->wtype == WC_HSCROLL ? wxSB_HORIZONTAL : wxSB_VERTICAL;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxScrollBar* sb = new wxScrollBar((wxWindow*)parent_win,
|
|
|
|
|
win_def_p->v.ctl.ctrl_id,
|
2002-02-28 14:26:23 +00:00
|
|
|
|
rct.GetPosition(), rct.GetSize(), style);
|
|
|
|
|
win = (WINDOW)sb;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
default:
|
2002-02-28 14:26:23 +00:00
|
|
|
|
SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
return win;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ SORRY_BOX(); } // Ignored
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Debug functions
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2002-09-13 14:56:23 +00:00
|
|
|
|
void xvt_debug_printf(const char* fmt, ...)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
static FILE* f = NULL;
|
|
|
|
|
if (f == NULL)
|
|
|
|
|
f = fopen("trace.log", "w");
|
|
|
|
|
if (f != NULL)
|
|
|
|
|
{
|
|
|
|
|
char msg[256];
|
|
|
|
|
va_list argptr;
|
|
|
|
|
va_start(argptr,fmt);
|
|
|
|
|
vsprintf(msg,fmt,argptr);
|
|
|
|
|
va_end(argptr);
|
|
|
|
|
fprintf(f, "%s\n", msg);
|
|
|
|
|
fflush(f);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-04-30 15:43:51 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Dongle functions
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_dongle_hl_crypt(unsigned short* data) // Array di 4 words (8 bytes)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_HL_Crypt(data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_HL_Crypt(data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dongle_hl_login(unsigned short address, const unsigned char* label, const unsigned char* password)
|
2003-04-30 15:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_HL_Login(address, label, password);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_HL_Login(address, label, password);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dongle_hl_logout()
|
2003-04-30 15:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_HL_Logout();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_HL_Logout();
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dongle_hl_read(unsigned short reg, unsigned short* data)
|
2003-04-30 15:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_HL_Read(reg, data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_HL_Read(reg, data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dongle_hl_read_block(unsigned char* data)
|
2003-04-30 15:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_HL_ReadBlock(data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_HL_ReadBlock(data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dongle_hl_write(unsigned short reg, unsigned short data)
|
2003-04-30 15:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_HL_Write(reg, data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_HL_Write(reg, data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_dongle_sl_crypt(unsigned short* data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_SL_Crypt(data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_SL_Crypt(data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_dongle_sl_login(const unsigned char* label, const unsigned char* password)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_SL_Login(label, password);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_SL_Login(label, password);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_dongle_sl_logout()
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_SL_Logout();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_SL_Logout();
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_dongle_sl_read_block(unsigned short reg, unsigned short size, unsigned short* data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_SL_ReadBlock(reg, size, data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_SL_ReadBlock(reg, size, data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_dongle_sl_write_block(unsigned short reg, unsigned short size, const unsigned short* data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_SL_WriteBlock(reg, size, data);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_SL_WriteBlock(reg, size, data);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Common dialogs
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-03-20 10:30:21 +00:00
|
|
|
|
static wxString GetMainTitle()
|
|
|
|
|
{
|
|
|
|
|
wxString strTitle;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (_task_win != NULL)
|
2003-03-20 10:30:21 +00:00
|
|
|
|
{
|
|
|
|
|
strTitle = _task_win->GetTitle();
|
|
|
|
|
const int space = strTitle.Find(" -");
|
|
|
|
|
if (space > 0)
|
|
|
|
|
strTitle = strTitle.Left(space);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strTitle = "CAMPO";
|
|
|
|
|
return strTitle;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-24 16:22:11 +00:00
|
|
|
|
COLOR xvt_dm_post_choose_color(WINDOW win, COLOR xc)
|
|
|
|
|
{
|
|
|
|
|
CAST_COLOR(xc, wc);
|
|
|
|
|
|
|
|
|
|
wxColourData cd;
|
|
|
|
|
cd.SetChooseFull(true);
|
|
|
|
|
cd.SetColour(wc);
|
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
|
{
|
|
|
|
|
const unsigned char val = (i & 0x8) ? 255 : 127;
|
|
|
|
|
const unsigned char red = (i & 0x1) ? val : 0;
|
|
|
|
|
const unsigned char green = (i & 0x2) ? val : 0;
|
|
|
|
|
const unsigned char blue = (i & 0x4) ? val : 0;
|
|
|
|
|
wxColour col(red, green, blue);
|
|
|
|
|
cd.SetCustomColour(i, col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
wxColourDialog dialog(&w, &cd);
|
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
xc = MAKE_XVT_COLOR(dialog.GetColourData().GetColour());
|
|
|
|
|
|
|
|
|
|
return xc;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3, const char* fmt)
|
|
|
|
|
{
|
2003-03-20 10:30:21 +00:00
|
|
|
|
int nFlags = wxCENTRE | wxICON_QUESTION | wxYES_NO;
|
|
|
|
|
if (Btn3 == NULL)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (wxStricmp(Btn1, "no") == 0)
|
2003-03-20 10:30:21 +00:00
|
|
|
|
nFlags |= wxNO_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nFlags |= wxCANCEL;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
|
|
|
|
int answer = wxMessageBox(fmt, GetMainTitle(), nFlags);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
return answer == wxYES ? RESP_DEFAULT : (answer == wxNO ? RESP_2 : RESP_3);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dm_post_error(const char *fmt)
|
|
|
|
|
{
|
|
|
|
|
wxMessageBox(fmt, GetMainTitle(), wxOK | wxCENTRE | wxICON_ERROR);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dm_post_fatal_exit(const char *fmt)
|
|
|
|
|
{
|
2003-03-24 16:22:11 +00:00
|
|
|
|
wxLogFatalError(fmt);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static wxString MakeFileName(const wxChar* name, const wxChar* ext)
|
|
|
|
|
{
|
|
|
|
|
wxString f = name;
|
|
|
|
|
if (ext && *ext)
|
|
|
|
|
{
|
|
|
|
|
if (*ext != '.')
|
|
|
|
|
f += '.';
|
|
|
|
|
f += ext;
|
|
|
|
|
}
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
static FL_STATUS xvt_dm_post_file_ask(FILE_SPEC *fsp, const char *msg, int flags)
|
2003-03-20 10:30:21 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxString path = fsp->dir.path;
|
2003-03-20 10:30:21 +00:00
|
|
|
|
wxString name = MakeFileName(fsp->name, fsp->type);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxString extension = fsp->type;
|
2003-03-20 10:30:21 +00:00
|
|
|
|
wxString mask = MakeFileName("*", fsp->type);
|
|
|
|
|
|
|
|
|
|
wxString selectedname = wxFileSelector(msg, path, name, extension , mask, flags);
|
2002-06-05 11:00:45 +00:00
|
|
|
|
if (selectedname.IsEmpty())
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return FL_CANCEL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-03-20 10:30:21 +00:00
|
|
|
|
wxFileName::SplitPath(selectedname, &path, &name, &extension);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
strcpy(fsp->dir.path, path);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
strcpy(fsp->name, MakeFileName(name, extension));
|
2002-02-28 14:26:23 +00:00
|
|
|
|
strcpy(fsp->type, extension);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return FL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg)
|
|
|
|
|
{
|
2003-03-20 10:30:21 +00:00
|
|
|
|
const int flags = wxOPEN | wxHIDE_READONLY | wxFILE_MUST_EXIST;
|
|
|
|
|
return xvt_dm_post_file_ask(fsp, msg, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const int flags = wxSAVE | wxHIDE_READONLY;
|
2003-03-20 10:30:21 +00:00
|
|
|
|
return xvt_dm_post_file_ask(fsp, msg, flags);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD *precp, unsigned long reserved)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxFontData data;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
data.SetInitialFont(font.Font(NULL));
|
2002-02-28 14:26:23 +00:00
|
|
|
|
data.EnableEffects(FALSE);
|
|
|
|
|
wxFontDialog dlg(_task_win, &data);
|
|
|
|
|
BOOLEAN ok = dlg.ShowModal() == wxID_OK;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
font.Copy(dlg.GetFontData().GetChosenFont());
|
|
|
|
|
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_FONT;
|
|
|
|
|
e.v.font.font_id = font_id;
|
|
|
|
|
_task_win_handler(win, &e);
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dm_post_message(const char *fmt)
|
|
|
|
|
{
|
|
|
|
|
wxMessageBox(fmt, GetMainTitle(), wxOK | wxCENTRE | wxICON_INFORMATION);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dm_post_note(const char *fmt)
|
|
|
|
|
{
|
|
|
|
|
wxMessageBox(fmt, GetMainTitle(), wxOK | wxCENTRE | wxICON_EXCLAMATION);
|
2003-03-20 10:30:21 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
char* xvt_dm_post_string_prompt(const char* message, char* response, int response_len)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(message && response && response_len > 0);
|
|
|
|
|
SORRY_BOX();
|
|
|
|
|
*response = '\0';
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dm_post_warning(const char *fmt)
|
|
|
|
|
{
|
|
|
|
|
wxMessageBox(fmt, GetMainTitle(), wxOK | wxCENTRE | wxICON_EXCLAMATION);
|
2003-03-24 16:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Help system
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
struct XVAGA_HELP_INFO
|
|
|
|
|
{
|
|
|
|
|
wxString m_strFilename;
|
|
|
|
|
bool m_hlp;
|
|
|
|
|
wxHtmlHelpController m_hc;
|
|
|
|
|
} help_info;
|
|
|
|
|
|
|
|
|
|
XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags)
|
|
|
|
|
{
|
|
|
|
|
if (!help_info.m_strFilename.IsEmpty())
|
|
|
|
|
xvt_help_close_helpfile((XVT_HELP_INFO)&help_info);
|
|
|
|
|
|
|
|
|
|
const char* ext[] = { ".zip", ".htb", ".hlp", NULL };
|
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
|
|
|
{
|
|
|
|
|
wxString base = fs->name;
|
|
|
|
|
if (j == 1)
|
|
|
|
|
base.Replace("campo", "prassi", true);
|
|
|
|
|
for (int i = 0; ext[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
wxString strName;
|
|
|
|
|
if (i < 2)
|
|
|
|
|
strName = "help/";
|
|
|
|
|
strName << base;
|
|
|
|
|
strName << ext[i];
|
|
|
|
|
if (::wxFileExists(strName))
|
|
|
|
|
{
|
|
|
|
|
help_info.m_strFilename = strName;
|
|
|
|
|
help_info.m_hlp = i == 2;
|
|
|
|
|
if (!help_info.m_hlp)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxFileSystem::AddHandler(new wxZipFSHandler);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
help_info.m_hc.AddBook(strName, true);
|
|
|
|
|
}
|
|
|
|
|
return (XVT_HELP_INFO)&help_info;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-10-24 10:47:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL_HELP_INFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_help_close_helpfile(XVT_HELP_INFO hi)
|
|
|
|
|
{
|
|
|
|
|
if (hi == NULL_HELP_INFO)
|
|
|
|
|
hi = (XVT_HELP_INFO)&help_info;
|
|
|
|
|
|
|
|
|
|
XVAGA_HELP_INFO* ahi = (XVAGA_HELP_INFO*)hi;
|
|
|
|
|
if (!ahi->m_strFilename.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
if (ahi->m_hlp)
|
|
|
|
|
{
|
|
|
|
|
unsigned int hwnd = (unsigned int)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
|
|
|
|
|
OsWin32_Help(hwnd, ahi->m_strFilename, 0, NULL); // HELP_QUIT
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (!ahi->m_hlp)
|
|
|
|
|
ahi->m_hc.Quit();
|
|
|
|
|
ahi->m_strFilename.Empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN bProcessed = FALSE;
|
|
|
|
|
|
|
|
|
|
if (hi == NULL_HELP_INFO)
|
|
|
|
|
return bProcessed;
|
|
|
|
|
|
|
|
|
|
XVAGA_HELP_INFO* ahi = (XVAGA_HELP_INFO*)hi;
|
|
|
|
|
if (ahi->m_strFilename.IsEmpty())
|
|
|
|
|
return bProcessed;
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
if (ahi->m_hlp)
|
|
|
|
|
{
|
|
|
|
|
unsigned int hwnd = (unsigned int)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
|
|
|
|
|
switch (ev->type)
|
|
|
|
|
{
|
|
|
|
|
case E_COMMAND:
|
|
|
|
|
bProcessed = OsWin32_Help(hwnd, ahi->m_strFilename, ev->v.cmd.tag, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case E_HELP:
|
|
|
|
|
bProcessed = OsWin32_Help(hwnd, ahi->m_strFilename, M_HELP_ONCONTEXT, (const char*)ev->v.help.tid);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return bProcessed;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch (ev->type)
|
|
|
|
|
{
|
|
|
|
|
case E_COMMAND:
|
|
|
|
|
switch (ev->v.cmd.tag)
|
|
|
|
|
{
|
|
|
|
|
case M_HELP_CONTENTS:
|
|
|
|
|
ahi->m_hc.DisplayContents();
|
|
|
|
|
bProcessed = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case M_HELP_SEARCH:
|
|
|
|
|
ahi->m_hc.DisplayIndex();
|
|
|
|
|
bProcessed = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case E_HELP:
|
|
|
|
|
ahi->m_hc.Display((const char*)ev->v.help.tid);
|
|
|
|
|
bProcessed = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bProcessed;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Image handling
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TXVT_IMAGE
|
|
|
|
|
{
|
|
|
|
|
wxImage m_image;
|
|
|
|
|
wxBitmap m_bitmap;
|
|
|
|
|
bool m_bDirty;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
const wxImage& Image() const { return m_image; }
|
|
|
|
|
wxImage& Image() { m_bDirty = TRUE; return m_image; }
|
|
|
|
|
const wxBitmap& Bitmap();
|
|
|
|
|
TXVT_IMAGE() : m_bDirty(FALSE) { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const wxBitmap& TXVT_IMAGE::Bitmap()
|
|
|
|
|
{
|
|
|
|
|
if (m_bDirty)
|
|
|
|
|
{
|
|
|
|
|
m_bitmap = m_image.ConvertToBitmap();
|
|
|
|
|
// m_image.Destroy(); // Sarebbe bello poterlo fare
|
|
|
|
|
m_bDirty = FALSE;
|
|
|
|
|
}
|
|
|
|
|
return m_bitmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Font Handling
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TFontId::Copy(const TFontId& rFont)
|
|
|
|
|
{
|
|
|
|
|
m_strFace = rFont.m_strFace;
|
|
|
|
|
m_nSize = rFont.m_nSize;
|
|
|
|
|
m_wMask = rFont.m_wMask;
|
|
|
|
|
m_win = rFont.m_win;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TFontId::IsEqual(const TFontId& rFont) const
|
|
|
|
|
{
|
|
|
|
|
if (m_strFace != rFont.m_strFace)
|
|
|
|
|
return false;
|
|
|
|
|
if (m_nSize != rFont.m_nSize)
|
|
|
|
|
return false;
|
|
|
|
|
if (m_wMask != rFont.m_wMask)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
const char* TFontId::FaceName() const
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (m_strFace.IsEmpty())
|
|
|
|
|
return XVT_FFN_COURIER;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return m_strFace;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TFontId::Family() const
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (m_strFace.IsEmpty() || m_strFace == XVT_FFN_COURIER)
|
|
|
|
|
return wxMODERN;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (m_strFace == XVT_FFN_HELVETICA)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return wxSWISS;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (m_strFace == XVT_FFN_TIMES)
|
|
|
|
|
return wxROMAN;
|
|
|
|
|
if (m_strFace == XVT_FFN_FIXED)
|
|
|
|
|
return wxMODERN;
|
|
|
|
|
if (m_strFace == XVT_FFN_SYSTEM)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return wxDEFAULT;
|
|
|
|
|
return wxROMAN;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TFontId::Style() const
|
|
|
|
|
{
|
|
|
|
|
return (m_wMask & XVT_FS_ITALIC) ? wxITALIC : wxNORMAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TFontId::Underline() const
|
|
|
|
|
{
|
|
|
|
|
return (m_wMask & XVT_FS_UNDERLINE) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-05 14:26:24 +00:00
|
|
|
|
|
|
|
|
|
wxFont& TFontId::Font(wxDC* dc) const
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
int nSize = PointSize();
|
|
|
|
|
if (m_win == _print_win)
|
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
|
static wxDC* lastDC = NULL;
|
|
|
|
|
static double dPrintScale = 1.0;
|
|
|
|
|
|
|
|
|
|
if (dc != lastDC)
|
|
|
|
|
{
|
|
|
|
|
const wxSize ppi = dc->GetPPI();
|
|
|
|
|
dPrintScale = ppi.x / 96.0; // First guess for scaling factor
|
|
|
|
|
int nBestSize = 0;
|
|
|
|
|
|
|
|
|
|
double nMin = dPrintScale-0.1;
|
|
|
|
|
double nMax = dPrintScale+0.1;
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
const double nScale = (nMin+nMax)/2.0;
|
|
|
|
|
const int nFontSize = int(12.0 * nScale); // First guess for PointSize
|
|
|
|
|
if (nFontSize == nBestSize)
|
|
|
|
|
break;
|
|
|
|
|
wxFont courier(nFontSize, wxMODERN, wxNORMAL, wxNORMAL);
|
|
|
|
|
dc->SetFont(courier);
|
|
|
|
|
int tw; dc->GetTextExtent("0123456789", &tw, NULL);
|
|
|
|
|
|
|
|
|
|
if (tw > ppi.x)
|
|
|
|
|
nMax = nScale;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nMin = nScale;
|
|
|
|
|
nBestSize = nFontSize;
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dPrintScale = nBestSize / 12.0;
|
|
|
|
|
lastDC = dc;
|
|
|
|
|
}
|
|
|
|
|
nSize = int(nSize * dPrintScale);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2003-02-05 14:26:24 +00:00
|
|
|
|
|
|
|
|
|
const int nWeight = (m_wMask & XVT_FS_BOLD) ? wxBOLD : wxNORMAL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxFont* font = wxTheFontList->FindOrCreateFont(
|
2003-02-05 14:26:24 +00:00
|
|
|
|
nSize, Family(), Style(), nWeight, Underline(), FaceName());
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return *font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TFontId::Copy(const wxFont& rFont)
|
|
|
|
|
{
|
|
|
|
|
m_strFace = rFont.GetFaceName();
|
|
|
|
|
m_nSize = rFont.GetPointSize();
|
|
|
|
|
m_wMask = XVT_FS_NONE;
|
|
|
|
|
if (rFont.GetUnderlined())
|
|
|
|
|
m_wMask |= XVT_FS_UNDERLINE;
|
|
|
|
|
if (rFont.GetWeight() >= 700)
|
|
|
|
|
m_wMask |= XVT_FS_BOLD;
|
|
|
|
|
if (rFont.GetStyle() & wxITALIC)
|
|
|
|
|
m_wMask |= XVT_FS_ITALIC;
|
|
|
|
|
m_win = NULL_WIN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Drawable windows
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_clear(WINDOW win, COLOR col)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
CAST_COLOR(col, brush_color);
|
|
|
|
|
wxBrush brush(brush_color, wxSOLID);
|
|
|
|
|
dc.SetBackground(brush);
|
|
|
|
|
dc.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_arc(WINDOW Win, RCT* r, int sx, int sy, int ex, int ey)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ SORRY_BOX(); }
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxIcon* ico = ::GetIconResource(rid);
|
|
|
|
|
if (ico)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
dc.DrawIcon(*ico, x, y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(image != NULL);
|
|
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect src = NormalizeRCT(source);
|
|
|
|
|
const wxRect dst = NormalizeRCT(dest);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
const wxBitmap& bmp = ((TXVT_IMAGE*)image)->Bitmap();
|
|
|
|
|
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize())
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
dc.DrawBitmap(bmp, dst.GetPosition());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2003-05-22 15:25:25 +00:00
|
|
|
|
OsWin32_DrawBitmap(bmp.GetHBITMAP(), dc.GetHDC(),
|
2002-07-03 14:53:33 +00:00
|
|
|
|
dst.x, dst.y, dst.width, dst.height,
|
|
|
|
|
src.x, src.y, src.width, src.height);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
|
|
|
|
|
wxImage sub = img.GetSubImage(src);
|
|
|
|
|
|
|
|
|
|
sub.Rescale(dst.width, dst.height);
|
|
|
|
|
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_dwin_draw_oval(WINDOW Win, RCT* r) { SORRY_BOX(); }
|
|
|
|
|
void xvt_dwin_draw_pie(WINDOW win, RCT *rctp, int start_x, int start_y, int stop_x, int stop_y) { SORRY_BOX(); }
|
|
|
|
|
void xvt_dwin_draw_polygon(WINDOW win, PNT *lpnts, int npnts) { SORRY_BOX(); }
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_rect(WINDOW win, RCT *rctp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
dc.DrawRectangle(rct);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp)
|
|
|
|
|
{
|
2003-02-25 15:22:52 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
OsWin32_DrawDottedRect(dc.GetHDC(), rctp->left, rctp->top, rctp->right, rctp->bottom);
|
|
|
|
|
#else
|
|
|
|
|
DRAW_CTOOLS dct;
|
2003-05-22 15:07:21 +00:00
|
|
|
|
xvt_dwin_get_draw_ctools(win, &dct);
|
2003-02-25 15:22:52 +00:00
|
|
|
|
|
|
|
|
|
CPEN pen;
|
|
|
|
|
pen.width = 1;
|
|
|
|
|
pen.pat = PAT_SOLID;
|
|
|
|
|
pen.style = P_DOT;
|
|
|
|
|
pen.color = dct.fore_color;
|
|
|
|
|
xvt_dwin_set_cpen(win, &pen);
|
|
|
|
|
|
|
|
|
|
CBRUSH brush;
|
|
|
|
|
brush.color = dct.back_color;
|
|
|
|
|
brush.pat = PAT_HOLLOW;
|
2003-04-01 07:34:53 +00:00
|
|
|
|
xvt_dwin_set_cbrush(win, &brush);
|
2003-02-25 15:22:52 +00:00
|
|
|
|
|
|
|
|
|
xvt_dwin_draw_rect(win, rctp);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-02-25 15:22:52 +00:00
|
|
|
|
xvt_dwin_set_draw_ctools(win, &dct);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc._pnt.x = pnt.h;
|
|
|
|
|
dc._pnt.y = pnt.v;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (s && *s && len != 0)
|
|
|
|
|
{
|
2003-05-22 15:07:21 +00:00
|
|
|
|
/*
|
2003-04-16 15:50:37 +00:00
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
wxRect rct; dc.GetClippingBox(rct);
|
|
|
|
|
const int maxx = rct.GetRight();
|
|
|
|
|
if (maxx <= 0 || x < maxx)
|
|
|
|
|
{
|
|
|
|
|
wxString str(s);
|
|
|
|
|
if (len >= 0)
|
|
|
|
|
str.Truncate(len);
|
|
|
|
|
int height, desc, lead;
|
|
|
|
|
dc.GetTextExtent(str, NULL, &height, &desc, &lead);
|
|
|
|
|
y -= height-desc; // Triste necessita'!
|
|
|
|
|
dc.DrawText(str, x, y);
|
|
|
|
|
}
|
2003-05-22 15:07:21 +00:00
|
|
|
|
*/
|
|
|
|
|
CAST_TDC(win, tdc);
|
|
|
|
|
RCT rct;
|
|
|
|
|
const bool noclip = !tdc.GetClippingBox(&rct);
|
|
|
|
|
if (noclip || x < rct.right)
|
|
|
|
|
{
|
|
|
|
|
wxString str(s);
|
|
|
|
|
if (len >= 0)
|
|
|
|
|
str.Truncate(len);
|
|
|
|
|
tdc.GetDC().DrawText(str, x, y-tdc.GetFontDelta());
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc.GetClippingBox(rct);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return rct;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
DRAW_CTOOLS* xvt_dwin_get_draw_ctools(WINDOW win, DRAW_CTOOLS *ctoolsp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
memcpy(ctoolsp, &dc._dct, sizeof(DRAW_CTOOLS));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return ctoolsp;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_FNTID xvt_dwin_get_font(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
TFontId* pFont = new TFontId(dc._font);
|
|
|
|
|
return pFont;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxString str = "Mq";
|
|
|
|
|
int height, desc, lead;
|
|
|
|
|
|
|
|
|
|
dc.GetTextExtent(str, NULL, &height, &desc, &lead);
|
|
|
|
|
if (leadingp)
|
|
|
|
|
*leadingp = lead;
|
|
|
|
|
if (ascentp)
|
|
|
|
|
*ascentp = height-lead-desc;
|
|
|
|
|
if (descentp)
|
|
|
|
|
*descentp = desc;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long xvt_dwin_get_font_size_mapped(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, dc);
|
|
|
|
|
const wxFont& font = dc.GetFont();
|
|
|
|
|
int height = font.GetPointSize();
|
|
|
|
|
return height;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2002-09-13 14:56:23 +00:00
|
|
|
|
int xvt_dwin_get_text_width(WINDOW win, const char *s, int len)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
int width = 0, height;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (s && *s && len != 0)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
wxString str = s;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (len >= 0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
str.Truncate(len);
|
|
|
|
|
if (str.StartsWith("ABCDEFGH") || str.StartsWith("MMMMMMMM"))
|
|
|
|
|
{
|
|
|
|
|
const wxString emme('m', str.Length());
|
|
|
|
|
str = emme;
|
|
|
|
|
}
|
|
|
|
|
dc.GetTextExtent(str, &width, &height);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return width;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_invalidate_rect(WINDOW win, RCT* rctp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
if (rctp)
|
|
|
|
|
{
|
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
w.Refresh(FALSE, &rct);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
w.Refresh(FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_dwin_is_update_needed(WINDOW win, RCT* rctp)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (rctp != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
CAST_WIN(win, w);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxRect rect1 = NormalizeRCT(rctp);
|
|
|
|
|
const wxRect rect2 = w.GetUpdateRegion().GetBox();
|
|
|
|
|
return RectIntersect(rect1, rect2);
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return FALSE;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (dh != 0 || dv != 0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (rctp != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
if (rct.width > 0 && rct.height > 0)
|
|
|
|
|
w.ScrollWindow(dh, dv, &rct);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
w.ScrollWindow(dh, dv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_back_color(WINDOW win, COLOR color)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc._dct.back_color = color;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_cbrush(WINDOW win, CBRUSH* cbrush)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
memcpy(&dc._dct.brush, cbrush, sizeof(CBRUSH));
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_clip(WINDOW win, RCT* rctp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc.SetClippingBox(rctp);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_cpen(WINDOW win, CPEN* cpen)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
memcpy(&dc._dct.pen, cpen, sizeof(CPEN));
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_draw_ctools(WINDOW win, DRAW_CTOOLS* xct)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
memcpy(&dc._dct, xct, sizeof(DRAW_CTOOLS));
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_draw_mode(WINDOW win, DRAW_MODE mode)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc._dct.mode = mode;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_font(WINDOW win, XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(font_id != NULL);
|
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
const TFontId& font = *(const TFontId*)font_id;
|
|
|
|
|
if (dc._font != font)
|
|
|
|
|
{
|
|
|
|
|
dc._font = font;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_fore_color(WINDOW win, COLOR color)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc._dct.fore_color = color;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_set_std_cpen(WINDOW win, long flag)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CPEN pen; memset(&pen, 0, sizeof(CPEN));
|
|
|
|
|
pen.style = P_SOLID;
|
|
|
|
|
|
|
|
|
|
switch(flag)
|
|
|
|
|
{
|
|
|
|
|
case TL_PEN_BLACK: pen.color = COLOR_BLACK; pen.pat = PAT_SOLID; break;
|
|
|
|
|
case TL_PEN_HOLLOW: pen.pat = PAT_HOLLOW; break;
|
|
|
|
|
case TL_PEN_WHITE: pen.color = COLOR_WHITE; pen.pat = PAT_SOLID; break;
|
|
|
|
|
case TL_PEN_RUBBER: pen.pat = PAT_RUBBER; break;
|
|
|
|
|
default: SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
xvt_dwin_set_cpen(win, &pen);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_line(WINDOW win, PNT pnt)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
const wxPoint to(pnt.h, pnt.v);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
if (dc._pnt != to)
|
|
|
|
|
dc.GetDC().DrawLine(dc._pnt, to);
|
|
|
|
|
dc.GetDC().DrawPoint(to);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
dc._pnt = to;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_update(WINDOW win)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
// "sembra" che non serva ad un fico secco, ma FORSE in Windows serve!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
CAST_TWIN(win, w);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
OsWin32_UpdateWindow(w.GetHWND());
|
|
|
|
|
#else
|
|
|
|
|
OsLinux_UpdateWindow(win);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Debug functions
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_ERRSEV xvt_errmsg_get_sev_id(XVT_ERRMSG err)
|
|
|
|
|
{
|
|
|
|
|
return (XVT_ERRSEV)err;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Fonts
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_copy(XVT_FNTID dest_font_id, XVT_FNTID src_font_id, XVT_FONT_ATTR_MASK mask)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(dest_font_id && src_font_id && mask == XVT_FA_ALL);
|
|
|
|
|
TFontId* dst = (TFontId*)dest_font_id;
|
|
|
|
|
TFontId* src = (TFontId*)src_font_id;
|
|
|
|
|
*dst = *src;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_FNTID xvt_font_create(void)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId* pFont = new TFontId;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return (XVT_FNTID)pFont;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_deserialize(XVT_FNTID font_id, char *buf)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
// 01\\Courier\\0\\10\\WIN01/-13/0/0/0/400/0/0/0/0/1/2/1/49/Courier
|
|
|
|
|
|
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
char* s = strchr(buf, '/');
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (s == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return;
|
|
|
|
|
const int nSize = atoi(s+1);
|
|
|
|
|
if (nSize > 0)
|
|
|
|
|
font.SetPointSize(nSize);
|
|
|
|
|
else
|
|
|
|
|
font.SetPointSize(-nSize * 10 / 13);
|
|
|
|
|
|
|
|
|
|
// Ignore 4 fields
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < 4; i++)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
s = strchr(s+1, '/');
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (s == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
s++;
|
|
|
|
|
const int nWeight = atoi(s);
|
|
|
|
|
if (nWeight >= 600)
|
|
|
|
|
font.SetMask(font.Mask() | XVT_FS_BOLD);
|
|
|
|
|
|
|
|
|
|
s = strchr(s, '/');
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (s == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return;
|
|
|
|
|
const int nItalic = atoi(s+1);
|
|
|
|
|
if (nItalic)
|
|
|
|
|
font.SetMask(font.Mask() | XVT_FS_ITALIC);
|
|
|
|
|
|
|
|
|
|
// Ignore 8 fields
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
s = strchr(s+1, '/');
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (s == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
font.SetFaceName(s+1);
|
|
|
|
|
font.SetWin(NULL_WIN);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_destroy(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
delete (TFontId*)font_id;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_font_get_family(XVT_FNTID font_id, char* buf, long max_buf)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const TFontId& font = *(TFontId*)font_id;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
strncpy(buf, font.FaceName(), max_buf);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
buf[max_buf-1] = '\0';
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return TRUE;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_font_get_family_mapped(XVT_FNTID font_id, char* buf, long max_buf)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ return xvt_font_get_family(font_id, buf, max_buf); }
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *descentp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
WINDOW win = font.Win();
|
|
|
|
|
if (win == NULL_WIN)
|
|
|
|
|
win = TASK_WIN;
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxString str = "Mq";
|
|
|
|
|
int height, desc, lead;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
dc.GetTextExtent(str, NULL, &height, &desc, &lead, &font.Font(&dc));
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (leadingp)
|
|
|
|
|
*leadingp = lead;
|
|
|
|
|
if (ascentp)
|
|
|
|
|
*ascentp = height-desc-lead;
|
|
|
|
|
if (descentp)
|
|
|
|
|
*descentp = desc;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_font_get_native_desc(XVT_FNTID font_id, char *buf, long max_buf)
|
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
|
long len = xvt_font_serialize(font_id, buf, max_buf);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return len > 0;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long xvt_font_get_size(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return ((TFontId*)font_id)->PointSize();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_FONT_STYLE_MASK xvt_font_get_style(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return ((TFontId*)font_id)->Mask();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_font_get_win(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return ((TFontId*)font_id)->Win();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_font_is_mapped(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
bool yes = ((TFontId*)font_id)->Win() != NULL_WIN;
|
|
|
|
|
return yes;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_map(XVT_FNTID font_id, WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId* pFont = (TFontId*)font_id;
|
|
|
|
|
pFont->SetWin(win);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_map_using_default(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
xvt_font_map(font_id, TASK_WIN);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_set_family(XVT_FNTID font_id, char* family)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
font.SetFaceName(family);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_set_size(XVT_FNTID font_id, long size)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
font.SetPointSize(size);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_set_style(XVT_FNTID font_id, XVT_FONT_STYLE_MASK mask)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
font.SetMask(mask);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long xvt_font_serialize(XVT_FNTID font_id, char *buf, long max_buf)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
// 01\\Courier\\0\\10\\WIN01/-13/0/0/0/400/0/0/0/0/1/2/1/49/Courier
|
|
|
|
|
|
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
const char* name = font.FaceName();
|
|
|
|
|
const int size = font.PointSize();
|
|
|
|
|
const int italic = (font.Mask() & XVT_FS_ITALIC) != 0;
|
|
|
|
|
const int weight = 400; // Normal size
|
|
|
|
|
|
|
|
|
|
wxString str;
|
|
|
|
|
str = wxString::Format("01\\%s\\0\\%d\\WIN01/%d/%d/0/0/%d/0/0/0/0/0/0/0/0/%s",
|
|
|
|
|
name, size, size, weight, italic, name);
|
|
|
|
|
|
|
|
|
|
strncpy(buf, str, max_buf);
|
|
|
|
|
buf[max_buf-1] = '\0';
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return strlen(buf);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_unmap(XVT_FNTID font_id)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TFontId& font = *(TFontId*)font_id;
|
|
|
|
|
font.SetWin(NULL_WIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// File system
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-04-22 14:01:47 +00:00
|
|
|
|
BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirname, const char *leafroot, const char *leafext, const char* /* leafvers */)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
_makepath(mbs, volname, dirname, leafroot, leafext);
|
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
*mbs = '\0';
|
2003-04-22 14:01:47 +00:00
|
|
|
|
if (dirname && *dirname)
|
|
|
|
|
strcpy(mbs, dirname);
|
|
|
|
|
if (leafroot && *leafroot)
|
|
|
|
|
{
|
|
|
|
|
if (*leafroot != '/' && *leafroot != '\\')
|
|
|
|
|
strcat(mbs, "/");
|
|
|
|
|
strcat(mbs, leafroot);
|
|
|
|
|
}
|
|
|
|
|
if (leafext && *leafext)
|
|
|
|
|
{
|
|
|
|
|
if (*leafext != '.')
|
|
|
|
|
strcat(mbs, ".");
|
|
|
|
|
strcat(mbs, leafext);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_parse_pathname(const char *mbs, char *volname, char *dirname, char *leafroot, char *leafext, char *leafvers)
|
|
|
|
|
{
|
|
|
|
|
wxString volume, path, file, ext;
|
|
|
|
|
wxFileName::SplitPath(mbs, &volume, &path, &file, &ext);
|
2003-05-23 10:32:27 +00:00
|
|
|
|
if (volname)
|
|
|
|
|
{
|
|
|
|
|
strcpy(volname, volume);
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
if (volname[0] != '\0' && volname[1] == '\0')
|
|
|
|
|
strcat(volname, ":");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2003-04-22 14:01:47 +00:00
|
|
|
|
if (dirname) strcpy(dirname, path);
|
|
|
|
|
if (leafroot) strcpy(leafroot, file);
|
|
|
|
|
if (leafext) strcpy(leafext, ext);
|
|
|
|
|
if (leafvers) strcpy(leafvers, ""); // TBI put here last change date/time?
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY *dirp, char *path, int sz_path)
|
|
|
|
|
{
|
2003-04-01 07:34:53 +00:00
|
|
|
|
wxStrncpy(path, dirp->path, sz_path);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
path[sz_path-1] = '\0';
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
strcpy(dirp->path, path);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_fsys_get_default_dir(DIRECTORY *dirp)
|
|
|
|
|
{
|
2003-06-06 10:13:43 +00:00
|
|
|
|
if (_startup_dir.IsEmpty())
|
|
|
|
|
wxFileName::SplitPath(wxTheApp->argv[0], &_startup_dir, NULL, NULL);
|
|
|
|
|
if (dirp != NULL)
|
|
|
|
|
xvt_fsys_convert_str_to_dir(_startup_dir, dirp);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxString str = ::wxGetCwd();
|
|
|
|
|
return xvt_fsys_convert_str_to_dir(str, dirp);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-28 15:33:49 +00:00
|
|
|
|
BOOLEAN xvt_fsys_is_removable_drive(const char* path)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#ifdef WIN32
|
2003-06-04 10:33:13 +00:00
|
|
|
|
char drive[_MAX_DRIVE+1];
|
|
|
|
|
xvt_fsys_parse_pathname(path,drive,NULL,NULL,NULL,NULL);
|
|
|
|
|
strcat(drive,"\\");
|
|
|
|
|
return GetDriveType(drive) == DRIVE_REMOVABLE;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
char dev[_MAX_PATH];
|
|
|
|
|
|
|
|
|
|
OsLinux_GetFileSys(path, dev, NULL, NULL);
|
|
|
|
|
return strncmp(dev, "/dev/fd", 7) == 0;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_is_network_drive(const char* path)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2003-06-04 10:33:13 +00:00
|
|
|
|
char drive[_MAX_DRIVE+1];
|
|
|
|
|
xvt_fsys_parse_pathname(path,drive,NULL,NULL,NULL,NULL);
|
|
|
|
|
strcat(drive,"\\");
|
|
|
|
|
return GetDriveType(drive) == DRIVE_REMOTE;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return OsLinux_IsNetworkDrive(path);
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_is_fixed_drive(const char* path)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2003-06-04 10:33:13 +00:00
|
|
|
|
char drive[_MAX_DRIVE+1];
|
|
|
|
|
xvt_fsys_parse_pathname(path,drive,NULL,NULL,NULL,NULL);
|
|
|
|
|
strcat(drive,"\\");
|
|
|
|
|
return GetDriveType(drive) == DRIVE_FIXED;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
return !(xvt_fsys_is_network_drive(path) || xvt_fsys_is_removable_drive(path));
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned long compute_disk_size(const char* path, bool tot, char unit)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#ifdef WIN32
|
2003-03-28 15:33:49 +00:00
|
|
|
|
char drive[_MAX_DRIVE+1];
|
2003-05-22 15:47:31 +00:00
|
|
|
|
xvt_fsys_parse_pathname(path, drive, NULL, NULL, NULL, NULL);
|
2003-03-28 15:33:49 +00:00
|
|
|
|
strcat(drive, "/");
|
|
|
|
|
DWORD nSecPerClust, nBytePerSec, nFreeClust, nTotalClust;
|
|
|
|
|
::GetDiskFreeSpace(drive, &nSecPerClust, &nBytePerSec, &nFreeClust, &nTotalClust);
|
|
|
|
|
__int64 nBytes = tot ? nTotalClust : nFreeClust;
|
|
|
|
|
nBytes *= nSecPerClust;
|
|
|
|
|
nBytes *= nBytePerSec;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int64_t nBytes = OsLinux_GetDiskFreeSpace(path);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#endif
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-03-28 15:33:49 +00:00
|
|
|
|
switch (unit)
|
|
|
|
|
{
|
|
|
|
|
case 'K': nBytes >>= 10; break; // Kilobytes
|
|
|
|
|
case 'M': nBytes >>= 20; break; // Megabytes
|
|
|
|
|
case 'G': nBytes >>= 30; break; // Gigabytes
|
|
|
|
|
case 'T': nBytes >>= 40; break; // Terabytes
|
2003-05-22 15:25:25 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const unsigned long nMax = (unsigned long)(~0L);
|
|
|
|
|
unsigned long nVal = nBytes > nMax ? nMax : (unsigned long)nBytes;
|
|
|
|
|
return nVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long xvt_fsys_get_disk_size(const char* path, char unit)
|
|
|
|
|
{
|
|
|
|
|
return compute_disk_size(path, true, unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long xvt_fsys_get_disk_free_space(const char* path, char unit)
|
|
|
|
|
{
|
|
|
|
|
return compute_disk_size(path, false, unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize)
|
|
|
|
|
{
|
|
|
|
|
// Arrotonda per eccesso al Kilobyte
|
|
|
|
|
unsigned long kb = filesize/1024+4;
|
|
|
|
|
return kb <= xvt_fsys_get_disk_free_space(path, 'K');
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// File system
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
SLIST xvt_fsys_list_files(char *type, char *pat, BOOLEAN dirs)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
SLIST list = xvt_slist_create();
|
|
|
|
|
|
|
|
|
|
int flags = 0;
|
|
|
|
|
if (dirs)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(type, DIR_TYPE) == 0)
|
|
|
|
|
flags = wxDIR;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
flags = wxFILE;
|
|
|
|
|
|
|
|
|
|
wxString f = ::wxFindFirstFile(pat, flags);
|
|
|
|
|
while (!f.IsEmpty())
|
|
|
|
|
{
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (f.StartsWith(".\\"))
|
|
|
|
|
f = f.Mid(2);
|
|
|
|
|
xvt_slist_add_at_elt(list, NULL, f, 0L);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
f = ::wxFindNextFile();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return list;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static wxString _strSavedir;
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_fsys_restore_dir()
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
::wxSetWorkingDirectory(_strSavedir);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_fsys_save_dir()
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_strSavedir = ::wxGetCwd();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_fsys_set_dir(DIRECTORY *dirp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return ::wxSetWorkingDirectory(dirp->path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Images
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, long reserved)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TXVT_IMAGE* i = new TXVT_IMAGE;
|
|
|
|
|
i->Image().Create(width, height);
|
|
|
|
|
return (XVT_IMAGE)i;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_image_destroy(XVT_IMAGE image)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
delete (TXVT_IMAGE*)image;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
COLOR xvt_image_get_clut(XVT_IMAGE image, short index)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(image != NULL);
|
2003-01-07 12:20:49 +00:00
|
|
|
|
#if wxCHECK_VERSION(2,3,0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (image)
|
|
|
|
|
{
|
|
|
|
|
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
|
|
|
|
|
if (bmp.HasPalette())
|
|
|
|
|
{
|
|
|
|
|
const wxPalette& pal = bmp.GetPalette();
|
|
|
|
|
unsigned char r, g, b;
|
|
|
|
|
pal.GetRGB(index, &r, &g, &b);
|
|
|
|
|
return MAKE_COLOR(r, g, b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return COLOR_BLACK;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_image_get_dimensions(XVT_IMAGE image, short *width, short *height)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
|
|
|
|
|
if (img.Ok())
|
|
|
|
|
{
|
|
|
|
|
*width = img.GetWidth();
|
|
|
|
|
*height = img.GetHeight();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const wxBitmap& bmp = ((TXVT_IMAGE*)image)->Bitmap();
|
|
|
|
|
*width = bmp.GetWidth();
|
|
|
|
|
*height = bmp.GetHeight();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image)
|
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
|
#if wxCHECK_VERSION(2,3,0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return img.HasPalette() ? XVT_IMAGE_CL8 : XVT_IMAGE_RGB;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#else
|
|
|
|
|
return XVT_IMAGE_RGB;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
short xvt_image_get_ncolors(XVT_IMAGE image)
|
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
|
#if wxCHECK_VERSION(2,3,0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
int n = 0;
|
|
|
|
|
if (image)
|
|
|
|
|
{
|
|
|
|
|
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
|
|
|
|
|
if (bmp.HasPalette())
|
|
|
|
|
{
|
|
|
|
|
const wxPalette& pal = bmp.GetPalette();
|
|
|
|
|
unsigned char r, g, b;
|
|
|
|
|
for (n = 16; n < 255; n++)
|
|
|
|
|
{
|
|
|
|
|
if (!pal.GetRGB(n, &r, &g, &b))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return n;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#else
|
|
|
|
|
int n = 0;
|
|
|
|
|
if (image)
|
|
|
|
|
{
|
|
|
|
|
wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
|
|
|
|
|
n = bmp.CountColours(257);
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return n > 256 ? 0 : n;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
|
|
|
|
|
int r = bmp.GetRed(x, y);
|
|
|
|
|
int g = bmp.GetGreen(x, y);
|
|
|
|
|
int b = bmp.GetBlue(x, y);
|
|
|
|
|
return MAKE_COLOR(r, g, b);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE xvt_image_read(const char* filenamep)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
TXVT_IMAGE* i = NULL;
|
|
|
|
|
const wxString name = filenamep;
|
|
|
|
|
if (::wxFileExists(name))
|
|
|
|
|
{
|
|
|
|
|
i = new TXVT_IMAGE;
|
|
|
|
|
i->Image().LoadFile(name);
|
|
|
|
|
if (!i->Image().Ok())
|
|
|
|
|
{
|
|
|
|
|
delete i;
|
|
|
|
|
i = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (XVT_IMAGE)i;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE xvt_image_read_bmp(const char *filenamep)
|
|
|
|
|
{
|
2002-07-30 14:11:47 +00:00
|
|
|
|
return xvt_image_read(filenamep); // Very clever!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
|
2003-01-07 12:20:49 +00:00
|
|
|
|
#if wxCHECK_VERSION(2,3,0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (bmp.HasPalette())
|
|
|
|
|
{
|
|
|
|
|
const wxPalette& pal = bmp.GetPalette();
|
|
|
|
|
|
|
|
|
|
CAST_COLOR (color, c);
|
|
|
|
|
unsigned char ri, gi, bi;
|
|
|
|
|
pal.GetRGB(index, &ri, &gi, &bi);
|
|
|
|
|
|
|
|
|
|
const int w = bmp.GetWidth();
|
|
|
|
|
const int h = bmp.GetHeight();
|
|
|
|
|
for (int y = 0; y < h; y++) for (int x = 0; x < w; x++)
|
|
|
|
|
{
|
|
|
|
|
unsigned char r = bmp.GetRed(x, y);
|
|
|
|
|
if (r != ri) continue;
|
|
|
|
|
unsigned char g = bmp.GetGreen(x, y);
|
|
|
|
|
if (g != gi) continue;
|
|
|
|
|
unsigned char b = bmp.GetBlue(x, y);
|
|
|
|
|
if (b != bi) continue;
|
|
|
|
|
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors)
|
|
|
|
|
{
|
|
|
|
|
// SORRY_BOX();
|
2003-02-04 09:35:14 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
|
|
|
|
|
CAST_COLOR (color, c);
|
|
|
|
|
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp)
|
2002-07-03 14:53:33 +00:00
|
|
|
|
{
|
|
|
|
|
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
|
|
|
|
|
const wxImage& src = ((const TXVT_IMAGE*)srcimage)->Image();
|
|
|
|
|
const wxRect rctDst = NormalizeRCT(dstrctp);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxImage sub = src.GetSubImage(rctSrc);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
sub.Rescale(rctDst.width, rctDst.height);
|
|
|
|
|
if (rctDst.x == 0 && rctDst.y == 0)
|
|
|
|
|
dst = sub;
|
|
|
|
|
else
|
|
|
|
|
SORRY_BOX();
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Memory management
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
DATA_PTR xvt_mem_alloc(size_t size)
|
|
|
|
|
{
|
2002-09-13 14:56:23 +00:00
|
|
|
|
DATA_PTR ptr = (DATA_PTR)malloc(size);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return ptr;
|
2002-09-13 14:56:23 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_mem_free(DATA_PTR p)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ free(p); }
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
DATA_PTR xvt_mem_realloc(DATA_PTR p, size_t size)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ return (DATA_PTR)realloc(p, size); }
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
DATA_PTR xvt_mem_rep(DATA_PTR dst, DATA_PTR src, unsigned int srclen, long reps)
|
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
XVT_ASSERT(dst != NULL || src != NULL);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
|
if (srclen == 1)
|
|
|
|
|
memset(dst, *src, reps);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (long i = 0; i < reps; i++)
|
|
|
|
|
memcpy(dst + i*srclen, src, srclen);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return dst;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
DATA_PTR xvt_mem_zalloc(size_t size)
|
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
DATA_PTR ptr = xvt_mem_alloc(size);
|
|
|
|
|
memset(ptr, 0, size);
|
|
|
|
|
return ptr;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Menu management
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
int xvt_menu_count(const MENU_ITEM* m)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
for (n = 0; m[n].tag != 0; n++);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Funzione inventata
|
|
|
|
|
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m)
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* TheMenu = NULL;
|
|
|
|
|
if (m != NULL && m->tag > 0)
|
|
|
|
|
{
|
|
|
|
|
const int n = xvt_menu_count(m)+1;
|
2002-07-03 14:53:33 +00:00
|
|
|
|
TheMenu = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*n);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
memcpy(TheMenu, m, n*sizeof(MENU_ITEM));
|
|
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* mi = &TheMenu[i];
|
|
|
|
|
mi->text = xvt_str_duplicate(mi->text);
|
|
|
|
|
mi->child = xvt_menu_duplicate_tree(mi->child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TheMenu;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
MENU_ITEM* xvt_menu_get_tree(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
MENU_ITEM* m = NULL;
|
|
|
|
|
if (win == TASK_WIN)
|
|
|
|
|
{
|
|
|
|
|
TTaskWin& w = *(TTaskWin*)win;
|
|
|
|
|
m = xvt_menu_duplicate_tree(w.GetMenuTree());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
m = xvt_menu_duplicate_tree(w.GetMenuTree());
|
|
|
|
|
}
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-03 13:09:57 +00:00
|
|
|
|
BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos,
|
|
|
|
|
XVT_POPUP_ALIGNMENT /* alignment */, MENU_TAG /* item */)
|
|
|
|
|
{
|
|
|
|
|
wxMenu menu;
|
|
|
|
|
for (MENU_ITEM* mi = menu_p; mi != NULL && mi->tag != 0; mi++)
|
|
|
|
|
{
|
|
|
|
|
wxMenuItem* item = NULL;
|
|
|
|
|
if (mi->separator)
|
|
|
|
|
item = new wxMenuItem(&menu, wxID_SEPARATOR);
|
|
|
|
|
else
|
|
|
|
|
item = new wxMenuItem(&menu, mi->tag, mi->text, wxEmptyString, mi->checkable);
|
|
|
|
|
menu.DoAppend(item);
|
|
|
|
|
}
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
bool ok = w.PopupMenu(&menu, pos.h, pos.v);
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
static void TranslateMenu(wxMenu* pMenu, TRANSLATE_CALLBACK tc)
|
2002-09-13 14:56:23 +00:00
|
|
|
|
{
|
|
|
|
|
wxMenuItemList& list = pMenu->GetMenuItems();
|
|
|
|
|
for (unsigned i = 0; i < list.GetCount(); i++)
|
|
|
|
|
{
|
|
|
|
|
wxMenuItem* mi = list[i];
|
|
|
|
|
if (!mi->IsSeparator())
|
|
|
|
|
{
|
|
|
|
|
const char* ita = mi->GetText();
|
|
|
|
|
const char* eng = tc(ita);
|
|
|
|
|
mi->SetText(eng);
|
|
|
|
|
wxMenu* pMenu = mi->GetSubMenu();
|
|
|
|
|
if (pMenu != NULL)
|
|
|
|
|
TranslateMenu(pMenu, tc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc)
|
|
|
|
|
{
|
|
|
|
|
if (win == TASK_WIN)
|
|
|
|
|
{
|
|
|
|
|
TTaskWin& w = *(TTaskWin*)win;
|
|
|
|
|
wxMenuBar* pMenuBar = w.GetMenuBar();
|
|
|
|
|
if (pMenuBar != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (int m = pMenuBar->GetMenuCount()-1; m >= 0; m--)
|
|
|
|
|
{
|
|
|
|
|
const char* ita = pMenuBar->GetLabelTop(m);
|
|
|
|
|
const char* eng = tc(ita);
|
|
|
|
|
pMenuBar->SetLabelTop(m, eng);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-09-13 14:56:23 +00:00
|
|
|
|
wxMenu* pMenu = pMenuBar->GetMenu(m);
|
|
|
|
|
TranslateMenu(pMenu, tc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_menu_set_font_sel(WINDOW win, XVT_FNTID font_id)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ /* Ignored */ }
|
|
|
|
|
|
|
|
|
|
static wxMenuItem* GetXvtMenuItem(WINDOW /* win */, MENU_TAG tag)
|
|
|
|
|
{
|
|
|
|
|
wxMenuBar* bar = ((TTaskWin*)_task_win)->GetMenuBar();
|
|
|
|
|
wxMenuItem* item = bar ? bar->FindItem(tag) : NULL;
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_menu_set_item_checked(WINDOW win, MENU_TAG tag, BOOLEAN check)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxMenuItem* item = GetXvtMenuItem(win, tag);
|
|
|
|
|
if (item)
|
|
|
|
|
item->Check(check != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_menu_set_item_enabled(WINDOW win, MENU_TAG tag, BOOLEAN enable)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxMenuItem* item = GetXvtMenuItem(win, tag);
|
|
|
|
|
if (item)
|
|
|
|
|
item->Enable(enable != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, char* text)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxMenuItem* item = GetXvtMenuItem(win, tag);
|
|
|
|
|
if (item)
|
|
|
|
|
item->SetText(text);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
if (win == TASK_WIN)
|
|
|
|
|
{
|
|
|
|
|
TTaskWin& w = *(TTaskWin*)win;
|
|
|
|
|
w.SetMenuTree(tree);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
w.SetMenuTree(tree);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_menu_update(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxMenuBar* bar = ((TTaskWin*)_task_win)->GetMenuBar();
|
|
|
|
|
if (bar)
|
|
|
|
|
bar->Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Palette management
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
short xvt_palet_add_colors(XVT_PALETTE palet, COLOR *colorsp, short numcolors) { return 0; }
|
|
|
|
|
short xvt_palet_add_colors_from_image(XVT_PALETTE palet, XVT_IMAGE image) { return 0; }
|
|
|
|
|
XVT_PALETTE xvt_palet_create(XVT_PALETTE_TYPE type, XVT_PALETTE_ATTR reserved) { return NULL; }
|
|
|
|
|
void xvt_palet_destroy(XVT_PALETTE palet) { SORRY_BOX(); }
|
|
|
|
|
short xvt_palet_get_colors(XVT_PALETTE palet, COLOR *colorsp, short maxcolors) { return 0; }
|
|
|
|
|
short xvt_palet_get_ncolors(XVT_PALETTE palet) { return 0; }
|
|
|
|
|
int xvt_palet_get_tolerance(XVT_PALETTE p) { return 0; }
|
|
|
|
|
void xvt_palet_set_tolerance(XVT_PALETTE p, int t) { SORRY_BOX(); }
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Rectangles
|
|
|
|
|
///////////////////////////////////////////////////////////
|
2002-04-26 10:50:41 +00:00
|
|
|
|
int xvt_rect_get_height(RCT *rctp)
|
|
|
|
|
{
|
|
|
|
|
return rctp->bottom - rctp->top;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int xvt_rect_get_width(RCT *rctp)
|
|
|
|
|
{
|
|
|
|
|
return rctp->right - rctp->left;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_rect_has_point(RCT *rctp, PNT pnt)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
return rct.Inside(pnt.h, pnt.v);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_rect_intersect(RCT *drctp, RCT *rctp1, RCT *rctp2)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
const wxRect rect1 = NormalizeRCT(rctp1);
|
|
|
|
|
const wxRect rect2 = NormalizeRCT(rctp2);
|
|
|
|
|
BOOLEAN yes = RectIntersect(rect1, rect2);
|
|
|
|
|
if (yes && drctp)
|
|
|
|
|
{
|
|
|
|
|
drctp->left = max(rect1.x, rect2.x);
|
|
|
|
|
drctp->top = max(rect1.y, rect2.y);
|
|
|
|
|
drctp->right = min(rect1.GetRight(), rect2.GetRight())+1;
|
|
|
|
|
drctp->bottom = min(rect1.GetBottom(), rect2.GetBottom())+1;
|
|
|
|
|
}
|
|
|
|
|
return yes;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
|
BOOLEAN xvt_rect_is_empty(const RCT *rct)
|
2002-04-26 10:50:41 +00:00
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
return rct == NULL || (rct->left==rct->right && rct->top==rct->bottom);
|
2002-04-26 10:50:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_rect_offset(RCT *rctp, short dh, short dv)
|
|
|
|
|
{
|
2002-04-26 10:50:41 +00:00
|
|
|
|
XVT_ASSERT(rctp != NULL);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
rctp->left += dh;
|
|
|
|
|
rctp->top += dv;
|
|
|
|
|
rctp->right += dh;
|
|
|
|
|
rctp->bottom += dv;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_rect_set(RCT *rctp, short left, short top, short right, short bottom)
|
|
|
|
|
{
|
2002-04-26 10:50:41 +00:00
|
|
|
|
XVT_ASSERT(rctp != NULL);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
rctp->left = left;
|
|
|
|
|
rctp->top = top;
|
|
|
|
|
rctp->right = right;
|
|
|
|
|
rctp->bottom = bottom;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_rect_set_empty(RCT *rctp)
|
|
|
|
|
{
|
2002-04-26 10:50:41 +00:00
|
|
|
|
XVT_ASSERT(rctp != NULL);
|
|
|
|
|
rctp->right = rctp->left;
|
|
|
|
|
rctp->bottom = rctp->top;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_rect_set_pos(RCT *rctp, PNT pos)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
BOOLEAN ok = rctp != NULL;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
const short w = rctp->right-rctp->left;
|
|
|
|
|
const short h = rctp->bottom-rctp->top;
|
|
|
|
|
rctp->left = pos.h;
|
|
|
|
|
rctp->top = pos.v;
|
|
|
|
|
rctp->right = pos.h + w;
|
|
|
|
|
rctp->bottom = pos.v + h;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Resource management
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_res_free_menu_tree(MENU_ITEM* tree)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(tree != NULL);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
if (tree != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
for (MENU_ITEM* item = tree; item->tag != 0; item++)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
|
if (item->text)
|
|
|
|
|
xvt_mem_free(item->text);
|
|
|
|
|
if (item->child != NULL)
|
|
|
|
|
xvt_res_free_menu_tree(item->child);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2002-07-03 14:53:33 +00:00
|
|
|
|
xvt_mem_free((DATA_PTR)tree);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE xvt_res_get_image(int rid)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxString strFileName = ::GetResourceName("Image", rid);
|
2002-09-13 14:56:23 +00:00
|
|
|
|
const bool ok = !strFileName.IsEmpty();
|
|
|
|
|
XVT_ASSERT(ok);
|
|
|
|
|
return ok ? xvt_image_read(strFileName) : NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int SplitString(const wxString& str, wxArrayString& a)
|
|
|
|
|
{
|
|
|
|
|
const char* s = str;
|
|
|
|
|
char* comma = "";
|
|
|
|
|
a.Clear();
|
|
|
|
|
while (comma)
|
|
|
|
|
{
|
|
|
|
|
comma = strchr(s, ',');
|
|
|
|
|
if (comma)
|
|
|
|
|
{
|
|
|
|
|
*comma = '\0';
|
|
|
|
|
a.Add(s);
|
|
|
|
|
*comma = ',';
|
|
|
|
|
s = comma+1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
a.Add(s);
|
|
|
|
|
}
|
|
|
|
|
return a.GetCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void FillMenuItem(const wxString& strValue, MENU_ITEM* mi)
|
|
|
|
|
{
|
|
|
|
|
wxArrayString a;
|
|
|
|
|
const int n = SplitString(strValue, a);
|
|
|
|
|
mi->tag = n > 0 ? atoi(a[0]) : 0;
|
|
|
|
|
if (mi->tag > 0)
|
|
|
|
|
{
|
|
|
|
|
const wxString& str = a[1];
|
|
|
|
|
const size_t accelera = str.Find('&');
|
|
|
|
|
if (accelera >= 0)
|
|
|
|
|
mi->mkey = str[accelera+1];
|
|
|
|
|
mi->text = xvt_str_duplicate(str);
|
|
|
|
|
mi->enabled = n < 3 || (a[2].Find('D')<0);
|
|
|
|
|
mi->checkable = n >= 3 && (a[2].Find('C')>=0);
|
|
|
|
|
mi->checked = n >= 3 && (a[2].Find('c')>=0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mi->tag = -1;
|
|
|
|
|
mi->separator = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
MENU_ITEM* xvt_res_get_menu(int rid)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxString strName;
|
|
|
|
|
strName = _startup_dir;
|
|
|
|
|
strName += "/res/resource.ini";
|
|
|
|
|
wxFileConfig ini("", "", strName);
|
|
|
|
|
|
|
|
|
|
const int MAX_MENU = 16;
|
2002-07-03 14:53:33 +00:00
|
|
|
|
MENU_ITEM* TheMenu = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*MAX_MENU);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
if (rid >= 10000 && rid < 10100)
|
|
|
|
|
{
|
2003-04-30 15:43:51 +00:00
|
|
|
|
wxFileName::SplitPath(wxTheApp->argv[0], NULL, &strName, NULL);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
strName.MakeUpper();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
strName = wxString::Format("/Menu_%s-%X", (const char *) strName.Left(3), (rid-1)%16);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strName = wxString::Format("/Menu_%d", rid);
|
|
|
|
|
ini.SetPath(strName);
|
|
|
|
|
|
|
|
|
|
wxString strItem;
|
|
|
|
|
for (int i = 0; i < MAX_MENU; i++)
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* mi = &TheMenu[i];
|
|
|
|
|
strItem = wxString::Format("Item_%02d", i);
|
|
|
|
|
if (ini.Read(strItem, &strName))
|
|
|
|
|
{
|
|
|
|
|
FillMenuItem(strName, mi);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
mi = mi->child = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*MAX_MENU);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
for (int j = 0; j < MAX_MENU; j++, mi++)
|
|
|
|
|
{
|
|
|
|
|
strItem = wxString::Format("Item_%02d_%02d", i, j);
|
|
|
|
|
if (ini.Read(strItem, &strName))
|
|
|
|
|
FillMenuItem(strName, mi);
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (TheMenu->tag == 0)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(false); // Menu not found
|
|
|
|
|
xvt_res_free_menu_tree(TheMenu);
|
|
|
|
|
TheMenu = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TheMenu;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
char* xvt_res_get_str(int rid, char *s, int sz_s)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(s != NULL && sz_s > 0);
|
|
|
|
|
const wxString str = ::GetResourceName("String", rid);
|
|
|
|
|
strncpy(s, str, sz_s);
|
2002-09-13 14:56:23 +00:00
|
|
|
|
s[sz_s-1] = '\0';
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return s;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Scroll bars
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#define CAST_SCROLL(win, sb) XVT_ASSERT(win != NULL_WIN); wxScrollBar& sb = *(wxScrollBar*)win;
|
|
|
|
|
#define CAST_SCROLL_TYPE(t, dir) const int dir = t == HSCROLL ? wxHORIZONTAL : wxVERTICAL;
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (t == HSCROLL || t == VSCROLL)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
return w.GetScrollPos(dir);
|
|
|
|
|
}
|
|
|
|
|
CAST_SCROLL(win, sb);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return sb.GetThumbPosition();
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int xvt_sbar_get_proportion(WINDOW win, SCROLL_TYPE t)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (t == HSCROLL || t == VSCROLL)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
return w.GetScrollThumb(dir);
|
|
|
|
|
}
|
|
|
|
|
CAST_SCROLL(win, sb);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return sb.GetThumbSize();
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_get_range(WINDOW win, SCROLL_TYPE t, int *minp, int *maxp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
*minp = 0;
|
|
|
|
|
if (t == HSCROLL || t == VSCROLL)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
*maxp = w.GetScrollRange(dir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
*maxp = sb.GetRange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (t == HSCROLL || t == VSCROLL)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
w.SetScrollPos(dir, pos);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
const int range = sb.GetRange();
|
|
|
|
|
const int size = sb.GetThumbSize();
|
|
|
|
|
sb.SetScrollbar(pos, size, range, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_set_proportion(WINDOW win, SCROLL_TYPE t, int proportion)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (t == HSCROLL || t == VSCROLL)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
const int pos = w.GetScrollPos(dir);
|
|
|
|
|
const int range = w.GetScrollRange(dir);
|
|
|
|
|
w.SetScrollbar(dir, pos, proportion, range);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
const int pos = sb.GetThumbPosition();
|
|
|
|
|
const int range = sb.GetRange();
|
|
|
|
|
sb.SetScrollbar(pos, proportion, range, proportion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(min == 0);
|
|
|
|
|
if (t == HSCROLL || t == VSCROLL)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
const int pos = w.GetScrollPos(dir);
|
|
|
|
|
const int size = w.GetScrollThumb(dir);
|
|
|
|
|
w.SetScrollbar(dir, pos, size, max);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
const int pos = sb.GetThumbPosition();
|
|
|
|
|
const int size = sb.GetThumbSize();
|
|
|
|
|
sb.SetScrollbar(pos, size, max, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Window manager
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_scr_beep(void)
|
2002-07-30 14:11:47 +00:00
|
|
|
|
{
|
2003-04-01 07:34:53 +00:00
|
|
|
|
xvt_sys_beep(0);
|
2002-07-30 14:11:47 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_scr_get_focus_topwin(void)
|
|
|
|
|
{
|
|
|
|
|
WINDOW win = (WINDOW)_task_win->FindFocus();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return win;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_scr_get_focus_vobj(void)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return xvt_scr_get_focus_topwin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void AddWinToList(SLIST list, WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
if (win != NULL_WIN)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
2003-03-28 15:33:49 +00:00
|
|
|
|
const char* title = w.GetTitle();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
xvt_slist_add_at_elt(list, NULL, title, win);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
SLIST xvt_scr_list_wins()
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
SLIST list = xvt_slist_create();
|
2003-04-16 15:50:37 +00:00
|
|
|
|
_nice_windows.BeginFind();
|
|
|
|
|
for (wxNode *node = _nice_windows.Next(); node; node = _nice_windows.Next())
|
2003-03-28 15:33:49 +00:00
|
|
|
|
{
|
|
|
|
|
WINDOW win = (WINDOW)node->GetData();
|
|
|
|
|
AddWinToList(list, win);
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return list;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_scr_set_busy_cursor()
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
xvt_win_set_cursor(TASK_WIN, CURSOR_WAIT);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_scr_set_focus_vobj(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.SetFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// String lists
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_slist_add_at_elt(SLIST list, SLIST_ELT e, const char *sx, long data)
|
|
|
|
|
{
|
|
|
|
|
const BOOLEAN ok = list != NULL;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
SLIST_ELT item = new SLIST_ITEM;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
item->str = xvt_str_duplicate(sx);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
item->data = data;
|
|
|
|
|
item->next = NULL;
|
|
|
|
|
|
2003-04-02 15:11:53 +00:00
|
|
|
|
SLIST_ELT last = NULL;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
if (e != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (SLIST_ELT i = list->head; i; i = (SLIST_ELT)i->next)
|
|
|
|
|
{
|
|
|
|
|
last = i;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (i == e)
|
2003-03-28 15:33:49 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-02 15:11:53 +00:00
|
|
|
|
if (last == NULL)
|
|
|
|
|
{
|
|
|
|
|
item->next = list->head;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
list->head = item;
|
2003-04-02 15:11:53 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
item->next = last->next;
|
|
|
|
|
last->next = item;
|
|
|
|
|
}
|
|
|
|
|
list->count++;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int xvt_slist_count(SLIST list)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(list != NULL);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return list ? list->count : 0;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
SLIST xvt_slist_create()
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
SLIST list = new xvtList;
|
|
|
|
|
list->head = NULL;
|
|
|
|
|
list->count = 0;
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_slist_destroy(SLIST list)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(list != NULL);
|
|
|
|
|
if (list)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
SLIST_ELT obj = list->head;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
while (obj != NULL)
|
|
|
|
|
{
|
|
|
|
|
SLIST_ELT tokill = obj;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
xvt_mem_free(tokill->str);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
obj = (SLIST_ELT)tokill->next;
|
|
|
|
|
delete tokill;
|
|
|
|
|
}
|
|
|
|
|
delete list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
char* xvt_slist_get(SLIST list, SLIST_ELT e, long* datap)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(list != NULL);
|
|
|
|
|
if (e != NULL)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (datap != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
*datap = e->data;
|
|
|
|
|
return e->str;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long* xvt_slist_get_data(SLIST_ELT elt)
|
|
|
|
|
{
|
|
|
|
|
return elt != NULL ? &elt->data : NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
SLIST_ELT xvt_slist_get_first(SLIST list)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(list != NULL);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return list != NULL ? list->head : NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
SLIST_ELT xvt_slist_get_next(SLIST list, SLIST_ELT item)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(list != NULL);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return (SLIST_ELT)(item ? item->next : NULL);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// XVT Strings???
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-07 13:08:31 +00:00
|
|
|
|
int xvt_str_compare_ignoring_case (const char* s1, const char* s2)
|
|
|
|
|
{
|
|
|
|
|
return wxStricmp(s1, s2);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
char* xvt_str_duplicate(const char* str)
|
|
|
|
|
{
|
|
|
|
|
return str ? strdup(str) : NULL; // bleah!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_str_match(const char *mbs, const char *pat, BOOLEAN case_sensitive)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxString text = mbs;
|
|
|
|
|
wxString pattern = pat;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (!case_sensitive)
|
|
|
|
|
{
|
|
|
|
|
text.MakeUpper();
|
|
|
|
|
pattern.MakeUpper();
|
|
|
|
|
}
|
|
|
|
|
return text.Matches(pattern);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-27 12:15:57 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// XVT system calls (added by Guy)
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-04-01 07:34:53 +00:00
|
|
|
|
void xvt_sys_beep(int severity)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
OsWin32_Beep(severity);
|
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxBell();
|
2003-04-01 07:34:53 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 15:43:51 +00:00
|
|
|
|
BOOLEAN xvt_sys_get_host_name(char* name, int maxlen)
|
|
|
|
|
{
|
|
|
|
|
wxString str = wxGetHostName();
|
|
|
|
|
const int len = str.Length();
|
|
|
|
|
strncpy(name, str, maxlen);
|
|
|
|
|
name[maxlen-1] = '\0';
|
|
|
|
|
return len > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_sys_get_user_name(char* name, int maxlen)
|
|
|
|
|
{
|
|
|
|
|
wxString str = wxGetUserId();
|
|
|
|
|
str.MakeUpper();
|
|
|
|
|
const int len = str.Length();
|
|
|
|
|
strncpy(name, str, maxlen);
|
|
|
|
|
name[maxlen-1] = '\0';
|
|
|
|
|
return len > 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
|
|
|
|
|
{
|
|
|
|
|
long exitcode = 0;
|
|
|
|
|
|
|
|
|
|
if (sync)
|
|
|
|
|
{
|
|
|
|
|
if (iconizetask)
|
|
|
|
|
{
|
|
|
|
|
wxEnableTopLevelWindows(FALSE);
|
2003-05-22 15:07:21 +00:00
|
|
|
|
((wxFrame*)_task_win)->Iconize();
|
2003-04-16 15:50:37 +00:00
|
|
|
|
}
|
|
|
|
|
exitcode = wxExecute(cmdline, wxEXEC_SYNC);
|
|
|
|
|
if (iconizetask)
|
|
|
|
|
{
|
2003-05-22 15:07:21 +00:00
|
|
|
|
((wxFrame*)_task_win)->Restore();
|
2003-04-16 15:50:37 +00:00
|
|
|
|
wxEnableTopLevelWindows(TRUE);
|
|
|
|
|
_task_win->Raise();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2003-04-16 15:50:37 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
exitcode = wxExecute(cmdline, wxEXEC_ASYNC);
|
|
|
|
|
|
|
|
|
|
return exitcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long xvt_sys_execute_in_window(const char* cmdline, WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
long inst = xvt_sys_execute(cmdline, FALSE, FALSE);
|
|
|
|
|
if (inst > 0)
|
2003-05-23 10:32:27 +00:00
|
|
|
|
#ifdef WIN32
|
2003-04-16 15:50:37 +00:00
|
|
|
|
OsWin32_PlaceProcessInWindow(inst, "", xvt_vobj_get_attr(ATTR_NATIVE_WINDOW, win));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
OsLinux_PlaceProcessInWindow(inst, "", xvt_vobj_get_attr(ATTR_NATIVE_WINDOW, win));
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#endif
|
|
|
|
|
return inst;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 15:43:51 +00:00
|
|
|
|
BOOLEAN xvt_sys_goto_url(const char* url, const char* action)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_GotoUrl(url, action);
|
|
|
|
|
#else
|
|
|
|
|
SORRY_BOX(); // TBI
|
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
BOOLEAN xvt_sys_dongle_server_is_running()
|
|
|
|
|
{
|
2003-05-16 09:25:11 +00:00
|
|
|
|
wxSingleInstanceChecker sic("Authorization");
|
|
|
|
|
BOOLEAN ok = sic.IsAnotherRunning();
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#ifdef WIN32
|
2003-05-16 09:25:11 +00:00
|
|
|
|
if (!ok) // Testo anche Frontend!
|
|
|
|
|
ok = ::GlobalFindAtom("DONGLE_SERVER_ATOM") != 0;
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2003-05-16 09:25:11 +00:00
|
|
|
|
return ok;
|
2003-04-16 15:50:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
|
2003-03-27 12:15:57 +00:00
|
|
|
|
const char* defval, char* value, int maxsize)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2003-05-16 13:11:09 +00:00
|
|
|
|
int len = ::GetPrivateProfileString(paragraph, name, defval, value, maxsize, file);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
#else
|
|
|
|
|
wxFileConfig ini("", "", file);
|
|
|
|
|
|
|
|
|
|
wxString path;
|
|
|
|
|
path << "/" << paragraph;
|
|
|
|
|
ini.SetPath(path);
|
|
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
wxString val;
|
|
|
|
|
if (!ini.Read(name, &val))
|
|
|
|
|
val = defval;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-03-27 12:15:57 +00:00
|
|
|
|
len = val.Length();
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
wxStrncpy(value, val, maxsize);
|
|
|
|
|
value[maxsize-1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
|
2003-03-27 12:15:57 +00:00
|
|
|
|
const char* value)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2003-05-16 13:11:09 +00:00
|
|
|
|
return ::WritePrivateProfileString(paragraph, name, value, file);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
#else
|
|
|
|
|
wxFileConfig ini("", "", file);
|
|
|
|
|
|
|
|
|
|
wxString path;
|
|
|
|
|
path << "/" << paragraph;
|
|
|
|
|
ini.SetPath(path);
|
|
|
|
|
|
|
|
|
|
return ini.Write(name, value);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-16 13:11:09 +00:00
|
|
|
|
BOOLEAN xvt_sys_find_editor(const char* file, char* editor)
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
BOOLEAN ok = FALSE;
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
const wxString e = OsWin32_File2App(file);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
const wxString e = OsLinux_File2App(file);
|
|
|
|
|
#endif
|
2003-04-16 15:50:37 +00:00
|
|
|
|
ok = !e.IsEmpty();
|
2003-05-16 13:11:09 +00:00
|
|
|
|
if (ok && editor != NULL)
|
|
|
|
|
strcpy(editor, e);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int xvt_sys_load_icon(const char* file)
|
|
|
|
|
{
|
|
|
|
|
unsigned int id = 0;
|
|
|
|
|
wxIcon* icon = NULL;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
wxString str = file;
|
|
|
|
|
str.MakeLower();
|
|
|
|
|
if (str.Find(".ico") > 0)
|
|
|
|
|
icon = new wxIcon(file, wxBITMAP_TYPE_ICO);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
WXHICON hicon = OsWin32_LoadIcon(file);
|
|
|
|
|
if (hicon)
|
|
|
|
|
{
|
|
|
|
|
icon = new wxIcon;
|
|
|
|
|
icon->SetHICON(hicon);
|
|
|
|
|
}
|
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
icon = new wxIcon;
|
|
|
|
|
// icon = new wxIcon(wxICON(file)); //verificare
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (icon != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (id = 60001; ; id++)
|
|
|
|
|
{
|
|
|
|
|
wxIcon* ico = (wxIcon*)_nice_icons.Get(id);
|
|
|
|
|
if (ico == NULL)
|
|
|
|
|
{
|
|
|
|
|
_nice_icons.Put(id, icon);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#ifdef WIN32
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (ico->GetHICON() == icon->GetHICON()) // C'e' gia'
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
if (ico == icon) // C'e' gia'
|
|
|
|
|
#endif
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
delete icon;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-28 15:33:49 +00:00
|
|
|
|
unsigned long xvt_sys_get_free_memory()
|
|
|
|
|
{
|
2003-04-01 07:34:53 +00:00
|
|
|
|
unsigned long mem = ::wxGetFreeMemory();
|
2003-03-28 15:33:49 +00:00
|
|
|
|
return mem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long xvt_sys_get_free_memory_kb()
|
|
|
|
|
{
|
|
|
|
|
unsigned long mem = xvt_sys_get_free_memory();
|
2003-04-01 07:34:53 +00:00
|
|
|
|
return mem / 1024; // Arrotondo per difetto
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int xvt_sys_get_os_version()
|
2003-04-01 07:34:53 +00:00
|
|
|
|
{
|
|
|
|
|
int os = 0;
|
|
|
|
|
int major, minor;
|
|
|
|
|
switch (::wxGetOsVersion(&major, &minor))
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case wxGTK:
|
2003-04-01 07:34:53 +00:00
|
|
|
|
os = XVT_WS_LINUX_GTK; break;
|
|
|
|
|
case wxWIN95:
|
|
|
|
|
os = minor == 0 ? XVT_WS_WIN_95 : XVT_WS_WIN_98; break;
|
|
|
|
|
case wxWINDOWS_NT:
|
|
|
|
|
os = XVT_WS_WIN_NT; break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_sys_sleep(unsigned long msec)
|
|
|
|
|
{
|
|
|
|
|
wxThread::Sleep(msec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_sys_test_network_version()
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
if (xvt_sys_get_os_version() == XVT_WS_WIN_95)
|
|
|
|
|
return OsWin32_TestNetworkVersion();
|
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// XVT system calls (added by Alex)
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void xvt_sys_searchenv(const char * filename, const char * varname, char * pathname)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
_searchenv(filename, varname, pathname);
|
|
|
|
|
#else
|
|
|
|
|
const char * value = getenv(varname);
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
2003-05-23 10:32:27 +00:00
|
|
|
|
/*
|
|
|
|
|
char path_list[4096];
|
2003-05-22 15:25:25 +00:00
|
|
|
|
const char * s = path_list;
|
|
|
|
|
strcpy(path_list, value);
|
|
|
|
|
do
|
|
|
|
|
{
|
2003-05-23 10:32:27 +00:00
|
|
|
|
char* s1 = strchr(s, ';');
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (s1 != NULL)
|
|
|
|
|
*s1 = '\0';
|
|
|
|
|
char fname[256];
|
|
|
|
|
strcpy(fname, s);
|
|
|
|
|
strcat(fname, filename);
|
|
|
|
|
if (wxFileExists(fname))
|
2003-05-23 10:32:27 +00:00
|
|
|
|
strcpy(pathname, s); // Secondo Guy manca break
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (s1 != NULL)
|
|
|
|
|
s = s1 + 1;
|
2003-05-23 10:32:27 +00:00
|
|
|
|
} while (s); // Secondo Guy e' sempre != NULL
|
|
|
|
|
*/
|
|
|
|
|
char path_list[4096];
|
|
|
|
|
strcpy(path_list, value);
|
|
|
|
|
for (const char* s = path_list; *s; )
|
|
|
|
|
{
|
|
|
|
|
char* s1 = strchr(s, ';');
|
|
|
|
|
if (s1 != NULL)
|
|
|
|
|
*s1 = '\0';
|
|
|
|
|
xvt_fsys_build_pathname(pathname, NULL, s, filename, NULL, NULL);
|
|
|
|
|
if (xvt_fsys_file_exists(pathname))
|
|
|
|
|
break;
|
|
|
|
|
if (s1 != NULL)
|
|
|
|
|
s = s1 + 1;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*pathname = '\0';
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_access(const char *pathname, int mode)
|
|
|
|
|
{
|
|
|
|
|
return access(pathname, mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_file_exists(const char *pathname)
|
|
|
|
|
{
|
|
|
|
|
return wxFileExists(pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_mkdir(const char *pathname)
|
|
|
|
|
{
|
|
|
|
|
return wxMkdir(pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_rmdir(const char *pathname)
|
|
|
|
|
{
|
|
|
|
|
return wxRmdir(pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_removefile(const char *pathname)
|
|
|
|
|
{
|
|
|
|
|
return wxRemoveFile(pathname);
|
|
|
|
|
}
|
2003-04-01 07:34:53 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Timers
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long xvt_timer_create(WINDOW win, long interval)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
if (w._timer == NULL)
|
|
|
|
|
{
|
|
|
|
|
w._timer = new wxTimer(&w, TIMER_ID);
|
|
|
|
|
w._timer->Start(interval);
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return win;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_timer_destroy(long id)
|
|
|
|
|
{
|
2003-05-15 09:49:25 +00:00
|
|
|
|
if (id > 0L)
|
|
|
|
|
{
|
|
|
|
|
CAST_TWIN(id, w);
|
|
|
|
|
wxTimer*& t = w._timer;
|
|
|
|
|
if (t != NULL)
|
|
|
|
|
{
|
|
|
|
|
t->Stop();
|
|
|
|
|
delete t;
|
|
|
|
|
t = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Visual objects
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_destroy(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (win != _print_win)
|
|
|
|
|
{
|
2003-03-28 15:33:49 +00:00
|
|
|
|
if (_TheCaret.Owner() == win)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_TheCaret.Kill();
|
|
|
|
|
|
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
_dc_map.DestroyTDC(&w);
|
|
|
|
|
|
2003-03-28 15:33:49 +00:00
|
|
|
|
w.Close(true);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long xvt_vobj_get_attr(WINDOW win, long data)
|
|
|
|
|
{
|
|
|
|
|
long ret = 0L;
|
|
|
|
|
switch(data)
|
|
|
|
|
{
|
2002-10-24 10:47:49 +00:00
|
|
|
|
case ATTR_APP_CTL_COLORS:
|
|
|
|
|
{
|
|
|
|
|
XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_mem_zalloc(sizeof(XVT_COLOR_COMPONENT)*6);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[0].type = XVT_COLOR_FOREGROUND;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xcc[0].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNTEXT));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[1].type = XVT_COLOR_BACKGROUND;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xcc[1].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[2].type = XVT_COLOR_CAPTIONLT;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_ACTIVECAPTION));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[3].type = XVT_COLOR_CAPTIONDK;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_INACTIVECAPTION));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[4].type = XVT_COLOR_CAPTIONTEXT;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_CAPTIONTEXT));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[5].type = XVT_COLOR_NULL;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xcc[5].color = 0;
|
|
|
|
|
ret = (long)xcc;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-03-27 12:15:57 +00:00
|
|
|
|
case ATTR_FRAME_WIDTH:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_X);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
break;
|
|
|
|
|
case ATTR_FRAME_HEIGHT:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_Y);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
break;
|
2003-04-16 15:50:37 +00:00
|
|
|
|
case ATTR_MENU_HEIGHT:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_MENU_Y);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
break;
|
2003-03-27 12:15:57 +00:00
|
|
|
|
case ATTR_TITLE_HEIGHT:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_CAPTION_Y);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
break;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
case ATTR_CTL_VERT_SBAR_WIDTH:
|
2003-05-22 15:25:25 +00:00
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_CTL_HORZ_SBAR_HEIGHT:
|
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_HSCROLL_Y);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case ATTR_DISPLAY_TYPE:
|
|
|
|
|
switch (::wxDisplayDepth())
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
case 1: ret = XVT_DISPLAY_MONO; break;
|
|
|
|
|
case 4: ret = XVT_DISPLAY_COLOR_16; break;
|
|
|
|
|
case 8: ret = XVT_DISPLAY_COLOR_256; break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
default: ret = XVT_DISPLAY_DIRECT_COLOR; break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_ERRMSG_HANDLER:
|
|
|
|
|
ret = (long)_error_handler;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case ATTR_NATIVE_GRAPHIC_CONTEXT:
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (_nice_windows.Get(win) != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#ifdef WIN32
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
ret = dc.GetHDC();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
|
|
|
|
SORRY_BOX(); //verificare
|
|
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_NATIVE_WINDOW:
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (_nice_windows.Get(win) != NULL)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
ret = w.GetHandle();
|
|
|
|
|
#else
|
|
|
|
|
SORRY_BOX(); //verificare
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ATTR_SCREEN_HEIGHT:
|
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_SCREEN_WIDTH:
|
|
|
|
|
ret = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_X);
|
|
|
|
|
break;
|
|
|
|
|
case ATTR_SCREEN_WINDOW:
|
2002-10-24 10:47:49 +00:00
|
|
|
|
ret = NULL_WIN; // Non bellissimo ma per ora...
|
2003-05-22 15:25:25 +00:00
|
|
|
|
break;
|
|
|
|
|
case ATTR_TASK_WINDOW:
|
|
|
|
|
ret = long(_task_win);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
case ATTR_WIN_INSTANCE:
|
|
|
|
|
ret = 0;
|
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_WIN_PM_DRAWABLE_TWIN:
|
|
|
|
|
ret = TRUE;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
default: SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(rctp != NULL);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
int l, h;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (win != NULL_WIN)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (win == _print_win)
|
|
|
|
|
{
|
|
|
|
|
l = h = 6000; // circa A4 height
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.GetClientSize(&l, &h);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2003-04-16 15:50:37 +00:00
|
|
|
|
else // NULL_WIN -> SREEN_WINDOW
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
l = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_X);
|
|
|
|
|
h = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rctp->left = rctp->top = 0;
|
|
|
|
|
rctp->right = l; rctp->bottom = h;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return rctp;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long xvt_vobj_get_data(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
return w._app_data;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
RCT* xvt_vobj_get_outer_rect(WINDOW win, RCT *rctp)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(rctp != NULL);
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
const wxRect rct = w.GetRect();
|
|
|
|
|
rctp->left = rct.x; rctp->top = rct.y;
|
|
|
|
|
rctp->right = rct.x + rct.width;
|
|
|
|
|
rctp->bottom = rct.y + rct.height;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return rctp;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_PALETTE xvt_vobj_get_palet(WINDOW win)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{ return NULL; }
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_vobj_get_parent(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (win == TASK_WIN)
|
|
|
|
|
return NULL_WIN;
|
|
|
|
|
CAST_WIN(win, w);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return (WINDOW)w.GetParent();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
strncpy(title, w.GetTitle(), sz_title);
|
|
|
|
|
title[sz_title-1] = '\0';
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return title;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WIN_TYPE xvt_vobj_get_type(WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
return w._type;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_maximize(WINDOW win)
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
wxFrame* pMain = (wxFrame*)_task_win;
|
|
|
|
|
if (win != (WINDOW)pMain)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
int width, height;
|
|
|
|
|
pMain->GetClientSize(&width, &height);
|
|
|
|
|
w.SetSize(0, 0, width, height);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pMain->Maximize();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_minimize(WINDOW win)
|
2003-04-17 12:53:36 +00:00
|
|
|
|
{
|
|
|
|
|
wxFrame* pMain = (wxFrame*)_task_win;
|
|
|
|
|
if (win == (WINDOW)pMain)
|
|
|
|
|
pMain->Iconize();
|
|
|
|
|
else
|
|
|
|
|
SORRY_BOX();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_move(WINDOW win, RCT *rctp)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxRect rct = NormalizeRCT(rctp);
|
2003-05-15 09:49:25 +00:00
|
|
|
|
w.Move(rct.x, rct.y);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w.SetClientSize(rct.width, rct.height);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_raise(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.Raise();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_attr(WINDOW win, long data, long value)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
switch(data)
|
|
|
|
|
{
|
|
|
|
|
case ATTR_ERRMSG_HANDLER: _error_handler = (XVT_ERRMSG_HANDLER)value; break;
|
2003-03-27 12:15:57 +00:00
|
|
|
|
case ATTR_EVENT_HOOK: SORRY_BOX(); break; // TBI?: Native events hook!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case ATTR_WIN_PM_DRAWABLE_TWIN: break; // Ignored: Always TRUE
|
2003-03-27 12:15:57 +00:00
|
|
|
|
case ATTR_WIN_PM_TWIN_STARTUP_RCT: _startup_rect = *(RCT*)value; break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case ATTR_WIN_PM_TWIN_STARTUP_STYLE: break; // TBI
|
|
|
|
|
default: SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_data(WINDOW win, long AppData)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
w._app_data = AppData;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_enabled(WINDOW win, BOOLEAN enabled)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.Enable(enabled != 0);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_palet(WINDOW win, XVT_PALETTE palet)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
// Do not implement!
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_title(WINDOW win, char *title)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.SetTitle(title);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_visible(WINDOW win, BOOLEAN show)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.Show(show != 0);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int npnts)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(from_win != NULL_WIN && to_win != NULL_WIN);
|
|
|
|
|
XVT_ASSERT(pntp != NULL && npnts > 0);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
CAST_WIN(from_win, w1);
|
|
|
|
|
CAST_WIN(to_win, w2);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
for (int i = 0; i < npnts; i++)
|
|
|
|
|
{
|
|
|
|
|
int x = pntp[i].h;
|
|
|
|
|
int y = pntp[i].v;
|
|
|
|
|
w1.ClientToScreen(&x, &y);
|
|
|
|
|
w2.ScreenToClient(&x, &y);
|
|
|
|
|
pntp[i].h = x;
|
|
|
|
|
pntp[i].v = y;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Real windows
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WINDOW parent, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(rct_p != NULL);
|
|
|
|
|
|
|
|
|
|
const wxString caption = title;
|
|
|
|
|
const wxPoint pos(rct_p->left, rct_p->top);
|
|
|
|
|
const wxSize size(rct_p->right-rct_p->left, rct_p->bottom-rct_p->top);
|
2003-01-07 12:20:49 +00:00
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long style = wxNO_3D | wxWANTS_CHARS |
|
2003-01-07 12:20:49 +00:00
|
|
|
|
wxCLIP_CHILDREN | wxCLIP_SIBLINGS | // Clippa per bene
|
|
|
|
|
wxPOPUP_WINDOW; // Inizialmente invisibile!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
if (win_flags & WSF_VSCROLL)
|
|
|
|
|
style |= wxVSCROLL;
|
|
|
|
|
if (win_flags & WSF_HSCROLL)
|
|
|
|
|
style |= wxHSCROLL;
|
|
|
|
|
|
|
|
|
|
TwxWindow* w = NULL;
|
|
|
|
|
switch (wtype)
|
|
|
|
|
{
|
|
|
|
|
case W_DOC:
|
|
|
|
|
style |= wxBORDER;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (!caption.IsEmpty())
|
2002-02-28 14:26:23 +00:00
|
|
|
|
style |= wxCAPTION | wxSYSTEM_MENU;
|
|
|
|
|
break;
|
|
|
|
|
case W_PLAIN:
|
2002-07-03 14:53:33 +00:00
|
|
|
|
// style |= wxBORDER; // Non attivare MAI il bordo!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
default:
|
2002-02-28 14:26:23 +00:00
|
|
|
|
SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
w = new TwxWindow((wxWindow*)parent, -1, caption, pos, size, style);
|
2003-03-28 15:33:49 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w->_type = wtype;
|
|
|
|
|
w->_app_data = app_data;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
|
|
|
|
|
if (win_flags & WSF_INVISIBLE)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w->Hide();
|
|
|
|
|
else
|
|
|
|
|
w->Show();
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC);
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
|
if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* mi = xvt_res_get_menu(menu_rid);
|
|
|
|
|
if (mi)
|
|
|
|
|
{
|
|
|
|
|
w->SetMenuTree(mi);
|
|
|
|
|
xvt_res_free_menu_tree(mi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (style & wxHSCROLL)
|
|
|
|
|
w->SetScrollbar(wxHORIZONTAL, 0, 1, 100);
|
|
|
|
|
if (style & wxVSCROLL)
|
|
|
|
|
w->SetScrollbar(wxVERTICAL, 0, 1, 100);
|
|
|
|
|
|
|
|
|
|
if (win_flags & WSF_DISABLED)
|
|
|
|
|
w->Disable();
|
|
|
|
|
else
|
|
|
|
|
w->Enable();
|
|
|
|
|
|
2002-10-24 10:47:49 +00:00
|
|
|
|
xvt_vobj_move((WINDOW)w, rct_p);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
// Accetta messaggi solo da ora!
|
|
|
|
|
w->_eh = eh;
|
|
|
|
|
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(e));
|
|
|
|
|
e.type = E_CREATE;
|
|
|
|
|
eh((WINDOW)w, &e);
|
|
|
|
|
|
|
|
|
|
xvt_app_process_pending_events();
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return (WINDOW)w;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
long xvt_win_dispatch_event(WINDOW win, EVENT* event_p)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_ASSERT(event_p != NULL);
|
|
|
|
|
CAST_TWIN(win, w);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return w._eh(win, event_p);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_post_event(WINDOW win, EVENT* event_p)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
// Per ora funziona solo con la task window
|
|
|
|
|
XVT_ASSERT(win == (WINDOW)_task_win && event_p != NULL);
|
2003-04-01 07:34:53 +00:00
|
|
|
|
|
|
|
|
|
switch (event_p->type)
|
|
|
|
|
{
|
|
|
|
|
case E_COMMAND:
|
|
|
|
|
{
|
|
|
|
|
wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, event_p->v.cmd.tag);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
e.SetEventObject(_task_win);
|
|
|
|
|
wxPostEvent(_task_win, e);
|
2003-04-01 07:34:53 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
default:
|
|
|
|
|
SORRY_BOX();
|
2003-04-01 07:34:53 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_release_pointer(void)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
|
if (_mouse_trapper != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2003-01-07 12:20:49 +00:00
|
|
|
|
// cap SHOULD be equal to _mouse_trapper :-)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxWindow* cap = _mouse_trapper->GetCapture();
|
2003-01-07 12:20:49 +00:00
|
|
|
|
if (cap != NULL)
|
|
|
|
|
cap->ReleaseMouse();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_mouse_trapper = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_set_caret_size(WINDOW win, int width, int height)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_TheCaret.SetSize(width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_set_caret_pos(WINDOW win, PNT p)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_TheCaret.SetPos(p.h, p.v-1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_set_caret_visible(WINDOW win, BOOLEAN on)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_TheCaret.Show(win, on != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_set_cursor(WINDOW win, CURSOR cursor)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
wxCursor* cur = wxSTANDARD_CURSOR; // Dummy initilization
|
|
|
|
|
switch (cursor)
|
|
|
|
|
{
|
|
|
|
|
case CURSOR_ARROW: cur = wxSTANDARD_CURSOR; break;
|
|
|
|
|
case CURSOR_CROSS: cur = wxCROSS_CURSOR; break;
|
|
|
|
|
case CURSOR_WAIT : cur = wxHOURGLASS_CURSOR; break;
|
|
|
|
|
default: cur = GetCursorResource(cursor); break; // Always succeeds
|
|
|
|
|
}
|
|
|
|
|
w.SetCursor(*cur);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_set_handler(WINDOW win, EVENT_HANDLER eh)
|
|
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (win == (WINDOW)_task_win)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
_task_win_handler = eh;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
w._eh = eh;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_trap_pointer(WINDOW win)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
2003-01-07 12:20:49 +00:00
|
|
|
|
xvt_win_release_pointer();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w.CaptureMouse();
|
|
|
|
|
_mouse_trapper = &w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Status bar
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
static wxString strDefaultStatbarText;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const char* statbar_set_title(WINDOW win, const char* text)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(win == TASK_WIN);
|
|
|
|
|
wxFrame& w = *(wxFrame*)win;
|
|
|
|
|
|
|
|
|
|
if (text == NULL)
|
|
|
|
|
text = strDefaultStatbarText;
|
|
|
|
|
char* tab = strchr(text, '\t');
|
|
|
|
|
if (tab)
|
|
|
|
|
{
|
|
|
|
|
w.SetStatusText(tab+1, 1);
|
|
|
|
|
*tab = '\0';
|
|
|
|
|
w.SetStatusText(text);
|
|
|
|
|
*tab = '\t';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
w.SetStatusText(text);
|
|
|
|
|
return text;
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const char* statbar_set_default_title(WINDOW win, const char *text)
|
|
|
|
|
{
|
|
|
|
|
strDefaultStatbarText = text;
|
|
|
|
|
return statbar_set_title(win, strDefaultStatbarText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XVT_FNTID statbar_set_fontid(WINDOW win, XVT_FNTID fontid)
|
|
|
|
|
{
|
|
|
|
|
return fontid; // TBI???
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
XVT_FNTID statbar_get_fontid(WINDOW win, XVT_FNTID fontid)
|
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return fontid; // VERIFICARE
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
|
|
|
|
|
int prop_count, char **prop_list, WINDOW parent_win,
|
|
|
|
|
int parent_rid, long parent_flags, char *parent_class)
|
|
|
|
|
{
|
|
|
|
|
XVT_ASSERT(parent_win == TASK_WIN);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
TTaskWin& w = *(TTaskWin*)_task_win;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w.CreateStatusBar(2);
|
2002-07-03 14:53:33 +00:00
|
|
|
|
w.GetStatusBar()->Show();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
wxSize sz = w.GetClientSize();
|
|
|
|
|
|
|
|
|
|
int widths[2];
|
|
|
|
|
widths[0] = -1;
|
|
|
|
|
widths[1] = sz.x / 4;
|
|
|
|
|
w.SetStatusWidths(2, widths);
|
|
|
|
|
|
|
|
|
|
return (WINDOW)&w;
|
2003-04-01 07:34:53 +00:00
|
|
|
|
}
|