diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index 743101f49..e0b58dc7d 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -3,6 +3,7 @@ #include "wx/image.h" #include "wx/paper.h" #include "wx/printdlg.h" +#include "wx/msw/helpchm.h" #include "oswin32.h" #include "aclapi.h" @@ -11,12 +12,10 @@ #include "xvt_help.h" #include "xvtart.h" -#define WIN32_LEAN_AND_MEAN -#define WIN32_EXTRA_LEAN -#define STRICT -#include -#include -#include +#include "xvt_defs.h" +#include "xvt_env.h" +#include "xvt_type.h" +#include "xvtwin.h" bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size) { @@ -450,9 +449,7 @@ void OsWin32_Beep(int severity) } static wxString GetHelpDir() -{ - return "htmlhelp/"; -} +{ return "htmlhelp/"; } static wxString FindHelpFile(const char* topic) { @@ -469,35 +466,84 @@ static wxString FindHelpFile(const char* topic) wxString str; for (int i = 0; i < 2; i++) + { + str = GetHelpDir(); + str += i == 0 ? strTopic.Left(2) : strApp.Left(2); + str += "help.pdf"; + if (::wxFileExists(str)) + return str; + } + + for (int i = 0; i < 2; i++) + { + str = GetHelpDir(); + str += i == 0 ? strTopic.Left(2) : strApp.Left(2); + str += "help.chm"; + if (::wxFileExists(str)) + return str; + } + for (int i = 0; i < 2; i++) { str = GetHelpDir(); str += i == 0 ? strTopic.Left(2) : strApp.Left(2); str += "/"; str += strTopic; str += ".html"; - if (wxFileExists(str)) - break; + if (::wxFileExists(str)) + return str; } - return str; + + return wxEmptyString; } -int OsWin32_Help(WXHWND handle, const char* WXUNUSED(hlp), unsigned int cmd, const char* topic) +int OsWin32_Help(WXHWND handle, const char* hlp, unsigned int cmd, const char* topic) { - wxString str; - switch(cmd) - { - case M_HELP_ONCONTEXT: - str = FindHelpFile(topic); - if (wxFileExists(str)) + wxString str = hlp; + if (str.IsEmpty() || !wxFileExists(str)) + { + switch(cmd) + { + case M_HELP_ONCONTEXT: + str = FindHelpFile(topic); + if (wxFileExists(str)) + break; + default: + str = FindHelpFile(topic); + if (wxFileExists(str)) + { + topic = NULL; + } + else + { + str = GetHelpDir(); + str += "index.html"; + } break; - default: - str = GetHelpDir(); - str += "index.html"; - break; - } + } + } if (!str.IsEmpty() && wxFileExists(str)) { - ::ShellExecute((HWND)handle, "open", str, NULL, NULL, SW_SHOWDEFAULT); + if (str.EndsWith(".pdf")) + { + wxString strCmd = OsWin32_File2App(str); + if (topic && *topic) + strCmd << " /A nameddest=" << topic; + strCmd << " " << str; + ::wxExecute(strCmd); + } else + if (str.EndsWith(".chm")) + { + static wxCHMHelpController* hlp = new wxCHMHelpController; + if (hlp->LoadFile(str)) + { + wxString strSection = topic; + strSection += ".html"; + hlp->DisplaySection(strSection); + } + } else + if (str.EndsWith(".html")) + ::ShellExecute((HWND)handle, "open", str, NULL, NULL, SW_SHOWDEFAULT); + return true; } OsWin32_Beep(1); @@ -803,7 +849,11 @@ wxString OsWin32_File2App(const char* filename) if (*filename == '.') ext = filename; else + { wxSplitPath(filename, NULL, NULL, &ext); + if (!ext.StartsWith(".")) + ext = "." + ext; + } ext.MakeLower(); wxString key; @@ -834,7 +884,7 @@ static bool IsInternetAddress(const char* filename) return true; wxString ext; wxFileName::SplitPath(url, NULL, NULL, NULL, &ext); - const char* const extensions[] = { "com","edu","gov","it","mil","net","org", NULL }; + const char* const extensions[] = { "com","edu","eu","gov","it","mil","net","org", NULL }; for (int e = 0; extensions[e]; e++) if (ext == extensions[e]) return true; @@ -934,28 +984,6 @@ bool OsWin32_GotoUrl(const char* url, const char* action) return ok; } -/* -void OsWin32_SpoolNewLine(unsigned int hdc) -{ - char output[4]; - output[0] = 1; // Lunghezza: byte basso - output[1] = 0; // Lunghezza: byte alto - output[2] = '\n'; // A capo - output[3] = 0; // Shwarzenegger - ::Escape((HDC)hdc, PASSTHROUGH, 0, output, NULL ); -} - -bool OsWin32_IsGenericTextOnly(void* data) -{ - LPDEVMODE pdm = (LPDEVMODE)data; - if (pdm->dmYResolution == 6) // Win 9x only - return true; - if (strstr((const char*)pdm->dmDeviceName, "eneric") != NULL) - return true; - return false; -} -*/ - #ifdef SPEECH_API #include "\Programmi\Microsoft Speech SDK 5.1\Include\sapi.h" diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 9f5e9d258..0ee163098 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -1845,6 +1845,12 @@ BOOLEAN xvt_fsys_set_dir(const DIRECTORY *dirp) inline bool XVT_SAME_COLOR(COLOR col1, COLOR col2) { return (col1 & 0x00FFFFFF) == (col2 & 0x00FFFFFF); } +void xvt_image_blur(XVT_IMAGE img, short radius) +{ + CAST_TIMAGE(img, image); + image->Blur(radius); +} + XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* src) { wxRect r; diff --git a/xvaga/xvt.h b/xvaga/xvt.h index e33173d4d..8709272e1 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -47,7 +47,7 @@ XVTDLL void xvt_app_create(int argc, char **argv, unsigned long flags, EVENT XVTDLL void xvt_app_destroy(void); XVTDLL BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD*, long* ph, long* pw, long* pvr, long* phr); XVTDLL DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS* ct); -XVTDLL void xvt_app_process_pending_events(void); +XVTDLL void xvt_app_process_pending_events(void); XVTDLL char* xvt_cb_alloc_data(long size); XVTDLL BOOLEAN xvt_cb_close(void); @@ -61,6 +61,7 @@ XVTDLL void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindo XVTDLL WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data); XVTDLL void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check); XVTDLL void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR_ACTION action); +XVTDLL void xvt_ctl_set_texture(WINDOW win, XVT_IMAGE img); XVTDLL void xvt_debug_printf(const char* fmt, ...); @@ -205,6 +206,7 @@ XVTDLL void xvt_help_close_helpfile(XVT_HELP_INFO hi); XVTDLL XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags); XVTDLL BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev); +XVTDLL void xvt_image_blur(XVT_IMAGE image, short radius); XVTDLL XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* rct); XVTDLL XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, COLOR color); XVTDLL void xvt_image_destroy(XVT_IMAGE image); diff --git a/xvaga/xvtctl.cpp b/xvaga/xvtctl.cpp index a90d32a1c..e560a843c 100755 --- a/xvaga/xvtctl.cpp +++ b/xvaga/xvtctl.cpp @@ -167,6 +167,8 @@ public: class TwxPopUp : public wxVListBox { + DECLARE_DYNAMIC_CLASS(TwxPopUp); + wxArrayString m_menu; int m_nHovering; wxCoord m_nRowHeight; @@ -174,6 +176,7 @@ class TwxPopUp : public wxVListBox DECLARE_EVENT_TABLE() void NotifySelection(); + TwxPopUp() { wxFAIL; } protected: virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; @@ -1744,6 +1747,8 @@ int xvt_list_count(WINDOW win) // TwxPopUp /////////////////////////////////////////////////////////// +IMPLEMENT_DYNAMIC_CLASS(TwxPopUp, wxVListBox) + BEGIN_EVENT_TABLE(TwxPopUp, wxVListBox) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, TwxPopUp::OnSelected) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, TwxPopUp::OnSelected) @@ -1984,15 +1989,18 @@ MENU_TAG xvt_list_popup(WINDOW parent_win, const RCT* ownrct, const MENU_ITEM* m class TwxToolBar : public TwxToolBarBase { DECLARE_DYNAMIC_CLASS(TwxToolBar) + wxBitmap m_texture; protected: DECLARE_EVENT_TABLE() void OnTool(wxCommandEvent& evt); + void OnEraseBackground(wxEraseEvent& evt); virtual bool SetBackgroundColour(const wxColour& colour); TwxToolBar() : TwxToolBarBase(NULL, wxID_ANY) { wxASSERT(false); } public: void ShowTool(int id, bool on); + void SetBackgroundTexture(XVT_IMAGE img); TwxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style); }; @@ -2001,6 +2009,7 @@ IMPLEMENT_DYNAMIC_CLASS(TwxToolBar, TwxToolBarBase) BEGIN_EVENT_TABLE(TwxToolBar, TwxToolBarBase) EVT_TOOL(wxID_ANY, TwxToolBar::OnTool) + EVT_ERASE_BACKGROUND(TwxToolBar::OnEraseBackground) END_EVENT_TABLE(); void TwxToolBar::OnTool(wxCommandEvent& evt) @@ -2013,6 +2022,26 @@ void TwxToolBar::OnTool(wxCommandEvent& evt) win->DoXvtEvent(e); } +void TwxToolBar::OnEraseBackground(wxEraseEvent& evt) +{ + wxDC& dc = *evt.GetDC(); + if (m_texture.IsOk()) + { + const wxCoord tw = m_texture.GetWidth(); + const wxCoord th = m_texture.GetHeight(); + wxCoord cw, ch; dc.GetSize(&cw, &ch); + for (wxCoord y = 0; y < ch; y += th) + for (wxCoord x = 0; x < cw; x += tw) + dc.DrawBitmap(m_texture, x, y); + } + else + { + wxBrush brush(GetBackgroundColour()); + dc.SetBackground(brush); + dc.Clear(); + } +} + bool TwxToolBar::SetBackgroundColour(const wxColour& colour) { const bool ok = TwxToolBarBase::SetBackgroundColour(colour); @@ -2025,6 +2054,35 @@ bool TwxToolBar::SetBackgroundColour(const wxColour& colour) return ok; } +void TwxToolBar::SetBackgroundTexture(XVT_IMAGE xvt_img) +{ + if (xvt_img != NULL) + { + const wxImage& img = *(wxImage*)xvt_img; + m_texture = wxBitmap(img); + + wxImageHistogram histogram; + if (img.ComputeHistogram(histogram)) + { + unsigned long nModa = 0; + wxColour cModa; + for(wxImageHistogram::iterator it = histogram.begin(); it != histogram.end(); ++it) + { + const wxImageHistogramEntry& e = it->second; + if (e.value > nModa) + { + cModa = it->first; + nModa = e.value; + } + } + if (nModa > 0) + SetBackgroundColour(cModa); + } + } + else + m_texture = wxNullBitmap; +} + TwxToolBar::TwxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : TwxToolBarBase(parent, id, pos, size, style) { } @@ -2203,6 +2261,7 @@ void xvt_toolbar_realize(WINDOW win) UnlockPane(win); } } + // Iucunde repetita juvant: forzo il colore del gripper che viene spesso dimenticato wxAuiDockArt* pArtist = FindArtist(ptb); if (pArtist != NULL) @@ -2235,6 +2294,13 @@ void xvt_dwin_draw_tool(WINDOW win, int x, int y, int rid, int size) } } +void xvt_ctl_set_texture(WINDOW win, XVT_IMAGE xvt_img) +{ + TwxToolBar* w = wxDynamicCast((wxObject*)win, TwxToolBar); + if (w != NULL) + w->SetBackgroundTexture(xvt_img); +} + /////////////////////////////////////////////////////////// // wxPropertyGrid /////////////////////////////////////////////////////////// diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index 5a138af55..095f19da6 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -480,7 +480,7 @@ long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array, long size = 0; *scalable = FALSE; -#ifdef WIN32 +#ifdef __WXMSW__ if (xvt_print_is_valid(precp)) { const TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)precp); @@ -503,7 +503,7 @@ long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_famil long size = 0; family_array[0] = NULL; -#ifdef WIN32 +#ifdef __WXMSW__ if (xvt_print_is_valid(precp)) { TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)precp); @@ -532,7 +532,7 @@ void xvt_print_close(void) // Nothing to do ? } -BOOLEAN xvt_print_close_page(PRINT_RCD* precp) +BOOLEAN xvt_print_close_page(PRINT_RCD* WXUNUSED(precp)) { BOOLEAN ok = m_PrintoutCache.Printing(); if (ok) @@ -540,13 +540,6 @@ BOOLEAN xvt_print_close_page(PRINT_RCD* precp) const TwxPrintOut& po = m_PrintoutCache.Get(NULL); wxDC* dc = po.GetDC(); dc->EndPage(); -/* -#ifdef __WXMSW__ - TPRINT_RCD* prcd = (TPRINT_RCD*)precp; - if (OsWin32_IsGenericTextOnly(prcd->m_data)) - OsWin32_SpoolNewLine((unsigned int)dc->GetHDC()); -#endif -*/ } return ok; } @@ -563,12 +556,12 @@ int xvt_print_set_name(PRINT_RCD* precp, const char* name) if (precp == NULL) return 0; - if (!name || !*name) + if (name == NULL || !*name) return 0; wxString n = name; -#ifdef WIN32 +#ifdef __WXMSW__ wxStrncpy(((char*)precp) + 4, name, 32); #else TPRINT_RCD* rcd = (TPRINT_RCD*)precp; @@ -592,8 +585,16 @@ PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name) if (ispdf) name = NULL; -#ifdef WIN32 +#ifdef __WXMSW__ void* data = OsWin32_GetPrinterInfo(*sizep, name); + if (data == NULL) + { + SLIST plist = xvt_print_list_devices(); + SLIST_ELT pitem = xvt_slist_get_first(plist); + name = xvt_slist_get(plist, pitem, NULL); + data = OsWin32_GetPrinterInfo(*sizep, name); + xvt_slist_destroy(plist); + } if (data != NULL) { pr = new TPRINT_RCD; @@ -903,7 +904,7 @@ static bool is_cups() SLIST xvt_print_list_devices() { SLIST list = xvt_slist_create(); -#ifdef WIN32 +#ifdef __WXMSW__ const DWORD dwFlags = PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS; const int level = xvt_sys_get_os_version() >= XVT_WS_WIN_NT ? 4 : 5; DWORD dwSize = 0, dwPrinters = 0; diff --git a/xvaga/xvtwin.cpp b/xvaga/xvtwin.cpp index 2d51db1d0..c898a95ff 100755 --- a/xvaga/xvtwin.cpp +++ b/xvaga/xvtwin.cpp @@ -901,7 +901,7 @@ BOOLEAN TwxWindow::AddPane(wxWindow* wnd, const char* caption, int nDock, int nF pane.CentrePane().CaptionVisible(true).BottomDockable(); break; case 62: // Top toolbar - pane.ToolbarPane().Top().MinSize(wxSize(-1,sz.y)); + pane.ToolbarPane().Top().MinSize(wxSize(-1,sz.y)).Gripper(false); break; default: // Center pane.CentrePane().Floatable(false);