From fe281cbced6e2d70c2e303001242806a8c9fd6c9 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 24 Oct 2008 15:49:08 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : xvaga.dl Ricompilazione Demo : [ ] Commento : Corrette funzioni per supporto Copia/Incolla git-svn-id: svn://10.65.10.50/trunk@17474 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- xvaga/oswin32.h | 1 - xvaga/xvaga.cpp | 97 +++++++++++++++++++++++----------------------- xvaga/xvt.h | 16 ++++---- xvaga/xvtextra.cpp | 3 +- 4 files changed, 58 insertions(+), 59 deletions(-) diff --git a/xvaga/oswin32.h b/xvaga/oswin32.h index 8aac47ad8..7674ec2d2 100755 --- a/xvaga/oswin32.h +++ b/xvaga/oswin32.h @@ -24,7 +24,6 @@ void OsWin32_UpdateWindow(unsigned int handle); void OsWin32_NumberFormat(char* str, int size); int OsWin32_Help(WXHWND handle, const char* hlp, unsigned int cmd, const char* topic); -bool OsWin32_TestNetworkVersion(); bool OsWin32_HL_Crypt(unsigned short* data); bool OsWin32_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password); diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 268e1ffeb..b2884996e 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -34,7 +34,7 @@ #include #endif -#define XVT_ASSERT(test) _AssertBox((test), __FUNCTION__, __FILE__ , __LINE__) +#define XVT_ASSERT(test) _AssertBox((test), __FUNCTION__, __FILE__, __LINE__) #define CAST_WIN(win,w) wxWindow& w = *wxStaticCast((wxObject*)win, wxWindow); #define CAST_TWIN(win,w) TwxWindow& w = *wxStaticCast((wxObject*)win, TwxWindow); #define CAST_TDC(win,dc) TDC& dc = GetTDCMapper().GetTDC(win); @@ -413,8 +413,10 @@ XVTDLL void xvt_app_pre_create(void) ::wxInitAllImageHandlers(); +#ifdef WIN32 if (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32) wxSystemOptions::SetOption(wxT("msw.remap"), 2); +#endif #ifdef SPEECH_API xvt_dm_enable_speech(0xFF); @@ -1438,7 +1440,7 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const #endif } -void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE img, RCT* dest, RCT* source) +void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE img, const RCT* dest, const RCT* source) { CAST_TIMAGE(img, image); if (image != NULL) @@ -1649,28 +1651,28 @@ int xvt_dwin_get_text_width(WINDOW win, const char *s, int len) return width; } -void xvt_dwin_invalidate_rect(WINDOW win, RCT* rctp) +void xvt_dwin_invalidate_rect(WINDOW win, const RCT* rctp) { if (win != NULL_WIN) { CAST_WIN(win, w); - if (rctp) + if (rctp != NULL) { const wxRect rct = NormalizeRCT(rctp); - w.Refresh(FALSE, &rct); + w.Refresh(false, &rct); } else - w.Refresh(FALSE); + w.Refresh(false); } } -BOOLEAN xvt_dwin_is_update_needed(WINDOW win, RCT* rctp) +BOOLEAN xvt_dwin_is_update_needed(WINDOW win, const RCT* rctp) { if (win != NULL_WIN && rctp != NULL) { if (win == PRINTER_WIN || win == SCREEN_WIN) return TRUE; - CAST_WIN(win, w); + CAST_WIN(win, w); // child windows and TASK_WIN const wxRect rect1 = NormalizeRCT(rctp); const wxRect rect2 = w.GetUpdateRegion().GetBox(); return RectIntersect(rect1, rect2); @@ -1688,7 +1690,7 @@ void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv) const wxRect rct = NormalizeRCT(rctp); if (!rct.IsEmpty()) // w.ScrollWindow(dh, dv, &rct); // Metodo ortodosso ma impreciso di un pixel - xvt_dwin_invalidate_rect(win, rctp); // Pezza "TEMPORANEA" per evitare artefatti + w.Refresh(false, &rct); // Pezza "TEMPORANEA" per evitare artefatti } else w.ScrollWindow(dh, dv); @@ -2637,7 +2639,7 @@ BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos, wxMenu menu; for (MENU_ITEM* mi = menu_p; mi != NULL && mi->tag != 0; mi++) { - if (mi->separator) + if (mi->separator || mi->text == NULL) menu.AppendSeparator(); else { @@ -2646,7 +2648,8 @@ BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos, item = menu.AppendCheckItem(mi->tag, mi->text); else item = menu.Append(mi->tag, mi->text); - item->Enable(mi->enabled); // Fattibile solo dopo l'append + // Operazioni fattibili solo dopo la menu.Append(), non prima! + item->Enable(mi->enabled); if (mi->checkable) item->Check(mi->checked); } @@ -2685,8 +2688,7 @@ void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc) { if (win == TASK_WIN) { - TTaskWin& w = *(TTaskWin*)win; - wxMenuBar* pMenuBar = w.GetMenuBar(); + wxMenuBar* pMenuBar = _task_win->GetMenuBar(); if (pMenuBar != NULL) { for (int m = pMenuBar->GetMenuCount()-1; m >= 0; m--) @@ -2713,7 +2715,7 @@ static wxMenuItem* GetXvtMenuItem(WINDOW win, MENU_TAG tag) { wxMenuBar* bar = pFrame->GetMenuBar(); if (bar != NULL) - item = bar->FindItem(tag); + item = bar->FindItem(tag); } return item; } @@ -2743,8 +2745,8 @@ void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree) { if (win == TASK_WIN) { - TTaskWin& w = *(TTaskWin*)win; //occhio - w.SetMenuTree(tree); + TTaskWin* w = wxStaticCast((wxObject*)win, TTaskWin); //occhio + w->SetMenuTree(tree); } else { @@ -2753,9 +2755,9 @@ void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree) } } -void xvt_menu_update(WINDOW win) +void xvt_menu_update(WINDOW /*win*/) { - wxMenuBar* bar = ((TTaskWin*)_task_win)->GetMenuBar(); + wxMenuBar* bar = _task_win->GetMenuBar(); if (bar) bar->Refresh(); } @@ -2776,43 +2778,43 @@ void xvt_palet_set_tolerance(XVT_PALETTE p, int t) { SORRY_BOX(); } /////////////////////////////////////////////////////////// // Rectangles /////////////////////////////////////////////////////////// -int xvt_rect_get_height(RCT *rctp) +int xvt_rect_get_height(const RCT *rctp) { return rctp ? abs(rctp->bottom - rctp->top) : 0; // 3.1 return rctp ? rctp->bottom - rctp->top : 0; } -int xvt_rect_get_width(RCT *rctp) +int xvt_rect_get_width(const RCT *rctp) { return rctp ? abs(rctp->right - rctp->left) : 0; // 3.1 return rctp ? rctp->right - rctp->left : 0; } -BOOLEAN xvt_rect_has_point(RCT *rctp, PNT pnt) +BOOLEAN xvt_rect_has_point(const RCT *rctp, PNT pnt) { const wxRect rct = NormalizeRCT(rctp); return rct.Contains(pnt.h, pnt.v); } -BOOLEAN xvt_rect_intersect(RCT *drctp, RCT *rctp1, RCT *rctp2) +BOOLEAN xvt_rect_intersect(RCT *drctp, const RCT *rctp1, const RCT *rctp2) { const wxRect rect1 = NormalizeRCT(rctp1); const wxRect rect2 = NormalizeRCT(rctp2); - BOOLEAN yes = RectIntersect(rect1, rect2); - if (yes && drctp) + const BOOLEAN yes = RectIntersect(rect1, rect2); + if (drctp) { - drctp->left = max(rect1.x, rect2.x); - drctp->top = max(rect1.y, rect2.y); - drctp->right = min(rect1.GetRight(), rect2.GetRight())+1; - drctp->bottom = min(rect1.GetBottom(), rect2.GetBottom())+1; - } - else - { - if (drctp) - { - drctp->left = drctp->right = rect1.x; - drctp->top = drctp->bottom = rect1.y; - } + if (yes) + { + drctp->left = max(rect1.x, rect2.x); + drctp->top = max(rect1.y, rect2.y); + drctp->right = min(rect1.GetRight(), rect2.GetRight())+1; + drctp->bottom = min(rect1.GetBottom(), rect2.GetBottom())+1; + } + else + { + drctp->left = drctp->right = rect1.x; + drctp->top = drctp->bottom = rect1.y; + } } return yes; } @@ -3234,13 +3236,15 @@ void xvt_scr_beep(void) WINDOW xvt_scr_get_focus_topwin(void) { - WINDOW win = (WINDOW)_task_win->FindFocus(); - return win; + wxWindow* w = _task_win->FindFocus(); + while (w != NULL && w->IsKindOf(CLASSINFO(wxControl))) + w = w->GetParent(); + return (WINDOW)w; } WINDOW xvt_scr_get_focus_vobj(void) { - return xvt_scr_get_focus_topwin(); + return (WINDOW)_task_win->FindFocus(); } SLIST xvt_scr_list_wins() @@ -3249,7 +3253,7 @@ SLIST xvt_scr_list_wins() _nice_windows.BeginFind(); for (wxHashTable::Node* node = _nice_windows.Next(); node; node = _nice_windows.Next()) { - wxWindow* pWin = (wxWindow*)node->GetData(); + wxWindow* pWin = wxDynamicCast(node->GetData(), wxWindow); if (pWin != NULL) { const char* title = pWin->GetLabel(); @@ -3311,8 +3315,7 @@ BOOLEAN xvt_slist_add_at_elt(SLIST list, SLIST_ELT e, const char *sx, long data) int xvt_slist_count(SLIST list) { - XVT_ASSERT(list != NULL); - return list ? list->count : 0; + return list != NULL ? list->count : 0; } SLIST xvt_slist_create() @@ -3325,8 +3328,7 @@ SLIST xvt_slist_create() void xvt_slist_destroy(SLIST list) { - XVT_ASSERT(list != NULL); - if (list) + if (list != NULL) { SLIST_ELT obj = list->head; while (obj != NULL) @@ -3342,8 +3344,7 @@ void xvt_slist_destroy(SLIST list) char* xvt_slist_get(SLIST list, SLIST_ELT e, long* datap) { - XVT_ASSERT(list != NULL); - if (e != NULL) + if (list != NULL && e != NULL) { if (datap != NULL) *datap = e->data; @@ -3359,14 +3360,12 @@ long* xvt_slist_get_data(SLIST_ELT elt) SLIST_ELT xvt_slist_get_first(SLIST list) { - XVT_ASSERT(list != NULL); return list != NULL ? list->head : NULL; } SLIST_ELT xvt_slist_get_next(SLIST list, SLIST_ELT item) { - XVT_ASSERT(list != NULL); - return (SLIST_ELT)(item ? item->next : NULL); + return (SLIST_ELT)(list != NULL && item != NULL ? item->next : NULL); } /////////////////////////////////////////////////////////// diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 81ae387b6..da77bd54d 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -100,7 +100,7 @@ XVTDLL void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid); XVTDLL void xvt_dwin_draw_gradient_circular(WINDOW win, const RCT* r, COLOR col1, COLOR col2, const PNT* center); // Added by AGA XVTDLL void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR col2, int angle); // Added by AGA XVTDLL void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, RCT* dest); // Added by AGA -XVTDLL void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source); +XVTDLL void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, const RCT* dest, const RCT* source); XVTDLL void xvt_dwin_draw_oval(WINDOW Win, const RCT* r); XVTDLL void xvt_dwin_draw_pie(WINDOW win, const RCT *rctp, int start_x, int start_y, int stop_x, int stop_y); XVTDLL void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts); @@ -117,8 +117,8 @@ XVTDLL XVT_FNTID xvt_dwin_get_font(WINDOW win); XVTDLL void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp); XVTDLL long xvt_dwin_get_font_size_mapped(WINDOW win); XVTDLL int xvt_dwin_get_text_width(WINDOW win, const char *s, int len); -XVTDLL void xvt_dwin_invalidate_rect(WINDOW win, RCT *rctp); -XVTDLL BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, RCT* rctp); +XVTDLL void xvt_dwin_invalidate_rect(WINDOW win, const RCT *rctp); +XVTDLL BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, const RCT* rctp); XVTDLL void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv); XVTDLL void xvt_dwin_set_back_color(WINDOW win, COLOR color); XVTDLL void xvt_dwin_set_cbrush(WINDOW win, CBRUSH* cbrush); @@ -279,10 +279,10 @@ XVTDLL BOOLEAN xvt_print_restart_thread(); XVTDLL BOOLEAN xvt_print_is_pdf(const PRINT_RCD* precp); XVTDLL BOOLEAN xvt_print_pdf_version(char* version, int size); -XVTDLL int xvt_rect_get_height(RCT *rctp); -XVTDLL int xvt_rect_get_width(RCT *rctp); -XVTDLL BOOLEAN xvt_rect_has_point(RCT *rctp, PNT pnt); -XVTDLL BOOLEAN xvt_rect_intersect(RCT *drctp, RCT *rctp1, RCT *rctp2); +XVTDLL int xvt_rect_get_height(const RCT *rctp); +XVTDLL int xvt_rect_get_width(const RCT *rctp); +XVTDLL BOOLEAN xvt_rect_has_point(const RCT *rctp, PNT pnt); +XVTDLL BOOLEAN xvt_rect_intersect(RCT *drctp, const RCT *rctp1, const RCT *rctp2); XVTDLL BOOLEAN xvt_rect_is_empty(const RCT *rctp); XVTDLL void xvt_rect_offset(RCT *rctp, short dh, short dv); XVTDLL void xvt_rect_set(RCT *rctp, short left, short top, short right, short bottom); @@ -380,7 +380,7 @@ XVTDLL int xvt_sys_get_os_version(); XVTDLL int xvt_sys_get_version(char* os_version, char* ptk_version, int maxsize); 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_search_env(const char* filename, const char* varname, char* pathname); XVTDLL void xvt_sys_searchenv(const char * filename, const char * varname, char * pathname); // DEPRECATED! XVTDLL BOOLEAN xvt_sys_set_env(const char* varname, const char* value); diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index e50865655..2f56599b7 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -292,7 +292,8 @@ unsigned long TwxPrintOutCache::Signature(const TPRINT_RCD* prcd) const if (prcd != NULL) { const unsigned char* data = (const unsigned char*)prcd; - for (size_t c = 0; c < prcd->GetSize(); c++) + const size_t sz = prcd->GetSize(); + for (size_t c = 0; c < sz; c++) { h = (h << 2) + data[c]; const unsigned long i = h & 0xC0000000;