Patch level : 10.0
Files correlati : xvaga Ricompilazione Demo : [ ] Commento : Corretta gestione immagini e notebook git-svn-id: svn://10.65.10.50/trunk@16789 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1fb9f09beb
commit
a697b9169b
227
xvaga/xvaga.cpp
227
xvaga/xvaga.cpp
@ -38,13 +38,14 @@
|
||||
#endif
|
||||
|
||||
#define XVT_ASSERT(test) _AssertBox((test), __FUNCTION__, __FILE__ , __LINE__)
|
||||
#define CAST_WIN(win,w) wxWindow& w = *(wxWindow*)win; wxASSERT(win != NULL_WIN && w.IsKindOf(CLASSINFO(wxWindow)));
|
||||
#define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w);
|
||||
#define CAST_TDC(win,dc) XVT_ASSERT(win != NULL_WIN); TDC& dc = GetTDCMapper().GetTDC(win);
|
||||
#define CAST_DC(win,dc) XVT_ASSERT(win != NULL_WIN); wxDC& dc = GetTDCMapper().GetDC(win);
|
||||
#define CAST_WIN(win,w) wxWindow& w = *wxStaticCast((wxWindow*)win, wxWindow);
|
||||
#define CAST_TWIN(win,w) TwxWindow& w = *wxStaticCast((wxWindow*)win, TwxWindow);
|
||||
#define CAST_TDC(win,dc) TDC& dc = GetTDCMapper().GetTDC(win);
|
||||
#define CAST_DC(win,dc) wxDC& dc = GetTDCMapper().GetDC(win);
|
||||
|
||||
wxWindow* _mouse_trapper = NULL;
|
||||
RCT _startup_rect = { 0,0,0,0 };
|
||||
long _startup_style = 0;
|
||||
wxString _startup_dir;
|
||||
wxString _strDefaultStatbarText;
|
||||
wxString _appl_name;
|
||||
@ -59,14 +60,17 @@ class TMessageBox : public wxDialog
|
||||
{
|
||||
protected:
|
||||
void OnButton(wxCommandEvent& evt);
|
||||
void OnMouseCaptureLost(wxMouseCaptureLostEvent& evt);
|
||||
void AddButton(wxSizer* sz, int id, int ico);
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
public:
|
||||
TMessageBox(const wxString& msg, int nStyle);
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(TMessageBox, wxDialog)
|
||||
EVT_BUTTON(wxID_ANY, TMessageBox::OnButton)
|
||||
EVT_MOUSE_CAPTURE_LOST(TMessageBox::OnMouseCaptureLost)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TMessageBox::OnButton(wxCommandEvent& evt)
|
||||
@ -82,6 +86,11 @@ void TMessageBox::OnButton(wxCommandEvent& evt)
|
||||
EndModal(ec);
|
||||
}
|
||||
|
||||
void TMessageBox::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(e))
|
||||
{
|
||||
// Segnaposto inutile nella realta' ... ma indispensabile per qualche genio di wxWidgets
|
||||
}
|
||||
|
||||
void TMessageBox::AddButton(wxSizer* sz, int id, int WXUNUSED(ico))
|
||||
{
|
||||
sz->Add(new wxButton(this, id, wxEmptyString, wxDefaultPosition,
|
||||
@ -477,6 +486,9 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_startup_style & WSF_NO_TASKBAR)
|
||||
style |= wxFRAME_NO_TASKBAR;
|
||||
|
||||
_task_win = new TTaskWin(ICON_RSRC, title, pos, size, style);
|
||||
_task_win->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint
|
||||
_nice_windows.Put((WINDOW)_task_win, _task_win);
|
||||
@ -571,7 +583,7 @@ void xvt_app_process_pending_events(void)
|
||||
while (a->Pending())
|
||||
a->Dispatch();
|
||||
a->ProcessIdle(); // Necessario per wxAUI
|
||||
//a->Yield(true); // Non so se serva veramente
|
||||
a->Yield(true); // Non so se serva veramente
|
||||
}
|
||||
}
|
||||
|
||||
@ -1082,9 +1094,10 @@ BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev)
|
||||
// Image handling
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TXVT_IMAGE
|
||||
class TXVT_IMAGE : public wxImage
|
||||
{
|
||||
wxImage m_image;
|
||||
DECLARE_DYNAMIC_CLASS(TXVT_IMAGE);
|
||||
|
||||
int m_nDepth;
|
||||
bool m_bDirty;
|
||||
|
||||
@ -1098,8 +1111,8 @@ protected:
|
||||
void Destroy();
|
||||
|
||||
public:
|
||||
const wxImage& Image() const { return m_image; }
|
||||
wxImage& Image() { m_bDirty = true; return m_image; }
|
||||
const wxImage& Image() const { return *this; }
|
||||
wxImage& Image() { m_bDirty = true; return *this; }
|
||||
|
||||
#ifdef WIN32
|
||||
HBITMAP Bitmap(wxDC& dc);
|
||||
@ -1111,6 +1124,11 @@ public:
|
||||
~TXVT_IMAGE();
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(TXVT_IMAGE, wxImage);
|
||||
|
||||
#define CAST_IMAGE(xvtimg, imgptr) TXVT_IMAGE* imgptr = wxDynamicCast(xvtimg, TXVT_IMAGE);
|
||||
#define CONST_IMAGE(xvtimg, imgptr) const TXVT_IMAGE* imgptr = wxDynamicCast(xvtimg, TXVT_IMAGE);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
HBITMAP TXVT_IMAGE::Bitmap(wxDC& dc)
|
||||
@ -1119,8 +1137,8 @@ HBITMAP TXVT_IMAGE::Bitmap(wxDC& dc)
|
||||
{
|
||||
Destroy();
|
||||
m_nDepth = dc.GetDepth();
|
||||
m_bDirty = FALSE;
|
||||
m_bitmap = OsWin32_CreateBitmap(m_image, dc);
|
||||
m_bitmap = OsWin32_CreateBitmap(*this, dc);
|
||||
m_bDirty = false;
|
||||
}
|
||||
return m_bitmap;
|
||||
}
|
||||
@ -1133,8 +1151,8 @@ const wxBitmap& TXVT_IMAGE::Bitmap(wxDC& dc)
|
||||
{
|
||||
Destroy();
|
||||
m_nDepth = dc.GetDepth();
|
||||
m_bDirty = FALSE;
|
||||
m_bitmap = new wxBitmap(m_image, m_nDepth);
|
||||
m_bitmap = new wxBitmap(*this, m_nDepth);
|
||||
m_bDirty = false;
|
||||
}
|
||||
return *m_bitmap;
|
||||
}
|
||||
@ -1437,10 +1455,9 @@ void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, RCT* dest)
|
||||
((TwxPDFDC&)dc).DrawImage(name, dst);
|
||||
}
|
||||
|
||||
|
||||
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
|
||||
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE img, RCT* dest, RCT* source)
|
||||
{
|
||||
XVT_ASSERT(image != NULL);
|
||||
CAST_IMAGE(img, image);
|
||||
if (image != NULL)
|
||||
{
|
||||
if (xvt_dwin_is_update_needed(win, dest))
|
||||
@ -1448,7 +1465,7 @@ void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
|
||||
CAST_DC(win, dc);
|
||||
const wxRect src = NormalizeRCT(source);
|
||||
const wxRect dst = NormalizeRCT(dest);
|
||||
DrawImageOnDC(dc, (TXVT_IMAGE*)image, dst, src);
|
||||
DrawImageOnDC(dc, image, dst, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2376,18 +2393,19 @@ XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, l
|
||||
return (XVT_IMAGE)i;
|
||||
}
|
||||
|
||||
void xvt_image_destroy(XVT_IMAGE image)
|
||||
void xvt_image_destroy(XVT_IMAGE img)
|
||||
{
|
||||
CAST_IMAGE(img, image);
|
||||
if (image != NULL)
|
||||
delete (TXVT_IMAGE*)image;
|
||||
delete image;
|
||||
}
|
||||
|
||||
COLOR xvt_image_get_clut(XVT_IMAGE image, short index)
|
||||
COLOR xvt_image_get_clut(XVT_IMAGE img, short index)
|
||||
{
|
||||
XVT_ASSERT(image != NULL);
|
||||
CONST_IMAGE(img, image);
|
||||
if (image)
|
||||
{
|
||||
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
|
||||
const wxImage& bmp = image->Image();
|
||||
if (bmp.HasPalette())
|
||||
{
|
||||
const wxPalette& pal = bmp.GetPalette();
|
||||
@ -2401,30 +2419,38 @@ COLOR xvt_image_get_clut(XVT_IMAGE image, short index)
|
||||
|
||||
void xvt_image_get_dimensions(XVT_IMAGE image, short *width, short *height)
|
||||
{
|
||||
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
|
||||
if (img.Ok())
|
||||
{
|
||||
*width = img.GetWidth();
|
||||
*height = img.GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = *height = 0;
|
||||
}
|
||||
*width = *height = 0;
|
||||
|
||||
CONST_IMAGE(image, img);
|
||||
if (img != NULL)
|
||||
{
|
||||
const wxImage& bmp = img->Image();
|
||||
if (bmp.Ok())
|
||||
{
|
||||
*width = bmp.GetWidth();
|
||||
*height = bmp.GetHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image)
|
||||
{
|
||||
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
|
||||
return img.HasPalette() ? XVT_IMAGE_CL8 : XVT_IMAGE_RGB;
|
||||
CONST_IMAGE(image, i);
|
||||
if (i != NULL)
|
||||
{
|
||||
const wxImage& img = i->Image();
|
||||
return img.HasPalette() ? XVT_IMAGE_CL8 : XVT_IMAGE_RGB;
|
||||
}
|
||||
return XVT_IMAGE_NONE;
|
||||
}
|
||||
|
||||
short xvt_image_get_ncolors(XVT_IMAGE image)
|
||||
{
|
||||
int n = 0;
|
||||
if (image)
|
||||
CONST_IMAGE(image, i);
|
||||
if (i != NULL)
|
||||
{
|
||||
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
|
||||
const wxImage& bmp = i->Image();
|
||||
if (bmp.HasPalette())
|
||||
{
|
||||
const wxPalette& pal = bmp.GetPalette();
|
||||
@ -2441,11 +2467,16 @@ short xvt_image_get_ncolors(XVT_IMAGE image)
|
||||
|
||||
COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y)
|
||||
{
|
||||
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
|
||||
int r = bmp.GetRed(x, y);
|
||||
int g = bmp.GetGreen(x, y);
|
||||
int b = bmp.GetBlue(x, y);
|
||||
return XVT_MAKE_COLOR(r, g, b);
|
||||
CONST_IMAGE(image, i);
|
||||
if (i != NULL)
|
||||
{
|
||||
const wxImage& bmp = i->Image();
|
||||
int r = bmp.GetRed(x, y);
|
||||
int g = bmp.GetGreen(x, y);
|
||||
int b = bmp.GetBlue(x, y);
|
||||
return XVT_MAKE_COLOR(r, g, b);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
XVT_IMAGE xvt_image_read(const char* filenamep)
|
||||
@ -2482,27 +2513,31 @@ XVT_IMAGE xvt_image_read_bmp(const char *filenamep)
|
||||
|
||||
void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color)
|
||||
{
|
||||
wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
|
||||
if (bmp.HasPalette())
|
||||
{
|
||||
const wxPalette& pal = bmp.GetPalette();
|
||||
CAST_COLOR (color, c);
|
||||
unsigned char ri, gi, bi;
|
||||
pal.GetRGB(index, &ri, &gi, &bi);
|
||||
CAST_IMAGE(image, i);
|
||||
if (i != NULL)
|
||||
{
|
||||
wxImage& bmp = i->Image();
|
||||
if (bmp.HasPalette())
|
||||
{
|
||||
const wxPalette& pal = bmp.GetPalette();
|
||||
CAST_COLOR (color, c);
|
||||
unsigned char ri, gi, bi;
|
||||
pal.GetRGB(index, &ri, &gi, &bi);
|
||||
|
||||
const int w = bmp.GetWidth();
|
||||
const int h = bmp.GetHeight();
|
||||
for (int y = 0; y < h; y++) for (int x = 0; x < w; x++)
|
||||
{
|
||||
unsigned char r = bmp.GetRed(x, y);
|
||||
if (r != ri) continue;
|
||||
unsigned char g = bmp.GetGreen(x, y);
|
||||
if (g != gi) continue;
|
||||
unsigned char b = bmp.GetBlue(x, y);
|
||||
if (b != bi) continue;
|
||||
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
}
|
||||
const int w = bmp.GetWidth();
|
||||
const int h = bmp.GetHeight();
|
||||
for (int y = 0; y < h; y++) for (int x = 0; x < w; x++)
|
||||
{
|
||||
unsigned char r = bmp.GetRed(x, y);
|
||||
if (r != ri) continue;
|
||||
unsigned char g = bmp.GetGreen(x, y);
|
||||
if (g != gi) continue;
|
||||
unsigned char b = bmp.GetBlue(x, y);
|
||||
if (b != bi) continue;
|
||||
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors)
|
||||
@ -2512,22 +2547,30 @@ void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors)
|
||||
|
||||
void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color)
|
||||
{
|
||||
wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
|
||||
CAST_COLOR (color, c);
|
||||
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
|
||||
CAST_IMAGE(image, i);
|
||||
if (i != NULL)
|
||||
{
|
||||
wxImage& bmp = i->Image();
|
||||
CAST_COLOR (color, c);
|
||||
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
}
|
||||
|
||||
void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp)
|
||||
{
|
||||
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
|
||||
const wxRect rctDst = NormalizeRCT(dstrctp);
|
||||
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
||||
wxMemoryDC dc;
|
||||
wxBitmap bmp(dst);
|
||||
dc.SelectObject(bmp);
|
||||
DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc);
|
||||
dst = bmp.ConvertToImage();
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
CAST_IMAGE(dstimage, dst);
|
||||
CAST_IMAGE(srcimage, src);
|
||||
if (dst != NULL && src != NULL)
|
||||
{
|
||||
const wxRect rctDst = NormalizeRCT(dstrctp);
|
||||
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
||||
wxMemoryDC dc;
|
||||
wxBitmap bmp(dst->Image());
|
||||
dc.SelectObject(bmp);
|
||||
DrawImageOnDC(dc, src, rctDst, rctSrc);
|
||||
dst->Image() = bmp.ConvertToImage();
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -4029,6 +4072,9 @@ long xvt_vobj_get_attr(WINDOW win, long data)
|
||||
case ATTR_WIN_PM_DRAWABLE_TWIN:
|
||||
ret = TRUE;
|
||||
break;
|
||||
case ATTR_WIN_PM_TWIN_STARTUP_STYLE:
|
||||
ret = _startup_style;
|
||||
break;
|
||||
case ATTR_ICON_WIDTH:
|
||||
ret = wxSystemSettings::GetMetric(wxSYS_ICON_X);
|
||||
break;
|
||||
@ -4096,7 +4142,7 @@ XVT_PALETTE xvt_vobj_get_palet(WINDOW win)
|
||||
|
||||
WINDOW xvt_vobj_get_parent(WINDOW win)
|
||||
{
|
||||
if (win == TASK_WIN)
|
||||
if (win == NULL_WIN || win == TASK_WIN)
|
||||
return NULL_WIN;
|
||||
CAST_WIN(win, w);
|
||||
return (WINDOW)w.GetParent();
|
||||
@ -4105,27 +4151,32 @@ WINDOW xvt_vobj_get_parent(WINDOW win)
|
||||
char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
strncpy(title, w.GetLabel(), sz_title);
|
||||
wxStrncpy(title, w.GetLabel(), sz_title);
|
||||
title[sz_title-1] = '\0';
|
||||
return title;
|
||||
}
|
||||
|
||||
WIN_TYPE xvt_vobj_get_type(WINDOW win)
|
||||
{
|
||||
if (win == NULL_WIN)
|
||||
return W_NONE;
|
||||
if (win == TASK_WIN)
|
||||
return W_TASK;
|
||||
if (win == SCREEN_WIN)
|
||||
return W_SCREEN;
|
||||
if (win == PRINTER_WIN)
|
||||
return W_PRINT;
|
||||
|
||||
CAST_TWIN(win, w);
|
||||
return w._type;
|
||||
|
||||
TwxWindow* w = wxDynamicCast((wxObject*)win, TwxWindow);
|
||||
if (w != NULL)
|
||||
return w->_type;
|
||||
|
||||
return WO_TE; // Unknown custom control
|
||||
}
|
||||
|
||||
BOOLEAN xvt_vobj_is_focusable(WINDOW win)
|
||||
{
|
||||
BOOLEAN ok = win != NULL_WIN && win != PRINTER_WIN;
|
||||
BOOLEAN ok = (win != NULL_WIN) && (win != PRINTER_WIN);
|
||||
if (ok)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
@ -4136,22 +4187,22 @@ BOOLEAN xvt_vobj_is_focusable(WINDOW win)
|
||||
|
||||
void xvt_vobj_maximize(WINDOW win)
|
||||
{
|
||||
wxFrame* pMain = (wxFrame*)_task_win;
|
||||
if (win != (WINDOW)pMain)
|
||||
wxFrame* pMain = wxDynamicCast((wxObject*)win, wxFrame);
|
||||
if (pMain != NULL)
|
||||
pMain->Maximize();
|
||||
else
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
int width, height;
|
||||
pMain->GetClientSize(&width, &height);
|
||||
_task_win->GetClientSize(&width, &height);
|
||||
w.SetSize(0, 0, width, height);
|
||||
}
|
||||
else
|
||||
pMain->Maximize();
|
||||
}
|
||||
|
||||
void xvt_vobj_minimize(WINDOW win)
|
||||
{
|
||||
wxFrame* pMain = (wxFrame*)_task_win;
|
||||
if (win == (WINDOW)pMain)
|
||||
wxFrame* pMain = wxDynamicCast((wxObject*)win, wxFrame);
|
||||
if (pMain != NULL)
|
||||
pMain->Iconize();
|
||||
else
|
||||
SORRY_BOX();
|
||||
@ -4173,13 +4224,13 @@ void xvt_vobj_raise(WINDOW win)
|
||||
|
||||
void xvt_vobj_set_attr(WINDOW win, long data, long value)
|
||||
{
|
||||
switch(data)
|
||||
switch (data)
|
||||
{
|
||||
case ATTR_ERRMSG_HANDLER: _error_handler = (XVT_ERRMSG_HANDLER)value; break;
|
||||
case ATTR_EVENT_HOOK: SORRY_BOX(); break; // TBI?: Native events hook!
|
||||
case ATTR_WIN_PM_DRAWABLE_TWIN: break; // Ignored: Always TRUE
|
||||
case ATTR_WIN_PM_TWIN_STARTUP_RCT: _startup_rect = *(RCT*)value; break;
|
||||
case ATTR_WIN_PM_TWIN_STARTUP_STYLE: break; // TBI
|
||||
case ATTR_WIN_PM_TWIN_STARTUP_STYLE: _startup_style = value; break;
|
||||
case ATTR_SPEECH_MODE: xvt_dm_enable_speech(value); break;
|
||||
default: SORRY_BOX(); break;
|
||||
}
|
||||
|
23
xvaga/xvt.h
23
xvaga/xvt.h
@ -370,21 +370,24 @@ XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragra
|
||||
const char* defval, char* value, int maxsize);
|
||||
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();
|
||||
XVTDLL int xvt_sys_get_os_version();
|
||||
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
|
||||
XVTDLL void xvt_sys_sleep(unsigned long msec);
|
||||
XVTDLL BOOLEAN xvt_sys_test_network_version();
|
||||
XVTDLL void xvt_sys_searchenv(const char *filename, const char *varname, char *pathname);
|
||||
XVTDLL void xvt_sys_sorry_box(const char* func, const char* file, int line);
|
||||
XVTDLL void xvt_sys_deprecated_box(const char * file, int line);
|
||||
XVTDLL int xvt_sys_get_session_id();
|
||||
XVTDLL unsigned long xvt_sys_get_free_memory();
|
||||
XVTDLL unsigned long xvt_sys_get_free_memory_kb();
|
||||
XVTDLL int xvt_sys_get_os_version();
|
||||
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
|
||||
XVTDLL void xvt_sys_sleep(unsigned long msec);
|
||||
XVTDLL BOOLEAN xvt_sys_test_network_version();
|
||||
XVTDLL void xvt_sys_searchenv(const char* filename, const char* varname, char* pathname);
|
||||
XVTDLL void xvt_sys_sorry_box(const char* func, const char* file, int line);
|
||||
XVTDLL void xvt_sys_deprecated_box(const char * file, int line);
|
||||
|
||||
XVTDLL struct tm* xvt_time_now();
|
||||
XVTDLL long xvt_timer_create(WINDOW win, long interval);
|
||||
XVTDLL void xvt_timer_destroy(long id);
|
||||
|
||||
XVTDLL WINDOW xvt_trayicon_create(WINDOW owned, short icon, const char* tooltip);
|
||||
XVTDLL void xvt_trayicon_destroy(WINDOW tray);
|
||||
|
||||
XVTDLL void xvt_vobj_destroy(WINDOW win);
|
||||
XVTDLL long xvt_vobj_get_attr(WINDOW win, long data);
|
||||
XVTDLL RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Agreement with XVT Software.
|
||||
*
|
||||
* $RCSfile: xvt_defs.h,v $
|
||||
* $Revision: 1.8 $
|
||||
* $Revision: 1.9 $
|
||||
*
|
||||
* Purpose: Global XVT macro definitions.
|
||||
*
|
||||
@ -263,6 +263,7 @@
|
||||
#define WSF_PLACE_EXACT 0x00002000L /* do not auto-place */
|
||||
#define WSF_DEFER_MODAL 0x00008000L /* defer modal state for W_MODAL windows */
|
||||
#define WSF_TRANSPARENT 0x00010000L /* trasparent */
|
||||
#define WSF_NO_TASKBAR 0x00020000L /* No task bar icon */
|
||||
|
||||
#define DLG_FLAG_DISABLED 0x00000001L
|
||||
#define DLG_FLAG_INVISIBLE 0x00000002L
|
||||
|
@ -93,11 +93,15 @@ class TwxNoteBook : public wxAuiNotebook
|
||||
enum { BOOK_ICO_SIZE = 16 };
|
||||
bool m_bSuspended;
|
||||
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
void OnPageChanged(wxNotebookEvent& e);
|
||||
DECLARE_DYNAMIC_CLASS(TwxNoteBook)
|
||||
|
||||
protected:
|
||||
void OnPageChanged(wxAuiNotebookEvent& e);
|
||||
long Flags2Style(long flags) const;
|
||||
|
||||
TwxNoteBook() {}
|
||||
|
||||
public:
|
||||
int ChangeSelection(size_t tab_no); // wxNotebook had it!
|
||||
void SetTabImage(size_t tab_no, XVT_IMAGE img);
|
||||
@ -279,9 +283,9 @@ void xvt_ctl_check_radio_button(WINDOW win, WINDOW* wins, int NbrWindows)
|
||||
wxASSERT(NbrWindows >= 2);
|
||||
for (int i = 0; i < NbrWindows; i++)
|
||||
{
|
||||
wxRadioButton* rb = (wxRadioButton*)wins[i];
|
||||
wxASSERT(rb != NULL && rb->IsKindOf(CLASSINFO(wxRadioButton)));
|
||||
rb->SetValue(win == wins[i]);
|
||||
wxRadioButton* rb = wxDynamicCast((wxWindow*)wins[i], wxRadioButton);
|
||||
if (rb != NULL)
|
||||
rb->SetValue(win == wins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,27 +304,28 @@ void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down)
|
||||
{
|
||||
if (win != NULL_WIN && up != NULL)
|
||||
{
|
||||
wxBitmapButton* pb = (wxBitmapButton*)win;
|
||||
wxASSERT(pb->IsKindOf(CLASSINFO(wxBitmapButton)));
|
||||
wxBitmap bmpUp(Image2Bitmap(up, TRUE));
|
||||
if (bmpUp.Ok())
|
||||
{
|
||||
pb->SetBitmapLabel(bmpUp);
|
||||
const wxImage imgGay = ((wxImage*)up)->ConvertToGreyscale();
|
||||
wxBitmap bmpGay(imgGay);
|
||||
pb->SetBitmapDisabled(bmpGay);
|
||||
}
|
||||
|
||||
if (down != NULL)
|
||||
{
|
||||
wxBitmap bmpDown(Image2Bitmap(down, TRUE));
|
||||
if (bmpDown.Ok())
|
||||
pb->SetBitmapSelected(bmpDown);
|
||||
}
|
||||
else
|
||||
wxBitmapButton* pb = wxDynamicCast((wxWindow*)win, wxBitmapButton);
|
||||
if (pb != NULL)
|
||||
{
|
||||
wxBitmap bmpUp(Image2Bitmap(up, TRUE));
|
||||
if (bmpUp.Ok())
|
||||
pb->SetBitmapSelected(bmpUp);
|
||||
{
|
||||
pb->SetBitmapLabel(bmpUp);
|
||||
const wxImage imgGay = ((wxImage*)up)->ConvertToGreyscale();
|
||||
wxBitmap bmpGay(imgGay);
|
||||
pb->SetBitmapDisabled(bmpGay);
|
||||
}
|
||||
if (down != NULL)
|
||||
{
|
||||
wxBitmap bmpDown(Image2Bitmap(down, TRUE));
|
||||
if (bmpDown.Ok())
|
||||
pb->SetBitmapSelected(bmpDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bmpUp.Ok())
|
||||
pb->SetBitmapSelected(bmpUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -403,16 +408,18 @@ XVTDLL BOOLEAN xvt_pane_detach(WINDOW win)
|
||||
// Notebook interface
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#define CAST_NOTEBOOK(win, nb) wxASSERT(win); TwxNoteBook& nb = *(TwxNoteBook*)win;
|
||||
IMPLEMENT_DYNAMIC_CLASS(TwxNoteBook, wxAuiNotebook)
|
||||
|
||||
#define CAST_NOTEBOOK(win, nb) TwxNoteBook& nb = *wxStaticCast((wxObject*)win, TwxNoteBook);
|
||||
|
||||
inline bool VALID_NOTEBOOK(WINDOW notebk, short page_no)
|
||||
{ return notebk != NULL_WIN && page_no >= 0; }
|
||||
{ return page_no >= 0 && wxDynamicCast((wxObject*)notebk, TwxNoteBook)!=NULL; }
|
||||
|
||||
BEGIN_EVENT_TABLE(TwxNoteBook, wxAuiNotebook)
|
||||
EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, TwxNoteBook::OnPageChanged)
|
||||
EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, OnPageChanged)
|
||||
END_EVENT_TABLE();
|
||||
|
||||
void TwxNoteBook::OnPageChanged(wxNotebookEvent& evt)
|
||||
void TwxNoteBook::OnPageChanged(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
if (!m_bSuspended)
|
||||
{
|
||||
@ -426,7 +433,7 @@ void TwxNoteBook::OnPageChanged(wxNotebookEvent& evt)
|
||||
e.v.ctl.ci.v.notebk.tab_no = evt.GetSelection();
|
||||
e.v.ctl.ci.v.notebk.page_no = evt.GetOldSelection();
|
||||
|
||||
TwxWindow* win = (TwxWindow*)GetParent();
|
||||
TwxWindow* win = wxStaticCast(GetParent(), TwxWindow);
|
||||
win->DoXvtEvent(e);
|
||||
m_bSuspended = false;
|
||||
}
|
||||
@ -435,15 +442,13 @@ void TwxNoteBook::OnPageChanged(wxNotebookEvent& evt)
|
||||
short TwxNoteBook::AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE xvt_img, short idx)
|
||||
{
|
||||
wxBitmap bmp;
|
||||
|
||||
if (xvt_img != NULL)
|
||||
{
|
||||
wxImage& img = *(wxImage*)xvt_img;
|
||||
wxImage& img = *(wxImage*)xvt_img; // Piccola porcata...
|
||||
img.Rescale(BOOK_ICO_SIZE, BOOK_ICO_SIZE, wxIMAGE_QUALITY_HIGH);
|
||||
bmp = Image2Bitmap(xvt_img, true);
|
||||
}
|
||||
|
||||
if (pPage->GetParent() != this)
|
||||
pPage->Reparent(this);
|
||||
if (idx < 0 || idx >= (int)GetPageCount())
|
||||
{
|
||||
AddPage(pPage, text, false, bmp);
|
||||
@ -459,7 +464,7 @@ void TwxNoteBook::SetTabImage(size_t idx, XVT_IMAGE img)
|
||||
{
|
||||
if (img != NULL)
|
||||
{
|
||||
wxImage ico(*(wxImage*)img);
|
||||
wxImage ico(*wxStaticCast(img, wxImage));
|
||||
ico.Rescale(BOOK_ICO_SIZE, BOOK_ICO_SIZE, wxIMAGE_QUALITY_HIGH);
|
||||
const wxBitmap bmp(ico);
|
||||
SetPageBitmap(idx, bmp);
|
||||
@ -498,13 +503,13 @@ TwxNoteBook::TwxNoteBook(wxWindow *parent, wxWindowID id,
|
||||
TwxNoteBook::~TwxNoteBook()
|
||||
{
|
||||
// Il wxAuiNotebook non gradisce le pagine doppie, per cui ... le ammazzo io.
|
||||
m_bSuspended = true;
|
||||
for (int i = GetPageCount()-1; i > 0; i--)
|
||||
{
|
||||
wxWindow* page = GetPage(i); // Pagina corrente a partire dall'ultima
|
||||
if (GetPageIndex(page) < i) // C'e' anche prima ...
|
||||
RemovePage(i); // ... allora la rimuovo (senza delete!)
|
||||
}
|
||||
|
||||
_nice_windows.Delete((WINDOW)this);
|
||||
}
|
||||
|
||||
@ -617,7 +622,7 @@ void xvt_notebk_set_tab_icon(WINDOW notebk, short tab_no, int rid)
|
||||
|
||||
void xvt_notebk_set_tab_title(WINDOW notebk, short tab_no, const char* title)
|
||||
{
|
||||
if (notebk != NULL_WIN && tab_no >= 0)
|
||||
if (VALID_NOTEBOOK(notebk, tab_no))
|
||||
{
|
||||
CAST_NOTEBOOK(notebk, nb);
|
||||
const short pc = nb.GetPageCount();
|
||||
@ -639,7 +644,7 @@ BEGIN_EVENT_TABLE(TwxTreeCtrl, wxTreeCtrl)
|
||||
EVT_TREE_ITEM_ACTIVATED(wxID_ANY, TwxTreeCtrl::OnActivated)
|
||||
END_EVENT_TABLE();
|
||||
|
||||
#define CAST_TREEVIEW(win, tv) wxASSERT(win); TwxTreeCtrl& tv = *(TwxTreeCtrl*)win;
|
||||
#define CAST_TREEVIEW(win, tv) TwxTreeCtrl& tv = *wxStaticCast((wxObject*)win, TwxTreeCtrl);
|
||||
|
||||
struct TwxTreeItemData : public wxTreeItemData
|
||||
{
|
||||
@ -660,7 +665,7 @@ void TwxTreeCtrl::OnExpanding(wxTreeEvent& evt)
|
||||
e.v.ctl.ci.v.treeview.expanded = TRUE;
|
||||
if (GetChildrenCount(id) == 0) // Trucco perfido ...
|
||||
e.v.ctl.ci.v.treeview.collapsed = TRUE; // ... stato indeterminato = EXPANDING
|
||||
TwxWindow* win = (TwxWindow*)GetParent();
|
||||
TwxWindow* win = wxStaticCast(GetParent(), TwxWindow);
|
||||
win->DoXvtEvent(e);
|
||||
if (GetChildrenCount(id) == 0) // Allora e' proprio vero ...
|
||||
SetItemHasChildren(id, false);
|
||||
@ -679,7 +684,7 @@ void TwxTreeCtrl::OnCollapsed(wxTreeEvent& evt)
|
||||
e.v.ctl.ci.win = WINDOW(this);
|
||||
e.v.ctl.ci.v.treeview.node = evt.GetItem().m_pItem;
|
||||
e.v.ctl.ci.v.treeview.collapsed = TRUE;
|
||||
TwxWindow* win = (TwxWindow*)GetParent();
|
||||
TwxWindow* win = wxStaticCast(GetParent(), TwxWindow);
|
||||
win->DoXvtEvent(e);
|
||||
Resume();
|
||||
}
|
||||
@ -700,7 +705,7 @@ void TwxTreeCtrl::OnClick(wxTreeEvent& evt, bool bDouble)
|
||||
e.v.ctl.ci.v.treeview.dbl_click = TRUE;
|
||||
else
|
||||
e.v.ctl.ci.v.treeview.sgl_click = TRUE;
|
||||
TwxWindow* win = (TwxWindow*)GetParent();
|
||||
TwxWindow* win = wxStaticCast(GetParent(), TwxWindow);
|
||||
win->DoXvtEvent(e);
|
||||
Resume();
|
||||
}
|
||||
@ -1283,10 +1288,7 @@ TwxToolBar::TwxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||
|
||||
static wxToolBar* Win2Bar(WINDOW win)
|
||||
{
|
||||
wxWindow* wnd = (wxWindow*)win;
|
||||
if (wnd != NULL && wnd->IsKindOf(CLASSINFO(wxToolBar)))
|
||||
return (wxToolBar*)wnd;
|
||||
return NULL;
|
||||
return wxDynamicCast((wxWindow*)win, wxToolBar);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char *title,
|
||||
|
@ -4,11 +4,12 @@
|
||||
#include "xvt.h"
|
||||
#include "xvtwin.h"
|
||||
|
||||
#include "wx/aui/aui.h"
|
||||
#include "wx/dcbuffer.h"
|
||||
#include "wx/notebook.h"
|
||||
#include "wx/treectrl.h"
|
||||
#include "wx/vlbox.h"
|
||||
#include <wx/aui/aui.h>
|
||||
#include <wx/dcbuffer.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/taskbar.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/vlbox.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utilities
|
||||
@ -236,7 +237,7 @@ bool TDC::ClipChanged() const
|
||||
#ifdef LINUX
|
||||
bool is_printer_dc(wxDC * dc)
|
||||
{
|
||||
return dc->IsKindOf(CLASSINFO(wxPostScriptDC));
|
||||
return wxDynamicCast(dc, wxPostScriptDC) != NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -433,6 +434,7 @@ TDC& TDCMapper::GetTDC(WINDOW owner)
|
||||
{
|
||||
if (owner != _pLastOwner)
|
||||
{
|
||||
wxASSERT(owner != NULL_WIN);
|
||||
TDC* pTDC = (*this)[owner];
|
||||
if (pTDC == NULL)
|
||||
{
|
||||
@ -1112,3 +1114,80 @@ TTaskWin::~TTaskWin()
|
||||
}
|
||||
_nice_windows.Delete((WINDOW)this);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TwxTaskBarIcon
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TwxTaskBarIcon : public wxTaskBarIcon
|
||||
{
|
||||
wxWindow* _owned;
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
protected:
|
||||
void OnClick(wxTaskBarIconEvent& e);
|
||||
|
||||
public:
|
||||
TwxTaskBarIcon(wxWindow* owned, short icon, wxString strTip);
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(TwxTaskBarIcon, wxTaskBarIcon)
|
||||
EVT_TASKBAR_LEFT_DOWN(OnClick)
|
||||
EVT_TASKBAR_RIGHT_DOWN(OnClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TwxTaskBarIcon::OnClick(wxTaskBarIconEvent& WXUNUSED(e))
|
||||
{
|
||||
if (_owned != NULL)
|
||||
{
|
||||
if (_owned->IsShown())
|
||||
_owned->Show(false);
|
||||
else
|
||||
{
|
||||
_owned->Show();
|
||||
_owned->Raise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TwxTaskBarIcon::TwxTaskBarIcon(wxWindow* owned, short icon, wxString strTip)
|
||||
: _owned(owned)
|
||||
{
|
||||
const wxIcon* pIcon = NULL;
|
||||
if (icon <= 0)
|
||||
{
|
||||
const wxFrame* pFrame = wxDynamicCast(_owned, wxFrame);
|
||||
if (pFrame != NULL)
|
||||
pIcon = &pFrame->GetIcon();
|
||||
}
|
||||
if (pIcon == NULL)
|
||||
{
|
||||
if (icon <= 0)
|
||||
icon = ICON_RSRC;
|
||||
pIcon = &_GetIconResource(icon);
|
||||
}
|
||||
|
||||
if (strTip.IsEmpty())
|
||||
{
|
||||
const wxWindow* pWin = wxDynamicCast(_owned, wxWindow);
|
||||
if (pWin != NULL)
|
||||
strTip = pWin->GetLabel();
|
||||
}
|
||||
|
||||
SetIcon(*pIcon, strTip);
|
||||
}
|
||||
|
||||
WINDOW xvt_trayicon_create(WINDOW owned, short icon, const char* tooltip)
|
||||
{
|
||||
WINDOW ti = NULL_WIN;
|
||||
if (owned != NULL_WIN)
|
||||
ti = (WINDOW)new TwxTaskBarIcon((wxWindow*)owned, icon, tooltip);
|
||||
return ti;
|
||||
}
|
||||
|
||||
void xvt_trayicon_destroy(WINDOW tray)
|
||||
{
|
||||
wxTaskBarIcon* pTray = wxDynamicCast((wxObject*)tray, wxTaskBarIcon);
|
||||
if (pTray != NULL)
|
||||
delete pTray;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user