From cc70a2d1c707efa643fc45918ded89989c558ccc Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 1 Feb 2008 16:38:06 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : xvaga Ricompilazione Demo : [ ] Commento : Aggiunta gestione processi "figli" Corretta gestione alberi con icone grandi git-svn-id: svn://10.65.10.50/trunk@16082 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- xvaga/oswin32.cpp | 76 ++++++++++++++---------- xvaga/oswin32.h | 2 + xvaga/xvaga.cpp | 28 ++++++--- xvaga/xvt.h | 2 + xvaga/xvtextra.cpp | 1 - xvaga/xvtwin.cpp | 140 +++++++++++++++++++++++++++++++++++++-------- xvaga/xvtwin.h | 2 +- 7 files changed, 188 insertions(+), 63 deletions(-) diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index 95cff91e9..b68edc647 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -137,7 +137,7 @@ int FamilySorter(const void* p1,const void* p2) { const char* s1 = *(const char**)p1; const char* s2 = *(const char**)p2; - return strcmp(s1, s2); + return wxStricmp(s1, s2); } int OsWin32_EnumerateFamilies(WXHDC hDC, char** families, int max_count) @@ -168,7 +168,7 @@ int OsWin32_EnumerateSizes(WXHDC hDC, const char* name, long* sizes, short* scal void* OsWin32_GetPrinterInfo(int& size, const char* printer) { - char name[256]; + char name[_MAX_PATH]; size = 0; if (printer == NULL || *printer == '\0') @@ -507,12 +507,12 @@ static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) if (w->_instance != NULL) { - // Cerco di capire se e' la finetra principale dal fatto che - // abbia la caption ed i bottoni di chiusura - const DWORD dwWanted = WS_CAPTION | WS_SYSMENU; HINSTANCE inst = (HINSTANCE)::GetWindowLong(hwnd, GWL_HINSTANCE); if (inst == w->_instance) { + // Cerco di capire se e' la finetra principale dal fatto che + // abbia la caption ed i bottoni di chiusura + const DWORD dwWanted = WS_CAPTION | WS_SYSMENU; const DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); if ((style & dwWanted) == dwWanted) { @@ -599,6 +599,7 @@ static BOOL CALLBACK EnumCampoWindowsProc(HWND hwnd, LPARAM lParam) return TRUE; } + unsigned int OsWin32_FindMenuContainer() { TFindWindowInfo w; @@ -607,6 +608,18 @@ unsigned int OsWin32_FindMenuContainer() return (unsigned int)w._hwnd; } +static BOOL CALLBACK CloseChildrenProc(HWND hwnd, LPARAM lParam) +{ + ::PostMessage(hwnd, WM_CLOSE, 0, 0); + return TRUE; +} + +long OsWin32_CloseChildren(unsigned int parent) +{ + ::EnumChildWindows((HWND)parent, CloseChildrenProc, parent); + return 1; +} + /////////////////////////////////////////////////////////// // Hardlock Support /////////////////////////////////////////////////////////// @@ -723,13 +736,13 @@ bool OsWin32_SL_WriteBlock(unsigned short reg, unsigned short size, const unsign static long GetRegistryString(HKEY key, const char* subkey, wxString& retstr) { HKEY hkey; - long retval = RegOpenKey(key, subkey, &hkey); + long retval = ::RegOpenKey(key, subkey, &hkey); if (retval == ERROR_SUCCESS) { char retdata[_MAX_PATH]; long datasize = sizeof(retdata); - RegQueryValue(hkey, NULL, retdata, &datasize); - RegCloseKey(hkey); + ::RegQueryValue(hkey, NULL, retdata, &datasize); + ::RegCloseKey(hkey); retstr = retdata; } return retval; @@ -751,12 +764,12 @@ wxString OsWin32_File2App(const char* filename) if (app.IsEmpty()) { - char ext[_MAX_EXT]; + wxString ext; if (*filename == '.') - strcpy(ext, filename); + ext = filename; else - _splitpath(filename, NULL, NULL, NULL, ext); - _strlwr(ext); + wxSplitPath(filename, NULL, NULL, &ext); + ext.MakeLower(); wxString key; if (GetRegistryString(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS) @@ -779,18 +792,16 @@ wxString OsWin32_File2App(const char* filename) static bool IsInternetAddress(const char* filename) { - const wxString url(filename); + wxString url(filename); url.MakeLower(); if (url.StartsWith("http:") || url.StartsWith("ftp:")) - return TRUE; + return true; if (url.Find("www.") >= 0) - return TRUE; + return true; - char ext[_MAX_EXT]; - _splitpath(filename, NULL, NULL, NULL, ext); - _strlwr(ext); + wxString ext; wxFileName::SplitPath(url, NULL, NULL, NULL, &ext); const char* const extensions[] = { "com","edu","gov","it","mil","net","org", NULL }; for (int e = 0; extensions[e]; e++) - if (wxStricmp(ext, extensions[e]) == 0) + if (ext == extensions[e]) return true; return false; @@ -801,25 +812,25 @@ unsigned int OsWin32_LoadIcon(const char* filename) unsigned int icon = 0; int icon_number = 0; - char ext[_MAX_EXT]; + wxString ext; if (*filename == '.' && strlen(filename) < _MAX_EXT) - strcpy(ext, filename); + ext = filename; else { if (IsInternetAddress(filename)) - strcpy(ext, ".htm"); - else - _splitpath(filename, NULL, NULL, NULL, ext); + ext = ".htm"; + else + wxFileName::SplitPath(filename, NULL, NULL, NULL, &ext); } - _strlwr(ext); + ext.MakeLower(); wxString key; if (ext != ".exe") { - if (GetRegistryString(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS) + if (::GetRegistryString(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS) { key << "\\DefaultIcon"; - if (GetRegistryString(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) // Windows 95 only + if (::GetRegistryString(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) // Windows 95 only { const int comma = key.find(','); if (comma > 0) @@ -958,17 +969,22 @@ typedef BOOL (PASCAL *pfnProcessIdToSessionId)(DWORD dwProcessId,DWORD* pSession int OsWin32_GetSessionId() { - //modifiche del 5/4/04 per poter gestire le licenze con win2000/2003 server edition DWORD session = 0; - HMODULE kernel = GetModuleHandle("kernel32.dll"); +#if _MSC_VER >= 1300 + //modifiche del 1/2/08 per poter gestire le licenze con win2000/2003/2008 server edition + ::ProcessIdToSessionId(GetCurrentProcessId(), &session); +#else + //modifiche del 5/4/04 per poter gestire le licenze con win2000/2003 server edition + HMODULE kernel = GetModuleHandle("kernel32.dll"); if (kernel != NULL) { pfnProcessIdToSessionId fn = (pfnProcessIdToSessionId)GetProcAddress(kernel, "ProcessIdToSessionId"); if (fn != NULL) fn(GetCurrentProcessId(), &session); } - return (int) session; +#endif + return (int)session; } //definito il valore della variabile intera SM_REMOTESESSION diff --git a/xvaga/oswin32.h b/xvaga/oswin32.h index 69f9ca03b..6163f5d7e 100755 --- a/xvaga/oswin32.h +++ b/xvaga/oswin32.h @@ -17,6 +17,8 @@ void* OsWin32_GetPrinterInfo(int& size, const char* printer); void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent); unsigned int OsWin32_FindMenuContainer(); +long OsWin32_CloseChildren(unsigned int parent); + void OsWin32_UpdateWindow(unsigned int handle); int OsWin32_Help(WXHWND handle, const char* hlp, unsigned int cmd, const char* topic); diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index e9d0e35d8..1e333b8cf 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -144,7 +144,7 @@ wxString GetResourceName(const char* type, int rid) return strName; } -wxIcon* _GetIconResource(int rid) +const wxIcon* _GetIconResource(int rid) { wxIcon* icon = (wxIcon*)_nice_icons.Get(rid); if (icon == NULL) @@ -303,13 +303,14 @@ void xvt_app_create(int argc, char **argv, unsigned long flags, wxPoint pos = wxDefaultPosition; wxSize size = wxDefaultSize; - long style = wxDEFAULT_FRAME_STYLE - wxRESIZE_BORDER; + long style = wxDEFAULT_FRAME_STYLE; #ifdef WIN32 HWND hwndParent = (HWND)OsWin32_FindMenuContainer(); if (hwndParent != NULL) { - RECT rct; ::GetWindowRect(hwndParent, &rct); + style &= ~wxRESIZE_BORDER; + RECT rct; ::GetClientRect(hwndParent, &rct); if (rct.right - rct.left >= 720) xvt_rect_set(&_startup_rect, rct.left, rct.top, rct.right, rct.bottom); } @@ -344,7 +345,8 @@ void xvt_app_create(int argc, char **argv, unsigned long flags, if (hwndParent != NULL) { HWND hwndChild = (HWND)_task_win->GetHandle(); - ::SetWindowPos(hwndChild, HWND_TOPMOST, pos.x, pos.y, size.x, size.y, SWP_NOMOVE|SWP_NOSIZE); + //::SetWindowPos(hwndChild, HWND_TOPMOST, pos.x, pos.y, size.x, size.y, SWP_NOMOVE|SWP_NOSIZE); + ::SetParent(hwndChild, hwndParent); } #endif @@ -1277,7 +1279,7 @@ void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR c void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid) { - wxIcon* ico = _GetIconResource(rid); + const wxIcon* ico = _GetIconResource(rid); if (ico != NULL) { CAST_DC(win, dc); @@ -3407,6 +3409,16 @@ long xvt_sys_execute_in_window(const char* cmdline, WINDOW win) return inst; } +long xvt_sys_close_children(WINDOW win) +{ + long c = 0; +#ifdef WIN32 + CAST_WIN(win, w); + c = OsWin32_CloseChildren((unsigned int)w.GetHandle()); +#endif + return c; +} + BOOLEAN xvt_sys_goto_url(const char* url, const char* action) { #ifdef WIN32 @@ -4270,11 +4282,13 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom, { XVT_ASSERT(parent_win == TASK_WIN); wxFrame& w = *(wxFrame*)_task_win; - wxStatusBar* pStatusBar = w.CreateStatusBar(2, 0); // NOT w.CreateStatusBar(2, wxST_SIZEGRIP) + + const int nStyle = 0; // not wxST_SIZEGRIP + wxStatusBar* pStatusBar = w.CreateStatusBar(2, nStyle); if (pStatusBar != NULL) { const wxSize sz = pStatusBar->GetSize(); - const int widths[2] = { -1, 256 }; + const int widths[2] = { -1, 320 }; pStatusBar->SetStatusWidths(2, widths); } return (WINDOW)pStatusBar; diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 5ca2ad9b2..1aa68bd24 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -355,6 +355,8 @@ XVTDLL BOOLEAN xvt_chr_is_alnum(int c); XVTDLL void xvt_sys_beep(int severity); XVTDLL long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask); XVTDLL long xvt_sys_execute_in_window(const char* cmdline, WINDOW win); +XVTDLL long xvt_sys_close_children(WINDOW win); + XVTDLL BOOLEAN xvt_sys_get_host_name(char* name, int maxlen); XVTDLL BOOLEAN xvt_sys_get_user_name(char* name, int maxlen); XVTDLL BOOLEAN xvt_sys_goto_url(const char* url, const char* action); diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index 27cb7b525..50b8f6739 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -560,7 +560,6 @@ long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_famil return size; } - void xvt_print_close(void) { // Nothing to do ? diff --git a/xvaga/xvtwin.cpp b/xvaga/xvtwin.cpp index 7d05a0bda..7809e770f 100755 --- a/xvaga/xvtwin.cpp +++ b/xvaga/xvtwin.cpp @@ -1093,7 +1093,7 @@ TTaskWin::TTaskWin(wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, id, title, pos, size, style), m_menu(NULL), m_pOldBar(NULL), m_MenuOwner(NULL) { - wxIcon* ico = _GetIconResource(ICON_RSRC); + const wxIcon* ico = _GetIconResource(ICON_RSRC); if (ico) SetIcon(*ico); _nice_windows.Put((WINDOW)this, this); @@ -1179,13 +1179,16 @@ class TwxOutlookBar : public wxVListBox { enum { MAX_ITEMS = 32 }; TwxOutlookItem m_item[MAX_ITEMS]; + bool m_bCaptured; + int m_nHovering; DECLARE_EVENT_TABLE() protected: virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const; virtual wxCoord OnMeasureItem(size_t n) const; - + virtual void OnMouseMove(wxMouseEvent& e); + virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& e); virtual void OnSelected(wxCommandEvent& e); public: @@ -1545,6 +1548,22 @@ int TwxTreeCtrl::img2int(XVT_IMAGE xvt_img) il->Create(img.GetWidth(), img.GetHeight(), true, 3); AssignImageList(il); // DON'T CALL SetImageList! } + else + { + int w, h; il->GetSize(0, w, h); + if (img.GetWidth() > w) // L'immagine nuova e' troppo grande? + { + wxImageList* nil = new wxImageList; + nil->Create(img.GetWidth(), img.GetHeight(), true, 3); + for (int k = 0; k < il->GetImageCount(); k++) + { + wxImage old = il->GetBitmap(k).ConvertToImage(); + old.Rescale(img.GetWidth(), img.GetHeight(), wxIMAGE_QUALITY_HIGH); + nil->Add(old); + } + AssignImageList(il = nil); + } + } i = il->Add(wxBitmap(img)); #if wxCHECK_VERSION(2,8,7) m_img[xvt_img] = i+1; // Memorizzo indice+1 @@ -1810,6 +1829,11 @@ void xvt_treeview_suspend(WINDOW win) BEGIN_EVENT_TABLE(TwxOutlookBar, wxVListBox) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, TwxOutlookBar::OnSelected) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, TwxOutlookBar::OnSelected) + EVT_MOTION(TwxOutlookBar::OnMouseMove) +#if wxCHECK_VERSION(2,8,7) + EVT_MOUSE_CAPTURE_LOST(TwxOutlookBar::OnMouseCaptureLost) +#endif + END_EVENT_TABLE() static wxAuiDockArt* GetArtist(const wxWindow* pWindow) @@ -1821,29 +1845,53 @@ static wxAuiDockArt* GetArtist(const wxWindow* pWindow) return pArtist; } -static int GrayLevel(const wxColour& col) +static const wxColour ModulateColour(const wxColour& col, int percent) { - const unsigned char r = col.Red(); - const unsigned char g = col.Green(); - const unsigned char b = col.Blue(); - int k = (int)(0.299 * r + 0.587 * g + 0.114 * b); - return k; + int k = 0; + if (percent > 0) + k = 255; + else + percent = -percent; + int r = ((k * percent) + (col.Red() * (100-percent))) / 100; + int g = ((k * percent) + (col.Green() * (100-percent))) / 100; + int b = ((k * percent) + (col.Blue() * (100-percent))) / 100; + return wxColour(r, g, b); } +static wxColour DarkerColor(const wxColour& col, int percent = 20) +{ return ModulateColour(col, -percent); } + +static wxColour LighterColor(const wxColour& col, int percent = 20) +{ return ModulateColour(col, +percent); } + void TwxOutlookBar::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const { - wxAuiDockArt* pArtist = GetArtist(this); - wxColour color1, color2; - if (n == GetSelection()) + if (n == m_nHovering) { - color1 = wxColour(251,230,148); // Colori predefiniti di Outlook - color2 = wxColour(238,149, 21); + if (n == GetSelection()) + { + color1 = wxColour(232,127,8); + color2 = wxColour(247,218,124); + } + else + { + color1 = wxColour(255,255,220); + color2 = wxColour(247,192,91); + } } else { - color1 = pArtist->GetColour(wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR); - color2 = pArtist->GetColour(wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR); + if (n == GetSelection()) + { + color1 = wxColour(251,230,148); // Colori predefiniti di Outlook + color2 = wxColour(238,149, 21); + } + else + { + color1 = LighterColor(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); + color2 = DarkerColor(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + } } dc.GradientFillLinear(rect, color1, color2, wxDOWN); } @@ -1855,7 +1903,7 @@ void TwxOutlookBar::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const int nTextOffset = 4; if (oi.m_nIconId > 0) { - wxIcon* pIcon = _GetIconResource(oi.m_nIconId); + const wxIcon* pIcon = _GetIconResource(oi.m_nIconId); if (pIcon != NULL) { const wxSize szIco(pIcon->GetWidth(), pIcon->GetHeight()); @@ -1864,16 +1912,11 @@ void TwxOutlookBar::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const } } - wxAuiDockArt* pArtist = GetArtist(this); - wxFont font = pArtist->GetFont(wxAUI_DOCKART_CAPTION_FONT); + wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); font.SetWeight(wxFONTWEIGHT_BOLD); dc.SetFont(font); - wxColour color; - if (n == GetSelection()) - color = pArtist->GetColour(wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR ); - else - color = pArtist->GetColour(wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR ); + wxColour color = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT); dc.SetTextForeground(color); const wxSize szText = dc.GetTextExtent(oi.m_strText); @@ -1892,6 +1935,55 @@ wxCoord TwxOutlookBar::OnMeasureItem(size_t n) const return nHeight; } +void TwxOutlookBar::OnMouseMove(wxMouseEvent& evt) +{ + int nHover = HitTest(evt.GetPosition()); + if (m_bCaptured && nHover != wxNOT_FOUND) + { + const wxRect rect = GetClientRect(); + if (!rect.Contains(evt.GetPosition())) + nHover = wxNOT_FOUND; + } + + if (nHover == wxNOT_FOUND) + { + if (m_bCaptured) + { + m_bCaptured = false; + ReleaseMouse(); + } + } + else + { + if (!m_bCaptured) + { + m_bCaptured = true; + CaptureMouse(); + } + } + + if (nHover != m_nHovering) + { + const int nWasHovering = m_nHovering; + m_nHovering = nHover; + if (nWasHovering != wxNOT_FOUND) + RefreshLine(nWasHovering); + if (m_nHovering != wxNOT_FOUND) + RefreshLine(m_nHovering); + } +} + +void TwxOutlookBar::OnMouseCaptureLost(wxMouseCaptureLostEvent&) +{ + m_bCaptured = false; + if (m_nHovering != wxNOT_FOUND) + { + const int nWasHovering = m_nHovering; + m_nHovering = wxNOT_FOUND; + RefreshLine(nWasHovering); + } +} + void TwxOutlookBar::OnSelected(wxCommandEvent& evt) { EVENT e; memset(&e, 0, sizeof(EVENT)); @@ -1921,7 +2013,7 @@ int TwxOutlookBar::Add(short nIconId, const wxString strText, int nFlags) } TwxOutlookBar::TwxOutlookBar(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size) - : wxVListBox(parent, id, pos, size) + : wxVListBox(parent, id, pos, size), m_bCaptured(false), m_nHovering(wxNOT_FOUND) { SetItemCount(0); } diff --git a/xvaga/xvtwin.h b/xvaga/xvtwin.h index 9442aff26..462517aff 100755 --- a/xvaga/xvtwin.h +++ b/xvaga/xvtwin.h @@ -216,7 +216,7 @@ public: #define TIMER_ID 1 const wxString& _GetAppTitle(); -wxIcon* _GetIconResource(int rid); +const wxIcon* _GetIconResource(int rid); #define CAST_COLOR(xc, wc) wxColour wc((xc>>16)&0xFF, (xc>>8)&0xFF, xc&0xFF) #define MAKE_XVT_COLOR(wc) MAKE_COLOR(wc.Red(), wc.Green(), wc.Blue())