diff --git a/xvaga/email.cpp b/xvaga/email.cpp index 638f2e708..e3afbf558 100755 --- a/xvaga/email.cpp +++ b/xvaga/email.cpp @@ -4,7 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 2001-08-21 -// RCS-ID: $Id: email.cpp,v 1.3 2009-02-08 23:36:18 alex Exp $ +// RCS-ID: $Id: email.cpp,v 1.4 2009-02-23 11:44:41 guy Exp $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ // Send a message. // Specify profile, if empty use MAPI default profile #ifdef __WXMSW__ -bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, const wxString& WXUNUSED(sendMail)) +bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, bool bUI, const wxString& WXUNUSED(sendMail)) { wxASSERT (message.m_to.GetCount() > 0) ; @@ -52,12 +52,7 @@ bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, const wx if (!session.Logon(profile)) return FALSE; - bool Has_Valid_Address = false; - - for (unsigned int i = 0; !Has_Valid_Address && i < message.m_to.GetCount(); i++) - Has_Valid_Address = !message.m_to[i].empty(); - - return session.Send(message, Has_Valid_Address); + return session.Send(message, bUI); } #elif defined(__UNIX__) bool diff --git a/xvaga/email.h b/xvaga/email.h index d41f62f75..7817e320a 100755 --- a/xvaga/email.h +++ b/xvaga/email.h @@ -4,7 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 2001-08-21 -// RCS-ID: $Id: email.h,v 1.2 2008-03-11 15:43:15 alex Exp $ +// RCS-ID: $Id: email.h,v 1.3 2009-02-23 11:44:41 guy Exp $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -30,7 +30,7 @@ public: // Send a message. // Specify profile, or leave it to wxWidgets to find the current user name static bool Send(wxMailMessage& message, const wxString& profileName = wxEmptyString, - const wxString& sendMail = wxT("/usr/sbin/sendmail -t")); + bool bShowUI = false, const wxString& sendMail = wxT("/usr/sbin/sendmail -t")); protected: }; diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index d5709f337..b1a880efa 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -867,9 +867,8 @@ static bool IsInternetAddress(const char* filename) return false; } -unsigned int OsWin32_LoadIcon(const char* filename) +wxIcon* OsWin32_LoadIcon(const char* filename) { - unsigned int icon = 0; int icon_number = 0; wxString ext; @@ -914,7 +913,10 @@ unsigned int OsWin32_LoadIcon(const char* filename) const int ext_pos = key.Find(".exe"); 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) @@ -924,8 +926,14 @@ unsigned int OsWin32_LoadIcon(const char* filename) 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); - return icon; + return ico; } // action = [ open, edit, print ]; diff --git a/xvaga/oswin32.h b/xvaga/oswin32.h index b0dd19afa..c2d4eccb3 100755 --- a/xvaga/oswin32.h +++ b/xvaga/oswin32.h @@ -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); -unsigned int 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); diff --git a/xvaga/smapi.cpp b/xvaga/smapi.cpp index 3902a66eb..0e5d869af 100755 --- a/xvaga/smapi.cpp +++ b/xvaga/smapi.cpp @@ -4,7 +4,7 @@ // Author: PJ Naughter // Modified by: Julian Smart // Created: 2001-08-21 -// RCS-ID: $Id: smapi.cpp,v 1.2 2008-03-11 15:43:15 alex Exp $ +// RCS-ID: $Id: smapi.cpp,v 1.3 2009-02-23 11:44:41 guy Exp $ // Copyright: (c) PJ Naughter // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -281,7 +281,7 @@ bool wxMapiSession::Resolve(const wxString& sName, void* lppRecip1) return (nError == SUCCESS_SUCCESS); } -bool wxMapiSession::Send(wxMailMessage& message, bool hide_ui) +bool wxMapiSession::Send(wxMailMessage& message, bool show_ui) { wxASSERT(MapiInstalled()); //MAPI must be installed wxASSERT(m_data->m_lpfnMAPISendMail); //Function pointer must be valid @@ -453,7 +453,7 @@ bool wxMapiSession::Send(wxMailMessage& message, bool hide_ui) } //Do the actual send using MAPISendMail - ULONG nError = m_data->m_lpfnMAPISendMail(m_data->m_hSession, 0, &mapiMessage, hide_ui ? 0 : MAPI_DIALOG, 0); + ULONG nError = m_data->m_lpfnMAPISendMail(m_data->m_hSession, 0, &mapiMessage, show_ui ? MAPI_DIALOG : 0, 0); if (nError == SUCCESS_SUCCESS) { bSuccess = TRUE; diff --git a/xvaga/smapi.h b/xvaga/smapi.h index 6dbd8b977..a5388c350 100755 --- a/xvaga/smapi.h +++ b/xvaga/smapi.h @@ -4,7 +4,7 @@ // Author: PJ Naughter // Modified by: Julian Smart // Created: 2001-08-21 -// RCS-ID: $Id: smapi.h,v 1.2 2008-03-11 15:43:15 alex Exp $ +// RCS-ID: $Id: smapi.h,v 1.3 2009-02-23 11:44:41 guy Exp $ // Copyright: (c) PJ Naughter // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -30,7 +30,7 @@ public: bool Logoff(); //Send a message - bool Send(wxMailMessage& message, bool hide_ui); + bool Send(wxMailMessage& message, bool show_ui); //General MAPI support bool MapiInstalled() const; diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 4bdc4d0a5..c691ae88f 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -1137,9 +1137,12 @@ IMPLEMENT_DYNAMIC_CLASS(TXVT_IMAGE, wxImage); #define CAST_TIMAGE(xvtimg, img) TXVT_IMAGE* img = wxDynamicCast(xvtimg, TXVT_IMAGE); #define CAST_IMAGE(xvtimg, img) const wxImage* img = wxDynamicCast(xvtimg, wxImage); +// Chissa' perche' non esiste la GetRGB COLOR TXVT_IMAGE::GetPixel(int x, int y) const { - // Chissa' perche' non esiste la GetRGB + if (IsTransparent(x, y)) + return XVT_MAKE_COLOR(GetMaskRed(), GetMaskGreen(), GetMaskBlue()); + const long pos = XYToIndex(x, y) * 3; unsigned char* data = GetData() + pos; return XVT_MAKE_COLOR(data[0], data[1], data[2]); @@ -2416,6 +2419,8 @@ BOOLEAN xvt_fsys_set_dir(const DIRECTORY *dirp) // Images /////////////////////////////////////////////////////////// +inline bool XVT_SAME_COLOR(COLOR col1, COLOR col2) { return (col1 & 0x00FFFFFF) == (col2 & 0x00FFFFFF); } + XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* src) { wxRect r; @@ -2573,13 +2578,13 @@ void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color) wxImage& bmp = i->Image(); // Set dirty! - unsigned char ri, gi, bi; - bmp.GetOrFindMaskColour(&ri,&gi, &bi); - const int idx = xvt_image_find_clut_index(image, XVT_MAKE_COLOR(ri, gi, bi)); + const COLOR old_trans = XVT_MAKE_COLOR(bmp.GetMaskRed(), bmp.GetMaskGreen(), bmp.GetMaskBlue()); + const int idx = xvt_image_find_clut_index(image, old_trans); if (idx == index) bmp.SetMaskColour(c.Red(), c.Green(), c.Blue()); const wxPalette& pal = bmp.GetPalette(); + unsigned char ri, gi, bi; pal.GetRGB(index, &ri, &gi, &bi); const COLOR old_color = XVT_MAKE_COLOR(ri, gi, bi); @@ -2588,12 +2593,54 @@ void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color) for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { const COLOR rgb = i->GetPixel(x, y); - if (rgb == old_color) + if (XVT_SAME_COLOR(rgb, old_color)) i->SetPixel(x, y, color); } } } +void xvt_image_replace_color(XVT_IMAGE image, COLOR old_color, COLOR new_color) +{ + CAST_TIMAGE(image, i); + if (i != NULL && i->Ok()) + { + if (i->HasPalette()) + { + int index = -1; + while (true) + { + const int idx = xvt_image_find_clut_index(image, old_color); + if (idx > index) + { + xvt_image_set_clut(image, idx, new_color); + index = idx; + } + else + break; + } + } + else + { + wxImage& bmp = i->Image(); // Set dirty! + + const COLOR old_trans = XVT_MAKE_COLOR(bmp.GetMaskRed(), bmp.GetMaskGreen(), bmp.GetMaskBlue()); + + const int w = bmp.GetWidth(); + const int h = bmp.GetHeight(); + for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) + { + const COLOR rgb = i->GetPixel(x, y); + if (XVT_SAME_COLOR(rgb, old_color)) + i->SetPixel(x, y, new_color); + } + // Imposto la nuova trasparenza se cambiata + if (XVT_SAME_COLOR(old_trans, old_color)) + bmp.SetMaskColour(XVT_COLOR_GET_RED(new_color), XVT_COLOR_GET_GREEN(new_color), XVT_COLOR_GET_BLUE(new_color)); + } + } +} + + void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors) { // SORRY_BOX(); @@ -2832,7 +2879,7 @@ void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree) void xvt_menu_update(WINDOW /*win*/) { - wxMenuBar* bar = _task_win->GetMenuBar(); + wxMenuBar* bar = _task_win != NULL ? _task_win->GetMenuBar() : NULL; if (bar) bar->Refresh(); } @@ -2981,10 +3028,18 @@ XVT_FNTID xvt_res_get_font(int rid) XVT_IMAGE xvt_res_get_icon(int rid) { - const wxString strFileName = _GetResourceName("Icon", rid); - const bool ok = !strFileName.IsEmpty(); - XVT_ASSERT(ok); - return ok ? xvt_image_read(strFileName) : NULL; + const wxIcon& icon = _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()); + { + wxMemoryDC dc(bmp); + dc.DrawIcon(icon, 0, 0); + } + XVT_IMAGE_FORMAT xif = bmp.GetDepth()>8 ? XVT_IMAGE_RGB : XVT_IMAGE_CL8; + XVT_IMAGE img = xvt_image_create(xif, w, h, 0); + ((TXVT_IMAGE*)img)->Image() = bmp.ConvertToImage(); + return img; } XVT_IMAGE xvt_res_get_image(int rid) @@ -3817,12 +3872,7 @@ unsigned int xvt_sys_load_icon(const char* file) else { #ifdef WIN32 - WXHICON hicon = (WXHICON)OsWin32_LoadIcon(file); - if (hicon) - { - icon = new wxIcon; - icon->SetHICON(hicon); - } + icon = OsWin32_LoadIcon(file); #else icon = new wxIcon; #endif @@ -3916,14 +3966,14 @@ void xvt_sys_sleep(unsigned long msec) } /////////////////////////////////////////////////////////// -// XVT system calls (added by Alex) +// XVT system calls /////////////////////////////////////////////////////////// XVTDLL BOOLEAN xvt_sys_get_env(const char* varname, char* value, int max_size) { const wxString strName(varname); wxString strValue; - const BOOLEAN ok = wxGetEnv(strName, &strValue); + const bool ok = wxGetEnv(strName, &strValue); if (ok) wxStrncpy(value, strValue, max_size); return ok; @@ -4313,8 +4363,11 @@ void xvt_vobj_maximize(WINDOW win) else { CAST_WIN(win, w); + wxWindow* parent = w.GetParent(); + if (parent == NULL) + parent = _task_win; int width, height; - _task_win->GetClientSize(&width, &height); + parent->GetClientSize(&width, &height); w.SetSize(0, 0, width, height); } } diff --git a/xvaga/xvt.h b/xvaga/xvt.h index c7290c954..bb4fe976f 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -207,6 +207,7 @@ XVTDLL short xvt_image_get_ncolors(XVT_IMAGE image); XVTDLL COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y); XVTDLL XVT_IMAGE xvt_image_read(const char *filenamep); XVTDLL XVT_IMAGE xvt_image_read_bmp(const char *filenamep); +XVTDLL void xvt_image_replace_color(XVT_IMAGE image, COLOR old_color, COLOR new_color); XVTDLL void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color); XVTDLL void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors); XVTDLL void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color); diff --git a/xvaga/xvtctl.cpp b/xvaga/xvtctl.cpp index f3a9f8f84..60ad1793f 100755 --- a/xvaga/xvtctl.cpp +++ b/xvaga/xvtctl.cpp @@ -12,12 +12,23 @@ // Utility functions /////////////////////////////////////////////////////////// -static wxBitmap Image2Bitmap(XVT_IMAGE image, BOOLEAN trans) +static wxBitmap Image2Bitmap(XVT_IMAGE image, int maxx, int maxy, BOOLEAN trans) { if (image == NULL) return wxNullBitmap; wxImage& img = *(wxImage*)image; + + int w = img.GetWidth(), h = img.GetHeight(); + if (w > maxx || h > maxy) + { + const double mx = (maxx / 4) * 4, my = (maxy / 4) * 4; + const double rx = mx / w, ry = my / h; + const double r = rx < ry ? rx : ry; + w = int(w * r); h = int(h * r); + img.Rescale(w, h, wxIMAGE_QUALITY_HIGH); + } + if (trans && !img.HasMask()) { const int r = img.GetRed(0,0); @@ -217,7 +228,8 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data) case WC_HSCROLL: /* horizontal scrollbar control */ case WC_VSCROLL: /* vertical scrollbar control */ { - const long style = win_def_p->wtype == WC_HSCROLL ? wxSB_HORIZONTAL : wxSB_VERTICAL; + long style = win_def_p->wtype == WC_HSCROLL ? wxSB_HORIZONTAL : wxSB_VERTICAL; + style |= wxCLIP_SIBLINGS; TwxScrollBar* sb = new TwxScrollBar(pParent, id, rct.GetPosition(), rct.GetSize(), style); win = (WINDOW)sb; } @@ -242,19 +254,15 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data) { wxButton* pb = NULL; if (win_def_p->text && *win_def_p->text) // Bottone normale con label - { pb = new wxButton(pParent, id, win_def_p->text, rct.GetPosition(), rct.GetSize()); - } else - { // Bottone figo con immagini pb = new wxBitmapButton(pParent, id, wxNullBitmap, rct.GetPosition(), rct.GetSize()); - } win = (WINDOW)pb; } break; case WC_CHECKBOX: /* check box */ { - long style = wxCHK_2STATE; + long style = wxCHK_2STATE | wxCLIP_SIBLINGS; if (win_def_p->wtype == CTL_FLAG_RIGHT_JUST) style |= wxALIGN_RIGHT; wxCheckBox* cb = new wxCheckBox(pParent, id, win_def_p->text, @@ -264,7 +272,7 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data) break; case WC_RADIOBUTTON: /* radio button */ { - long style = wxRB_SINGLE | wxCLIP_SIBLINGS; + const long style = wxRB_SINGLE | wxCLIP_SIBLINGS; wxRadioButton* rb = new wxRadioButton(pParent, id, win_def_p->text, rct.GetPosition(), rct.GetSize(), style); win = (WINDOW)rb; @@ -403,7 +411,8 @@ void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down) wxBitmapButton* pb = wxDynamicCast((wxObject*)win, wxBitmapButton); if (pb != NULL) { - wxBitmap bmpUp(Image2Bitmap(up, TRUE)); + int mx, my; pb->GetSize(&mx, &my); + wxBitmap bmpUp(Image2Bitmap(up, mx, my, TRUE)); if (bmpUp.Ok()) { pb->SetBitmapLabel(bmpUp); @@ -413,7 +422,7 @@ void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down) } if (down != NULL) { - wxBitmap bmpDown(Image2Bitmap(down, TRUE)); + wxBitmap bmpDown(Image2Bitmap(down, mx, my, TRUE)); if (bmpDown.Ok()) pb->SetBitmapSelected(bmpDown); } @@ -647,13 +656,9 @@ void TwxNoteBook::OnPageChanged(wxAuiNotebookEvent& evt) short TwxNoteBook::AddTab(wxWindow* pPage, const wxString text, XVT_IMAGE xvt_img, short idx) { wxBitmap bmp; - if (xvt_img != NULL) - { - wxImage& img = *wxStaticCast(xvt_img, wxImage); - img.Rescale(BOOK_ICO_SIZE, BOOK_ICO_SIZE, wxIMAGE_QUALITY_HIGH); - bmp = Image2Bitmap(xvt_img, true); - } + bmp = Image2Bitmap(xvt_img, BOOK_ICO_SIZE, BOOK_ICO_SIZE, TRUE); + if (idx < 0 || idx >= (int)GetPageCount()) { AddPage(pPage, text, false, bmp); @@ -1701,7 +1706,7 @@ void TwxPopUp::OnKeyDown(wxKeyEvent& evt) } TwxPopUp::TwxPopUp(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size) - : wxVListBox(parent, id, pos, size, wxBORDER|wxPOPUP_WINDOW|wxCLIP_SIBLINGS), + : wxVListBox(parent, id, pos, size, wxBORDER|wxCLIP_SIBLINGS), m_nHovering(wxNOT_FOUND) { m_clrFore = wxSystemSettings::GetColour(wxSYS_COLOUR_HOTLIGHT); @@ -1788,13 +1793,15 @@ MENU_TAG xvt_list_popup(WINDOW parent_win, const RCT* ownrct, const MENU_ITEM* m } if (sel >= 0) lb->SetSelection(sel); - lb->Show(); + lb->Show(); lb->SetFocus(); while (lb->IsShown()) { wxApp* a = wxTheApp; // Memorizzo il risultato di wxGetInstance while (a->Pending()) a->Dispatch(); + lb->Raise(); + wxMilliSleep(50); } sel = lb->GetSelection(); delete lb; diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index c3a800a63..592245742 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -831,7 +831,6 @@ BOOLEAN xvt_print_restart_thread() return TRUE; } - BOOLEAN xvt_print_open_page(PRINT_RCD* precp) { BOOLEAN ok = m_PrintoutCache.Printing(); diff --git a/xvaga/xvtmail.cpp b/xvaga/xvtmail.cpp index 32e457d99..ee1c84c84 100755 --- a/xvaga/xvtmail.cpp +++ b/xvaga/xvtmail.cpp @@ -1,38 +1,51 @@ #include "wxinc.h" #include "xvt.h" -#include + #include "msg.h" #include "email.h" +#include BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, const char* subject, const char* msg, const char* attach, BOOLEAN ui) { - xvt_fsys_save_dir(); + wxStringTokenizer tokTo(to, _T(";")); - wxStringTokenizer tokAttach(attach, _T(";")); - - wxMailMessage Msg(subject, tokTo.GetNextToken(), msg, wxEmptyString, tokAttach.GetNextToken()); + wxMailMessage Msg(subject, tokTo.GetNextToken(), msg); while (tokTo.HasMoreTokens()) Msg.AddTo(tokTo.GetNextToken()); + if (Msg.m_to[0].IsEmpty()) + { + Msg.m_to[0] = " "; // Il destinatario "" fa piantare MAPI con errore 25 + ui = TRUE; // Forza user interface in assenza di recipient + } - while (tokAttach.HasMoreTokens()) - Msg.AddAttachment(tokAttach.GetNextToken()); + if (attach && *attach) + { + wxStringTokenizer tokAttach(attach, _T(";")); + while (tokAttach.HasMoreTokens()) + Msg.AddAttachment(tokAttach.GetNextToken()); + } - wxStringTokenizer Tok(cc, _T(";")); + if (cc && *cc) + { + wxStringTokenizer Tok(cc, _T(";")); + while (Tok.HasMoreTokens()) + Msg.AddCc(Tok.GetNextToken()); + } - while (Tok.HasMoreTokens()) - Msg.AddCc(Tok.GetNextToken()); - - Tok.SetString(ccn, _T(";")); + if (ccn && *ccn) + { + wxStringTokenizer Tok(ccn, _T(";")); + while (Tok.HasMoreTokens()) + Msg.AddBcc(Tok.GetNextToken()); + } + + xvt_fsys_save_dir(); + wxEmail Mail; + BOOLEAN ok = Mail.Send(Msg, wxEmptyString, ui != 0); + xvt_fsys_restore_dir(); - while (Tok.HasMoreTokens()) - Msg.AddBcc(Tok.GetNextToken()); - - wxEmail Mail; - - BOOLEAN ok = Mail.Send(Msg); - xvt_fsys_restore_dir(); - return ok; + return ok; } \ No newline at end of file