Patch level : 10.0
Files correlati : xvaga.dll Ricompilazione Demo : [ ] Commento : Corretta gestione evento di cambio pagina: ora arriva prima di cambiarla e non dopo! Migliorata gestione risorse grafiche: icone, bitmap e cursori git-svn-id: svn://10.65.10.50/trunk@19477 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7719849aca
commit
69d1f20de3
@ -8,6 +8,7 @@
|
||||
|
||||
#include "xvt_menu.h"
|
||||
#include "xvt_help.h"
|
||||
#include "xvtart.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
@ -221,10 +222,11 @@ void OsWin32_SetCaptionStyle(WXHWND handle, long style)
|
||||
::SetWindowLong(hWnd, GWL_STYLE, s);
|
||||
|
||||
if (style & wxCLOSE_BOX)
|
||||
{
|
||||
{
|
||||
HMENU hMenu = ::GetSystemMenu(hWnd, FALSE);
|
||||
::EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
|
||||
HICON hIcon = ::ExtractIcon(NULL, "res/campo.ico", 0);
|
||||
|
||||
WXHICON hIcon = xvtart_GetIconResource(0).GetHICON();
|
||||
::SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
||||
}
|
||||
}
|
||||
@ -869,7 +871,7 @@ static bool IsInternetAddress(const char* filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
wxIcon* OsWin32_LoadIcon(const char* filename)
|
||||
wxIcon OsWin32_LoadIcon(const char* filename)
|
||||
{
|
||||
int icon_number = 0;
|
||||
|
||||
@ -920,25 +922,11 @@ wxIcon* OsWin32_LoadIcon(const char* filename)
|
||||
if (ext_pos > 0)
|
||||
key.Truncate(ext_pos+4);
|
||||
|
||||
wxIcon* ico = new wxIcon;
|
||||
/*
|
||||
int icon = 0;
|
||||
HINSTANCE hInst = NULL;
|
||||
HICON hicon = ::ExtractIcon(hInst, key, icon_number);
|
||||
if (hicon == NULL && icon_number != 0)
|
||||
hicon = ::ExtractIcon(hInst, key, 0);
|
||||
if (hicon != NULL)
|
||||
{
|
||||
DWORD dwicon = DWORD((DWORD*)hicon);
|
||||
icon = LOWORD(dwicon);
|
||||
}
|
||||
ico->SetHandle(icon);
|
||||
*/
|
||||
wxString strFullName = key;
|
||||
if (icon_number > 0)
|
||||
strFullName << ";" << icon_number;
|
||||
ico->LoadFile(strFullName, wxBITMAP_TYPE_ICO, 32, 32);
|
||||
|
||||
|
||||
wxIcon ico(strFullName, wxBITMAP_TYPE_ICO);
|
||||
return ico;
|
||||
}
|
||||
|
||||
@ -948,7 +936,7 @@ bool OsWin32_GotoUrl(const char* url, const char* action)
|
||||
bool ok = false;
|
||||
|
||||
// Sarebbe meglio un flag esplicito, ma per ora attendiamo solo le stampe
|
||||
if (action && strcmp(action, "print") == 0)
|
||||
if (action && wxStricmp(action, "print") == 0)
|
||||
{
|
||||
SHELLEXECUTEINFO sei; memset(&sei, 0, sizeof(sei));
|
||||
sei.cbSize = sizeof(sei);
|
||||
@ -1039,25 +1027,10 @@ bool OsWin32_Speak(const char* text, bool async)
|
||||
|
||||
#endif
|
||||
|
||||
typedef BOOL (PASCAL *pfnProcessIdToSessionId)(DWORD dwProcessId,DWORD* pSessionId);
|
||||
|
||||
int OsWin32_GetSessionId()
|
||||
{
|
||||
DWORD session = 0;
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
//modifiche del 1/2/08 per poter gestire le licenze con win2000/2003/2008 server edition
|
||||
::ProcessIdToSessionId(GetCurrentProcessId(), &session);
|
||||
#else
|
||||
//modifiche del 5/4/04 per poter gestire le licenze con win2000/2003 server edition
|
||||
HMODULE kernel = GetModuleHandle("kernel32.dll");
|
||||
if (kernel != NULL)
|
||||
{
|
||||
pfnProcessIdToSessionId fn = (pfnProcessIdToSessionId)GetProcAddress(kernel, "ProcessIdToSessionId");
|
||||
if (fn != NULL)
|
||||
fn(GetCurrentProcessId(), &session);
|
||||
}
|
||||
#endif
|
||||
::ProcessIdToSessionId(::GetCurrentProcessId(), &session);
|
||||
return (int)session;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ void OsWin32_DrawDottedRect(WXHDC hDC, int left, int top, int right, int bottom)
|
||||
|
||||
wxString OsWin32_File2App(const char* filename);
|
||||
bool OsWin32_GotoUrl(const char* url, const char* action);
|
||||
wxIcon* OsWin32_LoadIcon(const char* file);
|
||||
wxIcon OsWin32_LoadIcon(const char* file);
|
||||
|
||||
int OsWin32_EnumerateFamilies(WXHDC hDC, char** families, int max_count);
|
||||
int OsWin32_EnumerateSizes(WXHDC hDC, const char* name, long* sizes, short* scalable, int max_count);
|
||||
|
434
xvaga/xvaga.cpp
434
xvaga/xvaga.cpp
@ -1,5 +1,6 @@
|
||||
#include "wxinc.h"
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/calctrl.h>
|
||||
#include <wx/colordlg.h>
|
||||
@ -22,6 +23,7 @@
|
||||
#include "agasys.h"
|
||||
#include "fstrcmp.h"
|
||||
#include "matche.h"
|
||||
#include "xvtart.h"
|
||||
#include "xvtwin.h"
|
||||
|
||||
#ifdef WIN32
|
||||
@ -32,7 +34,6 @@
|
||||
#include <unistd.h>
|
||||
#include "oslinux.h"
|
||||
#include <wx/dcps.h>
|
||||
#include <wx/hash.h>
|
||||
#endif
|
||||
|
||||
#define XVT_ASSERT(test) _AssertBox((test), __FUNCTION__, __FILE__, __LINE__)
|
||||
@ -50,25 +51,32 @@ wxString _strDefaultStatbarText;
|
||||
wxString _appl_name;
|
||||
wxLocale* _locale = NULL;
|
||||
|
||||
static wxHashTable _nice_icons;
|
||||
static XVT_ERRMSG_HANDLER _error_handler = NULL;
|
||||
|
||||
const wxString& _GetAppTitle()
|
||||
{ return _appl_name; }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMessageBox
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TMessageBox : public wxDialog
|
||||
{
|
||||
wxTimer m_timer;
|
||||
|
||||
protected:
|
||||
void OnButton(wxCommandEvent& evt);
|
||||
void OnTimeout(wxTimerEvent& evt);
|
||||
void AddButton(wxSizer* sz, int id, int ico);
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
TMessageBox(const wxString& msg, int nStyle);
|
||||
TMessageBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTimeout = 0);
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(TMessageBox, wxDialog)
|
||||
EVT_BUTTON(wxID_ANY, TMessageBox::OnButton)
|
||||
EVT_TIMER(wxID_ANY, TMessageBox::OnTimeout)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TMessageBox::OnButton(wxCommandEvent& evt)
|
||||
@ -84,27 +92,44 @@ void TMessageBox::OnButton(wxCommandEvent& evt)
|
||||
EndModal(ec);
|
||||
}
|
||||
|
||||
void TMessageBox::OnTimeout(wxTimerEvent& WXUNUSED(evt))
|
||||
{
|
||||
wxWindowID id = GetEscapeId();
|
||||
if (id <= 0)
|
||||
id = GetAffirmativeId();
|
||||
if (id > 0)
|
||||
{
|
||||
wxCommandEvent cmd(wxEVT_COMMAND_BUTTON_CLICKED, id);
|
||||
AddPendingEvent(cmd);
|
||||
}
|
||||
else
|
||||
EndModal(wxCANCEL);
|
||||
}
|
||||
|
||||
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)
|
||||
TMessageBox::TMessageBox(wxWindow* pParent, const wxString& msg, int nStyle, int nTimeout)
|
||||
: wxDialog(pParent, wxID_ANY, _GetAppTitle(), wxDefaultPosition, wxDefaultSize,
|
||||
wxCAPTION | wxRAISED_BORDER), m_timer(this)
|
||||
{
|
||||
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;
|
||||
|
||||
wxArtID nIco = wxART_INFORMATION;
|
||||
if (nStyle & wxICON_HAND) nIco = wxART_ERROR;
|
||||
if (nStyle & wxICON_INFORMATION) nIco = wxART_INFORMATION;
|
||||
if (nStyle & wxICON_EXCLAMATION) nIco = wxART_WARNING;
|
||||
if (nStyle & wxICON_QUESTION) nIco = wxART_QUESTION;
|
||||
const wxBitmap img = wxArtProvider::GetBitmap(nIco, wxART_MESSAGE_BOX, wxSize(64,64));
|
||||
|
||||
const int nBorder = 8;
|
||||
sz1->Add(new wxStaticBitmap(this, nIco, _GetToolResource(nIco, 64)), 0, wxALL, nBorder);
|
||||
sz1->Add(new wxStaticBitmap(this, wxID_ANY, img), 0, wxALL, nBorder);
|
||||
wxStaticText* ss = new wxStaticText(this, wxID_ANY, wxEmptyString);
|
||||
ss->Wrap(160);
|
||||
ss->SetLabel(msg);
|
||||
@ -116,14 +141,17 @@ TMessageBox::TMessageBox(const wxString& msg, int nStyle)
|
||||
sizer->Add(sz2, 0, wxALIGN_CENTER);
|
||||
if (nStyle & wxYES_NO)
|
||||
{
|
||||
SetAffirmativeId(wxID_YES);
|
||||
if (nStyle & wxNO_DEFAULT)
|
||||
{
|
||||
SetAffirmativeId(wxID_NO);
|
||||
SetEscapeId(wxID_YES);
|
||||
AddButton(sz2, wxID_NO, 102);
|
||||
AddButton(sz2, wxID_YES, 101);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAffirmativeId(wxID_YES);
|
||||
SetEscapeId(wxID_NO);
|
||||
AddButton(sz2, wxID_YES, 101);
|
||||
AddButton(sz2, wxID_NO, 102);
|
||||
}
|
||||
@ -139,26 +167,32 @@ TMessageBox::TMessageBox(const wxString& msg, int nStyle)
|
||||
AddButton(sz2, wxID_CANCEL, 102);
|
||||
}
|
||||
|
||||
sizer->SetSizeHints(this);
|
||||
SetSizerAndFit(sizer);
|
||||
|
||||
if (nStyle & wxCENTRE)
|
||||
Centre();
|
||||
|
||||
if (nTimeout > 0)
|
||||
m_timer.Start(1000*nTimeout, true);
|
||||
}
|
||||
|
||||
int _MessageBox(const wxString& msg, int nStyle)
|
||||
///////////////////////////////////////////////////////////
|
||||
// _*Box
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int _MessageBox(const wxString& msg, int nStyle, int nTimeout = 0)
|
||||
{
|
||||
xvt_dm_post_speech(msg, 1, TRUE);
|
||||
|
||||
//int ret = ::wxMessageBox(msg, _GetAppTitle(), nStyle);
|
||||
TMessageBox dlg(msg, nStyle);
|
||||
TMessageBox dlg(NULL, msg, nStyle, nTimeout);
|
||||
const int ret = dlg.ShowModal();
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
@ -178,6 +212,95 @@ void _AssertBox(bool test, const char* func, const char* file, int line)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// _PopUpBox
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TPopUpBox : public wxDialog
|
||||
{
|
||||
DECLARE_EVENT_TABLE();
|
||||
wxTimer m_Timer;
|
||||
int m_nStep;
|
||||
|
||||
protected:
|
||||
void OnTimer(wxTimerEvent& evt);
|
||||
void OnChar(wxKeyEvent& evt);
|
||||
|
||||
public:
|
||||
TPopUpBox(wxWindow* pParent, const wxString& msg, int nStyle);
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(TPopUpBox, wxDialog)
|
||||
EVT_TIMER(wxID_ANY, TPopUpBox::OnTimer)
|
||||
EVT_CHAR(TPopUpBox::OnChar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TPopUpBox::OnChar(wxKeyEvent& WXUNUSED(evt))
|
||||
{
|
||||
if (IsShown())
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void TPopUpBox::OnTimer(wxTimerEvent& WXUNUSED(evt))
|
||||
{
|
||||
if (IsShown())
|
||||
{
|
||||
const wxRect rctMain = GetParent()->GetRect();
|
||||
const wxRect rctMine = GetRect();
|
||||
const int msec = (m_nStep++)*m_Timer.GetInterval();
|
||||
if (msec <= 1000)
|
||||
{
|
||||
const int perc = msec/10;
|
||||
Move(0, rctMain.GetBottom() - rctMine.height * perc / 100);
|
||||
}
|
||||
if (msec >= 3000 && msec <= 4000)
|
||||
{
|
||||
const int perc = (4000-msec)/10;
|
||||
Move(0, rctMain.GetBottom() - rctMine.height * perc / 100);
|
||||
}
|
||||
if (msec > 4000)
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
}
|
||||
|
||||
TPopUpBox::TPopUpBox(wxWindow* pParent, const wxString& msg, int nStyle)
|
||||
: wxDialog(pParent, wxID_ANY, wxEmptyString, wxPoint(0,2024), wxDefaultSize, wxBORDER_SIMPLE),
|
||||
m_Timer(this), m_nStep(0)
|
||||
{
|
||||
wxBoxSizer* sz = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
wxArtID nIco = wxART_ERROR;
|
||||
if (nStyle & wxICON_HAND) nIco = wxART_ERROR;
|
||||
if (nStyle & wxICON_INFORMATION) nIco = wxART_INFORMATION;
|
||||
if (nStyle & wxICON_EXCLAMATION) nIco = wxART_WARNING;
|
||||
const wxBitmap img = wxArtProvider::GetBitmap(nIco, wxART_MESSAGE_BOX, wxSize(64,64));
|
||||
|
||||
wxStaticBitmap* bmp = new wxStaticBitmap(this, wxID_ANY, img);
|
||||
sz->Add(bmp, 0, wxALL, 8);
|
||||
|
||||
wxStaticText* ss = new wxStaticText(this, wxID_ANY, wxEmptyString);
|
||||
ss->Wrap(160);
|
||||
ss->SetLabel(msg);
|
||||
sz->Add(ss, 0, wxALL | wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 8);
|
||||
|
||||
SetSizerAndFit(sz);
|
||||
m_Timer.Start(25);
|
||||
}
|
||||
|
||||
static void _PopUpBox(const wxString& msg, int nStyle)
|
||||
{
|
||||
const int oem = xvt_sys_get_oem_int("OEM", -1);
|
||||
if (oem == 0)
|
||||
{
|
||||
wxWindow* pFrame = wxTheApp->GetTopWindow();
|
||||
xvt_sys_beep(nStyle & wxICON_ERROR ? 2 : 1);
|
||||
TPopUpBox dlg(pFrame, msg, nStyle);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
else
|
||||
_MessageBox(msg, nStyle|wxOK|wxCENTRE, 4);
|
||||
}
|
||||
|
||||
void xvt_sys_sorry_box(const char* func, const char* file, int line)
|
||||
{
|
||||
static wxHashTable sorry(wxKEY_STRING);
|
||||
@ -187,7 +310,7 @@ void xvt_sys_sorry_box(const char* func, const char* file, int line)
|
||||
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);
|
||||
_PopUpBox(strMessage, wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +323,7 @@ void xvt_sys_deprecated_box(const char* func, const char* file, int line)
|
||||
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);
|
||||
_MessageBox(strMessage, wxOK | wxICON_WARNING);
|
||||
_PopUpBox(strMessage, wxICON_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,127 +340,6 @@ static bool RectIntersect(const wxRect &rect1, const wxRect &rect2)
|
||||
return true;
|
||||
}
|
||||
|
||||
wxString GetResourceIni()
|
||||
{ return _startup_dir + "/res/resource.ini"; }
|
||||
|
||||
wxString _GetResourceName(const char* type, int rid)
|
||||
{
|
||||
wxString strName(type); strName << "s";
|
||||
wxString strKey; strKey.Printf("%d", rid);
|
||||
|
||||
if ((rid == ICON_RSRC || rid == 0) && strName == "Icons")
|
||||
{
|
||||
wxString strFileName = _startup_dir + "/setup/oem.ini";
|
||||
const int oem = xvt_sys_get_profile_int(strFileName, "MAIN", "OEM", -1);
|
||||
if (oem >= 0)
|
||||
{
|
||||
wxString strPara; strPara << "OEM_" << oem;
|
||||
char name[MAX_PATH];
|
||||
xvt_sys_get_profile_string(strFileName, strPara, "Icon", "", name, sizeof(name));
|
||||
if (*name)
|
||||
{
|
||||
strFileName = _startup_dir + "/setup/" + name;
|
||||
if (wxFileExists(strFileName))
|
||||
return strFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxString val;
|
||||
char* buff = val.GetWriteBuf(MAX_PATH);
|
||||
xvt_sys_get_profile_string(GetResourceIni(), strName, strKey, "", buff, MAX_PATH);
|
||||
val.UngetWriteBuf();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static wxIcon* _GetDefaultIcon()
|
||||
{
|
||||
wxIcon* icon = NULL;
|
||||
|
||||
wxString strName = _GetResourceName("Icon", ICON_RSRC);
|
||||
if (::wxFileExists(strName))
|
||||
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
|
||||
else
|
||||
{
|
||||
strName.Printf("%d", ICON_RSRC);
|
||||
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO_RESOURCE);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
const wxIcon& _GetIconResource(int rid)
|
||||
{
|
||||
wxIcon* icon = wxDynamicCast(_nice_icons.Get(rid), wxIcon);
|
||||
if (icon == NULL)
|
||||
{
|
||||
if (rid > 0 && rid != ICON_RSRC)
|
||||
{
|
||||
const wxString strName = _GetResourceName("Icon", rid);
|
||||
if (::wxFileExists(strName))
|
||||
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
|
||||
}
|
||||
if (icon == NULL)
|
||||
icon = _GetDefaultIcon(); // Icona di salvezza
|
||||
|
||||
_nice_icons.Put(rid, icon);
|
||||
}
|
||||
return *icon;
|
||||
}
|
||||
|
||||
const wxCursor* GetCursorResource(int rid)
|
||||
{
|
||||
static wxHashTable _nice_cursors;
|
||||
const wxCursor* cursor = wxDynamicCast(_nice_cursors.Get(rid), wxCursor);
|
||||
if (cursor == NULL)
|
||||
{
|
||||
switch (rid)
|
||||
{
|
||||
case CURSOR_CROCE: cursor = new wxCursor(wxCURSOR_CROSS); break;
|
||||
case CURSOR_IBEAM: cursor = new wxCursor(wxCURSOR_IBEAM); break;
|
||||
default:
|
||||
{
|
||||
const wxString strName = _GetResourceName("Cursor", rid);
|
||||
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)
|
||||
{
|
||||
XVT_ASSERT(false);
|
||||
cursor = wxSTANDARD_CURSOR;
|
||||
}
|
||||
_nice_cursors.Put(rid, (wxCursor*)cursor);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Font cache
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -434,6 +436,7 @@ XVTDLL void xvt_app_pre_create(void)
|
||||
_locale->AddCatalog("wxstd", wxLanguage(_locale->GetLanguage()), NULL);
|
||||
|
||||
::wxInitAllImageHandlers();
|
||||
xvtart_Init();
|
||||
|
||||
#ifdef WIN32
|
||||
if (::wxDisplayDepth() >= 32 && wxTheApp->GetComCtl32Version() >= 600)
|
||||
@ -567,7 +570,7 @@ void xvt_app_create(int argc, char **argv, unsigned long WXUNUSED(flags),
|
||||
// Simula main loop
|
||||
xvt_app_process_pending_events();
|
||||
}
|
||||
a->ExitMainLoop(); // Non entrare nel main loop di wxWindows
|
||||
a->ExitMainLoop(); // Non entrare nel main loop di wxWidgets
|
||||
}
|
||||
|
||||
void xvt_app_destroy(void)
|
||||
@ -600,10 +603,13 @@ DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS *ct)
|
||||
void xvt_app_process_pending_events(void)
|
||||
{
|
||||
wxApp* a = wxTheApp; // Memorizzo il risultato di wxGetInstance
|
||||
while (a->Pending())
|
||||
a->Dispatch();
|
||||
a->ProcessIdle(); // Necessario per wxAUI
|
||||
a->Yield(true); // Non so se serva veramente
|
||||
if (a != NULL) // Puo' succedere!
|
||||
{
|
||||
while (a->Pending())
|
||||
a->Dispatch();
|
||||
a->ProcessIdle(); // Necessario per wxAUI
|
||||
a->Yield(true); // Non so se serva veramente
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1072,6 +1078,21 @@ void xvt_dm_post_warning(const char *fmt)
|
||||
_MessageBox(fmt, wxOK | wxCENTRE | wxICON_EXCLAMATION);
|
||||
}
|
||||
|
||||
void xvt_dm_popup_error(const char *fmt)
|
||||
{
|
||||
_PopUpBox(fmt, wxICON_HAND);
|
||||
}
|
||||
|
||||
void xvt_dm_popup_message(const char *fmt)
|
||||
{
|
||||
_PopUpBox(fmt, wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
void xvt_dm_popup_warning(const char *fmt)
|
||||
{
|
||||
_PopUpBox(fmt, wxICON_EXCLAMATION);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Help system
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1456,7 +1477,7 @@ void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR c
|
||||
|
||||
void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid)
|
||||
{
|
||||
const wxIcon& ico = _GetIconResource(rid);
|
||||
const wxIcon ico = xvtart_GetIconResource(rid);
|
||||
if (ico.IsOk())
|
||||
{
|
||||
CAST_DC(win, dc);
|
||||
@ -3058,7 +3079,7 @@ XVT_FNTID xvt_res_get_font(int rid)
|
||||
|
||||
XVT_IMAGE xvt_res_get_icon(int rid)
|
||||
{
|
||||
const wxIcon& icon = _GetIconResource(rid);
|
||||
const wxIcon icon = xvtart_GetIconResource(rid);
|
||||
int w = icon.GetWidth(); if (w <= 0) w = 32;
|
||||
int h = icon.GetHeight(); if (h <= 0) h = 32;
|
||||
wxBitmap bmp(w, h, icon.GetDepth());
|
||||
@ -3074,7 +3095,7 @@ XVT_IMAGE xvt_res_get_icon(int rid)
|
||||
|
||||
XVT_IMAGE xvt_res_get_image(int rid)
|
||||
{
|
||||
const wxString strFileName = _GetResourceName("Image", rid);
|
||||
const wxString strFileName = xvtart_GetResourceName("Image", rid);
|
||||
const bool ok = !strFileName.IsEmpty();
|
||||
XVT_ASSERT(ok);
|
||||
return ok ? xvt_image_read(strFileName) : NULL;
|
||||
@ -3126,7 +3147,7 @@ static void FillMenuItem(const wxString& strValue, MENU_ITEM* mi)
|
||||
|
||||
MENU_ITEM* xvt_res_get_menu(int rid)
|
||||
{
|
||||
wxFileConfig ini("", "", GetResourceIni());
|
||||
wxFileConfig ini("", "", xvtart_GetResourceIni());
|
||||
|
||||
const int MAX_MENU = 16;
|
||||
MENU_ITEM* TheMenu = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*MAX_MENU);
|
||||
@ -3136,7 +3157,7 @@ MENU_ITEM* xvt_res_get_menu(int rid)
|
||||
{
|
||||
wxFileName::SplitPath(wxTheApp->argv[0], NULL, &strName, NULL);
|
||||
strName.MakeUpper();
|
||||
strName.Printf("/Menu_%s-%X", (const char *) strName.Left(3), (rid-1)%16);
|
||||
strName.Printf("/Menu_%s-%X", (const char*)strName.Left(3), (rid-1)%16);
|
||||
}
|
||||
else
|
||||
strName.Printf("/Menu_%d", rid);
|
||||
@ -3177,7 +3198,7 @@ MENU_ITEM* xvt_res_get_menu(int rid)
|
||||
char* xvt_res_get_str(int rid, char *s, int sz_s)
|
||||
{
|
||||
XVT_ASSERT(s != NULL && sz_s > 0);
|
||||
const wxString str = _GetResourceName("String", rid);
|
||||
const wxString str = xvtart_GetResourceName("String", rid);
|
||||
wxStrncpy(s, str, sz_s);
|
||||
s[sz_s-1] = '\0';
|
||||
return s;
|
||||
@ -3187,10 +3208,10 @@ char* xvt_res_get_str(int rid, char *s, int sz_s)
|
||||
// Scroll bars
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#define CAST_SCROLL(win, sb) XVT_ASSERT(win != NULL_WIN); wxScrollBar& sb = *(wxScrollBar*)win;
|
||||
#define CAST_GAUGE(win, pb) wxGauge& pb = *wxStaticCast((wxObject*)win, wxGauge);
|
||||
#define CAST_SLIDER(win, sc) wxSlider& sc = *wxStaticCast((wxObject*)win, wxSlider);
|
||||
#define CAST_SCROLL(win, sb) wxScrollBar& sb = *wxStaticCast((wxObject*)win, wxScrollBar);
|
||||
#define CAST_SCROLL_TYPE(t, dir) const int dir = t == HSCROLL ? wxHORIZONTAL : wxVERTICAL;
|
||||
#define CAST_GAUGE(win, pb) XVT_ASSERT(win != NULL_WIN); wxGauge& pb = *(wxGauge*)win;
|
||||
#define CAST_SLIDER(win, sc) XVT_ASSERT(win != NULL_WIN); wxSlider& sc = *(wxSlider*)win;
|
||||
|
||||
int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t)
|
||||
{
|
||||
@ -3258,6 +3279,7 @@ int xvt_sbar_get_proportion(WINDOW win, SCROLL_TYPE t)
|
||||
|
||||
void xvt_sbar_get_range(WINDOW win, SCROLL_TYPE t, int *minp, int *maxp)
|
||||
{
|
||||
wxASSERT(minp && maxp);
|
||||
*minp = 0;
|
||||
switch (t)
|
||||
{
|
||||
@ -3646,11 +3668,13 @@ int xvt_net_get_status()
|
||||
nStatus = 0x1; // 1 = Online
|
||||
|
||||
if (dum->IsAlwaysOnline())
|
||||
{
|
||||
nStatus |= 0x2; // 2 = Always Online
|
||||
|
||||
wxArrayString isp;
|
||||
if (dum->GetISPNames(isp) > 0)
|
||||
nStatus |= 0x4; // 4 = Internet enabled
|
||||
wxArrayString isp;
|
||||
if (dum->GetISPNames(isp) > 0)
|
||||
nStatus |= 0x4; // 4 = Internet enabled
|
||||
}
|
||||
}
|
||||
delete dum;
|
||||
}
|
||||
@ -3799,6 +3823,35 @@ BOOLEAN xvt_sys_dongle_server_is_running()
|
||||
return sic.IsAnotherRunning();
|
||||
}
|
||||
|
||||
int xvt_sys_get_oem_string(const char* name, const char* defval, char* value, int maxsize)
|
||||
{
|
||||
wxString strFileName = _startup_dir + "/setup/oem.ini";
|
||||
const int oem = xvt_sys_get_profile_int(strFileName, "MAIN", "OEM", -1);
|
||||
if (oem >= 0)
|
||||
{
|
||||
wxString strPara; strPara << "OEM_" << oem;
|
||||
return xvt_sys_get_profile_string(strFileName, strPara, name, defval, value, maxsize);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long xvt_sys_get_oem_int(const char* name, long defval)
|
||||
{
|
||||
wxString strFileName = _startup_dir + "/setup/oem.ini";
|
||||
const int oem = xvt_sys_get_profile_int(strFileName, "MAIN", "OEM", -1);
|
||||
if (oem >= 0)
|
||||
{
|
||||
if (wxStricmp(name, "OEM") != 0)
|
||||
{
|
||||
wxString strPara; strPara << "OEM_" << oem;
|
||||
defval = xvt_sys_get_profile_int(strFileName, strPara, name, defval);
|
||||
}
|
||||
else
|
||||
defval = oem;
|
||||
}
|
||||
return defval;
|
||||
}
|
||||
|
||||
int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
const char* defval, char* value, int maxsize)
|
||||
{
|
||||
@ -3878,56 +3931,11 @@ BOOLEAN xvt_sys_find_editor(const char* file, char* editor)
|
||||
#endif
|
||||
ok = !e.IsEmpty();
|
||||
if (ok && editor != NULL)
|
||||
wxStrcpy(editor, e);
|
||||
wxStrncpy(editor, e, _MAX_PATH);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
unsigned int xvt_sys_load_icon(const char* file)
|
||||
{
|
||||
unsigned int id = 0;
|
||||
wxIcon* icon = NULL;
|
||||
|
||||
wxString str = file;
|
||||
str.MakeLower();
|
||||
if (str.EndsWith(".ico"))
|
||||
icon = new wxIcon(file, wxBITMAP_TYPE_ICO);
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
icon = OsWin32_LoadIcon(file);
|
||||
#else
|
||||
icon = new wxIcon;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (icon != NULL)
|
||||
{
|
||||
for (id = 60001; ; id++)
|
||||
{
|
||||
wxIcon* ico = wxDynamicCast(_nice_icons.Get(id), wxIcon);
|
||||
if (ico == NULL)
|
||||
{
|
||||
_nice_icons.Put(id, icon);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (ico->GetHICON() == icon->GetHICON()) // C'e' gia'
|
||||
#else
|
||||
if (ico == icon) // C'e' gia'
|
||||
#endif
|
||||
{
|
||||
delete icon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
int xvt_sys_get_session_id()
|
||||
{
|
||||
@ -4681,15 +4689,15 @@ void xvt_win_release_pointer(void)
|
||||
void xvt_win_set_cursor(WINDOW win, CURSOR cursor)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
const wxCursor* cur = wxSTANDARD_CURSOR; // Dummy initilization
|
||||
wxCursor cur;
|
||||
switch (cursor)
|
||||
{
|
||||
case CURSOR_ARROW: cur = wxSTANDARD_CURSOR; break;
|
||||
case CURSOR_CROCE: cur = wxCROSS_CURSOR; break;
|
||||
case CURSOR_WAIT : cur = wxHOURGLASS_CURSOR; break;
|
||||
default: cur = GetCursorResource(cursor); break; // Always succeeds
|
||||
case CURSOR_ARROW: cur = *wxSTANDARD_CURSOR; break;
|
||||
case CURSOR_CROCE: cur = *wxCROSS_CURSOR; break;
|
||||
case CURSOR_WAIT : cur = *wxHOURGLASS_CURSOR; break;
|
||||
default: cur = xvtart_GetCursorResource(cursor); break; // Always succeeds
|
||||
}
|
||||
w.SetCursor(*cur);
|
||||
w.SetCursor(cur);
|
||||
}
|
||||
|
||||
void xvt_win_set_handler(WINDOW win, EVENT_HANDLER eh)
|
||||
|
11
xvaga/xvt.h
11
xvaga/xvt.h
@ -64,7 +64,11 @@ XVTDLL WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long ap
|
||||
XVTDLL void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check);
|
||||
XVTDLL void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR_ACTION action);
|
||||
|
||||
XVTDLL void xvt_debug_printf(const char* fmt, ...);
|
||||
XVTDLL void xvt_debug_printf(const char* fmt, ...);
|
||||
|
||||
XVTDLL void xvt_dm_popup_message(const char *fmt);
|
||||
XVTDLL void xvt_dm_popup_warning(const char *fmt);
|
||||
XVTDLL void xvt_dm_popup_error(const char *fmt);
|
||||
|
||||
XVTDLL ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3, const char* xin_buffer);
|
||||
XVTDLL COLOR xvt_dm_post_choose_color(WINDOW win, COLOR c); // Added by guy
|
||||
@ -379,11 +383,12 @@ XVTDLL BOOLEAN xvt_sys_goto_url(const char* url, const char* action);
|
||||
XVTDLL BOOLEAN xvt_sys_dongle_server_is_running();
|
||||
XVTDLL BOOLEAN xvt_sys_find_editor(const char* file, char* editor);
|
||||
XVTDLL BOOLEAN xvt_sys_get_env(const char* varname, char* value, int max_size);
|
||||
XVTDLL long xvt_sys_get_oem_int(const char* name, long defval);
|
||||
XVTDLL int xvt_sys_get_oem_string(const char* name, const char* defval, char* value, int maxsize);
|
||||
XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
const char* defval, char* value, int maxsize);
|
||||
XVTDLL long xvt_sys_get_profile_int(const char* file, const char* paragraph, const char* name, long defval);
|
||||
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
const char* value);
|
||||
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name, const char* value);
|
||||
XVTDLL int xvt_sys_get_session_id();
|
||||
XVTDLL unsigned long xvt_sys_get_free_memory();
|
||||
XVTDLL unsigned long xvt_sys_get_free_memory_kb();
|
||||
|
@ -300,9 +300,9 @@ BOOLEAN active;
|
||||
} listedit;
|
||||
struct s_notebk {
|
||||
|
||||
WINDOW face;
|
||||
short tab_no;
|
||||
short page_no;
|
||||
WINDOW page;
|
||||
short page_new;
|
||||
short page_old;
|
||||
|
||||
} notebk;
|
||||
struct s_html {
|
||||
|
337
xvaga/xvtart.cpp
Executable file
337
xvaga/xvtart.cpp
Executable file
@ -0,0 +1,337 @@
|
||||
#include "wxinc.h"
|
||||
|
||||
#include "xvt.h"
|
||||
#include "xvtart.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "oswin32.h"
|
||||
#endif
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
wxString xvtart_GetResourceIni()
|
||||
{
|
||||
DIRECTORY dir; xvt_fsys_get_default_dir(&dir);
|
||||
wxString str = dir.path;
|
||||
str += "/res/resource.ini";
|
||||
return str;
|
||||
}
|
||||
|
||||
wxString xvtart_GetResourceName(const char* type, int rid)
|
||||
{
|
||||
wxString strName(type); strName << "s";
|
||||
wxString strKey; strKey.Printf("%d", rid);
|
||||
|
||||
DIRECTORY dir; xvt_fsys_get_default_dir(&dir);
|
||||
wxString startup_dir = dir.path;
|
||||
|
||||
if ((rid == ICON_RSRC || rid == 0) && strName == "Icons")
|
||||
{
|
||||
char name[MAX_PATH];
|
||||
if (xvt_sys_get_oem_string("Icon", "", name, sizeof(name)))
|
||||
{
|
||||
wxFileName fname(startup_dir + "/setup/" + name);
|
||||
if (fname.FileExists())
|
||||
{
|
||||
fname.Normalize();
|
||||
strName = fname.GetFullPath().Lower();
|
||||
return strName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxString val;
|
||||
char* buff = val.GetWriteBuf(MAX_PATH);
|
||||
xvt_sys_get_profile_string(xvtart_GetResourceIni(), strName, strKey, "", buff, MAX_PATH);
|
||||
val.UngetWriteBuf();
|
||||
|
||||
if (!val.IsEmpty())
|
||||
{
|
||||
strName = startup_dir;
|
||||
strName += "/custom/";
|
||||
strName += val;
|
||||
|
||||
if (!wxFileExists(strName))
|
||||
{
|
||||
strName = startup_dir;
|
||||
strName += "/res/";
|
||||
strName += val;
|
||||
}
|
||||
|
||||
wxFileName fname(strName.Lower());
|
||||
fname.Normalize();
|
||||
strName = fname.GetFullPath();
|
||||
}
|
||||
else
|
||||
strName.Empty();
|
||||
|
||||
return strName;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TArtProvider
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TArtProvider : public wxArtProvider
|
||||
{
|
||||
#if !wxCHECK_VERSION(2,9,0)
|
||||
WX_DECLARE_STRING_HASH_MAP(wxIconBundle, TIconBundleHashTable);
|
||||
TIconBundleHashTable m_hmBundles;
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP(unsigned, TIconIdHashTable);
|
||||
TIconIdHashTable m_hmIds;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size);
|
||||
virtual wxIconBundle CreateIconBundle(const wxArtID& id, const wxArtClient& client);
|
||||
|
||||
public:
|
||||
#if !wxCHECK_VERSION(2,9,0)
|
||||
wxIconBundle GetIconBundle(const wxArtID& id, const wxArtClient& client);
|
||||
wxIcon GetIcon(const wxArtID& id, const wxArtClient& client = wxART_OTHER, const wxSize& size = wxDefaultSize);
|
||||
wxSize GetNativeSizeHint(const wxArtClient& client);
|
||||
#endif
|
||||
unsigned int GetIconBundleNumber(const wxArtID& id);
|
||||
};
|
||||
|
||||
TArtProvider* _TheArtProvider = NULL;
|
||||
|
||||
void xvtart_Init()
|
||||
{
|
||||
if (_TheArtProvider == NULL)
|
||||
_TheArtProvider = new TArtProvider;
|
||||
wxArtProvider::Push(_TheArtProvider);
|
||||
}
|
||||
|
||||
wxBitmap TArtProvider::CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size)
|
||||
{
|
||||
wxString strName;
|
||||
|
||||
long tool = -1;
|
||||
if (id.StartsWith(wxT("wxART")))
|
||||
{
|
||||
if (id == wxART_ERROR) tool = 201; else
|
||||
if (id == wxART_HELP) tool = 163; else
|
||||
if (id == wxART_INFORMATION) tool = 162; else
|
||||
if (id == wxART_NEW) tool = 105; else
|
||||
if (id == wxART_QUESTION) tool = 202; else
|
||||
if (id == wxART_QUIT) tool = 114; else
|
||||
if (id == wxART_WARNING) tool = 203; else
|
||||
;
|
||||
}
|
||||
else
|
||||
id.ToLong(&tool);
|
||||
|
||||
if (tool > 0)
|
||||
{
|
||||
strName = xvtart_GetResourceName("Tool", tool);
|
||||
if (strName.IsEmpty() || !::wxFileExists(strName))
|
||||
strName = xvtart_GetResourceName("Tool", 100); // Default empty icon
|
||||
}
|
||||
else
|
||||
strName = id;
|
||||
|
||||
if (!strName.IsEmpty() && ::wxFileExists(strName))
|
||||
{
|
||||
if (strName.EndsWith(".ico"))
|
||||
{
|
||||
const wxIcon ico = GetIcon(strName, client, size);
|
||||
return wxBitmap(ico);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sx = size.x, sy = size.y;
|
||||
if (sx <= 0 || sy <= 0)
|
||||
{
|
||||
const wxSize sz = GetNativeSizeHint(client);
|
||||
if (sx <= 0) sx = sz.x;
|
||||
if (sy <= 0) sy = sz.y;
|
||||
}
|
||||
wxImage img(strName, wxBITMAP_TYPE_ANY);
|
||||
img.Rescale(sx, sy, wxIMAGE_QUALITY_HIGH);
|
||||
return wxBitmap(img);
|
||||
}
|
||||
}
|
||||
|
||||
return wxNullBitmap;
|
||||
}
|
||||
|
||||
wxIconBundle TArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& WXUNUSED(client))
|
||||
{
|
||||
wxString strName = id;
|
||||
|
||||
long nIco = -1;
|
||||
if (id.StartsWith(wxT("wxART")))
|
||||
{
|
||||
if (id == wxART_EXECUTABLE_FILE) nIco = ICON_RSRC; else
|
||||
;
|
||||
}
|
||||
else
|
||||
id.ToLong(&nIco);
|
||||
|
||||
if (nIco > 0)
|
||||
strName = xvtart_GetResourceName("Icon", nIco);
|
||||
|
||||
wxIconBundle ib;
|
||||
bool bFound = false;
|
||||
if (::wxFileExists(strName))
|
||||
{
|
||||
const bool bLog = wxLog::EnableLogging(false); // Evita segnalazione di errore di formato icona
|
||||
if (strName.EndsWith(wxT(".ico")))
|
||||
{
|
||||
ib.AddIcon(strName, wxBITMAP_TYPE_ICO);
|
||||
bFound = true;
|
||||
}
|
||||
#ifdef __WXMSW__
|
||||
else
|
||||
{
|
||||
ib.AddIcon(OsWin32_LoadIcon(strName));
|
||||
bFound = true;
|
||||
}
|
||||
#endif
|
||||
wxLog::EnableLogging(bLog);
|
||||
}
|
||||
#ifdef __WXMSW__
|
||||
else
|
||||
{
|
||||
if (!strName.IsEmpty()) // Getione caso strName=".ext"
|
||||
{
|
||||
ib.AddIcon(OsWin32_LoadIcon(strName));
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!bFound && nIco == ICON_RSRC)
|
||||
{
|
||||
strName.Printf("%d", ICON_RSRC); // id puo' essere wxART_EXECUTABLE_FILE
|
||||
ib.AddIcon(wxIcon(strName, wxBITMAP_TYPE_ICO_RESOURCE));
|
||||
}
|
||||
|
||||
return ib;
|
||||
}
|
||||
|
||||
#if !wxCHECK_VERSION(2,9,0)
|
||||
|
||||
wxSize TArtProvider::GetNativeSizeHint(const wxArtClient& client)
|
||||
{
|
||||
if (client == wxART_FRAME_ICON)
|
||||
return wxSize(16,16);
|
||||
if (client == wxART_MESSAGE_BOX)
|
||||
return wxSize(64,64);
|
||||
return wxSize(32,32);
|
||||
}
|
||||
|
||||
wxIconBundle TArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client)
|
||||
{
|
||||
TIconBundleHashTable::iterator it = m_hmBundles.find(id);
|
||||
if (it == m_hmBundles.end())
|
||||
{
|
||||
const wxIconBundle b = CreateIconBundle(id, client);
|
||||
m_hmBundles[id] = b;
|
||||
|
||||
unsigned long uid = 0;
|
||||
if (!id.ToULong(&uid))
|
||||
{
|
||||
wxString numid; numid.Printf(wxT("%lu"), GetIconBundleNumber(id));
|
||||
m_hmBundles[numid] = b;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
wxIcon TArtProvider::GetIcon(const wxArtID& id, const wxArtClient& client, const wxSize& size)
|
||||
{
|
||||
const wxIconBundle bundle = GetIconBundle(id, client);
|
||||
return bundle.GetIcon(size == wxDefaultSize ? GetNativeSizeHint(client) : size);
|
||||
}
|
||||
|
||||
// Metodo fichissimo per assegnare un identificatore univoco alle icone chiamate per nome del file.*
|
||||
unsigned int TArtProvider::GetIconBundleNumber(const wxArtID& id)
|
||||
{
|
||||
unsigned int num = m_hmIds[id];
|
||||
if (num == 0)
|
||||
{
|
||||
num = 60000+m_hmIds.size();
|
||||
m_hmIds[id] = num;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// xvt_sys_load_icon
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const wxBitmap xvtart_GetToolResource(int nIcon, int nDesiredSize)
|
||||
{
|
||||
if (nDesiredSize < 16) nDesiredSize = 16; else
|
||||
if (nDesiredSize > 128) nDesiredSize = 128;
|
||||
wxArtID id; id.Printf("%d", nIcon);
|
||||
return wxArtProvider::GetBitmap(id, wxART_TOOLBAR, wxSize(nDesiredSize, nDesiredSize));
|
||||
}
|
||||
|
||||
|
||||
const wxIcon xvtart_GetIconResource(int nIcon, const char* client, const int size)
|
||||
{
|
||||
wxASSERT(_TheArtProvider != NULL);
|
||||
|
||||
if (nIcon <= 0)
|
||||
nIcon = ICON_RSRC;
|
||||
|
||||
wxArtID id; id.Printf("%d", nIcon);
|
||||
wxArtClient cl = client && * client ? client : wxART_OTHER;
|
||||
wxSize sz(size, size);
|
||||
return _TheArtProvider->GetIcon(id, cl, sz);
|
||||
}
|
||||
|
||||
unsigned int xvt_sys_load_icon(const char* file)
|
||||
{
|
||||
wxASSERT(_TheArtProvider != NULL);
|
||||
const wxArtID id = file;
|
||||
_TheArtProvider->GetIcon(id);
|
||||
return _TheArtProvider->GetIconBundleNumber(id);
|
||||
}
|
||||
|
||||
WX_DECLARE_HASH_MAP(int, wxCursor, wxIntegerHash, wxIntegerEqual, TCursorHashTable);
|
||||
|
||||
const wxCursor xvtart_GetCursorResource(int rid)
|
||||
{
|
||||
static TCursorHashTable _nice_cursors;
|
||||
wxCursor cursor = _nice_cursors[rid];
|
||||
|
||||
if (!cursor.IsOk())
|
||||
{
|
||||
switch (rid)
|
||||
{
|
||||
case CURSOR_CROCE: cursor = wxCURSOR_CROSS; break;
|
||||
case CURSOR_IBEAM: cursor = wxCURSOR_IBEAM; break;
|
||||
default:
|
||||
{
|
||||
const wxString strName = xvtart_GetResourceName("Cursor", rid);
|
||||
if (::wxFileExists(strName))
|
||||
{
|
||||
if (strName.Find(".ico") > 0)
|
||||
cursor = wxCursor(strName, wxBITMAP_TYPE_ICO);
|
||||
else
|
||||
cursor = wxCursor(strName, wxBITMAP_TYPE_CUR);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!cursor.IsOk())
|
||||
{
|
||||
wxFAIL_MSG(_("Invalid cursor"));
|
||||
cursor = *wxSTANDARD_CURSOR;
|
||||
}
|
||||
|
||||
_nice_cursors[rid] = cursor;
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
12
xvaga/xvtart.h
Executable file
12
xvaga/xvtart.h
Executable file
@ -0,0 +1,12 @@
|
||||
#ifndef __XVTART_H__
|
||||
#define __XVTART_H__
|
||||
|
||||
const wxCursor xvtart_GetCursorResource(int rid);
|
||||
const wxIcon xvtart_GetIconResource(int rid, const char* client = NULL, int size = -1);
|
||||
wxString xvtart_GetResourceIni();
|
||||
wxString xvtart_GetResourceName(const char* type, int rid);
|
||||
const wxBitmap xvtart_GetToolResource(int rid, int size);
|
||||
|
||||
void xvtart_Init();
|
||||
|
||||
#endif
|
@ -1,8 +1,10 @@
|
||||
#include "wxinc.h"
|
||||
#include "xvt.h"
|
||||
#include "xvtart.h"
|
||||
#include "xvtwin.h"
|
||||
#include "statbar.h"
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/vlbox.h>
|
||||
@ -49,40 +51,6 @@ static int RoundToIcon(int nSize)
|
||||
return nSize;
|
||||
}
|
||||
|
||||
const wxBitmap& _GetToolResource(int nIcon, int nDesiredSize)
|
||||
{
|
||||
static wxHashTable _tool_icons;
|
||||
|
||||
if (nDesiredSize < 16) nDesiredSize = 16; else
|
||||
if (nDesiredSize > 128) nDesiredSize = 128;
|
||||
const long nCode = 1000*nIcon + nDesiredSize;
|
||||
wxBitmap* bmp = wxDynamicCast(_tool_icons.Get(nCode), wxBitmap);
|
||||
if (bmp == NULL)
|
||||
{
|
||||
const int nIco[] = { nIcon, 100, ICON_RSRC, 0 };
|
||||
for (int i = 0; nIco[i]; i++)
|
||||
{
|
||||
wxString strName = _GetResourceName("Tool", nIco[i]).Lower();
|
||||
if (!strName.IsEmpty() && ::wxFileExists(strName))
|
||||
{
|
||||
if (strName.EndsWith(".ico"))
|
||||
{
|
||||
const wxIcon ico(strName, wxBITMAP_TYPE_ICO);
|
||||
bmp = new wxBitmap(ico);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxImage img(strName, wxBITMAP_TYPE_ANY);
|
||||
img.Rescale(nDesiredSize, nDesiredSize, wxIMAGE_QUALITY_HIGH);
|
||||
bmp = new wxBitmap(img);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
_tool_icons.Put(nCode, bmp);
|
||||
}
|
||||
return *bmp;
|
||||
}
|
||||
|
||||
static wxAuiDockArt* FindArtist(wxWindow* pWindow)
|
||||
{
|
||||
@ -119,7 +87,8 @@ class TwxNoteBook : public wxAuiNotebook
|
||||
protected:
|
||||
virtual bool SetBackgroundColour(const wxColour& col);
|
||||
|
||||
void OnPageChanged(wxAuiNotebookEvent& e);
|
||||
void OnPageChanging(wxAuiNotebookEvent& e);
|
||||
//void OnPageChanged(wxAuiNotebookEvent& e);
|
||||
long Flags2Style(long flags) const;
|
||||
|
||||
TwxNoteBook() {}
|
||||
@ -652,7 +621,8 @@ inline bool VALID_NOTEBOOK(WINDOW notebk, short page_no)
|
||||
{ return page_no >= 0 && wxDynamicCast((wxObject*)notebk, TwxNoteBook)!=NULL; }
|
||||
|
||||
BEGIN_EVENT_TABLE(TwxNoteBook, wxAuiNotebook)
|
||||
EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, OnPageChanged)
|
||||
EVT_AUINOTEBOOK_PAGE_CHANGING(wxID_ANY, OnPageChanging)
|
||||
//EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, OnPageChanged)
|
||||
END_EVENT_TABLE();
|
||||
|
||||
bool TwxNoteBook::SetBackgroundColour(const wxColour& col)
|
||||
@ -666,26 +636,50 @@ bool TwxNoteBook::SetBackgroundColour(const wxColour& col)
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
void TwxNoteBook::OnPageChanging(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
if (!m_bSuspended)
|
||||
{
|
||||
m_bSuspended = true;
|
||||
XVT_EVENT e(E_CONTROL);
|
||||
CONTROL_INFO& ci = e.v.ctl.ci;
|
||||
e.v.ctl.id = evt.GetId();
|
||||
ci.type = WC_NOTEBK;
|
||||
ci.win = WINDOW(this);
|
||||
ci.v.notebk.page = NULL_WIN;
|
||||
ci.v.notebk.page_new = evt.GetSelection();
|
||||
ci.v.notebk.page_old = evt.GetOldSelection();
|
||||
|
||||
TwxWindow* win = wxStaticCast(GetParent(), TwxWindow);
|
||||
const bool refused = win->DoXvtEvent(e) != 0;
|
||||
if (refused)
|
||||
evt.Veto();
|
||||
|
||||
m_bSuspended = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void TwxNoteBook::OnPageChanged(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
if (!m_bSuspended)
|
||||
{
|
||||
m_bSuspended = true;
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CONTROL;
|
||||
XVT_EVENT e(E_CONTROL);
|
||||
CONTROL_INFO& ci = e.v.ctl.ci;
|
||||
e.v.ctl.id = evt.GetId();
|
||||
e.v.ctl.ci.type = WC_NOTEBK;
|
||||
e.v.ctl.ci.win = WINDOW(this);
|
||||
e.v.ctl.ci.v.notebk.face = (WINDOW)GetPage(evt.GetSelection());
|
||||
e.v.ctl.ci.v.notebk.tab_no = evt.GetSelection();
|
||||
e.v.ctl.ci.v.notebk.page_no = evt.GetOldSelection();
|
||||
ci.type = WC_NOTEBK;
|
||||
ci.win = WINDOW(this);
|
||||
ci.v.notebk.page = (WINDOW)GetPage(evt.GetSelection());
|
||||
ci.v.notebk.page_new = evt.GetSelection();
|
||||
ci.v.notebk.page_old = evt.GetOldSelection();
|
||||
|
||||
TwxWindow* win = wxStaticCast(GetParent(), TwxWindow);
|
||||
win->DoXvtEvent(e);
|
||||
m_bSuspended = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
short TwxNoteBook::AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE xvt_img, short idx)
|
||||
{
|
||||
@ -871,7 +865,7 @@ void xvt_notebk_set_tab_image(WINDOW notebk, short tab_no, XVT_IMAGE img)
|
||||
|
||||
void xvt_notebk_set_tab_icon(WINDOW notebk, short tab_no, int rid)
|
||||
{
|
||||
const wxString strName = _GetResourceName("Icon", rid);
|
||||
const wxString strName = xvtart_GetResourceName("Icon", rid);
|
||||
XVT_IMAGE img = xvt_image_read(strName);
|
||||
xvt_notebk_set_tab_image(notebk, tab_no, img);
|
||||
xvt_image_destroy(img);
|
||||
@ -1462,7 +1456,8 @@ void TwxOutlookBar::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
|
||||
int nTextOffset = 4;
|
||||
if (oi.m_nIconId > 0)
|
||||
{
|
||||
const wxIcon& ico = _GetIconResource(oi.m_nIconId);
|
||||
const int sz = nSide > 16 ? (nSide < 48 ? (nSide/16*16) : 48) : 16;
|
||||
const wxIcon ico = xvtart_GetIconResource(oi.m_nIconId, wxART_TOOLBAR, sz);
|
||||
const wxSize szIco(ico.GetWidth(), ico.GetHeight());
|
||||
dc.DrawIcon(ico, rect.x+nTextOffset, rect.y+(nSide-szIco.y)/2);
|
||||
nTextOffset += nTextOffset+szIco.x;
|
||||
@ -1977,7 +1972,7 @@ BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char
|
||||
break;
|
||||
default:
|
||||
{
|
||||
const wxBitmap& bmp = _GetToolResource(ico, tb.GetToolBitmapSize().y);
|
||||
const wxBitmap bmp = xvtart_GetToolResource(ico, tb.GetToolBitmapSize().y);
|
||||
wxString cap, tip;
|
||||
wxChar acc = 0;
|
||||
for (const char* t = title; *t; t++)
|
||||
@ -2147,7 +2142,7 @@ void xvt_toolbar_show_control(WINDOW win, int cid, BOOLEAN on)
|
||||
// Funzione di utilita' un po' fuori posto (per poter accedere alla _GetToolResource)
|
||||
void xvt_dwin_draw_tool(WINDOW win, int x, int y, int rid, int size)
|
||||
{
|
||||
const wxBitmap& bmp = _GetToolResource(rid, size);
|
||||
const wxBitmap bmp = xvtart_GetToolResource(rid, size);
|
||||
if (bmp.IsOk())
|
||||
{
|
||||
wxDC& dc = GetTDCMapper().GetDC(win);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include "xvt.h"
|
||||
#include "xvtart.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "wx/dcps.h"
|
||||
@ -34,8 +35,6 @@ struct TPRINT_RCD : public PRINT_RCD
|
||||
|
||||
void GetData(wxPrintNativeDataBase * data) const;
|
||||
void SetData(void * data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
unsigned int GetSize() const { return m_size; }
|
||||
@ -47,6 +46,7 @@ struct TPRINT_RCD : public PRINT_RCD
|
||||
#pragma pack()
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
void TPRINT_RCD::SetData(void* data, unsigned int nSize)
|
||||
{
|
||||
if (nSize <= sizeof(m_data))
|
||||
@ -69,9 +69,10 @@ TPRINT_RCD::~TPRINT_RCD()
|
||||
{
|
||||
memset(m_data, 0, sizeof(m_data));
|
||||
m_size = 0;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void TPRINT_RCD::GetData(wxPrintNativeDataBase * data) const
|
||||
{
|
||||
memcpy(data, m_data, GetSize());
|
||||
@ -94,6 +95,7 @@ TPRINT_RCD::~TPRINT_RCD()
|
||||
{
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -768,17 +770,17 @@ void TwxPrintAbortDialog::Pulse()
|
||||
}
|
||||
|
||||
TwxPrintAbortDialog::TwxPrintAbortDialog()
|
||||
: wxPrintAbortDialog(NULL, wxT("Stampa"),
|
||||
: wxPrintAbortDialog(NULL, _("Stampa"),
|
||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||
{
|
||||
wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
button_sizer->Add(new wxStaticText(this, wxID_STATIC, wxT("Stampa in corso..."),
|
||||
button_sizer->Add(new wxStaticText(this, wxID_STATIC, _("Stampa in corso..."),
|
||||
wxDefaultPosition, wxSize(480,-1)), 0, wxALL, 10 );
|
||||
button_sizer->Add(new wxGauge(this, wxID_FORWARD, 1, wxDefaultPosition, wxSize(480,-1)), 0, wxALL, 10 );
|
||||
|
||||
//button_sizer->Add(new wxButton(this, wxID_CANCEL, wxT("Annulla") ), 0, wxALL | wxALIGN_CENTER, 10 );
|
||||
button_sizer->Add(new wxBitmapButton(this, wxID_CANCEL, _GetToolResource(102,32) ), 0, wxALL | wxALIGN_CENTER, 10 );
|
||||
button_sizer->Add(new wxBitmapButton(this, wxID_CANCEL, xvtart_GetToolResource(102,32) ), 0, wxALL | wxALIGN_CENTER, 10 );
|
||||
|
||||
SetAutoLayout(true);
|
||||
SetSizer(button_sizer);
|
||||
@ -840,7 +842,7 @@ BOOLEAN xvt_print_suspend_thread()
|
||||
BOOLEAN ok = m_PrintoutCache.Printing();
|
||||
if (ok)
|
||||
{
|
||||
TwxPrintOut& po = m_PrintoutCache.Get(NULL); // Sembra generare una pagina vuota indesiderata
|
||||
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
||||
po.OnEndDocument(); // Sembra generare una pagina vuota indesiderata
|
||||
po.OnEndPrinting();
|
||||
}
|
||||
@ -872,7 +874,10 @@ BOOLEAN xvt_print_open_page(PRINT_RCD* WXUNUSED(precp))
|
||||
// Aggiorna barra di attesa
|
||||
TwxPrintAbortDialog* pad = wxDynamicCast(wxPrinterBase::sm_abortWindow, TwxPrintAbortDialog);
|
||||
if (pad != NULL)
|
||||
{
|
||||
pad->Pulse();
|
||||
wxWakeUpIdle();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -1112,8 +1117,8 @@ int xvt_fsys_get_campo_stp_value(const char* name, char* value, int valsize)
|
||||
*/
|
||||
const char* xvt_fsys_get_campo_ini()
|
||||
{
|
||||
static char* prawin = NULL;
|
||||
if (prawin == NULL)
|
||||
static wxString prawin;
|
||||
if (prawin.IsEmpty())
|
||||
{
|
||||
BOOLEAN bFound = FALSE;
|
||||
char exedir[_MAX_PATH], path[_MAX_PATH];
|
||||
@ -1168,10 +1173,10 @@ const char* xvt_fsys_get_campo_ini()
|
||||
if (!xvt_fsys_file_exists(path))
|
||||
{
|
||||
char msg[_MAX_PATH];
|
||||
sprintf(msg, "Impossibile aprire '%s'", path);
|
||||
sprintf(msg, _("Impossibile aprire '%s'"), path);
|
||||
xvt_dm_post_fatal_exit(msg);
|
||||
}
|
||||
prawin = xvt_str_duplicate(path);
|
||||
prawin = path;
|
||||
}
|
||||
return prawin;
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
#include "wxinc.h"
|
||||
|
||||
#include "xvt.h"
|
||||
|
||||
#if wxUSE_ODBC
|
||||
|
||||
#include <wx/db.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -60,6 +57,13 @@ TwxConnectionDlg::TwxConnectionDlg() : wxDialog(NULL, wxID_ANY, "ODBC",
|
||||
|
||||
XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir)
|
||||
{
|
||||
static wxDbConnectInf* ci = NULL;
|
||||
if (ci == NULL)
|
||||
{
|
||||
ci = new wxDbConnectInf;
|
||||
ci->AllocHenv();
|
||||
}
|
||||
|
||||
wxString strDsn(dsn), strUsr(usr), strPwd(pwd), strDir(dir);
|
||||
if (strDsn.IsEmpty())
|
||||
{
|
||||
@ -76,11 +80,15 @@ XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* p
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxDbConnectInf dbci(NULL, strDsn, strUsr, strPwd, strDir);
|
||||
bool bSuccess = false;
|
||||
wxDb* db = new wxDb(ci->GetHenv(), true);
|
||||
|
||||
wxDb* db = new wxDb(dbci.GetHenv(), true);
|
||||
const bool opened = db->Open(dbci.GetDsn(), dbci.GetUserID(), dbci.GetPassword(), false);
|
||||
if (!opened)
|
||||
if (strDsn.Find(';') > 0)
|
||||
bSuccess = db->Open(strDsn, NULL, true);
|
||||
else
|
||||
bSuccess = db->Open(strDsn, strUsr, strPwd, true);
|
||||
|
||||
if (!bSuccess)
|
||||
{
|
||||
delete db;
|
||||
db = NULL;
|
||||
@ -219,22 +227,3 @@ BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size)
|
||||
}
|
||||
return handle != NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir)
|
||||
{
|
||||
SORRY_BOX();
|
||||
return XVT_ODBC(0);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle)
|
||||
{ return FALSE; }
|
||||
|
||||
ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly)
|
||||
{ return 0; }
|
||||
|
||||
BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size)
|
||||
{ return FALSE; }
|
||||
|
||||
#endif
|
100
xvaga/xvtwin.cpp
100
xvaga/xvtwin.cpp
@ -2,8 +2,10 @@
|
||||
|
||||
#define XTWIN_CPP 1
|
||||
#include "xvt.h"
|
||||
#include "xvtart.h"
|
||||
#include "xvtwin.h"
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/aui/aui.h>
|
||||
//#include <wx/dcbuffer.h>
|
||||
#include <wx/taskbar.h>
|
||||
@ -533,10 +535,12 @@ BEGIN_EVENT_TABLE(TwxWindow, TwxWindowBase)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, TwxWindow::OnRadioButton)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TwxWindow::DoXvtEvent(EVENT& e)
|
||||
long TwxWindow::DoXvtEvent(EVENT& e)
|
||||
{
|
||||
long ret = 0;
|
||||
if (this != NULL && _eh != NULL)
|
||||
_eh((WINDOW)this, &e);
|
||||
ret = _eh((WINDOW)this, &e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TwxWindow::OnChar(wxKeyEvent& evt)
|
||||
@ -550,8 +554,7 @@ void TwxWindow::OnChar(wxKeyEvent& evt)
|
||||
nSkipNextDotKey = strchr("1XY", *str) != NULL ? 0 : -1; // Dis/Abilita conversione punto in virgola
|
||||
}
|
||||
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CHAR;
|
||||
XVT_EVENT e(E_CHAR);
|
||||
int k = evt.GetKeyCode();
|
||||
|
||||
if (nSkipNextDotKey == 1)
|
||||
@ -653,8 +656,7 @@ void TwxWindow::OnKeyDown(wxKeyEvent& e)
|
||||
|
||||
void TwxWindow::OnClose(wxCloseEvent& WXUNUSED(e))
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CLOSE;
|
||||
XVT_EVENT e(E_CLOSE);
|
||||
DoXvtEvent(e);
|
||||
}
|
||||
|
||||
@ -663,16 +665,14 @@ void TwxWindow::OnKillFocus(wxFocusEvent& WXUNUSED(e))
|
||||
if (_TheCaret.Owner() == (WINDOW)this)
|
||||
_TheCaret.Hide();
|
||||
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_FOCUS;
|
||||
XVT_EVENT e(E_FOCUS);
|
||||
e.v.active = 0;
|
||||
DoXvtEvent(e);
|
||||
}
|
||||
|
||||
void TwxWindow::OnMenu(wxCommandEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_COMMAND;
|
||||
XVT_EVENT e(E_COMMAND);
|
||||
e.v.cmd.control = 0; e.v.cmd.shift = 0;
|
||||
e.v.cmd.tag = evt.GetId();
|
||||
DoXvtEvent(e);
|
||||
@ -685,8 +685,7 @@ void TwxWindow::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(e))
|
||||
|
||||
void TwxWindow::OnMouseDouble(wxMouseEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_MOUSE_DBL;
|
||||
XVT_EVENT e(E_MOUSE_DBL);
|
||||
e.v.mouse.button = (evt.RightDown() ? 1 : 0) + (evt.MiddleDown() ? 2 : 0);
|
||||
e.v.mouse.control = evt.ControlDown();
|
||||
e.v.mouse.shift = evt.ShiftDown();
|
||||
@ -697,8 +696,7 @@ void TwxWindow::OnMouseDouble(wxMouseEvent& evt)
|
||||
|
||||
void TwxWindow::OnMouseDown(wxMouseEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_MOUSE_DOWN;
|
||||
XVT_EVENT e(E_MOUSE_DOWN);
|
||||
e.v.mouse.button = (evt.RightDown() ? 1 : 0) + (evt.MiddleDown() ? 2 : 0);
|
||||
e.v.mouse.control = evt.ControlDown();
|
||||
e.v.mouse.shift = evt.ShiftDown();
|
||||
@ -710,8 +708,7 @@ void TwxWindow::OnMouseDown(wxMouseEvent& evt)
|
||||
|
||||
void TwxWindow::OnMouseMove(wxMouseEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_MOUSE_MOVE;
|
||||
XVT_EVENT e(E_MOUSE_MOVE);
|
||||
e.v.mouse.button = (evt.RightIsDown() ? 1 : 0) + (evt.MiddleIsDown() ? 2 : 0);
|
||||
e.v.mouse.control = evt.ControlDown();
|
||||
e.v.mouse.shift = evt.m_shiftDown;
|
||||
@ -722,8 +719,7 @@ void TwxWindow::OnMouseMove(wxMouseEvent& evt)
|
||||
|
||||
void TwxWindow::OnMouseUp(wxMouseEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_MOUSE_UP;
|
||||
XVT_EVENT e(E_MOUSE_UP);
|
||||
e.v.mouse.button = (evt.RightUp() ? 1 : 0) + (evt.MiddleUp() ? 2 : 0);
|
||||
e.v.mouse.control = evt.ControlDown();
|
||||
e.v.mouse.shift = evt.ShiftDown();
|
||||
@ -737,8 +733,7 @@ void TwxWindow::OnMouseWheel(wxMouseEvent& evt)
|
||||
const int nRot = evt.GetWheelRotation();
|
||||
if (nRot != 0)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_VSCROLL;
|
||||
XVT_EVENT e(E_VSCROLL);
|
||||
e.v.scroll.pos = evt.GetY();
|
||||
e.v.scroll.what = nRot > 0 ? SC_LINE_UP : SC_LINE_DOWN;
|
||||
DoXvtEvent(e);
|
||||
@ -749,12 +744,8 @@ void TwxWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
|
||||
{
|
||||
const wxRect rctDamaged = GetUpdateRegion().GetBox();
|
||||
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_UPDATE;
|
||||
|
||||
XVT_EVENT e(E_UPDATE);
|
||||
RCT& rct = e.v.update.rct;
|
||||
|
||||
//wxRect rctDamaged = GetUpdateRegion().GetBox();
|
||||
rct.left = rctDamaged.x;
|
||||
rct.top = rctDamaged.y;
|
||||
rct.right = rctDamaged.GetRight()+1;
|
||||
@ -793,8 +784,7 @@ void TwxWindow::OnScroll(wxScrollEvent& evt)
|
||||
SCROLL_CONTROL sc = ConvertScrollToXVT(evt.GetEventType());
|
||||
if (sc != SC_NONE)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CONTROL;
|
||||
XVT_EVENT e(E_CONTROL);
|
||||
e.v.ctl.id = evt.GetId();
|
||||
e.v.ctl.ci.type = evt.GetOrientation()==wxHORIZONTAL ? WC_HSCROLL : WC_VSCROLL;
|
||||
e.v.ctl.ci.win = (WINDOW)evt.GetEventObject();
|
||||
@ -811,8 +801,7 @@ void TwxWindow::OnScrollWin(wxScrollWinEvent& evt)
|
||||
const SCROLL_CONTROL sc = ConvertScrollToXVT(et);
|
||||
if (sc != SC_NONE)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = evt.GetOrientation() == wxHORIZONTAL ? E_HSCROLL : E_VSCROLL;
|
||||
XVT_EVENT e(evt.GetOrientation() == wxHORIZONTAL ? E_HSCROLL : E_VSCROLL);
|
||||
e.v.scroll.pos = evt.GetPosition();
|
||||
e.v.scroll.what = sc;
|
||||
DoXvtEvent(e);
|
||||
@ -821,16 +810,14 @@ void TwxWindow::OnScrollWin(wxScrollWinEvent& evt)
|
||||
|
||||
void TwxWindow::OnSetFocus(wxFocusEvent& WXUNUSED(e))
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_FOCUS;
|
||||
e.v.active = 1;
|
||||
XVT_EVENT e(E_FOCUS);
|
||||
e.v.active = TRUE;
|
||||
DoXvtEvent(e);
|
||||
}
|
||||
|
||||
void TwxWindow::OnSize(wxSizeEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_SIZE;
|
||||
XVT_EVENT e(E_SIZE);
|
||||
e.v.size.width = evt.GetSize().x;
|
||||
e.v.size.height = evt.GetSize().y;
|
||||
DoXvtEvent(e);
|
||||
@ -838,16 +825,14 @@ void TwxWindow::OnSize(wxSizeEvent& evt)
|
||||
|
||||
void TwxWindow::OnTimer(wxTimerEvent& WXUNUSED(evt))
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_TIMER;
|
||||
XVT_EVENT e(E_TIMER);
|
||||
e.v.timer.id = (WINDOW)this;
|
||||
DoXvtEvent(e);
|
||||
}
|
||||
|
||||
void TwxWindow::OnButton(wxCommandEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CONTROL;
|
||||
XVT_EVENT e(E_CONTROL);
|
||||
e.v.ctl.id = evt.GetId();
|
||||
e.v.ctl.ci.type = WC_PUSHBUTTON;
|
||||
DoXvtEvent(e);
|
||||
@ -855,8 +840,7 @@ void TwxWindow::OnButton(wxCommandEvent& evt)
|
||||
|
||||
void TwxWindow::OnCheckBox(wxCommandEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CONTROL;
|
||||
XVT_EVENT e(E_CONTROL);
|
||||
e.v.ctl.id = evt.GetId();
|
||||
e.v.ctl.ci.type = WC_CHECKBOX;
|
||||
DoXvtEvent(e);
|
||||
@ -864,8 +848,7 @@ void TwxWindow::OnCheckBox(wxCommandEvent& evt)
|
||||
|
||||
void TwxWindow::OnRadioButton(wxCommandEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CONTROL;
|
||||
XVT_EVENT e(E_CONTROL);
|
||||
e.v.ctl.id = evt.GetId();
|
||||
e.v.ctl.ci.type = WC_RADIOBUTTON;
|
||||
DoXvtEvent(e);
|
||||
@ -958,8 +941,7 @@ TwxWindow::~TwxWindow()
|
||||
if (!m_bInDestroy) // Controllo di non essere RIchiamato dalla gestione di E_DESTROY
|
||||
{
|
||||
m_bInDestroy = true;
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_DESTROY;
|
||||
XVT_EVENT e(E_DESTROY);
|
||||
DoXvtEvent(e);
|
||||
|
||||
// Rendo praticamente impossibile risalire a questo oggetto d'ora in poi
|
||||
@ -1011,8 +993,7 @@ void TTaskWin::OnClose(wxCloseEvent& evt)
|
||||
{
|
||||
if (evt.CanVeto())
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CLOSE;
|
||||
XVT_EVENT e(E_CLOSE);
|
||||
int veto = _task_win_handler((WINDOW)this, &e);
|
||||
evt.Veto(veto != 0);
|
||||
}
|
||||
@ -1022,8 +1003,7 @@ void TTaskWin::OnClose(wxCloseEvent& evt)
|
||||
|
||||
void TTaskWin::OnMenu(wxCommandEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_COMMAND;
|
||||
XVT_EVENT e(E_COMMAND);
|
||||
e.v.cmd.control = 0; e.v.cmd.shift = 0;
|
||||
e.v.cmd.tag = evt.GetId();
|
||||
|
||||
@ -1041,8 +1021,7 @@ void TTaskWin::OnPaint(wxPaintEvent& WXUNUSED(evt))
|
||||
{
|
||||
const wxRect rctDamaged = GetUpdateRegion().GetBox();
|
||||
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_UPDATE;
|
||||
XVT_EVENT e(E_UPDATE);
|
||||
RCT& rct = e.v.update.rct;
|
||||
rct.left = rctDamaged.x;
|
||||
rct.top = rctDamaged.y;
|
||||
@ -1057,8 +1036,7 @@ void TTaskWin::OnPaint(wxPaintEvent& WXUNUSED(evt))
|
||||
|
||||
void TTaskWin::OnSize(wxSizeEvent& evt)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_SIZE;
|
||||
XVT_EVENT e(E_SIZE);
|
||||
e.v.size.width = evt.GetSize().x;
|
||||
e.v.size.height = evt.GetSize().y;
|
||||
_task_win_handler((WINDOW)this, &e);
|
||||
@ -1141,7 +1119,7 @@ TTaskWin::TTaskWin(wxWindowID id, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxFrame(NULL, id, title, pos, size, style), m_menu(NULL), m_pOldBar(NULL), m_MenuOwner(NULL)
|
||||
{
|
||||
const wxIcon& ico = _GetIconResource(ICON_RSRC);
|
||||
const wxIcon ico = xvtart_GetIconResource(ICON_RSRC);
|
||||
SetIcon(ico);
|
||||
_nice_windows.Put((WINDOW)this, this);
|
||||
}
|
||||
@ -1196,24 +1174,20 @@ void TwxTaskBarIcon::OnClick(wxTaskBarIconEvent& WXUNUSED(e))
|
||||
TwxTaskBarIcon::TwxTaskBarIcon(wxWindow* owned, short icon, wxString strTip)
|
||||
: _owned(owned)
|
||||
{
|
||||
const wxIcon* pIcon = NULL;
|
||||
if (icon <= 0)
|
||||
wxIcon ico;
|
||||
if (icon <= 0 && _owned != NULL)
|
||||
{
|
||||
const wxFrame* pFrame = wxDynamicCast(_owned, wxFrame);
|
||||
if (pFrame != NULL)
|
||||
pIcon = &pFrame->GetIcon();
|
||||
}
|
||||
if (pIcon == NULL)
|
||||
{
|
||||
if (icon <= 0)
|
||||
icon = ICON_RSRC;
|
||||
pIcon = &_GetIconResource(icon);
|
||||
ico = pFrame->GetIcon();
|
||||
}
|
||||
else
|
||||
ico = xvtart_GetIconResource(icon);
|
||||
|
||||
if (strTip.IsEmpty())
|
||||
strTip = _owned->GetLabel();
|
||||
|
||||
SetIcon(*pIcon, strTip);
|
||||
SetIcon(ico, strTip);
|
||||
}
|
||||
|
||||
WINDOW xvt_trayicon_create(WINDOW owned, short icon, const char* tooltip)
|
||||
|
@ -163,7 +163,7 @@ protected:
|
||||
virtual void OnRadioButton(wxCommandEvent& e);
|
||||
|
||||
public:
|
||||
void DoXvtEvent(EVENT& e);
|
||||
long DoXvtEvent(EVENT& e);
|
||||
virtual void OnPaint(wxPaintEvent& e);
|
||||
virtual bool InDestroy() const { return m_bInDestroy; }
|
||||
|
||||
@ -218,11 +218,13 @@ public:
|
||||
virtual ~TTaskWin();
|
||||
};
|
||||
|
||||
struct XVT_EVENT : public EVENT
|
||||
{
|
||||
XVT_EVENT(EVENT_TYPE t) { memset(this, 0, sizeof(EVENT)); type = t; }
|
||||
};
|
||||
|
||||
#define TIMER_ID 1
|
||||
const wxString& _GetAppTitle();
|
||||
wxString _GetResourceName(const char* type, int rid);
|
||||
const wxIcon& _GetIconResource(int rid);
|
||||
const wxBitmap& _GetToolResource(int rid, int size);
|
||||
|
||||
#define CAST_COLOR(xc, wc) wxColour wc((xc>>16)&0xFF, (xc>>8)&0xFF, xc&0xFF)
|
||||
#define MAKE_XVT_COLOR(wc) XVT_MAKE_COLOR(wc.Red(), wc.Green(), wc.Blue())
|
||||
|
Loading…
x
Reference in New Issue
Block a user