Patch level : 2.0 nopatch
Files correlati : xvaga Ricompilazione Demo : [ ] Commento : Aggiunte nuove funzioni ad xvaga. git-svn-id: svn://10.65.10.50/trunk@10954 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2607ad4877
commit
2d8244859a
143
xvaga/xvaga.cpp
143
xvaga/xvaga.cpp
@ -31,6 +31,8 @@ wxWindow* _mouse_trapper = NULL;
|
||||
RCT _startup_rect = { 0,0,0,0 };
|
||||
wxString _startup_dir;
|
||||
|
||||
static wxHashTable _valid_windows;
|
||||
|
||||
static EVENT_HANDLER _task_win_handler = NULL;
|
||||
|
||||
static XVT_ERRMSG_HANDLER _error_handler = NULL;
|
||||
@ -590,10 +592,9 @@ class TwxWindow : public TwxWindowBase
|
||||
{
|
||||
MENU_ITEM* m_menu;
|
||||
|
||||
void DoXvtEvent(EVENT& e);
|
||||
|
||||
protected:
|
||||
virtual void OnChar(wxKeyEvent& e);
|
||||
virtual void OnClose(wxCloseEvent& e);
|
||||
virtual void OnKillFocus(wxFocusEvent& e);
|
||||
virtual void OnMenu(wxCommandEvent& event);
|
||||
virtual void OnMouseDouble(wxMouseEvent& e);
|
||||
@ -607,6 +608,7 @@ protected:
|
||||
virtual void OnTimer(wxTimerEvent& e);
|
||||
|
||||
public:
|
||||
void DoXvtEvent(EVENT& e);
|
||||
virtual void OnPaint(wxPaintEvent& event);
|
||||
|
||||
public:
|
||||
@ -663,6 +665,7 @@ IMPLEMENT_DYNAMIC_CLASS(TwxWindow, TwxWindowBase)
|
||||
|
||||
BEGIN_EVENT_TABLE(TwxWindow, TwxWindowBase)
|
||||
EVT_CHAR(TwxWindow::OnChar)
|
||||
EVT_CLOSE(TwxWindow::OnClose)
|
||||
EVT_KILL_FOCUS(TwxWindow::OnKillFocus)
|
||||
EVT_LEFT_DCLICK(TwxWindow::OnMouseDouble)
|
||||
EVT_LEFT_DOWN(TwxWindow::OnMouseDown)
|
||||
@ -761,6 +764,14 @@ void TwxWindow::OnChar(wxKeyEvent& event)
|
||||
DoXvtEvent(e);
|
||||
}
|
||||
|
||||
void TwxWindow::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_DESTROY;
|
||||
DoXvtEvent(e);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void TwxWindow::OnKillFocus(wxFocusEvent& event)
|
||||
{
|
||||
if (_TheCaret.Owner() == (WINDOW)this)
|
||||
@ -1153,6 +1164,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);
|
||||
|
||||
wxMenu* Menus[3];
|
||||
wxString Title[3];
|
||||
@ -1198,6 +1210,9 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
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)
|
||||
@ -2301,6 +2316,72 @@ BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp)
|
||||
return xvt_fsys_convert_str_to_dir(str, dirp);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_is_removable_drive(const char* path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetDriveType(path) == DRIVE_REMOVABLE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_is_network_drive(const char* path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetDriveType(path) == DRIVE_REMOTE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_is_fixed_drive(const char* path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetDriveType(path) == DRIVE_FIXED;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static unsigned long compute_disk_size(const char* path, bool tot, char unit)
|
||||
{
|
||||
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;
|
||||
switch (unit)
|
||||
{
|
||||
case 'K': nBytes >>= 10; break; // Kilobytes
|
||||
case 'M': nBytes >>= 20; break; // Megabytes
|
||||
case 'G': nBytes >>= 30; break; // Gigabytes
|
||||
case 'T': nBytes >>= 40; break; // Terabytes
|
||||
default: break;
|
||||
}
|
||||
|
||||
const unsigned long nMax = (unsigned long)(~0L);
|
||||
unsigned long nVal = nBytes > nMax ? nMax : (unsigned long)nBytes;
|
||||
return nVal;
|
||||
}
|
||||
|
||||
unsigned long xvt_fsys_get_disk_size(const char* path, char unit)
|
||||
{
|
||||
return compute_disk_size(path, true, unit);
|
||||
}
|
||||
|
||||
unsigned long xvt_fsys_get_disk_free_space(const char* path, char unit)
|
||||
{
|
||||
return compute_disk_size(path, false, unit);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize)
|
||||
{
|
||||
// Arrotonda per eccesso al Kilobyte
|
||||
unsigned long kb = filesize/1024+4;
|
||||
return kb <= xvt_fsys_get_disk_free_space(path, 'K');
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// File system
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -3056,7 +3137,7 @@ static void AddWinToList(SLIST list, WINDOW win)
|
||||
if (win != NULL_WIN)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
char* title = xvt_str_duplicate(w.GetTitle());
|
||||
const char* title = w.GetTitle();
|
||||
xvt_slist_add_at_elt(list, NULL, title, win);
|
||||
}
|
||||
}
|
||||
@ -3064,8 +3145,12 @@ static void AddWinToList(SLIST list, WINDOW win)
|
||||
SLIST xvt_scr_list_wins()
|
||||
{
|
||||
SLIST list = xvt_slist_create();
|
||||
AddWinToList(list, TASK_WIN);
|
||||
AddWinToList(list, xvt_scr_get_focus_topwin());
|
||||
_valid_windows.BeginFind();
|
||||
for (wxNode *node = _valid_windows.Next(); node; node = _valid_windows.Next())
|
||||
{
|
||||
WINDOW win = (WINDOW)node->GetData();
|
||||
AddWinToList(list, win);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -3091,18 +3176,20 @@ BOOLEAN xvt_slist_add_at_elt(SLIST list, SLIST_ELT e, const char *sx, long data)
|
||||
if (ok)
|
||||
{
|
||||
SLIST_ELT item = new SLIST_ITEM;
|
||||
item->str = strdup(sx ? sx : "");
|
||||
item->str = xvt_str_duplicate(sx);
|
||||
item->data = data;
|
||||
item->next = NULL;
|
||||
|
||||
SLIST_ELT last = NULL;
|
||||
for (SLIST_ELT i = list->head; i; i = (SLIST_ELT)i->next)
|
||||
{
|
||||
last = i;
|
||||
if (i == e)
|
||||
break;
|
||||
}
|
||||
|
||||
if (e != NULL)
|
||||
{
|
||||
for (SLIST_ELT i = list->head; i; i = (SLIST_ELT)i->next)
|
||||
{
|
||||
last = i;
|
||||
if (i == e)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (last == NULL) // Empty List
|
||||
list->head = item;
|
||||
else
|
||||
@ -3138,8 +3225,7 @@ void xvt_slist_destroy(SLIST list)
|
||||
while (obj != NULL)
|
||||
{
|
||||
SLIST_ELT tokill = obj;
|
||||
if (tokill->str)
|
||||
delete tokill->str;
|
||||
xvt_mem_free(tokill->str);
|
||||
obj = (SLIST_ELT)tokill->next;
|
||||
delete tokill;
|
||||
}
|
||||
@ -3245,6 +3331,25 @@ BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, cons
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long xvt_sys_get_free_memory()
|
||||
{
|
||||
unsigned long mem = 1024*1024;
|
||||
|
||||
#ifdef WIN32
|
||||
MEMORYSTATUS ms;
|
||||
GlobalMemoryStatus(&ms);
|
||||
mem = ms.dwAvailPhys;
|
||||
#endif
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
unsigned long xvt_sys_get_free_memory_kb()
|
||||
{
|
||||
unsigned long mem = xvt_sys_get_free_memory();
|
||||
return (mem + 512) / 1024;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Timers
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -3280,13 +3385,14 @@ void xvt_vobj_destroy(WINDOW win)
|
||||
{
|
||||
if (win != _print_win)
|
||||
{
|
||||
if (_TheCaret.Owner() == win)
|
||||
if (_TheCaret.Owner() == win)
|
||||
_TheCaret.Kill();
|
||||
|
||||
CAST_TWIN(win, w);
|
||||
_dc_map.DestroyTDC(&w);
|
||||
|
||||
w.Destroy();
|
||||
w.Close(true);
|
||||
_valid_windows.Delete(win);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3546,6 +3652,9 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
|
||||
SORRY_BOX(); break;
|
||||
}
|
||||
w = new TwxWindow((wxWindow*)parent, -1, caption, pos, size, style);
|
||||
|
||||
_valid_windows.Put((long)w, w);
|
||||
|
||||
w->_type = wtype;
|
||||
w->_app_data = app_data;
|
||||
|
||||
|
10
xvaga/xvt.h
10
xvaga/xvt.h
@ -132,6 +132,13 @@ SLIST xvt_fsys_list_files(char *type, char *pat, BOOLEAN dirs);
|
||||
void xvt_fsys_restore_dir();
|
||||
void xvt_fsys_save_dir();
|
||||
BOOLEAN xvt_fsys_set_dir(DIRECTORY *dirp);
|
||||
// Added by Guy
|
||||
unsigned long xvt_fsys_get_disk_size(const char* path, char unit);
|
||||
unsigned long xvt_fsys_get_disk_free_space(const char* path, char unit);
|
||||
BOOLEAN xvt_fsys_is_removable_drive(const char* path);
|
||||
BOOLEAN xvt_fsys_is_network_drive(const char* path);
|
||||
BOOLEAN xvt_fsys_is_fixed_drive(const char* path);
|
||||
BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize);
|
||||
|
||||
void xvt_help_close_helpfile(XVT_HELP_INFO hi);
|
||||
XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags);
|
||||
@ -236,6 +243,8 @@ int xvt_sys_get_profile_string(const char* file, const char* paragraph, cons
|
||||
const char* defval, char* value, int maxsize);
|
||||
BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
|
||||
const char* value);
|
||||
unsigned long xvt_sys_get_free_memory();
|
||||
unsigned long xvt_sys_get_free_memory_kb();
|
||||
|
||||
long xvt_timer_create(WINDOW win, long interval);
|
||||
void xvt_timer_destroy(long id);
|
||||
@ -274,4 +283,3 @@ void xvt_win_trap_pointer(WINDOW win);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -363,8 +363,6 @@ BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
|
||||
BOOLEAN ok = m_po != NULL;
|
||||
if (ok)
|
||||
{
|
||||
// TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
||||
// m_po->InitDC(rcd);
|
||||
m_po->GetDC()->StartPage();
|
||||
}
|
||||
return ok;
|
||||
|
Loading…
x
Reference in New Issue
Block a user