2002-02-28 14:26:23 +00:00
|
|
|
|
#include "wxinc.h"
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
|
#include <wx/calctrl.h>
|
|
|
|
|
#include <wx/colordlg.h>
|
|
|
|
|
#include <wx/dialup.h>
|
|
|
|
|
#include <wx/fileconf.h>
|
|
|
|
|
#include <wx/filename.h>
|
|
|
|
|
#include <wx/fontdlg.h>
|
|
|
|
|
#include <wx/image.h>
|
|
|
|
|
#include <wx/filefn.h>
|
2003-05-16 09:25:11 +00:00
|
|
|
|
#include <wx/snglinst.h>
|
2008-04-04 16:04:47 +00:00
|
|
|
|
#include <wx/statline.h>
|
2008-06-13 08:48:18 +00:00
|
|
|
|
#include <wx/sysopt.h>
|
2003-10-17 13:57:23 +00:00
|
|
|
|
#include <wx/thread.h>
|
2008-04-04 16:04:47 +00:00
|
|
|
|
#include <wx/tokenzr.h>
|
2008-11-11 16:17:40 +00:00
|
|
|
|
#include <wx/aui/aui.h>
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
#include "xvt.h"
|
|
|
|
|
#include "statbar.h"
|
|
|
|
|
|
|
|
|
|
#include "agasys.h"
|
2004-03-13 08:59:21 +00:00
|
|
|
|
#include "fstrcmp.h"
|
2005-10-24 15:21:30 +00:00
|
|
|
|
#include "matche.h"
|
2007-12-12 09:43:46 +00:00
|
|
|
|
#include "xvtwin.h"
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#include "oswin32.h"
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#include <errno.h>
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include "oslinux.h"
|
2005-09-23 15:55:44 +00:00
|
|
|
|
#include <wx/dcps.h>
|
|
|
|
|
#include <wx/hash.h>
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
#define XVT_ASSERT(test) _AssertBox((test), __FUNCTION__, __FILE__, __LINE__)
|
2008-09-26 13:35:22 +00:00
|
|
|
|
#define CAST_WIN(win,w) wxWindow& w = *wxStaticCast((wxObject*)win, wxWindow);
|
|
|
|
|
#define CAST_TWIN(win,w) TwxWindow& w = *wxStaticCast((wxObject*)win, TwxWindow);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
#define CAST_TDC(win,dc) TDC& dc = GetTDCMapper().GetTDC(win);
|
|
|
|
|
#define CAST_DC(win,dc) wxDC& dc = GetTDCMapper().GetDC(win);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
#define CAST_FONT(font_id, font) TFontId& font = *wxStaticCast(font_id, TFontId);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
wxWindow* _mouse_trapper = NULL;
|
|
|
|
|
RCT _startup_rect = { 0,0,0,0 };
|
2008-06-19 15:39:33 +00:00
|
|
|
|
long _startup_style = 0;
|
2008-04-04 16:04:47 +00:00
|
|
|
|
wxString _startup_dir;
|
|
|
|
|
wxString _strDefaultStatbarText;
|
|
|
|
|
wxString _appl_name;
|
2008-12-17 11:40:23 +00:00
|
|
|
|
wxLocale* _locale = NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
static wxHashTable _nice_icons;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
static XVT_ERRMSG_HANDLER _error_handler = NULL;
|
|
|
|
|
|
2007-02-19 09:36:55 +00:00
|
|
|
|
const wxString& _GetAppTitle()
|
|
|
|
|
{ return _appl_name; }
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
class TMessageBox : public wxDialog
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
void OnButton(wxCommandEvent& evt);
|
|
|
|
|
void AddButton(wxSizer* sz, int id, int ico);
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2008-06-19 15:39:33 +00:00
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
public:
|
|
|
|
|
TMessageBox(const wxString& msg, int nStyle);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(TMessageBox, wxDialog)
|
|
|
|
|
EVT_BUTTON(wxID_ANY, TMessageBox::OnButton)
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
void TMessageBox::OnButton(wxCommandEvent& evt)
|
|
|
|
|
{
|
|
|
|
|
int ec = wxCANCEL;
|
|
|
|
|
switch (evt.GetId())
|
|
|
|
|
{
|
|
|
|
|
case wxID_YES: ec = wxYES; break;
|
|
|
|
|
case wxID_OK : ec = wxOK; break;
|
|
|
|
|
case wxID_NO : ec = wxNO; break;
|
|
|
|
|
default : ec = wxCANCEL; break;
|
|
|
|
|
}
|
|
|
|
|
EndModal(ec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMessageBox::AddButton(wxSizer* sz, int id, int WXUNUSED(ico))
|
|
|
|
|
{
|
|
|
|
|
sz->Add(new wxButton(this, id, wxEmptyString, wxDefaultPosition,
|
|
|
|
|
wxSize(80, 32)), 0, wxALL, 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TMessageBox::TMessageBox(const wxString& msg, int nStyle)
|
|
|
|
|
: wxDialog(NULL, wxID_ANY, _GetAppTitle(), wxDefaultPosition, wxDefaultSize,
|
|
|
|
|
wxCAPTION | wxRAISED_BORDER)
|
|
|
|
|
{
|
|
|
|
|
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
SetSizer(sizer);
|
|
|
|
|
|
|
|
|
|
wxBoxSizer* sz1 = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
sizer->Add(sz1);
|
|
|
|
|
int nIco = 162;
|
|
|
|
|
if (nStyle & wxICON_ERROR) nIco = 201;
|
|
|
|
|
if (nStyle & wxICON_QUESTION) nIco = 202;
|
|
|
|
|
if (nStyle & wxICON_EXCLAMATION) nIco = 203;
|
|
|
|
|
const int nBorder = 8;
|
|
|
|
|
sz1->Add(new wxStaticBitmap(this, nIco, _GetToolResource(nIco, 64)), 0, wxALL, nBorder);
|
|
|
|
|
wxStaticText* ss = new wxStaticText(this, wxID_ANY, wxEmptyString);
|
|
|
|
|
ss->Wrap(160);
|
|
|
|
|
ss->SetLabel(msg);
|
|
|
|
|
sz1->Add(ss, 0, wxALL | wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, nBorder);
|
|
|
|
|
|
|
|
|
|
sizer->Add(new wxStaticLine(this), 0, wxALL | wxEXPAND, nBorder);
|
|
|
|
|
|
|
|
|
|
wxBoxSizer* sz2 = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
sizer->Add(sz2, 0, wxALIGN_CENTER);
|
|
|
|
|
if (nStyle & wxYES_NO)
|
|
|
|
|
{
|
|
|
|
|
SetAffirmativeId(wxID_YES);
|
|
|
|
|
if (nStyle & wxNO_DEFAULT)
|
|
|
|
|
{
|
|
|
|
|
AddButton(sz2, wxID_NO, 102);
|
|
|
|
|
AddButton(sz2, wxID_YES, 101);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AddButton(sz2, wxID_YES, 101);
|
|
|
|
|
AddButton(sz2, wxID_NO, 102);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nStyle & wxOK)
|
|
|
|
|
{
|
|
|
|
|
SetAffirmativeId(wxID_OK);
|
|
|
|
|
AddButton(sz2, wxID_OK, 101);
|
|
|
|
|
}
|
|
|
|
|
if (nStyle & wxCANCEL)
|
|
|
|
|
{
|
|
|
|
|
SetEscapeId(wxID_CANCEL);
|
|
|
|
|
AddButton(sz2, wxID_CANCEL, 102);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sizer->SetSizeHints(this);
|
|
|
|
|
|
|
|
|
|
if (nStyle & wxCENTRE)
|
|
|
|
|
Centre();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _MessageBox(const wxString& msg, int nStyle)
|
|
|
|
|
{
|
|
|
|
|
xvt_dm_post_speech(msg, 1, TRUE);
|
|
|
|
|
|
2008-06-20 05:28:10 +00:00
|
|
|
|
//int ret = ::wxMessageBox(msg, _GetAppTitle(), nStyle);
|
|
|
|
|
TMessageBox dlg(msg, nStyle);
|
|
|
|
|
const int ret = dlg.ShowModal();
|
2008-04-04 16:04:47 +00:00
|
|
|
|
|
|
|
|
|
switch(ret)
|
|
|
|
|
{
|
|
|
|
|
case wxOK : xvt_dm_post_speech("ok", 7, TRUE); break;
|
|
|
|
|
case wxYES: xvt_dm_post_speech("si", 7, TRUE); break;
|
|
|
|
|
case wxNO : xvt_dm_post_speech("no", 7, TRUE); break;
|
|
|
|
|
default : xvt_dm_post_speech("annulla", 7, TRUE); break;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _AssertBox(bool test, const char* func, const char* file, 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)
|
|
|
|
|
{
|
2007-02-19 09:36:55 +00:00
|
|
|
|
wxString strMessage;
|
2008-04-04 16:04:47 +00:00
|
|
|
|
strMessage.Printf("Sorry, the application passed some invalid parameters to\nfunction %s in file %s at line %d .",
|
|
|
|
|
func, file, line);
|
|
|
|
|
_MessageBox(strMessage, wxOK|wxICON_ERROR);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
void xvt_sys_sorry_box(const char* func, const char* file, int line)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
static wxHashTable sorry(wxKEY_STRING);
|
|
|
|
|
if (sorry.Get(func) == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
sorry.Put(func, &sorry); // Dummy
|
|
|
|
|
wxString strMessage;
|
|
|
|
|
strMessage.Printf("Function %s in file %s at line %d\nis not implemented yet: be patient...",
|
|
|
|
|
func, file, line);
|
|
|
|
|
_MessageBox(strMessage, wxOK | wxICON_WARNING);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-19 15:34:00 +00:00
|
|
|
|
void xvt_sys_deprecated_box(const char* func, const char* file, int line)
|
2007-12-12 09:43:46 +00:00
|
|
|
|
{
|
|
|
|
|
static wxHashTable deprecated;
|
2008-12-03 12:07:57 +00:00
|
|
|
|
if (deprecated.Get(func) == NULL)
|
2007-12-12 09:43:46 +00:00
|
|
|
|
{
|
2008-12-03 12:07:57 +00:00
|
|
|
|
deprecated.Put(func, &deprecated); // Dummy
|
|
|
|
|
wxString strMessage;
|
|
|
|
|
strMessage.Printf("Function %s in file %s at line %d is deprecated:\nYou can blame Guy for this, if you're bold enough!",
|
|
|
|
|
func, file, line);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
_MessageBox(strMessage, wxOK | wxICON_WARNING);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-19 08:17:48 +00:00
|
|
|
|
wxString GetResourceIni()
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
wxString strName;
|
2007-02-19 09:36:55 +00:00
|
|
|
|
strName = _startup_dir;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
strName += "/res/resource.ini";
|
2007-12-12 09:43:46 +00:00
|
|
|
|
return strName;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
wxString _GetResourceName(const char* type, int rid)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-10-20 14:59:24 +00:00
|
|
|
|
wxString strName(type); strName << "s";
|
2007-12-12 09:43:46 +00:00
|
|
|
|
wxString strKey; strKey.Printf("%d", rid);
|
|
|
|
|
wxString val;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
char* buff = val.GetWriteBuf(260);
|
|
|
|
|
::GetPrivateProfileString(strName, strKey, "", buff, 260, GetResourceIni());
|
|
|
|
|
val.UngetWriteBuf();
|
|
|
|
|
#else
|
|
|
|
|
wxFileConfig ini("", "", GetResourceIni());
|
|
|
|
|
strName.insert(0, '/');
|
|
|
|
|
ini.SetPath(strName);
|
|
|
|
|
ini.Read(strKey, &val);
|
|
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (!val.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
strName = _startup_dir;
|
|
|
|
|
strName += "/custom/";
|
|
|
|
|
strName += val;
|
|
|
|
|
if (!wxFileExists(strName))
|
|
|
|
|
{
|
|
|
|
|
strName = _startup_dir;
|
|
|
|
|
strName += "/res/";
|
|
|
|
|
strName += val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strName.Empty();
|
|
|
|
|
return strName;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
const wxIcon& _GetIconResource(int rid)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxIcon* icon = wxDynamicCast(_nice_icons.Get(rid), wxIcon);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (icon == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
wxString strName = _GetResourceName("Icon", rid);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (::wxFileExists(strName))
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2007-12-12 09:43:46 +00:00
|
|
|
|
else
|
2008-04-04 16:04:47 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
icon = wxDynamicCast(_nice_icons.Get(ICON_RSRC), wxIcon);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
if (icon == NULL)
|
2008-04-08 14:05:10 +00:00
|
|
|
|
{
|
|
|
|
|
strName.Printf("%d", ICON_RSRC);
|
|
|
|
|
icon = new wxIcon(strName); // Icona di salvezza
|
|
|
|
|
}
|
2008-04-04 16:04:47 +00:00
|
|
|
|
}
|
2008-04-08 14:05:10 +00:00
|
|
|
|
_nice_icons.Put(rid, icon);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2008-04-04 16:04:47 +00:00
|
|
|
|
return *icon;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const wxCursor* GetCursorResource(int rid)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
static wxHashTable _nice_cursors;
|
2008-12-03 12:07:57 +00:00
|
|
|
|
const wxCursor* cursor = wxDynamicCast(_nice_cursors.Get(rid), wxCursor);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (cursor == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
switch (rid)
|
|
|
|
|
{
|
|
|
|
|
case CURSOR_CROCE: cursor = new wxCursor(wxCURSOR_CROSS); break;
|
|
|
|
|
case CURSOR_IBEAM: cursor = new wxCursor(wxCURSOR_IBEAM); break;
|
|
|
|
|
default:
|
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
const wxString strName = _GetResourceName("Cursor", rid);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (::wxFileExists(strName))
|
|
|
|
|
{
|
|
|
|
|
if (strName.Find(".ico") > 0)
|
|
|
|
|
cursor = new wxCursor(strName, wxBITMAP_TYPE_ICO);
|
|
|
|
|
else
|
|
|
|
|
cursor = new wxCursor(strName, wxBITMAP_TYPE_CUR);
|
|
|
|
|
|
|
|
|
|
if (!cursor->Ok())
|
|
|
|
|
{
|
|
|
|
|
delete cursor;
|
|
|
|
|
cursor = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (cursor == NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
XVT_ASSERT(false);
|
2008-12-03 12:07:57 +00:00
|
|
|
|
cursor = wxSTANDARD_CURSOR;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2008-12-03 12:07:57 +00:00
|
|
|
|
_nice_cursors.Put(rid, (wxCursor*)cursor);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2007-12-12 09:43:46 +00:00
|
|
|
|
return cursor;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Font cache
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
WX_DECLARE_HASH_MAP(wxString, wxFont*, wxStringHash, wxStringEqual, wxFontHashMap);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
class TFontCache
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
wxFontHashMap* m_map;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
wxFont& FindOrCreate(int pointSize, int family, int style, int weight,
|
|
|
|
|
bool underline, const wxString& face);
|
|
|
|
|
void Destroy();
|
|
|
|
|
TFontCache() : m_map(NULL) { }
|
|
|
|
|
~TFontCache() { Destroy(); }
|
|
|
|
|
|
|
|
|
|
} XVT_FONT_CACHE;
|
|
|
|
|
|
|
|
|
|
void TFontCache::Destroy()
|
|
|
|
|
{
|
|
|
|
|
if (m_map)
|
|
|
|
|
{
|
|
|
|
|
m_map->clear();
|
|
|
|
|
// delete m_map; // NON funziona ma non si capisce perche': PAZIENZA!
|
|
|
|
|
m_map = NULL;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
wxFont& TFontCache::FindOrCreate(int pointSize, int family, int style, int weight,
|
|
|
|
|
bool underline, const wxString& face)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (m_map == NULL)
|
|
|
|
|
m_map = new wxFontHashMap;
|
|
|
|
|
|
|
|
|
|
wxString key;
|
|
|
|
|
key.Printf("%s_%d_%d_%d_%d", face, pointSize, style, weight, underline);
|
|
|
|
|
wxFont* pFont = (*m_map)[key];
|
|
|
|
|
if (pFont == NULL)
|
|
|
|
|
{
|
|
|
|
|
pFont = new wxFont(pointSize, family, style, weight, underline, face);
|
|
|
|
|
pFont->SetPointSize(pointSize); // Colpo di classe indispensabile per i PDF :-)
|
|
|
|
|
(*m_map)[key] = pFont;
|
|
|
|
|
}
|
|
|
|
|
return *pFont;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 13:40:52 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Speech support
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// 0 Errors
|
|
|
|
|
// 1 Warnings
|
|
|
|
|
// 2 Messages
|
|
|
|
|
// 3 Requests
|
|
|
|
|
// 7 Buttons
|
|
|
|
|
static int m_nSpeechMode = 0;
|
|
|
|
|
|
|
|
|
|
void xvt_dm_enable_speech(int mode)
|
|
|
|
|
{
|
|
|
|
|
#ifdef SPEECH_API
|
|
|
|
|
m_nSpeechMode = mode;
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
if (m_nSpeechMode != 0)
|
|
|
|
|
{
|
|
|
|
|
if (!OsWin32_InitializeSpeech())
|
|
|
|
|
m_nSpeechMode = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OsWin32_DeinitializeSpeech();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2008-06-13 08:48:18 +00:00
|
|
|
|
XVTDLL void xvt_app_pre_create(void)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-12-16 14:47:30 +00:00
|
|
|
|
DIRECTORY dir;
|
|
|
|
|
xvt_fsys_get_default_dir(&dir); // Init Startup Directory
|
|
|
|
|
wxString strResPath = dir.path; strResPath += "/res";
|
2008-06-13 08:48:18 +00:00
|
|
|
|
|
2008-12-17 11:40:23 +00:00
|
|
|
|
_locale = new wxLocale(wxLANGUAGE_DEFAULT); // wxLANGUAGE_ITALIAN
|
|
|
|
|
_locale->AddCatalogLookupPathPrefix(strResPath);
|
|
|
|
|
_locale->AddCatalog("wxstd", wxLanguage(_locale->GetLanguage()), NULL);
|
2008-06-13 08:48:18 +00:00
|
|
|
|
|
2008-06-06 09:10:28 +00:00
|
|
|
|
::wxInitAllImageHandlers();
|
2003-04-30 15:43:51 +00:00
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
#ifdef WIN32
|
2008-12-03 12:07:57 +00:00
|
|
|
|
if (::wxDisplayDepth() >= 32 && wxTheApp->GetComCtl32Version() >= 600)
|
2008-06-13 08:48:18 +00:00
|
|
|
|
wxSystemOptions::SetOption(wxT("msw.remap"), 2);
|
2008-12-03 12:07:57 +00:00
|
|
|
|
else
|
|
|
|
|
wxSystemOptions::SetOption(wxT("msw.remap"), 0);
|
2008-10-24 15:49:08 +00:00
|
|
|
|
#endif
|
2008-06-13 08:48:18 +00:00
|
|
|
|
|
2003-10-14 13:40:52 +00:00
|
|
|
|
#ifdef SPEECH_API
|
|
|
|
|
xvt_dm_enable_speech(0xFF);
|
|
|
|
|
#endif
|
2008-06-13 08:48:18 +00:00
|
|
|
|
}
|
2003-10-14 13:40:52 +00:00
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
void xvt_app_create(int argc, char **argv, unsigned long WXUNUSED(flags),
|
2008-06-13 08:48:18 +00:00
|
|
|
|
EVENT_HANDLER eh, XVT_CONFIG *config)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_task_win_handler = eh;
|
2007-02-19 09:36:55 +00:00
|
|
|
|
_appl_name = config->appl_name;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
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;
|
2008-02-01 16:38:06 +00:00
|
|
|
|
long style = wxDEFAULT_FRAME_STYLE;
|
2008-07-23 15:45:27 +00:00
|
|
|
|
|
|
|
|
|
wxWindow* pParent = NULL;
|
|
|
|
|
bool bHasMenu = true, bCanChangeFirm = true;
|
2008-01-31 14:15:52 +00:00
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
HWND hwndParent = (HWND)OsWin32_FindMenuContainer();
|
|
|
|
|
if (hwndParent != NULL)
|
|
|
|
|
{
|
2008-07-23 15:45:27 +00:00
|
|
|
|
pParent = new wxWindow;
|
|
|
|
|
pParent->AssociateHandle(hwndParent);
|
|
|
|
|
const wxSize szWin = pParent->GetSize();
|
|
|
|
|
const wxSize szCli = pParent->GetClientSize();
|
|
|
|
|
xvt_rect_set(&_startup_rect, 0, 0, szWin.x, szWin.y);
|
|
|
|
|
style = wxSYSTEM_MENU; // Lo stile si riduce al minimo: niente cornici
|
|
|
|
|
|
|
|
|
|
bHasMenu = (szWin.y - szCli.y) < 2;
|
|
|
|
|
bCanChangeFirm = false;
|
2008-01-31 14:15:52 +00:00
|
|
|
|
}
|
2004-04-30 10:52:00 +00:00
|
|
|
|
#endif
|
2008-07-23 15:45:27 +00:00
|
|
|
|
|
2008-01-31 14:15:52 +00:00
|
|
|
|
if (_startup_rect.right > _startup_rect.left)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2002-02-28 14:26:23 +00:00
|
|
|
|
style |= wxMAXIMIZE;
|
2004-04-30 10:52:00 +00:00
|
|
|
|
#else
|
2008-01-31 14:15:52 +00:00
|
|
|
|
style &= ~wxMAXIMIZE;
|
|
|
|
|
const wxRect rect = wxGetClientDisplayRect();
|
|
|
|
|
pos = rect.GetPosition();
|
2008-04-04 16:04:47 +00:00
|
|
|
|
size = rect.GetSize();
|
2004-04-30 10:52:00 +00:00
|
|
|
|
#endif
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-06-19 15:39:33 +00:00
|
|
|
|
if (_startup_style & WSF_NO_TASKBAR)
|
|
|
|
|
style |= wxFRAME_NO_TASKBAR;
|
|
|
|
|
|
2008-01-17 11:04:08 +00:00
|
|
|
|
_task_win = new TTaskWin(ICON_RSRC, title, pos, size, style);
|
2005-09-23 15:55:44 +00:00
|
|
|
|
_task_win->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint
|
|
|
|
|
_nice_windows.Put((WINDOW)_task_win, _task_win);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-07-23 15:45:27 +00:00
|
|
|
|
if (pParent != NULL)
|
2008-01-31 14:15:52 +00:00
|
|
|
|
{
|
2008-07-23 15:45:27 +00:00
|
|
|
|
_task_win->Reparent(pParent);
|
|
|
|
|
pParent->DissociateHandle();
|
|
|
|
|
pParent = NULL;
|
2008-01-31 14:15:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-23 15:45:27 +00:00
|
|
|
|
if (bHasMenu)
|
2008-01-31 14:15:52 +00:00
|
|
|
|
{
|
2008-07-23 15:45:27 +00:00
|
|
|
|
wxMenu* Menus[3];
|
|
|
|
|
wxString Title[3];
|
|
|
|
|
Title[0] = "&File";
|
|
|
|
|
Menus[0] = new wxMenu;
|
|
|
|
|
|
|
|
|
|
if (bCanChangeFirm)
|
|
|
|
|
{
|
|
|
|
|
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");
|
2008-01-31 14:15:52 +00:00
|
|
|
|
Menus[0]->AppendSeparator();
|
2008-07-23 15:45:27 +00:00
|
|
|
|
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");
|
|
|
|
|
Menus[1]->Append(M_EDIT_CLEAR, "&Elimina\tCanc");
|
2008-09-15 10:36:23 +00:00
|
|
|
|
Title[2] = "&?";
|
2008-07-23 15:45:27 +00:00
|
|
|
|
Menus[2] = new wxMenu;
|
|
|
|
|
Menus[2]->Append(M_HELP_CONTENTS, "&Sommario");
|
2008-09-15 10:36:23 +00:00
|
|
|
|
Menus[2]->Append(M_HELP_ONCONTEXT, "&Aiuto contestuale");
|
2008-07-23 15:45:27 +00:00
|
|
|
|
Menus[2]->AppendSeparator();
|
|
|
|
|
Menus[2]->Append(M_FILE_ABOUT, "&Informazioni");
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
_task_win->SetMenuBar(pMenubar);
|
2008-01-31 14:15:52 +00:00
|
|
|
|
}
|
2008-07-11 11:16:52 +00:00
|
|
|
|
|
2008-07-23 15:45:27 +00:00
|
|
|
|
if (style & wxMAXIMIZE)
|
|
|
|
|
_task_win->Maximize();
|
2005-09-23 15:55:44 +00:00
|
|
|
|
_task_win->Show();
|
|
|
|
|
|
|
|
|
|
wxApp* a = wxTheApp;
|
|
|
|
|
a->SetTopWindow(_task_win);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(e));
|
|
|
|
|
e.type = E_CREATE;
|
|
|
|
|
long ret = _task_win_handler((WINDOW)_task_win, &e);
|
|
|
|
|
if (ret != 0)
|
2005-09-23 15:55:44 +00:00
|
|
|
|
{
|
|
|
|
|
// Simula main loop
|
2007-02-19 09:36:55 +00:00
|
|
|
|
xvt_app_process_pending_events();
|
2005-09-23 15:55:44 +00:00
|
|
|
|
}
|
|
|
|
|
a->ExitMainLoop(); // Non entrare nel main loop di wxWindows
|
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();
|
2008-07-25 15:12:34 +00:00
|
|
|
|
if (_task_win != NULL)
|
|
|
|
|
_task_win->Destroy();
|
2003-10-14 13:40:52 +00:00
|
|
|
|
|
|
|
|
|
#ifdef SPEECH_API
|
|
|
|
|
xvt_dm_enable_speech(0x00);
|
|
|
|
|
#endif
|
2008-12-17 11:40:23 +00:00
|
|
|
|
|
|
|
|
|
if (_locale != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete _locale;
|
|
|
|
|
_locale = NULL;
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
|
wxApp* a = wxTheApp; // Memorizzo il risultato di wxGetInstance
|
|
|
|
|
if (a != NULL)
|
2003-04-30 15:43:51 +00:00
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
|
while (a->Pending())
|
2007-02-19 09:36:55 +00:00
|
|
|
|
a->Dispatch();
|
2008-06-13 08:48:18 +00:00
|
|
|
|
a->ProcessIdle(); // Necessario per wxAUI
|
2008-06-19 15:39:33 +00:00
|
|
|
|
a->Yield(true); // Non so se serva veramente
|
2003-04-30 15:43:51 +00:00
|
|
|
|
}
|
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();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
wxTheClipboard->Flush();
|
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
|
|
|
|
}
|
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
BOOLEAN xvt_cb_has_format(CB_FORMAT fmt, char* WXUNUSED(name))
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2007-02-19 09:36:55 +00:00
|
|
|
|
return (fmt == CB_TEXT) && wxTheClipboard->IsSupported(wxDF_TEXT);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
BOOLEAN xvt_cb_open(BOOLEAN WXUNUSED(writing))
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2007-02-19 09:36:55 +00:00
|
|
|
|
return wxTheClipboard->Open();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
BOOLEAN xvt_cb_put_data(CB_FORMAT cbfmt, char* WXUNUSED(name), long WXUNUSED(size), PICTURE WXUNUSED(pic))
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2008-12-03 12:07:57 +00:00
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return OsLinux_HL_Login(address, label, password);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Common dialogs
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-24 15:21:30 +00:00
|
|
|
|
class TwxCalendarDlg : public wxDialog
|
|
|
|
|
{
|
|
|
|
|
enum { ID_CAL = 1883 };
|
|
|
|
|
wxDateTime& m_date;
|
|
|
|
|
wxCalendarCtrl* m_cal;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool TransferDataFromWindow();
|
2007-04-03 10:53:21 +00:00
|
|
|
|
void OnCalendar(wxCalendarEvent& e);
|
2005-10-24 15:21:30 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TwxCalendarDlg(wxWindow* parent, const wxPoint& pnt, wxDateTime& date);
|
|
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(TwxCalendarDlg, wxDialog)
|
2007-02-19 09:36:55 +00:00
|
|
|
|
EVT_CALENDAR(wxID_ANY, TwxCalendarDlg::OnCalendar)
|
2005-10-24 15:21:30 +00:00
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
void TwxCalendarDlg::OnCalendar(wxCalendarEvent& WXUNUSED(e))
|
2005-10-24 15:21:30 +00:00
|
|
|
|
{
|
|
|
|
|
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
|
|
|
|
AddPendingEvent(evt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TwxCalendarDlg::TransferDataFromWindow()
|
|
|
|
|
{
|
|
|
|
|
bool ok = wxDialog::TransferDataFromWindow();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
m_date = m_cal->GetDate();
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TwxCalendarDlg::TwxCalendarDlg(wxWindow* parent, const wxPoint& pnt, wxDateTime& date)
|
|
|
|
|
: wxDialog(parent, wxID_ANY, "Data", pnt, wxDefaultSize, wxRAISED_BORDER), m_date(date)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
m_cal = new wxCalendarCtrl(this, ID_CAL, m_date,
|
|
|
|
|
pnt, wxDefaultSize,
|
|
|
|
|
wxCAL_MONDAY_FIRST | wxCAL_SHOW_HOLIDAYS | wxCAL_SHOW_SURROUNDING_WEEKS);
|
|
|
|
|
|
|
|
|
|
wxButton* button = new wxButton(this, wxID_OK, "OK");
|
|
|
|
|
|
|
|
|
|
wxGridSizer* sizer = new wxFlexGridSizer(2, 1, 8, 8);
|
|
|
|
|
sizer->Add(m_cal, 0, wxALIGN_CENTER);
|
|
|
|
|
sizer->Add(button, 0, wxALIGN_CENTER);
|
|
|
|
|
SetSizer(sizer);
|
|
|
|
|
sizer->SetSizeHints(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int xvt_dm_post_choose_date(WINDOW win, PNT pos, unsigned int ansidate)
|
|
|
|
|
{
|
|
|
|
|
int d = ansidate%100;
|
|
|
|
|
int m = (ansidate/100)%100;
|
|
|
|
|
int y = ansidate / 10000;
|
|
|
|
|
|
|
|
|
|
wxDateTime date;
|
|
|
|
|
if (d >= 1 && d <= 31 && m >= 1 && m <= 12 && y > 1900)
|
|
|
|
|
date.Set(d, wxDateTime::Month(m-1), y);
|
|
|
|
|
else
|
|
|
|
|
date = wxDateTime::Today();
|
|
|
|
|
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
|
|
|
|
|
wxPoint pnt(pos.h, pos.v);
|
|
|
|
|
if (pos.h < 0 || pos.v < 0)
|
|
|
|
|
pnt = wxDefaultPosition;
|
|
|
|
|
else
|
|
|
|
|
pnt = w.ClientToScreen(pnt);
|
|
|
|
|
|
|
|
|
|
wxDialog* dlg = new TwxCalendarDlg(&w, pnt, date);
|
|
|
|
|
|
|
|
|
|
if (dlg->ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
d = date.GetDay();
|
|
|
|
|
m = date.GetMonth()+1;
|
|
|
|
|
y = date.GetYear();
|
|
|
|
|
ansidate = y*10000 + m*100 + d;
|
|
|
|
|
}
|
|
|
|
|
dlg->Destroy();
|
|
|
|
|
|
|
|
|
|
return ansidate;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 13:40:52 +00:00
|
|
|
|
BOOLEAN xvt_dm_post_speech(const char* text, int priority, BOOLEAN async)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN ok = FALSE;
|
|
|
|
|
#ifdef SPEECH_API
|
|
|
|
|
if ((m_nSpeechMode & (1 << priority)) != 0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
ok = OsWin32_Speak(text, async != 0);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-19 09:36:55 +00:00
|
|
|
|
ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char* Btn2, const char* Btn3, const char* fmt)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
const int answer = _MessageBox(fmt, 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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
_MessageBox(fmt, wxOK | wxCENTRE | wxICON_HAND);
|
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-10-14 13:40:52 +00:00
|
|
|
|
xvt_dm_post_speech(fmt, 1, TRUE);
|
2003-03-24 16:22:11 +00:00
|
|
|
|
wxLogFatalError(fmt);
|
2003-10-14 13:40:52 +00:00
|
|
|
|
xvt_dm_post_speech("OK", 7, TRUE);
|
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;
|
2007-12-12 09:43:46 +00:00
|
|
|
|
xvt_fsys_convert_str_to_fspec(selectedname, fsp);
|
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)
|
|
|
|
|
{
|
2006-12-29 14:16:28 +00:00
|
|
|
|
const int flags = wxOPEN | wxFILE_MUST_EXIST;
|
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
|
|
|
|
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
const int flags = wxSAVE | wxOVERWRITE_PROMPT;
|
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
|
|
|
|
|
2005-06-01 11:20:06 +00:00
|
|
|
|
FL_STATUS xvt_dm_post_dir_sel(DIRECTORY *dir)
|
|
|
|
|
{
|
|
|
|
|
wxDirDialog dlg(_task_win);
|
|
|
|
|
dlg.SetPath(dir->path);
|
|
|
|
|
if (dlg.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
xvt_fsys_convert_str_to_dir(dlg.GetPath(), dir);
|
|
|
|
|
return FL_OK;
|
|
|
|
|
}
|
|
|
|
|
return FL_CANCEL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD* WXUNUSED(precp), unsigned long reserved)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
wxFontData data;
|
2004-03-17 17:15:44 +00:00
|
|
|
|
data.SetInitialFont(font.Font(NULL, win));
|
2004-03-23 16:41:20 +00:00
|
|
|
|
data.EnableEffects(reserved != 0);
|
2006-12-29 14:16:28 +00:00
|
|
|
|
wxFontDialog dlg(_task_win, data);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
BOOLEAN ok = dlg.ShowModal() == wxID_OK;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
font.Copy(dlg.GetFontData().GetChosenFont());
|
2004-03-23 16:41:20 +00:00
|
|
|
|
if (win == (WINDOW)_task_win)
|
|
|
|
|
{
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(EVENT));
|
|
|
|
|
e.type = E_FONT;
|
|
|
|
|
e.v.font.font_id = font_id;
|
|
|
|
|
_task_win_handler(win, &e);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
_MessageBox(fmt, 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)
|
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
_MessageBox(fmt, 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);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
wxTextEntryDialog dlg(NULL, message, _GetAppTitle(), response);
|
|
|
|
|
if (dlg.ShowModal() == wxID_OK)
|
2008-09-26 13:35:22 +00:00
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
wxStrncpy(response, dlg.GetValue(), response_len);
|
2008-09-26 13:35:22 +00:00
|
|
|
|
response[response_len-1] = '\0';
|
|
|
|
|
}
|
2008-04-04 16:04:47 +00:00
|
|
|
|
else
|
|
|
|
|
*response = '\0';
|
|
|
|
|
return response;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dm_post_warning(const char *fmt)
|
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
_MessageBox(fmt, 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;
|
|
|
|
|
} help_info;
|
|
|
|
|
|
2008-12-03 12:07:57 +00:00
|
|
|
|
XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC* WXUNUSED(fs), unsigned long WXUNUSED(flags))
|
2002-10-24 10:47:49 +00:00
|
|
|
|
{
|
2003-10-02 12:45:29 +00:00
|
|
|
|
return (XVT_HELP_INFO)&help_info;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_help_close_helpfile(XVT_HELP_INFO hi)
|
|
|
|
|
{
|
|
|
|
|
if (hi == NULL_HELP_INFO)
|
|
|
|
|
hi = (XVT_HELP_INFO)&help_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN bProcessed = FALSE;
|
|
|
|
|
|
2003-10-02 12:45:29 +00:00
|
|
|
|
#ifdef WIN32
|
2005-09-28 11:51:41 +00:00
|
|
|
|
WXHWND hwnd = (WXHWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
|
2003-10-02 12:45:29 +00:00
|
|
|
|
switch (ev->type)
|
|
|
|
|
{
|
|
|
|
|
case E_COMMAND:
|
|
|
|
|
bProcessed = OsWin32_Help(hwnd, "", ev->v.cmd.tag, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case E_HELP:
|
|
|
|
|
bProcessed = OsWin32_Help(hwnd, "", M_HELP_ONCONTEXT, (const char*)ev->v.help.tid);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#endif // WIN32
|
2002-10-24 10:47:49 +00:00
|
|
|
|
|
|
|
|
|
return bProcessed;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Image handling
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-06-19 15:39:33 +00:00
|
|
|
|
class TXVT_IMAGE : public wxImage
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-06-19 15:39:33 +00:00
|
|
|
|
DECLARE_DYNAMIC_CLASS(TXVT_IMAGE);
|
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
int m_nDepth;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
bool m_bDirty;
|
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
HBITMAP m_bitmap;
|
|
|
|
|
#else
|
|
|
|
|
wxBitmap* m_bitmap;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
public:
|
2008-06-19 15:39:33 +00:00
|
|
|
|
const wxImage& Image() const { return *this; }
|
|
|
|
|
wxImage& Image() { m_bDirty = true; return *this; }
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
HBITMAP Bitmap(wxDC& dc);
|
|
|
|
|
#else
|
|
|
|
|
const wxBitmap& Bitmap(wxDC& dc);
|
|
|
|
|
#endif
|
2008-11-11 16:17:40 +00:00
|
|
|
|
COLOR GetPixel(int x, int y) const;
|
|
|
|
|
void SetPixel(int x, int y, COLOR color);
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
|
|
|
|
TXVT_IMAGE() : m_bitmap(NULL), m_nDepth(0), m_bDirty(false) { }
|
|
|
|
|
~TXVT_IMAGE();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-06-19 15:39:33 +00:00
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(TXVT_IMAGE, wxImage);
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
#define CAST_TIMAGE(xvtimg, img) TXVT_IMAGE* img = wxDynamicCast(xvtimg, TXVT_IMAGE);
|
|
|
|
|
#define CAST_IMAGE(xvtimg, img) const wxImage* img = wxDynamicCast(xvtimg, wxImage);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
|
2008-11-11 16:17:40 +00:00
|
|
|
|
COLOR TXVT_IMAGE::GetPixel(int x, int y) const
|
|
|
|
|
{
|
|
|
|
|
// Chissa' perche' non esiste la GetRGB
|
|
|
|
|
const long pos = XYToIndex(x, y) * 3;
|
|
|
|
|
unsigned char* data = GetData() + pos;
|
|
|
|
|
return XVT_MAKE_COLOR(data[0], data[1], data[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TXVT_IMAGE::SetPixel(int x, int y, COLOR color)
|
|
|
|
|
{
|
|
|
|
|
SetRGB(x, y, XVT_COLOR_GET_RED(color), XVT_COLOR_GET_GREEN(color), XVT_COLOR_GET_BLUE(color));
|
|
|
|
|
m_bDirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
|
|
HBITMAP TXVT_IMAGE::Bitmap(wxDC& dc)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2004-11-30 22:02:59 +00:00
|
|
|
|
if (m_bDirty || m_bitmap == NULL || dc.GetDepth() != m_nDepth)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2004-11-30 22:02:59 +00:00
|
|
|
|
Destroy();
|
|
|
|
|
m_nDepth = dc.GetDepth();
|
2008-06-19 15:39:33 +00:00
|
|
|
|
m_bitmap = OsWin32_CreateBitmap(*this, dc);
|
|
|
|
|
m_bDirty = false;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
return m_bitmap;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
const wxBitmap& TXVT_IMAGE::Bitmap(wxDC& dc)
|
|
|
|
|
{
|
|
|
|
|
if (m_bDirty || m_bitmap == NULL || dc.GetDepth() != m_nDepth)
|
|
|
|
|
{
|
|
|
|
|
Destroy();
|
|
|
|
|
m_nDepth = dc.GetDepth();
|
2008-06-19 15:39:33 +00:00
|
|
|
|
m_bitmap = new wxBitmap(*this, m_nDepth);
|
|
|
|
|
m_bDirty = false;
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
return *m_bitmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void TXVT_IMAGE::Destroy()
|
|
|
|
|
{
|
|
|
|
|
if (m_bitmap != NULL)
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
::DeleteObject(m_bitmap);
|
|
|
|
|
#else
|
|
|
|
|
delete m_bitmap;
|
|
|
|
|
#endif
|
|
|
|
|
m_bitmap = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TXVT_IMAGE::~TXVT_IMAGE()
|
|
|
|
|
{
|
|
|
|
|
Destroy();
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Font Handling
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(TFontId, wxObject);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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;
|
2004-03-18 08:59:34 +00:00
|
|
|
|
return wxSWISS;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-28 11:51:41 +00:00
|
|
|
|
int TFontId::Weight() const
|
|
|
|
|
{
|
|
|
|
|
return (m_wMask & XVT_FS_BOLD) ? wxBOLD : wxNORMAL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 16:17:40 +00:00
|
|
|
|
const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2004-03-12 14:21:37 +00:00
|
|
|
|
int nSize = PointSize();
|
2005-09-23 15:55:44 +00:00
|
|
|
|
if (win == PRINTER_WIN)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
|
static wxDC* lastDC = NULL;
|
2006-01-05 13:46:00 +00:00
|
|
|
|
static wxSize lastPPI;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
static double dPrintScale = 1.0;
|
2006-01-05 13:46:00 +00:00
|
|
|
|
const wxSize ppi = dc->GetPPI();
|
|
|
|
|
if (dc != lastDC || ppi != lastPPI)
|
2004-03-17 17:15:44 +00:00
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
|
#ifdef WIN32
|
2006-01-05 13:46:00 +00:00
|
|
|
|
const char* const DEFAULT_FONT_NAME = "Courier New";
|
2005-09-23 15:55:44 +00:00
|
|
|
|
#else
|
2006-01-05 13:46:00 +00:00
|
|
|
|
const char* const DEFAULT_FONT_NAME = "Courier";
|
2005-09-23 15:55:44 +00:00
|
|
|
|
#endif
|
2005-10-28 12:13:28 +00:00
|
|
|
|
const int nTarget10 = 10 * ppi.x; // pixel in 10 pollici in larghezza
|
|
|
|
|
const int cpi10 = 10 * 120 / nSize; // caratteri stimati in 10 pollici
|
|
|
|
|
const wxString str('M', cpi10); // stringa campione per stimare la larghezza
|
2006-08-11 15:26:25 +00:00
|
|
|
|
int nMin = 1, nMax = nSize*16; // Limiti arbitrari
|
2004-03-18 08:59:34 +00:00
|
|
|
|
int nBest = 0;
|
|
|
|
|
while (nMin <= nMax)
|
2004-03-17 17:15:44 +00:00
|
|
|
|
{
|
|
|
|
|
const int nFontSize = (nMin+nMax)/2;
|
2005-10-28 12:13:28 +00:00
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
wxFont courier(nFontSize, wxFIXED, wxNORMAL, wxNORMAL, FALSE, DEFAULT_FONT_NAME);
|
2004-03-17 17:15:44 +00:00
|
|
|
|
dc->SetFont(courier);
|
|
|
|
|
int tw; dc->GetTextExtent(str, &tw, NULL);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
if (tw <= nTarget10)
|
2004-03-18 08:59:34 +00:00
|
|
|
|
{
|
2004-03-17 17:15:44 +00:00
|
|
|
|
nMin = nFontSize+1;
|
2004-03-18 08:59:34 +00:00
|
|
|
|
nBest = nFontSize;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
if (tw == nTarget10)
|
2004-03-18 08:59:34 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nMax = nFontSize-1;
|
2004-03-17 17:15:44 +00:00
|
|
|
|
}
|
2004-03-18 08:59:34 +00:00
|
|
|
|
if (nBest == 0)
|
|
|
|
|
nBest = nMax;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
#ifdef WIN32
|
2005-11-17 14:28:53 +00:00
|
|
|
|
// Pezza per cercare di ovviare a dimensioni assurde calcolate dai sistemi Win *
|
|
|
|
|
// Praticamente succede che il Courier 70 sia piu' piccolo del Curier 60
|
|
|
|
|
// Per cui una volta candidata una dimensione (nBest) tramite le righe precedenti
|
2006-08-11 15:26:25 +00:00
|
|
|
|
// cerco il primo font piu' piccolo che non sfondi
|
2005-11-17 14:28:53 +00:00
|
|
|
|
bool bPrevGood = true;
|
|
|
|
|
for (int i = 15; i > 0; i--)
|
2005-05-16 23:44:23 +00:00
|
|
|
|
{
|
2005-11-17 14:28:53 +00:00
|
|
|
|
const int nFontSize = nBest-i;
|
|
|
|
|
wxFont courier(nFontSize, wxFIXED, wxNORMAL, wxNORMAL, FALSE, DEFAULT_FONT_NAME);
|
2006-01-09 01:15:53 +00:00
|
|
|
|
|
2005-11-17 14:28:53 +00:00
|
|
|
|
dc->SetFont(courier);
|
|
|
|
|
int tw, th; dc->GetTextExtent(str, &tw, &th);
|
|
|
|
|
if (tw > nTarget10 && bPrevGood)
|
2005-05-16 23:44:23 +00:00
|
|
|
|
{
|
2005-11-17 14:28:53 +00:00
|
|
|
|
nBest = nFontSize-1;
|
|
|
|
|
break;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
}
|
2005-11-17 14:28:53 +00:00
|
|
|
|
bPrevGood = tw <= nTarget10;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
}
|
2005-09-23 15:55:44 +00:00
|
|
|
|
#endif
|
2006-01-09 01:15:53 +00:00
|
|
|
|
|
2004-03-18 08:59:34 +00:00
|
|
|
|
dPrintScale = double(nBest) / double(nSize);
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#ifdef LINUX
|
2005-10-24 15:21:30 +00:00
|
|
|
|
dPrintScale /= 10.0; // * wxPostScriptDC::GetResolution()) / 72.0);
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#endif
|
2004-03-17 17:15:44 +00:00
|
|
|
|
lastDC = dc;
|
2006-01-05 13:46:00 +00:00
|
|
|
|
lastPPI = ppi;
|
2004-03-17 17:15:44 +00:00
|
|
|
|
}
|
2004-03-18 08:59:34 +00:00
|
|
|
|
nSize = (int)(nSize * dPrintScale + 0.5);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2003-02-05 14:26:24 +00:00
|
|
|
|
|
2008-11-11 16:17:40 +00:00
|
|
|
|
const wxFont& ff1 = XVT_FONT_CACHE.FindOrCreate(nSize, Family(), Style(), Weight(), Underline(), FaceName());
|
|
|
|
|
if (ff1.GetPointSize() > 0)
|
|
|
|
|
return ff1;
|
|
|
|
|
|
|
|
|
|
XVT_FONT_CACHE.Destroy();
|
|
|
|
|
const wxFont& ff2 = XVT_FONT_CACHE.FindOrCreate(nSize, Family(), Style(), Weight(), Underline(), FaceName());
|
|
|
|
|
return ff2;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2004-03-25 16:35:20 +00:00
|
|
|
|
if (rFont.GetWeight() >= wxBOLD)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
m_wMask |= XVT_FS_BOLD;
|
2004-03-25 16:35:20 +00:00
|
|
|
|
if (rFont.GetStyle() == wxITALIC)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2008-11-17 10:02:54 +00:00
|
|
|
|
if (win != NULL_WIN && win != PRINTER_WIN)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
CAST_COLOR(col, colour);
|
|
|
|
|
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(colour, wxSOLID);
|
|
|
|
|
dc.SetBackground(*brush);
|
|
|
|
|
dc.Clear();
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey)
|
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
if (win != NULL_WIN && r != NULL)
|
2005-09-23 15:55:44 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
dc.DrawArc(sx, sy, ex, ey, (r->right+r->left)/2, (r->top+r->bottom)/2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2007-02-19 09:36:55 +00:00
|
|
|
|
void xvt_dwin_draw_gradient_circular(WINDOW win, const RCT* r, COLOR col1, COLOR col2, const PNT* center)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (win != NULL_WIN && r != NULL)
|
2007-02-19 09:36:55 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect rect = NormalizeRCT(r);
|
|
|
|
|
CAST_COLOR(col1, color1);
|
|
|
|
|
CAST_COLOR(col2, color2);
|
2008-03-28 10:19:02 +00:00
|
|
|
|
|
2007-02-19 09:36:55 +00:00
|
|
|
|
if (center != NULL)
|
|
|
|
|
dc.GradientFillConcentric(rect, color1, color2, wxPoint(center->h, center->v));
|
|
|
|
|
else
|
|
|
|
|
dc.GradientFillConcentric(rect, color1, color2);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
}
|
2007-02-19 09:36:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR col2, int angle)
|
|
|
|
|
{
|
2008-11-17 10:02:54 +00:00
|
|
|
|
if (win != NULL_WIN && r != NULL)
|
2007-02-19 09:36:55 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect rect = NormalizeRCT(r);
|
|
|
|
|
CAST_COLOR(col1, color1);
|
|
|
|
|
CAST_COLOR(col2, color2);
|
|
|
|
|
|
|
|
|
|
angle %= 360;
|
|
|
|
|
if (angle < 0)
|
|
|
|
|
angle += 360;
|
|
|
|
|
wxDirection dir = wxDOWN;
|
|
|
|
|
switch (angle / 90)
|
|
|
|
|
{
|
|
|
|
|
case 0: dir = wxRIGHT; break;
|
|
|
|
|
case 1: dir = wxUP; break;
|
|
|
|
|
case 2: dir = wxLEFT; break;
|
|
|
|
|
default: dir = wxDOWN; break;
|
|
|
|
|
}
|
2008-03-28 10:19:02 +00:00
|
|
|
|
|
2007-02-19 09:36:55 +00:00
|
|
|
|
dc.GradientFillLinear(rect, color1, color2, dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid)
|
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
const wxIcon& ico = _GetIconResource(rid);
|
2008-04-08 14:05:10 +00:00
|
|
|
|
if (ico.IsOk())
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
dc.DrawIcon(ico, x, y);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-03 09:42:58 +00:00
|
|
|
|
static wxRect ComputeRect(const wxRect& rct, int h, int v, int k)
|
2003-11-18 09:18:36 +00:00
|
|
|
|
{
|
|
|
|
|
const int sx = rct.x + h * rct.width / k;
|
|
|
|
|
const int ex = rct.x + (h+1) * rct.width / k;
|
|
|
|
|
const int sy = rct.y + v * rct.height / k;
|
|
|
|
|
const int ey = rct.y + (v+1) * rct.height / k;
|
|
|
|
|
return wxRect(sx, sy, ex-sx, ey-sy);
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-03 09:42:58 +00:00
|
|
|
|
static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const wxRect& src)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#ifdef WIN32
|
2004-11-30 22:02:59 +00:00
|
|
|
|
if (!OsWin32_DrawBitmap(image->Bitmap(dc), dc, dst, src))
|
|
|
|
|
{
|
|
|
|
|
const int k = 4;
|
|
|
|
|
for (int h = 0; h < k; h++)
|
2003-12-03 09:42:58 +00:00
|
|
|
|
{
|
2004-11-30 22:02:59 +00:00
|
|
|
|
for (int v = 0; v < k; v++)
|
2003-11-14 16:41:16 +00:00
|
|
|
|
{
|
2004-11-30 22:02:59 +00:00
|
|
|
|
const wxRect destin = ComputeRect(dst, h, v, k);
|
|
|
|
|
wxRect source = ComputeRect(src, h, v, k);
|
|
|
|
|
wxImage img = image->Image().GetSubImage(source);
|
|
|
|
|
source.x = source.y = 0;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
wxBitmap bmp(img);
|
|
|
|
|
OsWin32_DrawBitmap((HBITMAP)bmp.GetHBITMAP(), dc, destin, source);
|
2003-11-14 16:41:16 +00:00
|
|
|
|
}
|
2003-12-03 09:42:58 +00:00
|
|
|
|
}
|
2004-04-27 19:09:18 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#else
|
2004-11-30 22:02:59 +00:00
|
|
|
|
const wxBitmap& bmp = image->Bitmap(dc);
|
2004-04-27 19:09:18 +00:00
|
|
|
|
const bool printing = is_printer_dc(&dc);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
|
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize() && bmp.Ok())
|
|
|
|
|
dc.DrawBitmap(bmp, dst.GetX(), dst.GetY(), !printing);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wxImage img = image->Image().GetSubImage(src);
|
|
|
|
|
|
|
|
|
|
if (dst.GetHeight() < src.GetHeight() ||
|
|
|
|
|
dst.GetWidth() < src.GetWidth())
|
|
|
|
|
img.Rescale(dst.GetWidth() * 4, dst.GetHeight() * 4);
|
|
|
|
|
img.Rescale(dst.GetWidth(), dst.GetHeight());
|
2005-09-23 15:55:44 +00:00
|
|
|
|
wxBitmap bmp(img);
|
|
|
|
|
dc.DrawBitmap(bmp, dst.GetX(), dst.GetY(), !printing);
|
|
|
|
|
}
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#endif
|
2003-12-03 09:42:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE img, const RCT* dest, const RCT* source)
|
2003-12-03 09:42:58 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_TIMAGE(img, image);
|
2003-12-03 09:42:58 +00:00
|
|
|
|
if (image != NULL)
|
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (xvt_dwin_is_update_needed(win, dest))
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect src = NormalizeRCT(source);
|
|
|
|
|
const wxRect dst = NormalizeRCT(dest);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
DrawImageOnDC(dc, image, dst, src);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_dwin_draw_oval(WINDOW win, const RCT* rctp)
|
2004-03-25 16:35:20 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
dc.DrawEllipse(rct);
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_dwin_draw_pie(WINDOW win, const RCT *rctp, int start_x, int start_y, int stop_x, int stop_y)
|
|
|
|
|
{ SORRY_BOX(); }
|
|
|
|
|
|
|
|
|
|
void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts)
|
|
|
|
|
{
|
|
|
|
|
if (lpnts != NULL && npnts > 1)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
wxPoint* pt = new wxPoint[npnts];
|
|
|
|
|
for (int i = 0; i < npnts; i++)
|
|
|
|
|
{
|
|
|
|
|
pt[i].x = lpnts[i].h;
|
|
|
|
|
pt[i].y = lpnts[i].v;
|
|
|
|
|
}
|
|
|
|
|
dc.DrawPolygon(npnts, pt);
|
|
|
|
|
delete pt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_dwin_draw_polyline(WINDOW win, const PNT *lpnts, int npnts)
|
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
if (win != NULL_WIN && lpnts != NULL && npnts > 1) // Occorrono almeno 2 punti
|
2005-09-23 15:55:44 +00:00
|
|
|
|
{
|
|
|
|
|
xvt_dwin_draw_set_pos(win, lpnts[0]);
|
|
|
|
|
for (int i = 1; i < npnts; i++)
|
|
|
|
|
xvt_dwin_draw_line(win, lpnts[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-17 08:38:06 +00:00
|
|
|
|
void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int oval_height)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
dc.DrawRoundedRectangle(rct, min(oval_width, oval_height));
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2003-06-18 08:06:55 +00:00
|
|
|
|
static int can_draw_dots = -1;
|
|
|
|
|
if (can_draw_dots < 0)
|
|
|
|
|
can_draw_dots = xvt_sys_get_os_version() >= XVT_WS_WIN_NT;
|
|
|
|
|
if (can_draw_dots)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
2005-09-28 11:51:41 +00:00
|
|
|
|
OsWin32_DrawDottedRect(dc.GetHDC(), rctp->left, rctp->top, rctp->right, rctp->bottom);
|
2003-06-18 08:06:55 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2003-02-25 15:22:52 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
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);
|
2004-03-11 16:39:25 +00:00
|
|
|
|
wxDC& dc = tdc.GetDC(); // Prima getto il DC ...
|
|
|
|
|
const int delta = tdc.GetFontDelta(); // ... poi faccio la GetFontDelta!
|
2004-06-07 08:56:31 +00:00
|
|
|
|
#ifdef LINUX
|
|
|
|
|
if (tdc._dct.opaque_text)
|
|
|
|
|
{
|
2005-09-28 11:51:41 +00:00
|
|
|
|
RCT back;
|
2004-06-07 08:56:31 +00:00
|
|
|
|
back.left = x;
|
|
|
|
|
back.right = x + xvt_dwin_get_text_width(win, str, -1);
|
|
|
|
|
back.top = y - delta;
|
|
|
|
|
back.bottom = y;
|
|
|
|
|
CAST_COLOR(tdc._dct.back_color, brush_color);
|
|
|
|
|
|
|
|
|
|
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(brush_color, wxSOLID);
|
2005-09-23 15:55:44 +00:00
|
|
|
|
const wxBrush & old_brush = dc.GetBrush();
|
|
|
|
|
const wxPen & old_pen = dc.GetPen();
|
2004-06-07 08:56:31 +00:00
|
|
|
|
const wxRect rct = NormalizeRCT(&back);
|
|
|
|
|
|
|
|
|
|
dc.SetBrush(*brush);
|
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
|
dc.DrawRectangle(rct);
|
|
|
|
|
dc.SetBrush(old_brush);
|
|
|
|
|
dc.SetPen(old_pen);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2004-03-11 16:39:25 +00:00
|
|
|
|
dc.DrawText(str, x, y-delta);
|
2003-05-22 15:07:21 +00:00
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
2008-11-13 11:19:48 +00:00
|
|
|
|
DRAW_CTOOLS* xvt_dwin_get_draw_ctools(WINDOW win, DRAW_CTOOLS* ctoolsp)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
2008-11-28 09:55:06 +00:00
|
|
|
|
// Attenzione: non funziona la chiamate in cascata a xvt_font_get_metrics
|
|
|
|
|
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;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
int width = 0;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (s && *s && len != 0)
|
|
|
|
|
{
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
wxString str = s;
|
|
|
|
|
if (str.StartsWith("ABCDEFGH") || str.StartsWith("MMMMMMMM"))
|
|
|
|
|
{
|
2004-04-28 09:49:37 +00:00
|
|
|
|
const wxString emme('G', str.Length()); // Questa lettera cambia con le mode
|
2002-02-28 14:26:23 +00:00
|
|
|
|
str = emme;
|
|
|
|
|
}
|
2008-04-04 16:04:47 +00:00
|
|
|
|
if (len > 0)
|
|
|
|
|
str.Truncate(len);
|
2008-11-11 16:17:40 +00:00
|
|
|
|
int height = 0;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
dc.GetTextExtent(str, &width, &height);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return width;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
void xvt_dwin_invalidate_rect(WINDOW win, const RCT* rctp)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-04-04 16:04:47 +00:00
|
|
|
|
if (win != NULL_WIN)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
2008-10-24 15:49:08 +00:00
|
|
|
|
if (rctp != NULL)
|
2008-04-04 16:04:47 +00:00
|
|
|
|
{
|
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
2008-10-24 15:49:08 +00:00
|
|
|
|
w.Refresh(false, &rct);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2008-10-24 15:49:08 +00:00
|
|
|
|
w.Refresh(false);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
BOOLEAN xvt_dwin_is_update_needed(WINDOW win, const RCT* rctp)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (win != NULL_WIN && rctp != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2005-09-28 11:51:41 +00:00
|
|
|
|
if (win == PRINTER_WIN || win == SCREEN_WIN)
|
2005-02-17 18:13:12 +00:00
|
|
|
|
return TRUE;
|
2008-10-24 15:49:08 +00:00
|
|
|
|
CAST_WIN(win, w); // child windows and TASK_WIN
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxRect rect1 = NormalizeRCT(rctp);
|
2008-11-17 10:02:54 +00:00
|
|
|
|
const wxRect rect2 = w.GetUpdateClientRect(); // w.GetUpdateRegion().GetBox();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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
|
|
|
|
{
|
2008-09-26 13:35:22 +00:00
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
|
|
|
|
if (!rct.IsEmpty())
|
|
|
|
|
// w.ScrollWindow(dh, dv, &rct); // Metodo ortodosso ma impreciso di un pixel
|
2008-10-24 15:49:08 +00:00
|
|
|
|
w.Refresh(false, &rct); // Pezza "TEMPORANEA" per evitare artefatti
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_dwin_set_clip(WINDOW win, const RCT* rctp)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TDC(win, dc);
|
|
|
|
|
dc.SetClippingBox(rctp);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
dc.SetDirty();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
CAST_TDC(win, dc);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_dwin_set_std_cbrush(WINDOW win, long flag)
|
|
|
|
|
{
|
|
|
|
|
CBRUSH brush;
|
|
|
|
|
brush.pat = PAT_SOLID;
|
|
|
|
|
switch (flag)
|
|
|
|
|
{
|
|
|
|
|
case TL_BRUSH_BLACK: brush.color = COLOR_BLACK; break;
|
|
|
|
|
case TL_BRUSH_WHITE: brush.color = COLOR_WHITE; break;
|
|
|
|
|
default: SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
xvt_dwin_set_cbrush(win, &brush);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
pen.pat = PAT_SOLID;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
switch(flag)
|
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
|
case TL_PEN_BLACK : pen.color = COLOR_BLACK; break;
|
|
|
|
|
case TL_PEN_DKGRAY: pen.color = COLOR_DKGRAY; break;
|
|
|
|
|
case TL_PEN_GRAY : pen.color = COLOR_GRAY; break;
|
|
|
|
|
case TL_PEN_LTGRAY: pen.color = COLOR_LTGRAY; break;
|
|
|
|
|
case TL_PEN_WHITE : pen.color = COLOR_WHITE; break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case TL_PEN_HOLLOW: pen.pat = PAT_HOLLOW; 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)
|
|
|
|
|
{
|
2003-12-19 08:17:48 +00:00
|
|
|
|
CAST_TDC(win, tdc);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxPoint to(pnt.h, pnt.v);
|
2003-12-19 08:17:48 +00:00
|
|
|
|
wxDC& dc = tdc.GetDC();
|
|
|
|
|
if (tdc._pnt != to)
|
|
|
|
|
dc.DrawLine(tdc._pnt, to);
|
2008-09-26 13:35:22 +00:00
|
|
|
|
// dc.DrawPoint(to); // Un giorno capiro' il perche' servisse
|
2003-12-19 08:17:48 +00:00
|
|
|
|
tdc._pnt = to;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_dwin_update(WINDOW win)
|
|
|
|
|
{
|
2003-12-19 08:17:48 +00:00
|
|
|
|
CAST_WIN(win, w);
|
2003-12-03 09:42:58 +00:00
|
|
|
|
w.Update();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// 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);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(dest_font_id, dst);
|
|
|
|
|
CAST_FONT(src_font_id, src);
|
|
|
|
|
dst = src;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2005-09-28 11:51:41 +00:00
|
|
|
|
void xvt_font_deserialize(XVT_FNTID font_id, const char* buf)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font)
|
|
|
|
|
const 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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
if (font_id != NULL)
|
|
|
|
|
{
|
|
|
|
|
TFontId* fp = wxStaticCast(font_id, TFontId);
|
|
|
|
|
delete fp;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_font_get_family(XVT_FNTID font_id, char* buf, long max_buf)
|
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
BOOLEAN ok = font_id != NULL && buf != NULL && max_buf > 0;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
CAST_FONT(font_id, font);
|
|
|
|
|
wxStrncpy(buf, font.FaceName(), max_buf);
|
|
|
|
|
buf[max_buf-1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
WINDOW win = font.Win();
|
2008-11-11 16:17:40 +00:00
|
|
|
|
if (win != PRINTER_WIN)
|
|
|
|
|
win = TASK_WIN; // Non mi fido troppo della finestra su cui il font e' mappato
|
|
|
|
|
CAST_DC(win, dc);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxString str = "Mq";
|
2008-11-11 16:17:40 +00:00
|
|
|
|
int height = 0, desc = 0, lead = 0;
|
|
|
|
|
const wxFont& ff = font.Font(&dc, win);
|
|
|
|
|
dc.GetTextExtent(str, NULL, &height, &desc, &lead, (wxFont*)&ff);
|
|
|
|
|
if (height <= 0 || height > 64000) // Gestisce eventuali anomalie alla meno peggio
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(false);
|
|
|
|
|
height = ff.GetPointSize();
|
|
|
|
|
desc = height / 5;
|
|
|
|
|
lead = 0;
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
const long len = xvt_font_serialize(font_id, buf, max_buf);
|
|
|
|
|
return len > 0 && len < max_buf;
|
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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
|
|
|
|
return font.PointSize();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_FONT_STYLE_MASK xvt_font_get_style(XVT_FNTID font_id)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
|
|
|
|
return font.Mask();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_font_get_win(XVT_FNTID font_id)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
|
|
|
|
return font.Win();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_font_is_mapped(XVT_FNTID font_id)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return xvt_font_get_win(font_id) != NULL_WIN;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_map(XVT_FNTID font_id, WINDOW win)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
|
|
|
|
font.SetWin(win);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_font_set_family(XVT_FNTID font_id, const char* family)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
font.SetFaceName(family);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_set_size(XVT_FNTID font_id, long size)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const char* name = font.FaceName();
|
|
|
|
|
const int size = font.PointSize();
|
|
|
|
|
const int italic = (font.Mask() & XVT_FS_ITALIC) != 0;
|
2008-11-11 16:17:40 +00:00
|
|
|
|
const int weight = (font.Mask() & XVT_FS_BOLD) ? 700 : 400;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
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);
|
2008-11-11 16:17:40 +00:00
|
|
|
|
if (buf != NULL && max_buf > 0)
|
|
|
|
|
{
|
|
|
|
|
wxStrncpy(buf, str, max_buf);
|
|
|
|
|
buf[max_buf-1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
return str.Len();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_font_unmap(XVT_FNTID font_id)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
font.SetWin(NULL_WIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// File system
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-10-20 14:59:24 +00:00
|
|
|
|
BOOLEAN xvt_fsys_build_pathname(char* mbs, const char* volname, const char* dirname, const char* leafroot, const char* leafext, const char* /* leafvers */)
|
2003-04-22 14:01:47 +00:00
|
|
|
|
{
|
|
|
|
|
#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)
|
|
|
|
|
{
|
2003-10-03 11:01:47 +00:00
|
|
|
|
if (!wxEndsWithPathSeparator(mbs) && !wxIsPathSeparator(*leafroot))
|
2003-04-22 14:01:47 +00:00
|
|
|
|
strcat(mbs, "/");
|
|
|
|
|
strcat(mbs, leafroot);
|
|
|
|
|
}
|
|
|
|
|
if (leafext && *leafext)
|
|
|
|
|
{
|
|
|
|
|
if (*leafext != '.')
|
|
|
|
|
strcat(mbs, ".");
|
|
|
|
|
strcat(mbs, leafext);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-20 14:59:24 +00:00
|
|
|
|
BOOLEAN xvt_fsys_parse_pathname(const char* mbs, char* volname, char* dirname, char* leafroot, char* leafext, char* leafvers)
|
2003-04-22 14:01:47 +00:00
|
|
|
|
{
|
|
|
|
|
wxString volume, path, file, ext;
|
|
|
|
|
wxFileName::SplitPath(mbs, &volume, &path, &file, &ext);
|
2003-05-23 10:32:27 +00:00
|
|
|
|
if (volname)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (mbs[0] == mbs[1] && wxIsPathSeparator(mbs[0]))
|
2007-11-14 16:41:17 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
volume.insert(size_t(0), size_t(2), wxFILE_SEP_PATH); // Mette due slash all'inizio
|
|
|
|
|
if (!wxIsPathSeparator(path[0]))
|
|
|
|
|
volume << wxFILE_SEP_PATH; // Accoda uno slash
|
2007-11-14 16:41:17 +00:00
|
|
|
|
path.insert(0, volume);
|
|
|
|
|
*volname = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
wxStrcpy(volname, volume);
|
2003-05-23 10:32:27 +00:00
|
|
|
|
#ifdef WIN32
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (volname[0] != '\0' && volname[1] == '\0')
|
|
|
|
|
wxStrcat(volname, ":");
|
2003-05-23 10:32:27 +00:00
|
|
|
|
#endif
|
2007-12-12 09:43:46 +00:00
|
|
|
|
}
|
2007-11-14 16:41:17 +00:00
|
|
|
|
}
|
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?
|
2007-11-14 16:41:17 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-04-22 14:01:47 +00:00
|
|
|
|
|
2008-10-20 14:59:24 +00:00
|
|
|
|
BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY* dirp, char* path, int sz_path)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
BOOLEAN ok = dirp != NULL && path != NULL && sz_path > 0;
|
2008-10-20 14:59:24 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
wxStrncpy(path, dirp->path, sz_path-1);
|
|
|
|
|
path[sz_path-1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp)
|
|
|
|
|
{
|
2008-10-20 14:59:24 +00:00
|
|
|
|
BOOLEAN ok = path != NULL && dirp != NULL;
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
const int sz = sizeof(dirp->path)-1;
|
|
|
|
|
wxStrncpy(dirp->path, path, sz);
|
|
|
|
|
dirp->path[sz] = '\0';
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN ok = FALSE;
|
2008-11-11 16:17:40 +00:00
|
|
|
|
if (fs != NULL && path != NULL && sz_path > 0)
|
2006-12-13 16:22:33 +00:00
|
|
|
|
{
|
2008-01-17 11:04:08 +00:00
|
|
|
|
char mbs[_MAX_PATH];
|
2006-12-13 16:22:33 +00:00
|
|
|
|
xvt_fsys_build_pathname(mbs, "", fs->dir.path, fs->name, fs->type, NULL);
|
|
|
|
|
wxStrncpy(path, mbs, sz_path);
|
2008-01-17 11:04:08 +00:00
|
|
|
|
ok = *path > ' ';
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN ok = FALSE;
|
|
|
|
|
if (mbs && *mbs && fs != NULL)
|
|
|
|
|
{
|
2008-01-17 11:04:08 +00:00
|
|
|
|
memset(fs, 0, sizeof(FILE_SPEC));
|
2007-12-12 09:43:46 +00:00
|
|
|
|
char volume[_MAX_DRIVE], path[_MAX_PATH];
|
|
|
|
|
xvt_fsys_parse_pathname(mbs, volume, path, fs->name, fs->type, NULL);
|
|
|
|
|
wxStrcpy(fs->dir.path, volume);
|
|
|
|
|
wxStrcat(fs->dir.path, path);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
wxStrcpy(fs->creator, "CAMPO");
|
2007-11-14 16:41:17 +00:00
|
|
|
|
ok = fs->name[0] != '\0';
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
void xvt_fsys_get_default_dir(DIRECTORY *dirp)
|
|
|
|
|
{
|
2007-02-19 09:36:55 +00:00
|
|
|
|
if (_startup_dir.IsEmpty())
|
|
|
|
|
_startup_dir = ::wxGetCwd();
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
return xvt_fsys_convert_str_to_dir(::wxGetCwd(), dirp);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
static wxString get_disk_root(const char* path)
|
|
|
|
|
{
|
|
|
|
|
wxString str;
|
|
|
|
|
if (path && *path)
|
|
|
|
|
{
|
|
|
|
|
str = path;
|
|
|
|
|
if (!wxEndsWithPathSeparator(str))
|
|
|
|
|
str << wxFILE_SEP_PATH;
|
|
|
|
|
|
|
|
|
|
wxChar drive[_MAX_DRIVE], dir[_MAX_DIR];
|
|
|
|
|
xvt_fsys_parse_pathname(str,drive,dir,NULL,NULL,NULL);
|
|
|
|
|
|
|
|
|
|
if (*drive)
|
|
|
|
|
str = drive;
|
|
|
|
|
else
|
|
|
|
|
str = dir;
|
|
|
|
|
|
|
|
|
|
if (!wxEndsWithPathSeparator(str))
|
|
|
|
|
str << wxFILE_SEP_PATH;
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Il disco e' un floppy?
|
|
|
|
|
BOOLEAN xvt_fsys_is_floppy_drive(const char* path)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN yes = xvt_fsys_is_removable_drive(path);
|
|
|
|
|
if (yes)
|
|
|
|
|
{
|
|
|
|
|
const unsigned long mb = xvt_fsys_get_disk_size(path, 'M'); // Dimensioni in Mb
|
|
|
|
|
yes = mb < 4; // E' un vero floppy solo se e' piu' piccolo di 4 Mb
|
|
|
|
|
}
|
|
|
|
|
return yes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Il disco e' rimuovibile? (floppy / memory stick)
|
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
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
BOOLEAN yes = FALSE;
|
|
|
|
|
|
|
|
|
|
if (path && *path)
|
|
|
|
|
{
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#ifdef WIN32
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const wxString strRoot = get_disk_root(path);
|
2008-11-11 16:17:40 +00:00
|
|
|
|
yes = ::GetDriveType(strRoot) == DRIVE_REMOVABLE;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
2007-12-12 09:43:46 +00:00
|
|
|
|
char dev[_MAX_PATH];
|
|
|
|
|
OsLinux_GetFileSys(path, dev, NULL, NULL);
|
|
|
|
|
yes = strncmp(dev, "/dev/fd", 7) == 0;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#endif
|
2007-12-12 09:43:46 +00:00
|
|
|
|
}
|
|
|
|
|
return yes;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_is_network_drive(const char* path)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
BOOLEAN yes = FALSE;
|
|
|
|
|
if (path && *path)
|
|
|
|
|
{
|
|
|
|
|
if (wxIsPathSeparator(path[0]) && wxIsPathSeparator(path[1]))
|
|
|
|
|
yes = TRUE;
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#ifdef WIN32
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const wxString strRoot = get_disk_root(path);
|
2008-11-11 16:17:40 +00:00
|
|
|
|
yes = ::GetDriveType(strRoot) == DRIVE_REMOTE;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
2007-12-12 09:43:46 +00:00
|
|
|
|
yes = OsLinux_IsNetworkDrive(path);
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#endif
|
2007-12-12 09:43:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return yes;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_is_fixed_drive(const char* path)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
BOOLEAN yes = FALSE;
|
|
|
|
|
if (path && *path)
|
|
|
|
|
{
|
|
|
|
|
if (!wxIsPathSeparator(path[0]) || !wxIsPathSeparator(path[1]))
|
|
|
|
|
{
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#ifdef WIN32
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const wxString strRoot = get_disk_root(path);
|
2008-11-11 16:17:40 +00:00
|
|
|
|
yes = ::GetDriveType(strRoot) == DRIVE_FIXED;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
2007-12-12 09:43:46 +00:00
|
|
|
|
yes = !(xvt_fsys_is_network_drive(path) || xvt_fsys_is_removable_drive(path));
|
2003-03-28 15:33:49 +00:00
|
|
|
|
#endif
|
2007-12-12 09:43:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return yes;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned long compute_disk_size(const char* path, bool tot, char unit)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
long nVal = 0;
|
|
|
|
|
if (path && *path)
|
|
|
|
|
{
|
|
|
|
|
const wxString strRoot = get_disk_root(path);
|
|
|
|
|
wxLongLong total = 0, unused = 0;
|
2007-12-18 10:52:34 +00:00
|
|
|
|
wxGetDiskSpace(strRoot, &total, &unused);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
__int64 nBytes = tot ? total.ToDouble() : unused.ToDouble();
|
2003-03-28 15:33:49 +00:00
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (nBytes > 0)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
default : break;
|
|
|
|
|
}
|
|
|
|
|
const unsigned long nMax = (unsigned long)(~0L);
|
|
|
|
|
nVal = nBytes > nMax ? nMax : (unsigned long)nBytes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nVal;
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
// Usr friendly implementation
|
|
|
|
|
long xvt_fsys_file_attr(const char* path, long attr)
|
|
|
|
|
{
|
|
|
|
|
long ret = 0;
|
|
|
|
|
if (path && *path && attr >= XVT_FILE_ATTR_MINIMUM && attr <= XVT_FILE_ATTR_MAXIMUM)
|
|
|
|
|
{
|
|
|
|
|
const wxString name(path);
|
|
|
|
|
switch (attr)
|
|
|
|
|
{
|
|
|
|
|
case XVT_FILE_ATTR_EXIST:
|
|
|
|
|
ret = ::wxFileExists(name);
|
|
|
|
|
break;
|
|
|
|
|
case XVT_FILE_ATTR_READ:
|
|
|
|
|
ret = ::wxAccess(name, 0x1) != 0;
|
|
|
|
|
break;
|
|
|
|
|
case XVT_FILE_ATTR_WRITE:
|
|
|
|
|
ret = ::wxAccess(name, 0x2) != 0;
|
|
|
|
|
break;
|
|
|
|
|
case XVT_FILE_ATTR_DIRECTORY:
|
|
|
|
|
ret = ::wxDirExists(name);
|
|
|
|
|
break;
|
|
|
|
|
case XVT_FILE_ATTR_SIZE:
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const wxULongLong sz = wxFileName::GetSize(name);
|
2007-12-13 15:11:01 +00:00
|
|
|
|
ret = sz.GetHi() != 0 ? INT_MAX : sz.GetLo();
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case XVT_FILE_ATTR_MTIME:
|
|
|
|
|
ret = ::wxFileModificationTime(name);
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Original XVT implementation
|
|
|
|
|
long xvt_fsys_get_file_attr(const FILE_SPEC* fs, long attr)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
char mbs[_MAX_PATH]; xvt_fsys_convert_fspec_to_str(fs, mbs, sizeof(mbs));
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return xvt_fsys_file_attr(mbs, attr);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// File system
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2007-03-16 13:33:09 +00:00
|
|
|
|
SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
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())
|
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#ifdef WIN32
|
2003-01-28 14:27:05 +00:00
|
|
|
|
if (f.StartsWith(".\\"))
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#else
|
|
|
|
|
if (f.StartsWith("./"))
|
|
|
|
|
#endif
|
2003-01-28 14:27:05 +00:00
|
|
|
|
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()
|
|
|
|
|
{
|
2008-12-16 14:47:30 +00:00
|
|
|
|
wxASSERT(!_strSavedir.IsEmpty());
|
2002-02-28 14:26:23 +00:00
|
|
|
|
::wxSetWorkingDirectory(_strSavedir);
|
2008-12-16 14:47:30 +00:00
|
|
|
|
_strSavedir = wxEmptyString;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_fsys_save_dir()
|
|
|
|
|
{
|
2008-12-16 14:47:30 +00:00
|
|
|
|
wxASSERT(_strSavedir.IsEmpty());
|
2002-02-28 14:26:23 +00:00
|
|
|
|
_strSavedir = ::wxGetCwd();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-16 14:47:30 +00:00
|
|
|
|
BOOLEAN xvt_fsys_set_dir(const DIRECTORY *dirp)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
return ::wxSetWorkingDirectory(dirp->path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Images
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2004-06-04 13:01:45 +00:00
|
|
|
|
XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* src)
|
|
|
|
|
{
|
|
|
|
|
wxRect r;
|
|
|
|
|
if (src == NULL)
|
|
|
|
|
{
|
|
|
|
|
RCT rct; xvt_vobj_get_client_rect(win, &rct);
|
|
|
|
|
r = NormalizeRCT(&rct);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
r = NormalizeRCT(src);
|
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
wxBitmap bmp(r.GetWidth(), r.GetHeight());
|
2004-06-04 13:01:45 +00:00
|
|
|
|
CAST_DC(win, wdc);
|
2005-09-28 11:51:41 +00:00
|
|
|
|
|
2008-06-13 08:48:18 +00:00
|
|
|
|
wxMemoryDC mdc(bmp);
|
2004-06-04 13:01:45 +00:00
|
|
|
|
mdc.Blit(wxPoint(0,0), r.GetSize(), &wdc, r.GetPosition());
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
|
|
|
|
TXVT_IMAGE* i = new TXVT_IMAGE;
|
|
|
|
|
i->Image() = bmp.ConvertToImage();
|
2004-06-04 13:01:45 +00:00
|
|
|
|
|
|
|
|
|
return (XVT_IMAGE)i;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 15:39:33 +00:00
|
|
|
|
void xvt_image_destroy(XVT_IMAGE img)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_TIMAGE(img, image);
|
2008-06-13 08:48:18 +00:00
|
|
|
|
if (image != NULL)
|
2008-06-19 15:39:33 +00:00
|
|
|
|
delete image;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 16:17:40 +00:00
|
|
|
|
int xvt_image_find_clut_index(XVT_IMAGE img, COLOR rgb)
|
|
|
|
|
{
|
|
|
|
|
CAST_IMAGE(img, image);
|
|
|
|
|
int i = -1;
|
|
|
|
|
if (image && image->Ok() && image->HasPalette())
|
|
|
|
|
{
|
|
|
|
|
const wxPalette& pal = image->GetPalette();
|
|
|
|
|
for (i = 255; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
unsigned char ri, gi, bi;
|
|
|
|
|
if (pal.GetRGB(i, &ri, &gi, &bi))
|
|
|
|
|
{
|
|
|
|
|
const COLOR rgbi = XVT_MAKE_COLOR(ri, gi, bi);
|
|
|
|
|
if ((rgbi & 0x00FFFFFF) == (rgb & 0x00FFFFFF))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 15:39:33 +00:00
|
|
|
|
COLOR xvt_image_get_clut(XVT_IMAGE img, short index)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_IMAGE(img, image);
|
|
|
|
|
if (image && image->Ok() && image->HasPalette())
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
const wxPalette& pal = image->GetPalette();
|
|
|
|
|
unsigned char r, g, b;
|
2008-11-11 16:17:40 +00:00
|
|
|
|
if (pal.GetRGB(index, &r, &g, &b))
|
|
|
|
|
return XVT_MAKE_COLOR(r, g, b);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return COLOR_INVALID;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
void xvt_image_get_dimensions(XVT_IMAGE image, short* width, short* height)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-06-19 15:39:33 +00:00
|
|
|
|
*width = *height = 0;
|
2008-07-11 11:16:52 +00:00
|
|
|
|
|
|
|
|
|
CAST_IMAGE(image, img);
|
|
|
|
|
if (img != NULL && img->Ok())
|
2008-06-19 15:39:33 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
*width = img->GetWidth();
|
|
|
|
|
*height = img->GetHeight();
|
2008-06-19 15:39:33 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_IMAGE(image, img);
|
|
|
|
|
if (img != NULL && img->Ok())
|
|
|
|
|
return img->HasPalette() ? XVT_IMAGE_CL8 : XVT_IMAGE_RGB;
|
2008-06-19 15:39:33 +00:00
|
|
|
|
return XVT_IMAGE_NONE;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
short xvt_image_get_ncolors(XVT_IMAGE image)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
int n = 0;
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_IMAGE(image, i);
|
|
|
|
|
if (i != NULL && i->Ok() && i->HasPalette())
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
const wxPalette& pal = i->GetPalette();
|
|
|
|
|
unsigned char r, g, b;
|
|
|
|
|
for (n = 16; n < 256; n++)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
if (!pal.GetRGB(n, &r, &g, &b))
|
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return n;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y)
|
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
CAST_TIMAGE(image, i);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
if (i != NULL && i->Ok())
|
2008-11-11 16:17:40 +00:00
|
|
|
|
return i->GetPixel(x, y);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return COLOR_INVALID;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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;
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#ifdef WIN32
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxString name = filenamep;
|
2004-04-27 19:09:18 +00:00
|
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
|
wxString name;
|
2004-04-27 19:09:18 +00:00
|
|
|
|
if (isalpha(filenamep[0u]))
|
|
|
|
|
{
|
2007-02-19 09:36:55 +00:00
|
|
|
|
name = _startup_dir;
|
2004-04-27 19:09:18 +00:00
|
|
|
|
name += "/";
|
|
|
|
|
}
|
|
|
|
|
name += filenamep;
|
|
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
if (::wxFileExists(name))
|
|
|
|
|
{
|
|
|
|
|
i = new TXVT_IMAGE;
|
2008-07-11 11:16:52 +00:00
|
|
|
|
i->LoadFile(name);
|
|
|
|
|
if (!i->Ok())
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_TIMAGE(image, i);
|
|
|
|
|
if (i != NULL && i->Ok() && i->HasPalette())
|
2008-06-19 15:39:33 +00:00
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
CAST_COLOR(color, c);
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxImage& bmp = i->Image(); // Set dirty!
|
2008-11-11 16:17:40 +00:00
|
|
|
|
|
|
|
|
|
unsigned char ri, gi, bi;
|
|
|
|
|
bmp.GetOrFindMaskColour(&ri,&gi, &bi);
|
|
|
|
|
const int idx = xvt_image_find_clut_index(image, XVT_MAKE_COLOR(ri, gi, bi));
|
|
|
|
|
if (idx == index)
|
|
|
|
|
bmp.SetMaskColour(c.Red(), c.Green(), c.Blue());
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
const wxPalette& pal = bmp.GetPalette();
|
|
|
|
|
pal.GetRGB(index, &ri, &gi, &bi);
|
2008-11-11 16:17:40 +00:00
|
|
|
|
const COLOR old_color = XVT_MAKE_COLOR(ri, gi, bi);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
|
|
|
|
|
const int w = bmp.GetWidth();
|
|
|
|
|
const int h = bmp.GetHeight();
|
|
|
|
|
for (int y = 0; y < h; y++) for (int x = 0; x < w; x++)
|
2008-06-19 15:39:33 +00:00
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
const COLOR rgb = i->GetPixel(x, y);
|
|
|
|
|
if (rgb == old_color)
|
|
|
|
|
i->SetPixel(x, y, color);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_TIMAGE(image, i);
|
|
|
|
|
if (i != NULL && i->Ok())
|
2008-11-11 16:17:40 +00:00
|
|
|
|
i->SetPixel(x, y, color);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_TIMAGE(dstimage, dst);
|
|
|
|
|
CAST_TIMAGE(srcimage, src);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
if (dst != NULL && src != NULL)
|
|
|
|
|
{
|
|
|
|
|
const wxRect rctDst = NormalizeRCT(dstrctp);
|
|
|
|
|
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
|
|
|
|
wxMemoryDC dc;
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxBitmap bmp(*dst);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
dc.SelectObject(bmp);
|
|
|
|
|
DrawImageOnDC(dc, src, rctDst, rctSrc);
|
|
|
|
|
dst->Image() = bmp.ConvertToImage();
|
|
|
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
|
}
|
2002-07-03 14:53:33 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
static int xvt_menu_count(const MENU_ITEM* m)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-09-19 15:34:00 +00:00
|
|
|
|
int n = 0;
|
|
|
|
|
if (m != NULL)
|
|
|
|
|
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;
|
2008-09-19 15:34:00 +00:00
|
|
|
|
if (m != NULL && m->tag != 0)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
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++)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
if (mi->separator || mi->text == NULL)
|
2006-12-29 14:16:28 +00:00
|
|
|
|
menu.AppendSeparator();
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-09-19 15:34:00 +00:00
|
|
|
|
wxMenuItem* item = NULL;
|
|
|
|
|
if (mi->checkable)
|
2006-12-29 14:16:28 +00:00
|
|
|
|
item = menu.AppendCheckItem(mi->tag, mi->text);
|
|
|
|
|
else
|
|
|
|
|
item = menu.Append(mi->tag, mi->text);
|
2008-10-24 15:49:08 +00:00
|
|
|
|
// Operazioni fattibili solo dopo la menu.Append(), non prima!
|
|
|
|
|
item->Enable(mi->enabled);
|
2007-04-06 14:47:24 +00:00
|
|
|
|
if (mi->checkable)
|
|
|
|
|
item->Check(mi->checked);
|
|
|
|
|
}
|
2003-06-03 13:09:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-19 15:34:00 +00:00
|
|
|
|
wxPoint mp = wxDefaultPosition;
|
|
|
|
|
if (pos.h >= 0 && pos.v >= 0)
|
|
|
|
|
{
|
|
|
|
|
mp.x = pos.h;
|
|
|
|
|
mp.y = pos.v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
return w.PopupMenu(&menu, mp);
|
2003-06-03 13:09:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
wxMenuBar* pMenuBar = _task_win->GetMenuBar();
|
2002-09-13 14:56:23 +00:00
|
|
|
|
if (pMenuBar != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (int m = pMenuBar->GetMenuCount()-1; m >= 0; m--)
|
|
|
|
|
{
|
2006-08-01 10:35:58 +00:00
|
|
|
|
const wxString ita = pMenuBar->GetLabelTop(m);
|
2002-09-13 14:56:23 +00:00
|
|
|
|
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 */ }
|
|
|
|
|
|
2008-09-29 14:18:26 +00:00
|
|
|
|
static wxMenuItem* GetXvtMenuItem(WINDOW win, MENU_TAG tag)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-09-29 14:18:26 +00:00
|
|
|
|
wxMenuItem* item = NULL;
|
|
|
|
|
wxFrame* pFrame = wxDynamicCast((wxObject*)win, wxFrame);
|
|
|
|
|
if (pFrame != NULL)
|
|
|
|
|
{
|
|
|
|
|
wxMenuBar* bar = pFrame->GetMenuBar();
|
|
|
|
|
if (bar != NULL)
|
2008-10-24 15:49:08 +00:00
|
|
|
|
item = bar->FindItem(tag);
|
2008-09-29 14:18:26 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, const char* text)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
TTaskWin* w = wxStaticCast((wxObject*)win, TTaskWin); //occhio
|
|
|
|
|
w->SetMenuTree(tree);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAST_TWIN(win, w);
|
|
|
|
|
w.SetMenuTree(tree);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
void xvt_menu_update(WINDOW /*win*/)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
wxMenuBar* bar = _task_win->GetMenuBar();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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
|
|
|
|
|
///////////////////////////////////////////////////////////
|
2008-10-24 15:49:08 +00:00
|
|
|
|
int xvt_rect_get_height(const RCT *rctp)
|
2002-04-26 10:50:41 +00:00
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return rctp ? abs(rctp->bottom - rctp->top) : 0;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
// 3.1 return rctp ? rctp->bottom - rctp->top : 0;
|
2002-04-26 10:50:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
int xvt_rect_get_width(const RCT *rctp)
|
2002-04-26 10:50:41 +00:00
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return rctp ? abs(rctp->right - rctp->left) : 0;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
// 3.1 return rctp ? rctp->right - rctp->left : 0;
|
2002-04-26 10:50:41 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
BOOLEAN xvt_rect_has_point(const RCT *rctp, PNT pnt)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxRect rct = NormalizeRCT(rctp);
|
2008-03-28 10:19:02 +00:00
|
|
|
|
return rct.Contains(pnt.h, pnt.v);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-24 15:49:08 +00:00
|
|
|
|
BOOLEAN xvt_rect_intersect(RCT *drctp, const RCT *rctp1, const RCT *rctp2)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
|
|
|
|
const wxRect rect1 = NormalizeRCT(rctp1);
|
|
|
|
|
const wxRect rect2 = NormalizeRCT(rctp2);
|
2008-10-24 15:49:08 +00:00
|
|
|
|
const BOOLEAN yes = RectIntersect(rect1, rect2);
|
|
|
|
|
if (drctp)
|
2008-01-24 11:00:12 +00:00
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
if (yes)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
drctp->left = drctp->right = rect1.x;
|
|
|
|
|
drctp->top = drctp->bottom = rect1.y;
|
|
|
|
|
}
|
2008-01-24 11:00:12 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-19 09:36:55 +00:00
|
|
|
|
void xvt_rect_inflate(RCT *rctp, short ix, short iy)
|
|
|
|
|
{
|
|
|
|
|
if (rctp != NULL)
|
|
|
|
|
{
|
|
|
|
|
rctp->left -= ix; rctp->right += ix;
|
|
|
|
|
rctp->top -= iy; rctp->bottom += iy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-26 13:35:22 +00:00
|
|
|
|
XVT_FNTID xvt_res_get_font(int rid)
|
|
|
|
|
{
|
|
|
|
|
XVT_FNTID f = xvt_font_create();
|
|
|
|
|
if (rid <= 0)
|
|
|
|
|
{
|
|
|
|
|
CAST_FONT(f, font);
|
|
|
|
|
font.Copy(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
|
|
|
|
}
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 16:17:40 +00:00
|
|
|
|
XVT_IMAGE xvt_res_get_icon(int rid)
|
|
|
|
|
{
|
|
|
|
|
const wxString strFileName = _GetResourceName("Icon", rid);
|
|
|
|
|
const bool ok = !strFileName.IsEmpty();
|
|
|
|
|
XVT_ASSERT(ok);
|
|
|
|
|
return ok ? xvt_image_read(strFileName) : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
XVT_IMAGE xvt_res_get_image(int rid)
|
|
|
|
|
{
|
2008-04-04 16:04:47 +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)
|
|
|
|
|
{
|
2006-12-29 14:16:28 +00:00
|
|
|
|
comma = (char*)strchr(s, ',');
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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];
|
2005-03-03 15:42:04 +00:00
|
|
|
|
const int accelera = str.Find('&');
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2003-12-19 08:17:48 +00:00
|
|
|
|
wxFileConfig ini("", "", GetResourceIni());
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2003-12-19 08:17:48 +00:00
|
|
|
|
wxString strName;
|
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);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
const wxString str = _GetResourceName("String", rid);
|
2008-10-20 14:59:24 +00:00
|
|
|
|
wxStrncpy(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;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
#define CAST_GAUGE(win, pb) XVT_ASSERT(win != NULL_WIN); wxGauge& pb = *(wxGauge*)win;
|
2008-05-20 14:06:05 +00:00
|
|
|
|
#define CAST_SLIDER(win, sc) XVT_ASSERT(win != NULL_WIN); wxSlider& sc = *(wxSlider*)win;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-05-20 14:06:05 +00:00
|
|
|
|
int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-05-20 14:06:05 +00:00
|
|
|
|
int pos = 0;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
switch (t)
|
|
|
|
|
{
|
|
|
|
|
case HSCROLL:
|
|
|
|
|
case VSCROLL:
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
2008-05-20 14:06:05 +00:00
|
|
|
|
pos = w.GetScrollPos(dir);
|
2007-04-06 14:47:24 +00:00
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
break;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
case HVGAUGE:
|
|
|
|
|
{
|
|
|
|
|
CAST_GAUGE(win, g);
|
2008-05-20 14:06:05 +00:00
|
|
|
|
pos = g.GetValue();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HVSLIDER:
|
|
|
|
|
{
|
|
|
|
|
CAST_SLIDER(win, g);
|
|
|
|
|
pos = g.GetValue();
|
2007-04-06 14:47:24 +00:00
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
break;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
2008-05-20 14:06:05 +00:00
|
|
|
|
pos = sb.GetThumbPosition();
|
2007-04-06 14:47:24 +00:00
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
break;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
return pos;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-05-20 14:06:05 +00:00
|
|
|
|
int xvt_sbar_get_proportion(WINDOW win, SCROLL_TYPE t)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-05-20 14:06:05 +00:00
|
|
|
|
int p = 1;
|
|
|
|
|
switch (t)
|
|
|
|
|
{
|
|
|
|
|
case HSCROLL:
|
|
|
|
|
case VSCROLL:
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
p = w.GetScrollThumb(dir);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HVSLIDER:
|
|
|
|
|
{
|
|
|
|
|
CAST_SLIDER(win, sc);
|
|
|
|
|
p = sc.GetPageSize();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
p = sb.GetThumbSize();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
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;
|
2008-05-20 14:06:05 +00:00
|
|
|
|
switch (t)
|
|
|
|
|
{
|
|
|
|
|
case HSCROLL:
|
|
|
|
|
case VSCROLL:
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
*maxp = w.GetScrollRange(dir);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HVGAUGE:
|
2007-04-06 14:47:24 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_GAUGE(win, g);
|
|
|
|
|
*maxp = g.GetRange();
|
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2007-04-06 14:47:24 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
*maxp = sb.GetRange();
|
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos)
|
|
|
|
|
{
|
2007-04-06 14:47:24 +00:00
|
|
|
|
switch(t)
|
|
|
|
|
{
|
|
|
|
|
case HSCROLL:
|
|
|
|
|
case VSCROLL:
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
CAST_SCROLL_TYPE(t, dir);
|
|
|
|
|
w.SetScrollPos(dir, pos);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HVGAUGE:
|
|
|
|
|
{
|
|
|
|
|
CAST_GAUGE(win, g);
|
|
|
|
|
if (g.GetRange() <= 1)
|
|
|
|
|
g.Pulse();
|
|
|
|
|
else
|
|
|
|
|
g.SetValue(pos);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-05-20 14:06:05 +00:00
|
|
|
|
case HVSLIDER:
|
|
|
|
|
{
|
|
|
|
|
CAST_SLIDER(win, g);
|
|
|
|
|
g.SetValue(pos);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
const int range = sb.GetRange();
|
|
|
|
|
const int size = sb.GetThumbSize();
|
|
|
|
|
sb.SetScrollbar(pos, size, range, size);
|
|
|
|
|
}
|
2008-05-20 14:06:05 +00:00
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_set_proportion(WINDOW win, SCROLL_TYPE t, int proportion)
|
|
|
|
|
{
|
2008-05-20 14:06:05 +00:00
|
|
|
|
switch (t)
|
|
|
|
|
{
|
|
|
|
|
case HSCROLL:
|
|
|
|
|
case 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);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HVSLIDER:
|
|
|
|
|
{
|
|
|
|
|
CAST_SLIDER(win, sc);
|
|
|
|
|
sc.SetPageSize(proportion);
|
|
|
|
|
sc.SetTickFreq(sc.GetMax()/proportion, 0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
const int pos = sb.GetThumbPosition();
|
|
|
|
|
const int range = sb.GetRange();
|
|
|
|
|
sb.SetScrollbar(pos, proportion, range, proportion);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max)
|
|
|
|
|
{
|
2007-04-06 14:47:24 +00:00
|
|
|
|
XVT_ASSERT(min == 0 && max >= min);
|
|
|
|
|
switch (t)
|
|
|
|
|
{
|
|
|
|
|
case HSCROLL:
|
|
|
|
|
case 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);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HVGAUGE:
|
|
|
|
|
{
|
|
|
|
|
CAST_GAUGE(win, g);
|
|
|
|
|
g.SetRange(max);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-05-20 14:06:05 +00:00
|
|
|
|
case HVSLIDER:
|
|
|
|
|
{
|
|
|
|
|
CAST_SLIDER(win, g);
|
|
|
|
|
g.SetRange(min, max);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-04-06 14:47:24 +00:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
CAST_SCROLL(win, sb);
|
|
|
|
|
const int pos = sb.GetThumbPosition();
|
|
|
|
|
const int size = sb.GetThumbSize();
|
|
|
|
|
sb.SetScrollbar(pos, size, max, size);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// 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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
wxWindow* w = _task_win->FindFocus();
|
|
|
|
|
while (w != NULL && w->IsKindOf(CLASSINFO(wxControl)))
|
|
|
|
|
w = w->GetParent();
|
|
|
|
|
return (WINDOW)w;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
WINDOW xvt_scr_get_focus_vobj(void)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
return (WINDOW)_task_win->FindFocus();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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();
|
2006-12-29 14:16:28 +00:00
|
|
|
|
for (wxHashTable::Node* node = _nice_windows.Next(); node; node = _nice_windows.Next())
|
2003-12-19 08:17:48 +00:00
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
wxWindow* pWin = wxDynamicCast(node->GetData(), wxWindow);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
if (pWin != NULL)
|
|
|
|
|
{
|
|
|
|
|
const char* title = pWin->GetLabel();
|
|
|
|
|
xvt_slist_add_at_elt(list, NULL, title, (long)pWin);
|
|
|
|
|
}
|
2003-03-28 15:33:49 +00:00
|
|
|
|
}
|
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;
|
2004-01-19 15:30:28 +00:00
|
|
|
|
// if (e != NULL) // Add at head by default (else at tail)
|
|
|
|
|
// {
|
2003-03-28 15:33:49 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
2004-01-19 15:30:28 +00:00
|
|
|
|
// }
|
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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
return list != NULL ? 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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
if (list != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
if (list != NULL && e != NULL)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-10-24 15:49:08 +00:00
|
|
|
|
return (SLIST_ELT)(list != NULL && item != NULL ? 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)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return str ? wxStrdup(str) : NULL; // bleah!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
char* xvt_str_number_format(char* str, int size)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
OsWin32_NumberFormat(str, size);
|
|
|
|
|
#else
|
|
|
|
|
wxString txt;
|
|
|
|
|
for (const char* s = str; *s; s++)
|
|
|
|
|
{
|
|
|
|
|
if (isdigit(*s))
|
|
|
|
|
txt << *s;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (*s == '.')
|
|
|
|
|
txt << ',';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wxStrncpy(str, txt, size);
|
|
|
|
|
#endif
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-24 15:21:30 +00:00
|
|
|
|
BOOLEAN xvt_str_match(const char* mbs, const char *pat, BOOLEAN case_sensitive)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2005-10-24 15:21:30 +00:00
|
|
|
|
/*
|
|
|
|
|
// Attualmente la wxString::Matches funziona solo con * e ? :-(
|
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();
|
|
|
|
|
}
|
2005-10-24 15:21:30 +00:00
|
|
|
|
return text.Matches(pattern);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Uso la vecchia funzione implementata anticamente in agalib
|
|
|
|
|
if (case_sensitive)
|
|
|
|
|
return match(pat, mbs);
|
|
|
|
|
|
|
|
|
|
wxString text = mbs; text.MakeUpper();
|
|
|
|
|
wxString pattern = pat; pattern.MakeUpper();
|
|
|
|
|
return match(pattern, text);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-12 14:21:37 +00:00
|
|
|
|
void xvt_str_make_upper(char* str)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
wxString s(str);
|
|
|
|
|
s.MakeUpper();
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxStrcpy(str, s);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_str_make_lower(char* str)
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
wxString s(str);
|
|
|
|
|
s.MakeLower();
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxStrcpy(str, s);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-13 08:59:21 +00:00
|
|
|
|
double xvt_str_fuzzy_compare (const char* s1, const char* s2)
|
|
|
|
|
{
|
|
|
|
|
return fstrcmp(s1, s2);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
double xvt_str_fuzzy_compare_ignoring_case (const char* s1, const char* s2)
|
|
|
|
|
{
|
|
|
|
|
wxString str1(s1); str1.MakeUpper();
|
|
|
|
|
wxString str2(s2); str1.MakeUpper();
|
|
|
|
|
return fstrcmp(str1, str2);
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-03 16:53:05 +00:00
|
|
|
|
BOOLEAN xvt_chr_is_digit(int c)
|
|
|
|
|
{
|
|
|
|
|
return (c <= 255) && wxIsdigit(c);
|
|
|
|
|
}
|
2008-07-11 11:16:52 +00:00
|
|
|
|
|
2007-01-03 16:53:05 +00:00
|
|
|
|
BOOLEAN xvt_chr_is_alpha(int c)
|
|
|
|
|
{
|
|
|
|
|
return (c <= 255) && wxIsalpha(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_chr_is_alnum(int c)
|
|
|
|
|
{
|
|
|
|
|
return (c <= 255) && wxIsalnum(c);
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-20 16:07:06 +00:00
|
|
|
|
int xvt_net_get_status()
|
|
|
|
|
{
|
|
|
|
|
int nStatus = 0;
|
|
|
|
|
wxDialUpManager* dum = wxDialUpManager::Create();
|
|
|
|
|
if (dum != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (dum->IsOk() && dum->IsOnline())
|
|
|
|
|
{
|
|
|
|
|
nStatus = 0x1; // 1 = Online
|
|
|
|
|
|
|
|
|
|
if (dum->IsAlwaysOnline())
|
|
|
|
|
nStatus |= 0x2; // 2 = Always Online
|
|
|
|
|
|
|
|
|
|
wxArrayString isp;
|
|
|
|
|
if (dum->GetISPNames(isp) > 0)
|
|
|
|
|
nStatus |= 0x4; // 4 = Internet enabled
|
|
|
|
|
}
|
|
|
|
|
delete dum;
|
|
|
|
|
}
|
|
|
|
|
return nStatus;
|
|
|
|
|
}
|
2007-01-03 16:53:05 +00:00
|
|
|
|
|
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();
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxStrncpy(name, str, maxlen);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
name[maxlen-1] = '\0';
|
2004-06-04 13:01:45 +00:00
|
|
|
|
return *name > '\0';
|
2003-04-30 15:43:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_sys_get_user_name(char* name, int maxlen)
|
|
|
|
|
{
|
|
|
|
|
wxString str = wxGetUserId();
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxStrncpy(name, str, maxlen);
|
2003-04-30 15:43:51 +00:00
|
|
|
|
name[maxlen-1] = '\0';
|
2004-06-04 13:01:45 +00:00
|
|
|
|
return *name > '\0';
|
2003-04-30 15:43:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-17 13:57:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Process processing
|
|
|
|
|
///////////////////////////////////////////////////////////
|
2003-10-24 09:59:49 +00:00
|
|
|
|
static bool __bChildRunning = false;
|
|
|
|
|
|
2003-10-17 13:57:23 +00:00
|
|
|
|
class TIconizeTaskThread : public wxThread
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual ExitCode Entry();
|
|
|
|
|
public:
|
|
|
|
|
TIconizeTaskThread();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
wxThread::ExitCode TIconizeTaskThread::Entry()
|
|
|
|
|
{
|
2008-06-13 08:48:18 +00:00
|
|
|
|
::wxMilliSleep(500);
|
2003-10-24 09:59:49 +00:00
|
|
|
|
if (__bChildRunning) // Il programma e' ancora attivo
|
2008-07-23 15:45:27 +00:00
|
|
|
|
_task_win->Iconize();
|
2003-10-17 13:57:23 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TIconizeTaskThread::TIconizeTaskThread()
|
|
|
|
|
{
|
|
|
|
|
Create();
|
|
|
|
|
SetPriority(WXTHREAD_MIN_PRIORITY);
|
|
|
|
|
Run();
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
|
long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
|
|
|
|
|
{
|
|
|
|
|
long exitcode = 0;
|
2004-03-31 12:57:12 +00:00
|
|
|
|
wxString cmd(cmdline);
|
|
|
|
|
|
|
|
|
|
#ifdef LINUX
|
|
|
|
|
if (isalpha(cmd[0u]))
|
|
|
|
|
cmd = "./" + cmd;
|
|
|
|
|
#endif
|
2003-04-16 15:50:37 +00:00
|
|
|
|
|
|
|
|
|
if (sync)
|
|
|
|
|
{
|
|
|
|
|
if (iconizetask)
|
|
|
|
|
{
|
|
|
|
|
wxEnableTopLevelWindows(FALSE);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
|
|
|
|
|
TIconizeTaskThread* it = new TIconizeTaskThread(); // No need to delete
|
|
|
|
|
__bChildRunning = true;
|
2004-03-31 12:57:12 +00:00
|
|
|
|
exitcode = wxExecute(cmd, wxEXEC_SYNC);
|
2003-10-24 09:59:49 +00:00
|
|
|
|
__bChildRunning = false;
|
2003-10-17 13:57:23 +00:00
|
|
|
|
|
2008-07-23 15:45:27 +00:00
|
|
|
|
if (_task_win->IsIconized())
|
|
|
|
|
_task_win->Restore();
|
2003-04-16 15:50:37 +00:00
|
|
|
|
wxEnableTopLevelWindows(TRUE);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2003-10-17 13:57:23 +00:00
|
|
|
|
else
|
2008-04-04 16:04:47 +00:00
|
|
|
|
exitcode = wxExecute(cmd, wxEXEC_SYNC); // Valutare wxEXEC_NODISABLE
|
2008-07-23 15:45:27 +00:00
|
|
|
|
_task_win->Raise();
|
2003-04-16 15:50:37 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2004-03-31 12:57:12 +00:00
|
|
|
|
exitcode = wxExecute(cmd, wxEXEC_ASYNC);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
|
|
|
|
|
return exitcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long xvt_sys_execute_in_window(const char* cmdline, WINDOW win)
|
|
|
|
|
{
|
2008-01-31 14:15:52 +00:00
|
|
|
|
const long inst = xvt_sys_execute(cmdline, FALSE, FALSE);
|
|
|
|
|
if (inst > 0 && win != NULL_WIN)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
2003-05-23 10:32:27 +00:00
|
|
|
|
#ifdef WIN32
|
2008-01-31 14:15:52 +00:00
|
|
|
|
OsWin32_PlaceProcessInWindow(inst, "", (unsigned int)w.GetHandle());
|
2003-05-22 15:25:25 +00:00
|
|
|
|
#else
|
2008-01-31 14:15:52 +00:00
|
|
|
|
OsLinux_PlaceProcessInWindow(inst, "", w.GetHandle());
|
2003-04-16 15:50:37 +00:00
|
|
|
|
#endif
|
2008-01-31 14:15:52 +00:00
|
|
|
|
}
|
2003-04-16 15:50:37 +00:00
|
|
|
|
return inst;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-01 16:38:06 +00:00
|
|
|
|
long xvt_sys_close_children(WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
long c = 0;
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
c = OsWin32_CloseChildren((unsigned int)w.GetHandle());
|
|
|
|
|
#endif
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-21 16:54:43 +00:00
|
|
|
|
long xvt_sys_close_siblings(WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
long c = 0; // Non sto a perder tempo a contarli :-)
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
OsWin32_CloseSiblings((unsigned int)w.GetHandle());
|
|
|
|
|
#endif
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
return FALSE;
|
2006-04-13 17:56:02 +00:00
|
|
|
|
#endif
|
2003-04-30 15:43:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
2008-11-21 16:54:43 +00:00
|
|
|
|
if (!ok) // Testo anche il buon vecchio Frontend!
|
2003-05-16 09:25:11 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
if (file == NULL || *file == '\0')
|
|
|
|
|
file = xvt_fsys_get_campo_ini();
|
|
|
|
|
|
|
|
|
|
if (paragraph == NULL || *paragraph == '\0')
|
|
|
|
|
paragraph = "Main";
|
|
|
|
|
|
2003-03-27 12:15:57 +00:00
|
|
|
|
#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
|
2004-03-12 14:21:37 +00:00
|
|
|
|
wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
if (file == NULL || *file == '\0')
|
|
|
|
|
file = xvt_fsys_get_campo_ini();
|
|
|
|
|
|
|
|
|
|
if (paragraph == NULL || *paragraph == '\0')
|
|
|
|
|
paragraph = "Main";
|
|
|
|
|
|
2003-03-27 12:15:57 +00:00
|
|
|
|
#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
|
2004-03-12 14:21:37 +00:00
|
|
|
|
wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
|
|
|
|
|
ini.SetUmask(0x0);
|
2003-03-27 12:15:57 +00:00
|
|
|
|
|
|
|
|
|
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)
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxStrcpy(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();
|
2008-04-04 16:04:47 +00:00
|
|
|
|
if (str.EndsWith(".ico"))
|
2003-04-16 15:50:37 +00:00
|
|
|
|
icon = new wxIcon(file, wxBITMAP_TYPE_ICO);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
2005-09-23 15:55:44 +00:00
|
|
|
|
WXHICON hicon = (WXHICON)OsWin32_LoadIcon(file);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
if (hicon)
|
|
|
|
|
{
|
|
|
|
|
icon = new wxIcon;
|
|
|
|
|
icon->SetHICON(hicon);
|
|
|
|
|
}
|
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
|
icon = new wxIcon;
|
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++)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxIcon* ico = wxDynamicCast(_nice_icons.Get(id), wxIcon);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-31 12:57:12 +00:00
|
|
|
|
int xvt_sys_get_session_id()
|
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
return OsWin32_GetSessionId();
|
|
|
|
|
#else
|
|
|
|
|
return OsLinux_GetSessionId();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-28 15:33:49 +00:00
|
|
|
|
unsigned long xvt_sys_get_free_memory()
|
|
|
|
|
{
|
2006-12-29 14:16:28 +00:00
|
|
|
|
unsigned long mem = 0;
|
2008-03-28 10:19:02 +00:00
|
|
|
|
|
2006-12-29 14:16:28 +00:00
|
|
|
|
if (::wxGetFreeMemory().GetHi())
|
2008-12-03 12:07:57 +00:00
|
|
|
|
mem = (unsigned long)-1;
|
2006-12-29 14:16:28 +00:00
|
|
|
|
else
|
|
|
|
|
mem = ::wxGetFreeMemory().GetLo();
|
2008-03-28 10:19:02 +00:00
|
|
|
|
|
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))
|
|
|
|
|
{
|
2004-04-05 13:03:51 +00:00
|
|
|
|
#ifdef WIN32
|
2003-04-01 07:34:53 +00:00
|
|
|
|
case wxWIN95:
|
|
|
|
|
os = minor == 0 ? XVT_WS_WIN_95 : XVT_WS_WIN_98; break;
|
|
|
|
|
case wxWINDOWS_NT:
|
2004-04-05 13:03:51 +00:00
|
|
|
|
os = XVT_WS_WIN_NT;
|
|
|
|
|
if (OsWin32_IsWindowsServer())
|
|
|
|
|
os = XVT_WS_WIN_SERVER;
|
|
|
|
|
break;
|
|
|
|
|
#else
|
|
|
|
|
case wxGTK:
|
2004-04-27 19:09:18 +00:00
|
|
|
|
os = XVT_WS_LINUX; break;
|
2004-04-05 13:03:51 +00:00
|
|
|
|
#endif
|
2003-04-01 07:34:53 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-02 14:47:51 +00:00
|
|
|
|
int xvt_sys_get_version(char* os_version, char* ptk_version, int maxsize)
|
|
|
|
|
{
|
|
|
|
|
wxStrncpy(os_version, wxGetOsDescription(), maxsize);
|
|
|
|
|
wxStrncpy(ptk_version, wxVERSION_STRING, maxsize);
|
|
|
|
|
return xvt_sys_get_os_version();
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-01 07:34:53 +00:00
|
|
|
|
void xvt_sys_sleep(unsigned long msec)
|
|
|
|
|
{
|
2008-06-13 08:48:18 +00:00
|
|
|
|
::wxMilliSleep(msec);
|
2003-04-01 07:34:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// XVT system calls (added by Alex)
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-09-19 15:34:00 +00:00
|
|
|
|
XVTDLL BOOLEAN xvt_sys_get_env(const char* varname, char* value, int max_size)
|
|
|
|
|
{
|
|
|
|
|
const wxString strName(varname);
|
|
|
|
|
wxString strValue;
|
|
|
|
|
const BOOLEAN ok = wxGetEnv(strName, &strValue);
|
|
|
|
|
if (ok)
|
|
|
|
|
wxStrncpy(value, strValue, max_size);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_sys_searchenv(const char * filename, const char * varname, char * pathname)
|
2008-09-19 15:34:00 +00:00
|
|
|
|
{
|
|
|
|
|
DEPRECATED_BOX();
|
|
|
|
|
xvt_sys_search_env(filename, varname, pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_sys_search_env(const char * filename, const char * varname, char * pathname)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
_searchenv(filename, varname, pathname);
|
|
|
|
|
#else
|
2008-09-19 15:34:00 +00:00
|
|
|
|
const char * value = wxGetEnv(varname);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
if (value)
|
|
|
|
|
{
|
2003-05-23 10:32:27 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-19 15:34:00 +00:00
|
|
|
|
BOOLEAN xvt_sys_set_env(const char* varname, const char* value)
|
|
|
|
|
{
|
|
|
|
|
const wxString strName(varname);
|
|
|
|
|
return value != NULL ? wxSetEnv(strName, value) : wxUnsetEnv(strName);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
// BOOLEAN o int? Adso!
|
|
|
|
|
int xvt_fsys_access(const char *pathname, int mode)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return wxAccess(pathname, mode) == -1 ? errno : 0;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_file_exists(const char *pathname)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return xvt_fsys_file_attr(pathname, XVT_FILE_ATTR_EXIST);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_mkdir(const char *pathname)
|
|
|
|
|
{
|
2004-05-03 16:04:18 +00:00
|
|
|
|
if (wxDirExists(pathname))
|
|
|
|
|
return TRUE;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return wxMkdir(pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOLEAN xvt_fsys_rmdir(const char *pathname)
|
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
if (!wxDirExists(pathname))
|
2004-05-03 16:04:18 +00:00
|
|
|
|
return TRUE;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return wxRmdir(pathname);
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
BOOLEAN xvt_fsys_remove_file(const char *pathname)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
|
|
|
|
return wxRemoveFile(pathname);
|
|
|
|
|
}
|
2003-04-01 07:34:53 +00:00
|
|
|
|
|
2007-12-12 09:43:46 +00:00
|
|
|
|
BOOLEAN xvt_fsys_removefile(const char *pathname)
|
|
|
|
|
{
|
|
|
|
|
DEPRECATED_BOX();
|
|
|
|
|
return xvt_fsys_remove_file(pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Timers
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-05-20 14:06:05 +00:00
|
|
|
|
struct tm* xvt_time_now()
|
|
|
|
|
{
|
|
|
|
|
return wxDateTime::GetTmNow();
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
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;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
t = NULL;
|
2003-05-15 09:49:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Visual objects
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-09-19 15:34:00 +00:00
|
|
|
|
static wxWindow* SafeCastWin(WINDOW win)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxWindow* w = wxDynamicCast(_nice_windows.Get(win), wxWindow);
|
|
|
|
|
if (w != NULL)
|
2008-04-04 16:04:47 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxASSERT(win == (WINDOW)w);
|
2008-09-19 15:34:00 +00:00
|
|
|
|
const TwxWindow* tw = wxDynamicCast(w, TwxWindow);
|
|
|
|
|
if (tw != NULL && tw->InDestroy())
|
|
|
|
|
w = NULL;
|
|
|
|
|
}
|
|
|
|
|
return w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void xvt_vobj_destroy(WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
wxWindow* w = SafeCastWin(win);
|
|
|
|
|
if (w != NULL)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
xvt_win_set_caret_visible(win, FALSE);
|
|
|
|
|
w->Destroy(); // same as delete w
|
|
|
|
|
_nice_windows.Delete(win); // Elimina "di nuovo" dalla lista delle finestre attive
|
2008-04-04 16:04:47 +00:00
|
|
|
|
}
|
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:
|
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_mem_zalloc(sizeof(XVT_COLOR_COMPONENT)*16);
|
|
|
|
|
|
|
|
|
|
// XVT components
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[0].type = XVT_COLOR_FOREGROUND;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
xcc[0].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
2003-05-22 15:25:25 +00:00
|
|
|
|
xcc[1].type = XVT_COLOR_BACKGROUND;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
xcc[1].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
2007-12-12 09:43:46 +00:00
|
|
|
|
xcc[2].type = XVT_COLOR_BLEND;
|
|
|
|
|
xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
|
|
|
|
|
xcc[3].type = XVT_COLOR_BORDER;
|
|
|
|
|
xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
|
|
|
|
|
xcc[4].type = XVT_COLOR_SELECT;
|
|
|
|
|
xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
|
|
|
|
|
xcc[5].type = XVT_COLOR_HIGHLIGHT;
|
|
|
|
|
xcc[5].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
2008-05-20 14:06:05 +00:00
|
|
|
|
xcc[6].type = XVT_COLOR_TROUGH;
|
|
|
|
|
xcc[6].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
2007-12-12 09:43:46 +00:00
|
|
|
|
|
|
|
|
|
// AGA components
|
2008-05-20 14:06:05 +00:00
|
|
|
|
xcc[7].type = XVT_COLOR_CAPTIONLT;
|
|
|
|
|
xcc[7].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
|
|
|
|
|
xcc[8].type = XVT_COLOR_CAPTIONDK;
|
|
|
|
|
xcc[8].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION));
|
|
|
|
|
xcc[9].type = XVT_COLOR_CAPTIONTEXT;
|
|
|
|
|
xcc[9].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
|
2007-12-12 09:43:46 +00:00
|
|
|
|
|
|
|
|
|
// Last (NULL) component
|
2008-05-20 14:06:05 +00:00
|
|
|
|
xcc[10].type = XVT_COLOR_NULL;
|
|
|
|
|
xcc[10].color = 0;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
|
|
|
|
|
ret = (long)xcc;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2003-03-27 12:15:57 +00:00
|
|
|
|
case ATTR_FRAME_WIDTH:
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#ifdef LINUX
|
|
|
|
|
ret = 8; //verificare not impl
|
|
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_X);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#endif
|
2003-03-27 12:15:57 +00:00
|
|
|
|
break;
|
|
|
|
|
case ATTR_FRAME_HEIGHT:
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#ifdef LINUX
|
|
|
|
|
ret = 8; //verificare not impl
|
|
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_Y);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#endif
|
2003-03-27 12:15:57 +00:00
|
|
|
|
break;
|
2003-04-16 15:50:37 +00:00
|
|
|
|
case ATTR_MENU_HEIGHT:
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_MENU_Y);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
break;
|
2003-03-27 12:15:57 +00:00
|
|
|
|
case ATTR_TITLE_HEIGHT:
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#ifdef LINUX
|
|
|
|
|
ret = 32; //verificare not impl
|
|
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_CAPTION_Y);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#endif
|
2003-03-27 12:15:57 +00:00
|
|
|
|
break;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
case ATTR_CTL_VERT_SBAR_WIDTH:
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(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:
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
case ATTR_DISPLAY_TYPE:
|
2007-12-12 09:43:46 +00:00
|
|
|
|
switch (::wxDisplayDepth()) // Test ormai ridicolo?
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-01-31 14:15:52 +00:00
|
|
|
|
case 1: ret = XVT_DISPLAY_MONO; break; // Ridicolissimo :-)
|
2003-04-16 15:50:37 +00:00
|
|
|
|
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-06-18 08:06:55 +00:00
|
|
|
|
SORRY_BOX(); // Obsoleto e non piu' usato
|
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
|
|
|
|
{
|
2008-09-19 15:34:00 +00:00
|
|
|
|
const wxWindow* w = SafeCastWin(win);
|
|
|
|
|
if (w != NULL)
|
|
|
|
|
ret = (long)w->GetHandle();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ATTR_SCREEN_HEIGHT:
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_SCREEN_WIDTH:
|
2005-09-23 15:55:44 +00:00
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
break;
|
|
|
|
|
case ATTR_SCREEN_WINDOW:
|
2005-09-28 11:51:41 +00:00
|
|
|
|
ret = 882L; // Scelta arbitraria ma accettabile
|
|
|
|
|
break;
|
2003-10-14 13:40:52 +00:00
|
|
|
|
case ATTR_SPEECH_MODE:
|
|
|
|
|
ret = m_nSpeechMode;
|
|
|
|
|
break;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
case ATTR_TASK_WINDOW:
|
|
|
|
|
ret = long(_task_win);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
break;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
case ATTR_PRINTER_WINDOW:
|
|
|
|
|
ret = 883L; // Scelta arbitraria ma accettabile
|
|
|
|
|
break;
|
2003-01-28 14:27:05 +00:00
|
|
|
|
case ATTR_WIN_INSTANCE:
|
2004-04-28 09:49:37 +00:00
|
|
|
|
ret = 0;
|
|
|
|
|
break;
|
|
|
|
|
case ATTR_WIN_OPENFILENAME_HOOK:
|
2003-01-28 14:27:05 +00:00
|
|
|
|
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;
|
2008-06-19 15:39:33 +00:00
|
|
|
|
case ATTR_WIN_PM_TWIN_STARTUP_STYLE:
|
|
|
|
|
ret = _startup_style;
|
|
|
|
|
break;
|
2007-02-19 09:36:55 +00:00
|
|
|
|
case ATTR_ICON_WIDTH:
|
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_ICON_X);
|
|
|
|
|
break;
|
|
|
|
|
case ATTR_ICON_HEIGHT:
|
|
|
|
|
ret = wxSystemSettings::GetMetric(wxSYS_ICON_Y);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
SORRY_BOX();
|
|
|
|
|
break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
|
if (win == PRINTER_WIN)
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
l = h = 6000; // circa A4 height
|
2005-09-28 11:51:41 +00:00
|
|
|
|
} else
|
|
|
|
|
if (win == SCREEN_WIN)
|
|
|
|
|
{
|
|
|
|
|
l = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
|
|
|
|
|
h = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) - 32; // Puerile tentativo di escludere la task bar
|
|
|
|
|
} else
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
w.GetClientSize(&l, &h);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2005-09-28 11:51:41 +00:00
|
|
|
|
else // NULL_WIN = schermo intero
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
|
l = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
|
|
|
|
|
h = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-09-19 15:34:00 +00:00
|
|
|
|
const TwxWindow* w = wxDynamicCast(SafeCastWin(win), TwxWindow);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return w != NULL ? w->_app_data : 0L;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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();
|
2008-03-11 15:50:42 +00:00
|
|
|
|
rctp->left = rct.x;
|
|
|
|
|
rctp->top = rct.y;
|
|
|
|
|
rctp->right = rct.GetRight();
|
|
|
|
|
rctp->bottom = rct.GetBottom();
|
2003-05-22 15:25:25 +00:00
|
|
|
|
return rctp;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-02 15:58:43 +00:00
|
|
|
|
XVT_PALETTE xvt_vobj_get_palet(WINDOW WXUNUSED(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)
|
|
|
|
|
{
|
2008-06-19 15:39:33 +00:00
|
|
|
|
if (win == NULL_WIN || win == TASK_WIN)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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);
|
2008-06-19 15:39:33 +00:00
|
|
|
|
wxStrncpy(title, w.GetLabel(), sz_title);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2008-06-19 15:39:33 +00:00
|
|
|
|
if (win == NULL_WIN)
|
|
|
|
|
return W_NONE;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
if (win == TASK_WIN)
|
|
|
|
|
return W_TASK;
|
|
|
|
|
if (win == SCREEN_WIN)
|
|
|
|
|
return W_SCREEN;
|
|
|
|
|
if (win == PRINTER_WIN)
|
|
|
|
|
return W_PRINT;
|
2008-06-19 15:39:33 +00:00
|
|
|
|
|
|
|
|
|
TwxWindow* w = wxDynamicCast((wxObject*)win, TwxWindow);
|
|
|
|
|
if (w != NULL)
|
|
|
|
|
return w->_type;
|
|
|
|
|
|
|
|
|
|
return WO_TE; // Unknown custom control
|
2003-05-22 15:25:25 +00:00
|
|
|
|
}
|
2008-04-04 16:04:47 +00:00
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
BOOLEAN xvt_vobj_is_focusable(WINDOW win)
|
|
|
|
|
{
|
2008-10-08 08:48:36 +00:00
|
|
|
|
BOOLEAN ok = win != NULL_WIN && win != PRINTER_WIN && xvt_vobj_is_valid(win);
|
2008-04-04 16:04:47 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
ok = w.IsEnabled() && w.IsShownOnScreen();
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-08 08:48:36 +00:00
|
|
|
|
BOOLEAN xvt_vobj_is_valid(WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
return win != NULL_WIN && SafeCastWin(win) != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_maximize(WINDOW win)
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
2008-10-02 15:58:43 +00:00
|
|
|
|
XVT_ASSERT(win != NULL_WIN && _task_win != NULL);
|
|
|
|
|
if (win == TASK_WIN)
|
|
|
|
|
_task_win->Maximize();
|
2008-06-19 15:39:33 +00:00
|
|
|
|
else
|
2003-04-16 15:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
int width, height;
|
2008-06-19 15:39:33 +00:00
|
|
|
|
_task_win->GetClientSize(&width, &height);
|
2003-04-16 15:50:37 +00:00
|
|
|
|
w.SetSize(0, 0, width, height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_minimize(WINDOW win)
|
2003-04-17 12:53:36 +00:00
|
|
|
|
{
|
2008-06-19 15:39:33 +00:00
|
|
|
|
wxFrame* pMain = wxDynamicCast((wxObject*)win, wxFrame);
|
2008-10-10 08:51:36 +00:00
|
|
|
|
if (pMain != NULL)
|
|
|
|
|
pMain->Iconize();
|
2003-04-17 12:53:36 +00:00
|
|
|
|
else
|
|
|
|
|
SORRY_BOX();
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_vobj_move(WINDOW win, const RCT* rctp)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const 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();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 16:17:40 +00:00
|
|
|
|
static void SetArtistColor(WINDOW win, int id, long rgb)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(win, w);
|
|
|
|
|
const wxAuiManager* pMgr = wxAuiManager::GetManager(&w);
|
|
|
|
|
wxAuiDockArt* pArt = (pMgr != NULL) ? pMgr->GetArtProvider() : NULL;
|
|
|
|
|
if (pArt != NULL)
|
|
|
|
|
{
|
|
|
|
|
CAST_COLOR(rgb, col);
|
|
|
|
|
pArt->SetColour(id, col);
|
|
|
|
|
if (id == wxAUI_DOCKART_BACKGROUND_COLOUR)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_vobj_set_attr(WINDOW win, long data, long value)
|
|
|
|
|
{
|
2008-06-19 15:39:33 +00:00
|
|
|
|
switch (data)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-11-11 16:17:40 +00:00
|
|
|
|
case ATTR_BACK_COLOR: SetArtistColor(win, wxAUI_DOCKART_BACKGROUND_COLOUR, value); break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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;
|
2008-06-19 15:39:33 +00:00
|
|
|
|
case ATTR_WIN_PM_TWIN_STARTUP_STYLE: _startup_style = value; break;
|
2003-10-14 13:40:52 +00:00
|
|
|
|
case ATTR_SPEECH_MODE: xvt_dm_enable_speech(value); break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
default: SORRY_BOX(); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-10 08:51:36 +00:00
|
|
|
|
void xvt_vobj_set_data(WINDOW win, long app_data)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_TWIN(win, w);
|
2008-10-10 08:51:36 +00:00
|
|
|
|
w._app_data = app_data;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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!
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
void xvt_vobj_set_title(WINDOW win, const char* title)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
2006-12-29 14:16:28 +00:00
|
|
|
|
w.SetLabel(title);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int menu_rid, WINDOW parent, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data)
|
2003-05-22 15:25:25 +00:00
|
|
|
|
{
|
2007-12-12 09:43:46 +00:00
|
|
|
|
const wxRect rct = NormalizeRCT(rct_p);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
const wxString caption = title;
|
|
|
|
|
|
2008-10-02 15:58:43 +00:00
|
|
|
|
long style = wxCLIP_SIBLINGS | wxCLIP_CHILDREN | wxWANTS_CHARS;
|
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:
|
2008-10-22 15:27:16 +00:00
|
|
|
|
style |= wxSYSTEM_MENU; // Questo flag in realta' viene interpretato come wxCAPTION
|
2008-10-02 15:58:43 +00:00
|
|
|
|
if (win_flags & WSF_CLOSE)
|
2008-10-22 15:27:16 +00:00
|
|
|
|
style |= wxCLOSE_BOX;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
break;
|
|
|
|
|
case W_PLAIN:
|
2002-07-03 14:53:33 +00:00
|
|
|
|
// style |= wxBORDER; // Non attivare MAI il bordo!
|
2005-09-23 15:55:44 +00:00
|
|
|
|
if (win_flags & WSF_TRANSPARENT)
|
|
|
|
|
style |= wxTRANSPARENT_WINDOW;
|
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;
|
|
|
|
|
}
|
2005-10-24 15:21:30 +00:00
|
|
|
|
if (parent == SCREEN_WIN)
|
|
|
|
|
parent = NULL;
|
2007-12-12 09:43:46 +00:00
|
|
|
|
w = new TwxWindow((wxWindow*)parent, -1, caption, rct.GetPosition(), rct.GetSize(), 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;
|
2005-09-23 15:55:44 +00:00
|
|
|
|
w->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint
|
2006-12-29 14:16:28 +00:00
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#ifdef WIN32
|
2008-10-02 15:58:43 +00:00
|
|
|
|
OsWin32_SetCaptionStyle(w->GetHWND(), style);
|
2004-03-12 14:21:37 +00:00
|
|
|
|
#else
|
2008-10-02 15:58:43 +00:00
|
|
|
|
OsLinux_SetCaptionStyle(w, style);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
#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);
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
if (win_flags & WSF_DISABLED)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w->Disable();
|
|
|
|
|
else
|
|
|
|
|
w->Enable();
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
|
if (win_flags & WSF_INVISIBLE)
|
|
|
|
|
w->Hide();
|
|
|
|
|
else
|
2005-09-28 15:59:25 +00:00
|
|
|
|
w->Show(); // Non dovrebbe mai succedere nel nostro caso
|
2002-10-24 10:47:49 +00:00
|
|
|
|
|
2005-09-28 15:59:25 +00:00
|
|
|
|
// Accetta messaggi solo da ora!
|
2002-02-28 14:26:23 +00:00
|
|
|
|
w->_eh = eh;
|
|
|
|
|
|
|
|
|
|
EVENT e; memset(&e, 0, sizeof(e));
|
2005-09-28 15:59:25 +00:00
|
|
|
|
e.type = E_CREATE; // Serve a poco, ma fa' lo stesso
|
2002-02-28 14:26:23 +00:00
|
|
|
|
eh((WINDOW)w, &e);
|
2005-09-28 15:59:25 +00:00
|
|
|
|
|
2008-10-10 08:51:36 +00:00
|
|
|
|
xvt_vobj_move((WINDOW)w, rct_p); // Forza la giusta dimensione della client area
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2007-02-01 11:41:41 +00:00
|
|
|
|
XVT_ASSERT(win != NULL_WIN && event_p != NULL);
|
|
|
|
|
|
|
|
|
|
if (win == (WINDOW)_task_win)
|
|
|
|
|
return _task_win_handler(win, event_p);
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 16:04:47 +00:00
|
|
|
|
BOOLEAN xvt_win_enum_wins(WINDOW parent_win, XVT_ENUM_CHILDREN func, long data, unsigned long /*reserved*/)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(parent_win, w)
|
|
|
|
|
wxWindowList& list = w.GetChildren();
|
|
|
|
|
const BOOLEAN ok = list.GetCount() > 0;
|
|
|
|
|
if (ok && func != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (wxWindowList::iterator i = list.begin(); i != list.end(); ++i)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxWindow* tw = wxDynamicCast(*i, wxWindow);
|
|
|
|
|
if (tw != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!func((WINDOW)tw, data))
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-04-04 16:04:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long xvt_win_get_children_count(WINDOW parent_win)
|
|
|
|
|
{
|
|
|
|
|
long nCount = 0;
|
|
|
|
|
if (parent_win != NULL_WIN)
|
|
|
|
|
{
|
|
|
|
|
CAST_WIN(parent_win, w)
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
nCount = OsWin32_GetChildrenCount((unsigned int)w.GetHandle());
|
|
|
|
|
#else
|
|
|
|
|
nCount = w.GetChildren().GetCount();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return nCount;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
|
void xvt_win_post_event(WINDOW win, EVENT* event_p)
|
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
// Per ora e' garantito che funzioni solo con la task window
|
|
|
|
|
CAST_WIN(win, w);
|
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);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
e.SetEventObject(&w);
|
|
|
|
|
wxPostEvent(&w, 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 :-)
|
2008-07-11 11:16:52 +00:00
|
|
|
|
wxWindow* cap = wxWindow::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_cursor(WINDOW win, CURSOR cursor)
|
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
|
CAST_WIN(win, w);
|
2006-12-29 14:16:28 +00:00
|
|
|
|
const wxCursor* cur = wxSTANDARD_CURSOR; // Dummy initilization
|
2002-02-28 14:26:23 +00:00
|
|
|
|
switch (cursor)
|
|
|
|
|
{
|
|
|
|
|
case CURSOR_ARROW: cur = wxSTANDARD_CURSOR; break;
|
2006-12-29 14:16:28 +00:00
|
|
|
|
case CURSOR_CROCE: cur = wxCROSS_CURSOR; break;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-01-31 14:15:52 +00:00
|
|
|
|
static wxStatusBar* WIN2StatBar(WINDOW win)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-01-31 14:15:52 +00:00
|
|
|
|
wxStatusBar* pStatusBar = NULL;
|
|
|
|
|
if (win == NULL_WIN || win == TASK_WIN)
|
2008-07-23 15:45:27 +00:00
|
|
|
|
pStatusBar = _task_win->GetStatusBar();
|
2008-01-31 14:15:52 +00:00
|
|
|
|
else
|
2008-07-11 11:16:52 +00:00
|
|
|
|
pStatusBar = wxDynamicCast((wxObject*)win, wxStatusBar);
|
2008-01-31 14:15:52 +00:00
|
|
|
|
return pStatusBar;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-01-31 14:15:52 +00:00
|
|
|
|
const char* statbar_set_title(WINDOW win, const char* text)
|
|
|
|
|
{
|
|
|
|
|
wxStatusBar* pStatusBar = WIN2StatBar(win);
|
|
|
|
|
if (pStatusBar != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (text == NULL)
|
|
|
|
|
text = _strDefaultStatbarText;
|
|
|
|
|
wxStringTokenizer tok(text, "\t", wxTOKEN_RET_EMPTY);
|
|
|
|
|
for (int t = 0; tok.HasMoreTokens(); t++)
|
|
|
|
|
pStatusBar->SetStatusText(tok.GetNextToken(), t);
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2003-06-26 09:33:13 +00:00
|
|
|
|
_strDefaultStatbarText = text;
|
2008-01-31 14:15:52 +00:00
|
|
|
|
return statbar_set_title(win, text);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
XVT_FNTID statbar_set_fontid(WINDOW win, XVT_FNTID font_id)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-01-31 14:15:52 +00:00
|
|
|
|
wxStatusBar* pStatBar = WIN2StatBar(win);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
if (pStatBar != NULL && font_id != NULL)
|
2008-01-31 14:15:52 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2008-01-31 14:15:52 +00:00
|
|
|
|
pStatBar->SetFont(font.Font(NULL, win));
|
|
|
|
|
}
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return font_id;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
2008-07-11 11:16:52 +00:00
|
|
|
|
XVT_FNTID statbar_get_fontid(WINDOW win, XVT_FNTID font_id)
|
2002-02-28 14:26:23 +00:00
|
|
|
|
{
|
2008-01-31 14:15:52 +00:00
|
|
|
|
wxStatusBar* pStatBar = WIN2StatBar(win);
|
2008-07-11 11:16:52 +00:00
|
|
|
|
if (pStatBar != NULL && font_id != NULL)
|
2008-01-31 14:15:52 +00:00
|
|
|
|
{
|
2008-07-11 11:16:52 +00:00
|
|
|
|
CAST_FONT(font_id, font);
|
2008-01-31 14:15:52 +00:00
|
|
|
|
font.Copy(pStatBar->GetFont());
|
|
|
|
|
}
|
2008-07-11 11:16:52 +00:00
|
|
|
|
return font_id;
|
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)
|
|
|
|
|
{
|
2008-07-25 15:12:34 +00:00
|
|
|
|
wxStatusBar* pStatusBar = NULL;
|
2008-09-19 15:34:00 +00:00
|
|
|
|
wxFrame* w = wxDynamicCast(SafeCastWin(parent_win), wxFrame);
|
2008-07-25 15:12:34 +00:00
|
|
|
|
if (w != NULL)
|
2008-01-31 14:15:52 +00:00
|
|
|
|
{
|
2008-07-25 15:12:34 +00:00
|
|
|
|
const int nStyle = 0; // not wxST_SIZEGRIP
|
2008-08-22 09:04:39 +00:00
|
|
|
|
pStatusBar = w->CreateStatusBar(3, nStyle);
|
2008-07-25 15:12:34 +00:00
|
|
|
|
if (pStatusBar != NULL)
|
|
|
|
|
{
|
2008-09-26 13:35:22 +00:00
|
|
|
|
const int widths[4] = { -4, -5, -2, 0 };
|
2008-08-22 09:04:39 +00:00
|
|
|
|
pStatusBar->SetStatusWidths(3, widths);
|
2008-07-25 15:12:34 +00:00
|
|
|
|
}
|
2008-01-31 14:15:52 +00:00
|
|
|
|
}
|
|
|
|
|
return (WINDOW)pStatusBar;
|
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
2008-01-31 14:15:52 +00:00
|
|
|
|
BOOLEAN statbar_destroy(WINDOW win)
|
|
|
|
|
{
|
|
|
|
|
wxStatusBar* pStatusBar = WIN2StatBar(win);
|
|
|
|
|
if (pStatusBar != NULL)
|
|
|
|
|
{
|
2008-07-23 15:45:27 +00:00
|
|
|
|
if (_task_win->GetStatusBar() == pStatusBar)
|
|
|
|
|
_task_win->SetStatusBar(NULL);
|
2008-01-31 14:15:52 +00:00
|
|
|
|
pStatusBar->Destroy();
|
|
|
|
|
}
|
|
|
|
|
return pStatusBar != NULL;
|
2007-03-16 13:33:09 +00:00
|
|
|
|
}
|
2007-12-12 09:43:46 +00:00
|
|
|
|
|