Patch level : 2.0 nopatch
Files correlati : Ricompilazione Demo : [ ] Commento : recepite tutte le aggiunte emigrate da os_win32 git-svn-id: svn://10.65.10.50/trunk@11023 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2edfb10238
commit
a79a32a2a2
@ -247,9 +247,9 @@ void OsWin32_Beep(int severity)
|
||||
{
|
||||
switch (severity)
|
||||
{
|
||||
case 0: ::MessageBeep(MB_OK); break;
|
||||
case 1: ::MessageBeep(MB_ICONEXCLAMATION); break;
|
||||
default: ::MessageBeep(MB_ICONSTOP); break;
|
||||
case 2: ::MessageBeep(MB_ICONSTOP); break;
|
||||
default: ::MessageBeep(MB_OK); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,3 +323,211 @@ bool OsWin32_TestNetworkVersion()
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Execute in window support
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
struct TFindWindowInfo
|
||||
{
|
||||
HINSTANCE _instance;
|
||||
wxString _file;
|
||||
HWND _hwnd;
|
||||
|
||||
TFindWindowInfo() : _instance(NULL), _hwnd(NULL) { }
|
||||
};
|
||||
|
||||
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
TFindWindowInfo* w = (TFindWindowInfo*)lParam;
|
||||
|
||||
HINSTANCE inst = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE);
|
||||
if (inst == w->_instance)
|
||||
{
|
||||
const LONG style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
if ((style & WS_CAPTION) != 0) // Ha la caption?
|
||||
{
|
||||
w->_hwnd = hwnd;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char str[256];
|
||||
GetWindowText(hwnd, str, sizeof(str));
|
||||
wxString title = str;
|
||||
title.MakeUpper();
|
||||
if (title.find(w->_file) >= 0)
|
||||
{
|
||||
w->_hwnd = hwnd;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent)
|
||||
{
|
||||
TFindWindowInfo w;
|
||||
w._instance = (HINSTANCE)instance;
|
||||
w._file = name;
|
||||
w._file.MakeUpper();
|
||||
|
||||
for (int i = 0; w._hwnd == NULL && i < 20; i++)
|
||||
{
|
||||
wxThread::Sleep(500);
|
||||
::EnumWindows(EnumWindowsProc, LPARAM(&w));
|
||||
}
|
||||
|
||||
if (w._hwnd != NULL) // L'ho trovata!
|
||||
{
|
||||
RECT rct; ::GetClientRect((HWND)parent, &rct);
|
||||
::SetParent(w._hwnd, (HWND)parent);
|
||||
const int fx = ::GetSystemMetrics(SM_CXFRAME);
|
||||
const int fy = ::GetSystemMetrics(SM_CYFRAME);
|
||||
int cy = ::GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYBORDER);
|
||||
if (::GetMenu(w._hwnd) != NULL)
|
||||
cy += ::GetSystemMetrics(SM_CYMENU);
|
||||
::SetWindowPos(w._hwnd, (HWND)parent, -fx, -fy-cy, rct.right+2*fx, rct.bottom+cy+2*fy, SWP_NOZORDER);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Ex-Golem utilities
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
static long GetRegistryString(HKEY key, const char* subkey, wxString& retstr)
|
||||
{
|
||||
HKEY hkey;
|
||||
long retval = RegOpenKey(key, subkey, &hkey);
|
||||
if (retval == ERROR_SUCCESS)
|
||||
{
|
||||
char retdata[_MAX_PATH];
|
||||
long datasize = sizeof(retdata);
|
||||
RegQueryValue(hkey, NULL, retdata, &datasize);
|
||||
RegCloseKey(hkey);
|
||||
retstr = retdata;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
wxString OsWin32_File2App(const char* filename)
|
||||
{
|
||||
wxString app;
|
||||
|
||||
if (*filename != '.')
|
||||
{
|
||||
char retdata[_MAX_PATH];
|
||||
HINSTANCE hinst = ::FindExecutable(filename, ".", retdata);
|
||||
DWORD* pinst = (DWORD*)hinst;
|
||||
UINT err = LOWORD(pinst);
|
||||
if (err > 32)
|
||||
app = retdata;
|
||||
}
|
||||
|
||||
if (app.IsEmpty())
|
||||
{
|
||||
char ext[_MAX_EXT];
|
||||
if (*filename == '.')
|
||||
strcpy(ext, filename);
|
||||
else
|
||||
_splitpath(filename, NULL, NULL, NULL, ext);
|
||||
_strlwr(ext);
|
||||
|
||||
wxString key;
|
||||
if (GetRegistryString(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
|
||||
{
|
||||
key << "\\shell\\open\\command";
|
||||
if (GetRegistryString(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS)
|
||||
{
|
||||
key.Replace("\"", " ");
|
||||
int pos = key.Find("%1");
|
||||
if (pos > 0)
|
||||
key.Truncate(pos);
|
||||
key.Trim(false); key.Trim(true);
|
||||
app = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static bool IsInternetAddress(const char* filename)
|
||||
{
|
||||
const wxString url(filename);
|
||||
if (url.StartsWith("http:") || url.StartsWith("ftp:"))
|
||||
return TRUE;
|
||||
if (url.Find("www.") >= 0)
|
||||
return TRUE;
|
||||
|
||||
char ext[_MAX_EXT];
|
||||
_splitpath(filename, NULL, NULL, NULL, ext);
|
||||
_strlwr(ext);
|
||||
const char* const extensions[] = { "com","edu","gov","it","mil","net","org", NULL };
|
||||
for (int e = 0; extensions[e]; e++)
|
||||
if (stricmp(ext, extensions[e]) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int OsWin32_LoadIcon(const char* filename)
|
||||
{
|
||||
unsigned int icon = 0;
|
||||
int icon_number = 0;
|
||||
|
||||
char ext[_MAX_EXT];
|
||||
if (*filename == '.' && strlen(filename) < _MAX_EXT)
|
||||
strcpy(ext, filename);
|
||||
else
|
||||
{
|
||||
if (IsInternetAddress(filename))
|
||||
strcpy(ext, ".htm");
|
||||
else
|
||||
_splitpath(filename, NULL, NULL, NULL, ext);
|
||||
}
|
||||
_strlwr(ext);
|
||||
|
||||
wxString key;
|
||||
if (ext != ".exe")
|
||||
{
|
||||
if (GetRegistryString(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
|
||||
{
|
||||
key << "\\DefaultIcon";
|
||||
if (GetRegistryString(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) // Windows 95 only
|
||||
{
|
||||
const int comma = key.find(',');
|
||||
if (comma > 0)
|
||||
{
|
||||
icon_number = atoi(key.Mid(comma+1));
|
||||
key.Truncate(comma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key = OsWin32_File2App(filename);
|
||||
if (key.IsEmpty())
|
||||
key = OsWin32_File2App(".htm");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
key = filename;
|
||||
|
||||
// Toglie eventuali parametri sulla riga si comando
|
||||
const int ext_pos = key.Find(".exe");
|
||||
if (ext_pos > 0)
|
||||
key.Truncate(ext_pos+4);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize);
|
||||
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
|
||||
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
|
||||
void OsWin32_DrawDottedRect(unsigned int hDC, int left, int top, int right, int bottom);
|
||||
void OsWin32_DrawSmallIcon(unsigned int hIcon, unsigned int hDC, int x, int y);
|
||||
|
||||
wxString OsWin32_File2App(const char* filename);
|
||||
unsigned int OsWin32_LoadIcon(const char* file);
|
||||
|
||||
int OsWin32_EnumerateFamilies(unsigned int hDC, char** families, int max_count);
|
||||
int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, short* scalable, int max_count);
|
||||
@ -14,6 +16,8 @@ void* OsWin32_GetPrinterInfo(int& size, const char* printer);
|
||||
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h);
|
||||
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
|
||||
unsigned int hSrc, int xs, int ys, int ws, int hs);
|
||||
|
||||
void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
|
||||
void OsWin32_UpdateWindow(unsigned int handle);
|
||||
|
||||
int OsWin32_Help(unsigned int handle, const char* hlp, unsigned int cmd, const char* topic);
|
||||
|
267
xvaga/xvaga.cpp
267
xvaga/xvaga.cpp
@ -18,23 +18,23 @@
|
||||
#include "xvintern.h"
|
||||
#include "agasys.h"
|
||||
|
||||
// Funzione di utilita'
|
||||
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m);
|
||||
|
||||
#ifdef WIN32
|
||||
#include "oswin32.h"
|
||||
#endif
|
||||
|
||||
// Funzione interna di utilita'
|
||||
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m);
|
||||
|
||||
XVT_CONFIG* _config_ = NULL;
|
||||
wxWindow* _task_win = NULL;
|
||||
wxWindow* _mouse_trapper = NULL;
|
||||
RCT _startup_rect = { 0,0,0,0 };
|
||||
wxString _startup_dir;
|
||||
|
||||
static wxHashTable _valid_windows;
|
||||
static wxHashTable _nice_windows;
|
||||
static wxHashTable _nice_icons;
|
||||
|
||||
static EVENT_HANDLER _task_win_handler = NULL;
|
||||
|
||||
static XVT_ERRMSG_HANDLER _error_handler = NULL;
|
||||
|
||||
#define XVT_ASSERT(test) assert_box((test), __LINE__)
|
||||
@ -116,15 +116,14 @@ wxString GetResourceName(const char* type, int rid)
|
||||
|
||||
wxIcon* GetIconResource(int rid)
|
||||
{
|
||||
static wxHashTable icons;
|
||||
wxIcon* icon = (wxIcon*)icons.Get(rid);
|
||||
wxIcon* icon = (wxIcon*)_nice_icons.Get(rid);
|
||||
if (icon == NULL)
|
||||
{
|
||||
wxString strName = ::GetResourceName("Icon", rid);
|
||||
if (::wxFileExists(strName))
|
||||
{
|
||||
icon = new wxIcon(strName, wxBITMAP_TYPE_ICO);
|
||||
icons.Put(rid, icon);
|
||||
_nice_icons.Put(rid, icon);
|
||||
}
|
||||
}
|
||||
XVT_ASSERT(icon != NULL);
|
||||
@ -139,9 +138,8 @@ wxCursor* GetCursorResource(int rid)
|
||||
{
|
||||
switch (rid)
|
||||
{
|
||||
case CURSOR_IBEAM:
|
||||
cursor = new wxCursor(wxCURSOR_IBEAM);
|
||||
break;
|
||||
case CURSOR_CROSS: cursor = new wxCursor(wxCURSOR_CROSS); break;
|
||||
case CURSOR_IBEAM: cursor = new wxCursor(wxCURSOR_IBEAM); break;
|
||||
default:
|
||||
{
|
||||
wxString strName = ::GetResourceName("Cursor", rid);
|
||||
@ -359,7 +357,6 @@ static int PenStyleToStyle(PEN_STYLE s, PAT_STYLE p)
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
bool TDC::PenChanged() const
|
||||
{
|
||||
const int diff = memcmp(&_dct.pen, &_real_dct.pen, sizeof(_dct.pen));
|
||||
@ -883,7 +880,7 @@ static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et)
|
||||
|
||||
void TwxWindow::OnScroll(wxScrollEvent& event)
|
||||
{
|
||||
const SCROLL_CONTROL sc = ConvertScrollToXVT(event.GetEventType());
|
||||
SCROLL_CONTROL sc = ConvertScrollToXVT(event.GetEventType());
|
||||
if (sc != SC_NONE)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
@ -957,7 +954,9 @@ TwxWindow::TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size, long style)
|
||||
: TwxWindowBase(parent, id, title, pos, size, style),
|
||||
_timer(NULL), m_menu(NULL), _eh(NULL)
|
||||
{ }
|
||||
{
|
||||
_nice_windows.Put((WINDOW)this, this);
|
||||
}
|
||||
|
||||
TwxWindow::~TwxWindow()
|
||||
{
|
||||
@ -968,6 +967,8 @@ TwxWindow::~TwxWindow()
|
||||
xvt_res_free_menu_tree(m_menu);
|
||||
((TTaskWin*)_task_win)->PopMenuTree();
|
||||
}
|
||||
|
||||
_nice_windows.Delete((WINDOW)this);
|
||||
}
|
||||
|
||||
#define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w);
|
||||
@ -1117,6 +1118,7 @@ TTaskWin::TTaskWin(wxWindow *parent, wxWindowID id,
|
||||
wxIcon* ico = ::GetIconResource(ICON_RSRC);
|
||||
if (ico)
|
||||
SetIcon(*ico);
|
||||
_nice_windows.Put((WINDOW)this, this);
|
||||
}
|
||||
|
||||
TTaskWin::~TTaskWin()
|
||||
@ -1126,6 +1128,7 @@ TTaskWin::~TTaskWin()
|
||||
xvt_res_free_menu_tree(m_menu);
|
||||
m_menu = NULL;
|
||||
}
|
||||
_nice_windows.Delete((WINDOW)this);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1162,7 +1165,7 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
_startup_dir = ::wxGetCwd();
|
||||
|
||||
_task_win = new TTaskWin(NULL, ICON_RSRC, title, pos, size, style);
|
||||
_valid_windows.Put((long)_task_win, _task_win);
|
||||
_nice_windows.Put((long)_task_win, _task_win);
|
||||
|
||||
wxMenu* Menus[3];
|
||||
wxString Title[3];
|
||||
@ -1179,7 +1182,7 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
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\tDel");
|
||||
Menus[1]->Append(M_EDIT_CLEAR, "&Elimina\tCanc");
|
||||
Title[2] = "&Help";
|
||||
Menus[2] = new wxMenu;
|
||||
Menus[2]->Append(M_HELP_CONTENTS, "&Sommario");
|
||||
@ -1198,10 +1201,7 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
e.type = E_CREATE;
|
||||
long ret = _task_win_handler((WINDOW)_task_win, &e);
|
||||
if (ret != 0)
|
||||
{
|
||||
wxApp& app = wxGetApp();
|
||||
app.MainLoop();
|
||||
}
|
||||
wxGetApp().MainLoop();
|
||||
wxGetApp().ExitMainLoop(); // Non entrare nel main loop di xwWindows
|
||||
}
|
||||
|
||||
@ -1210,7 +1210,6 @@ void xvt_app_destroy(void)
|
||||
wxGetApp().ExitMainLoop();
|
||||
|
||||
_task_win->Destroy();
|
||||
_valid_windows.Delete((WINDOW)_task_win);
|
||||
}
|
||||
|
||||
DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS *ct)
|
||||
@ -1264,10 +1263,13 @@ char* xvt_cb_get_data(CB_FORMAT cbfmt, char *name, long *sizep)
|
||||
wxTextDataObject data;
|
||||
wxTheClipboard->GetData(data);
|
||||
*sizep = data.GetDataSize();
|
||||
|
||||
xvt_cb_alloc_data(*sizep);
|
||||
memcpy(ptrClipboardData, data.GetText(), *sizep);
|
||||
return ptrClipboardData;
|
||||
if (*sizep > 0)
|
||||
{
|
||||
xvt_cb_alloc_data(*sizep);
|
||||
memcpy(ptrClipboardData, data.GetText(), *sizep);
|
||||
(*sizep)--; // Elimino lo '/0' finale che non piace a XI
|
||||
return ptrClipboardData;
|
||||
}
|
||||
}
|
||||
sizep = 0;
|
||||
return NULL;
|
||||
@ -1874,16 +1876,21 @@ void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
|
||||
{
|
||||
if (s && *s && len != 0)
|
||||
{
|
||||
CAST_DC(win, dc);
|
||||
wxString str(s);
|
||||
if (len >= 0)
|
||||
str.Truncate(len);
|
||||
CAST_DC(win, dc);
|
||||
wxRect rct; dc.GetClippingBox(rct);
|
||||
const int maxx = rct.GetRight();
|
||||
if (maxx <= 0 || x < maxx)
|
||||
{
|
||||
wxString str(s);
|
||||
if (len >= 0)
|
||||
str.Truncate(len);
|
||||
|
||||
int height, desc, lead;
|
||||
dc.GetTextExtent(str, NULL, &height, &desc, &lead);
|
||||
y -= height-desc; // Triste necessita'!
|
||||
int height, desc, lead;
|
||||
dc.GetTextExtent(str, NULL, &height, &desc, &lead);
|
||||
y -= height-desc; // Triste necessita'!
|
||||
|
||||
dc.DrawText(str, x, y);
|
||||
dc.DrawText(str, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1959,8 +1966,6 @@ void xvt_dwin_invalidate_rect(WINDOW win, RCT* rctp)
|
||||
if (rctp)
|
||||
{
|
||||
const wxRect rct = NormalizeRCT(rctp);
|
||||
if (rct.x == 0 && rct.y == 0)
|
||||
rct.x;
|
||||
w.Refresh(FALSE, &rct);
|
||||
}
|
||||
else
|
||||
@ -1971,7 +1976,7 @@ void xvt_dwin_invalidate_rect(WINDOW win, RCT* rctp)
|
||||
|
||||
BOOLEAN xvt_dwin_is_update_needed(WINDOW win, RCT* rctp)
|
||||
{
|
||||
if (rctp)
|
||||
if (rctp != NULL)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
const wxRect rect1 = NormalizeRCT(rctp);
|
||||
@ -1983,10 +1988,10 @@ BOOLEAN xvt_dwin_is_update_needed(WINDOW win, RCT* rctp)
|
||||
|
||||
void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv)
|
||||
{
|
||||
if (dh || dv)
|
||||
if (dh != 0 || dv != 0)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
if (rctp)
|
||||
if (rctp != NULL)
|
||||
{
|
||||
wxRect rct = NormalizeRCT(rctp);
|
||||
if (dh > 0) rct.width -= dh;
|
||||
@ -1999,7 +2004,7 @@ void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv)
|
||||
}
|
||||
else
|
||||
w.ScrollWindow(dh, dv);
|
||||
xvt_dwin_update(win);
|
||||
// xvt_dwin_update(win); // Seems useless
|
||||
}
|
||||
}
|
||||
|
||||
@ -2092,7 +2097,7 @@ void xvt_dwin_draw_line(WINDOW win, PNT pnt)
|
||||
|
||||
void xvt_dwin_update(WINDOW win)
|
||||
{
|
||||
// "sembra" che non serva ad un fico secco, ma serve!
|
||||
// "sembra" che non serva ad un fico secco, ma FORSE in Windows serve!
|
||||
#ifdef WIN32
|
||||
CAST_TWIN(win, w);
|
||||
OsWin32_UpdateWindow(w.GetHWND());
|
||||
@ -2340,15 +2345,21 @@ BOOLEAN xvt_fsys_is_fixed_drive(const char* path)
|
||||
|
||||
static unsigned long compute_disk_size(const char* path, bool tot, char unit)
|
||||
{
|
||||
#ifdef WIN32
|
||||
char drive[_MAX_DRIVE+1];
|
||||
_splitpath(path, drive, NULL, NULL, NULL);
|
||||
strcat(drive, "/");
|
||||
DWORD nSecPerClust, nBytePerSec, nFreeClust, nTotalClust;
|
||||
::GetDiskFreeSpace(drive, &nSecPerClust, &nBytePerSec, &nFreeClust, &nTotalClust);
|
||||
|
||||
__int64 nBytes = tot ? nTotalClust : nFreeClust;
|
||||
nBytes *= nSecPerClust;
|
||||
nBytes *= nBytePerSec;
|
||||
#else
|
||||
unsigned long nBytes = 1024*1024;
|
||||
if (!xvt_fsys_is_removable_drive(path))
|
||||
nBytes *= 1024;
|
||||
#endif
|
||||
|
||||
switch (unit)
|
||||
{
|
||||
case 'K': nBytes >>= 10; break; // Kilobytes
|
||||
@ -3139,8 +3150,8 @@ static void AddWinToList(SLIST list, WINDOW win)
|
||||
SLIST xvt_scr_list_wins()
|
||||
{
|
||||
SLIST list = xvt_slist_create();
|
||||
_valid_windows.BeginFind();
|
||||
for (wxNode *node = _valid_windows.Next(); node; node = _valid_windows.Next())
|
||||
_nice_windows.BeginFind();
|
||||
for (wxNode *node = _nice_windows.Next(); node; node = _nice_windows.Next())
|
||||
{
|
||||
WINDOW win = (WINDOW)node->GetData();
|
||||
AddWinToList(list, win);
|
||||
@ -3292,6 +3303,51 @@ void xvt_sys_beep(int severity)
|
||||
#endif
|
||||
}
|
||||
|
||||
long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
|
||||
{
|
||||
long exitcode = 0;
|
||||
|
||||
if (sync)
|
||||
{
|
||||
if (iconizetask)
|
||||
{
|
||||
wxEnableTopLevelWindows(FALSE);
|
||||
_task_win->Hide();
|
||||
}
|
||||
exitcode = wxExecute(cmdline, wxEXEC_SYNC);
|
||||
if (iconizetask)
|
||||
{
|
||||
_task_win->Show();
|
||||
wxEnableTopLevelWindows(TRUE);
|
||||
_task_win->Raise();
|
||||
}
|
||||
}
|
||||
else
|
||||
exitcode = wxExecute(cmdline, wxEXEC_ASYNC);
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
long xvt_sys_execute_in_window(const char* cmdline, WINDOW win)
|
||||
{
|
||||
long inst = xvt_sys_execute(cmdline, FALSE, FALSE);
|
||||
#ifdef WIN32
|
||||
if (inst > 0)
|
||||
OsWin32_PlaceProcessInWindow(inst, "", xvt_vobj_get_attr(ATTR_NATIVE_WINDOW, win));
|
||||
#endif
|
||||
return inst;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_sys_dongle_server_is_running()
|
||||
{
|
||||
#ifdef WIN32
|
||||
ATOM a = GlobalFindAtom("DONGLE_SERVER_ATOM");
|
||||
return a != 0;
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
const char* defval, char* value, int maxsize)
|
||||
{
|
||||
@ -3336,6 +3392,70 @@ BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, cons
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN xvt_sys_find_editor(const char* file, char* editor, int editorsize)
|
||||
{
|
||||
XVT_ASSERT(editor != NULL && editorsize > 0);
|
||||
BOOLEAN ok = FALSE;
|
||||
|
||||
#ifdef WIN32
|
||||
const wxString e = OsWin32_File2App(file);
|
||||
ok = !e.IsEmpty();
|
||||
if (ok)
|
||||
strncpy(editor, e, editorsize);
|
||||
#else
|
||||
SORRY_BOX();
|
||||
#endif
|
||||
|
||||
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.Find(".ico") > 0)
|
||||
icon = new wxIcon(file, wxBITMAP_TYPE_ICO);
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
WXHICON hicon = OsWin32_LoadIcon(file);
|
||||
if (hicon)
|
||||
{
|
||||
icon = new wxIcon;
|
||||
icon->SetHICON(hicon);
|
||||
}
|
||||
#else
|
||||
id = ICON_RSRC; // TBI
|
||||
#endif
|
||||
}
|
||||
|
||||
if (icon != NULL)
|
||||
{
|
||||
for (id = 60001; ; id++)
|
||||
{
|
||||
wxIcon* ico = (wxIcon*)_nice_icons.Get(id);
|
||||
if (ico == NULL)
|
||||
{
|
||||
_nice_icons.Put(id, icon);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ico->GetHICON() == icon->GetHICON()) // C'e' gia'
|
||||
{
|
||||
delete icon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned long xvt_sys_get_free_memory()
|
||||
{
|
||||
unsigned long mem = ::wxGetFreeMemory();
|
||||
@ -3423,7 +3543,6 @@ void xvt_vobj_destroy(WINDOW win)
|
||||
_dc_map.DestroyTDC(&w);
|
||||
|
||||
w.Close(true);
|
||||
_valid_windows.Delete(win);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3456,6 +3575,9 @@ long xvt_vobj_get_attr(WINDOW win, long data)
|
||||
case ATTR_FRAME_HEIGHT:
|
||||
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_Y);
|
||||
break;
|
||||
case ATTR_MENU_HEIGHT:
|
||||
ret = wxSystemSettings::GetSystemMetric(wxSYS_MENU_Y);
|
||||
break;
|
||||
case ATTR_TITLE_HEIGHT:
|
||||
ret = wxSystemSettings::GetSystemMetric(wxSYS_CAPTION_Y);
|
||||
break;
|
||||
@ -3468,9 +3590,9 @@ long xvt_vobj_get_attr(WINDOW win, long data)
|
||||
case ATTR_DISPLAY_TYPE:
|
||||
switch (::wxDisplayDepth())
|
||||
{
|
||||
case 1: ret = XVT_DISPLAY_MONO; break;
|
||||
case 4: ret = XVT_DISPLAY_COLOR_16; break;
|
||||
case 8: ret = XVT_DISPLAY_COLOR_256; break;
|
||||
case 1: ret = XVT_DISPLAY_MONO; break;
|
||||
case 4: ret = XVT_DISPLAY_COLOR_16; break;
|
||||
case 8: ret = XVT_DISPLAY_COLOR_256; break;
|
||||
default: ret = XVT_DISPLAY_DIRECT_COLOR; break;
|
||||
}
|
||||
break;
|
||||
@ -3478,15 +3600,17 @@ long xvt_vobj_get_attr(WINDOW win, long data)
|
||||
ret = (long)_error_handler;
|
||||
break;
|
||||
case ATTR_NATIVE_GRAPHIC_CONTEXT:
|
||||
if (_nice_windows.Get(win) != NULL)
|
||||
{
|
||||
CAST_DC(win, dc);
|
||||
ret = dc.GetHDC();
|
||||
}
|
||||
break;
|
||||
case ATTR_NATIVE_WINDOW:
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
ret = w.GetHandle();
|
||||
if (_nice_windows.Get(win) != NULL)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
ret = w.GetHandle();
|
||||
}
|
||||
break;
|
||||
case ATTR_SCREEN_HEIGHT:
|
||||
@ -3518,10 +3642,17 @@ RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp)
|
||||
int l, h;
|
||||
if (win != NULL_WIN)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
w.GetClientSize(&l, &h);
|
||||
if (win == _print_win)
|
||||
{
|
||||
l = h = 6000; // circa A4 height
|
||||
}
|
||||
else
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
w.GetClientSize(&l, &h);
|
||||
}
|
||||
}
|
||||
else
|
||||
else // NULL_WIN -> SREEN_WINDOW
|
||||
{
|
||||
l = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_X);
|
||||
h = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y);
|
||||
@ -3574,6 +3705,20 @@ WIN_TYPE xvt_vobj_get_type(WINDOW win)
|
||||
return w._type;
|
||||
}
|
||||
|
||||
void xvt_vobj_maximize(WINDOW win)
|
||||
{
|
||||
wxFrame* pMain = (wxFrame*)_task_win;
|
||||
if (win != (WINDOW)pMain)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
int width, height;
|
||||
pMain->GetClientSize(&width, &height);
|
||||
w.SetSize(0, 0, width, height);
|
||||
}
|
||||
else
|
||||
pMain->Maximize();
|
||||
}
|
||||
|
||||
void xvt_vobj_move(WINDOW win, RCT *rctp)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
@ -3684,8 +3829,6 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
|
||||
}
|
||||
w = new TwxWindow((wxWindow*)parent, -1, caption, pos, size, style);
|
||||
|
||||
_valid_windows.Put((long)w, w);
|
||||
|
||||
w->_type = wtype;
|
||||
w->_app_data = app_data;
|
||||
|
||||
@ -3741,16 +3884,16 @@ long xvt_win_dispatch_event(WINDOW win, EVENT* event_p)
|
||||
|
||||
void xvt_win_post_event(WINDOW win, EVENT* event_p)
|
||||
{
|
||||
XVT_ASSERT(win != NULL_WIN && event_p != NULL);
|
||||
CAST_WIN(win, w);
|
||||
// Per ora funziona solo con la task window
|
||||
XVT_ASSERT(win == (WINDOW)_task_win && event_p != NULL);
|
||||
|
||||
switch (event_p->type)
|
||||
{
|
||||
case E_COMMAND:
|
||||
{
|
||||
wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, event_p->v.cmd.tag);
|
||||
e.SetEventObject(&w);
|
||||
wxPostEvent(&w, e);
|
||||
e.SetEventObject(_task_win);
|
||||
wxPostEvent(_task_win, e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -3802,7 +3945,7 @@ void xvt_win_set_cursor(WINDOW win, CURSOR cursor)
|
||||
|
||||
void xvt_win_set_handler(WINDOW win, EVENT_HANDLER eh)
|
||||
{
|
||||
if (win == TASK_WIN)
|
||||
if (win == (WINDOW)_task_win)
|
||||
{
|
||||
_task_win_handler = eh;
|
||||
}
|
||||
@ -3825,7 +3968,7 @@ void xvt_win_trap_pointer(WINDOW win)
|
||||
// Status bar
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
wxString strDefaultStatbarText;
|
||||
static wxString strDefaultStatbarText;
|
||||
|
||||
const char* statbar_set_title(WINDOW win, const char* text)
|
||||
{
|
||||
@ -3868,7 +4011,7 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
|
||||
int parent_rid, long parent_flags, char *parent_class)
|
||||
{
|
||||
XVT_ASSERT(parent_win == TASK_WIN);
|
||||
TTaskWin& w = *(TTaskWin*)parent_win;
|
||||
TTaskWin& w = *(TTaskWin*)_task_win;
|
||||
w.CreateStatusBar(2);
|
||||
w.GetStatusBar()->Show();
|
||||
wxSize sz = w.GetClientSize();
|
||||
|
12
xvaga/xvt.h
12
xvaga/xvt.h
@ -196,6 +196,10 @@ BOOLEAN xvt_print_is_valid(PRINT_RCD *precp);
|
||||
BOOLEAN xvt_print_open(void);
|
||||
BOOLEAN xvt_print_start_thread (BOOLEAN (* print_fcn)(long), long data);
|
||||
BOOLEAN xvt_print_open_page(PRINT_RCD *precp);
|
||||
// Added XVAGA
|
||||
SLIST xvt_print_list_devices();
|
||||
BOOLEAN xvt_print_set_default_device(const char* name);
|
||||
BOOLEAN xvt_print_get_default_device(char* name, int namesize);
|
||||
|
||||
int xvt_rect_get_height(RCT *rctp);
|
||||
int xvt_rect_get_width(RCT *rctp);
|
||||
@ -240,6 +244,10 @@ BOOLEAN xvt_str_match(const char* str, const char* pat, BOOLEAN case_sensitive);
|
||||
|
||||
// System calls by XVAGA
|
||||
void xvt_sys_beep(int severity);
|
||||
long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask);
|
||||
long xvt_sys_execute_in_window(const char* cmdline, WINDOW win);
|
||||
BOOLEAN xvt_sys_dongle_server_is_running();
|
||||
BOOLEAN xvt_sys_find_editor(const char* file, char* editor, int editorsize);
|
||||
int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
const char* defval, char* value, int maxsize);
|
||||
BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
@ -247,6 +255,7 @@ BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, cons
|
||||
unsigned long xvt_sys_get_free_memory();
|
||||
unsigned long xvt_sys_get_free_memory_kb();
|
||||
int xvt_sys_get_os_version();
|
||||
unsigned int xvt_sys_load_icon(const char* file);
|
||||
void xvt_sys_sleep(unsigned long msec);
|
||||
BOOLEAN xvt_sys_test_network_version();
|
||||
|
||||
@ -262,6 +271,7 @@ XVT_PALETTE xvt_vobj_get_palet(WINDOW win);
|
||||
WINDOW xvt_vobj_get_parent(WINDOW win);
|
||||
char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title);
|
||||
WIN_TYPE xvt_vobj_get_type(WINDOW win);
|
||||
void xvt_vobj_maximize(WINDOW win); // Added by XVAGA
|
||||
void xvt_vobj_move(WINDOW win, RCT *rctp);
|
||||
void xvt_vobj_raise(WINDOW win);
|
||||
void xvt_vobj_set_attr(WINDOW win, long data, long value);
|
||||
@ -274,7 +284,7 @@ void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp,
|
||||
|
||||
WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WINDOW parent_win, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data);
|
||||
long xvt_win_dispatch_event(WINDOW win, EVENT* event_p);
|
||||
void xvt_win_post_event(WINDOW win, EVENT* event_p); // Added by XVAGA
|
||||
void xvt_win_post_event(WINDOW win, EVENT* event_p); // Added by XVAGA
|
||||
void xvt_win_release_pointer(void);
|
||||
void xvt_win_set_caret_size(WINDOW win, int width, int height);
|
||||
void xvt_win_set_caret_pos(WINDOW win, PNT p);
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "wx/printdlg.h"
|
||||
|
||||
#include "xvt.h"
|
||||
#include "xvtextra.h"
|
||||
#include "oswin32.h"
|
||||
|
||||
#include "xvintern.h"
|
||||
@ -368,3 +367,58 @@ BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
|
||||
return ok;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Added by XVAGA
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
SLIST xvt_print_list_devices()
|
||||
{
|
||||
SLIST list = xvt_slist_create();
|
||||
#ifdef WIN32
|
||||
char buf[4096]; // ammazzao'
|
||||
GetProfileString("devices", NULL, "", buf, sizeof(buf));
|
||||
int start = 0;
|
||||
for (int i = 0; i < sizeof(buf); i++)
|
||||
{
|
||||
if (buf[i] == '\0')
|
||||
{
|
||||
if (buf[i+1] != '\0')
|
||||
{
|
||||
xvt_slist_add_at_elt(list, NULL, buf+start, NULL);
|
||||
start = i+1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
xvt_slist_add_at_elt(list, NULL, "/dev/prn", NULL); // TBI
|
||||
#endif
|
||||
return list;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_print_set_default_device(const char* name)
|
||||
{
|
||||
BOOLEAN ok = name && *name > ' ';
|
||||
#ifdef WIN32
|
||||
if (ok)
|
||||
{
|
||||
wxString pdev(name);
|
||||
if (pdev.Find(',') < 0)
|
||||
{
|
||||
char szDevice[256];
|
||||
GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
|
||||
pdev << ',' << szDevice;
|
||||
}
|
||||
ok = WriteProfileString("windows", "device", pdev) != 0;
|
||||
}
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_print_get_default_device(char* name, int namesize)
|
||||
{
|
||||
bool ok = GetProfileString ("windows", "device", ",,,", name, namesize) != 0;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user