diff --git a/include/os_dep.h b/include/os_dep.h deleted file mode 100755 index b862754c6..000000000 --- a/include/os_dep.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __OS_DEP_H -#define __OS_DEP_H - -#ifndef XVT_INCL -#include -#endif - -#ifndef __STRINGS_H -#include -#endif - -//void os_post_menu_event(WINDOW win, MENU_TAG tag); - -int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchild); -unsigned long os_execute_in_window(const TFilename& path, WINDOW win); - -bool os_destroy_native_icon(unsigned icon); -void os_draw_native_icon(WINDOW win, const RCT& rct, unsigned icon); - -bool os_spawn_by_menu(); - -void os_iconize_window(WINDOW win); -void os_maximize_window(WINDOW win); -void os_restore_window(WINDOW win); - -int os_get_printer_names(TToken_string& printers); -bool os_set_default_printer(const char* name); -bool os_get_default_printer(TString& name); - -bool os_dongle_server_running(); - -#endif diff --git a/include/os_win32.cpp b/include/os_win32.cpp deleted file mode 100755 index 31caeabcc..000000000 --- a/include/os_win32.cpp +++ /dev/null @@ -1,279 +0,0 @@ -#define XVT_INCL_NATIVE -#define WIN32_LEAN_AND_MEAN -#include - -#include - -#include -#include -#include -#include - -/////////////////////////////////////////////////////////// -// Operating system dependent functions -/////////////////////////////////////////////////////////// - -bool os_destroy_native_icon(unsigned icon) -{ - return DestroyIcon((HICON)icon) != 0; -} - -void os_draw_native_icon(WINDOW win, const RCT& rct, unsigned icon) -{ - HDC hdc = (HDC)xvt_vobj_get_attr(win, ATTR_NATIVE_GRAPHIC_CONTEXT); - int x = (rct.right + rct.left - 32) / 2; - int y = (rct.bottom + rct.top - 32) / 2; - DrawIcon(hdc, x, y, (HICON)icon); -} - -int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchild) -{ - int exitcode = -1; - - STARTUPINFO start; - PROCESS_INFORMATION pi; - - memset(&start, 0, sizeof(start)); - start.cb = sizeof(start); - start.dwX = start.dwY = start.dwXSize = start.dwYSize = CW_USEDEFAULT; - start.dwFlags = STARTF_USESHOWWINDOW; - start.wShowWindow = showchild ? SW_SHOW : SW_HIDE; - BOOL started = CreateProcess(NULL,(char*)(const char*)path, NULL, NULL, FALSE, 0, - NULL, NULL, &start, &pi); - if (started) - { - HANDLE hProcess = pi.hProcess; - - if (sync) - { - ATOM aBa0Atom = NULL; - if (iconizetask && showchild && main_app().name() == "ba0100") - { - TString str; - str << "ba0100->" << cmd2name(path); - aBa0Atom = GlobalAddAtom(str); - } - - WaitForInputIdle(hProcess, INFINITE); - - bool was_maximized = FALSE; - if (iconizetask) - { - TTemp_window tw(TASK_WIN); - RCT rct_scr, rct_tsk; - xvt_vobj_get_client_rect(SCREEN_WIN, &rct_scr); - xvt_vobj_get_client_rect(tw.win(), &rct_tsk); - was_maximized = rct_scr.right == rct_tsk.right; - tw.iconize(); - tw.deactivate(); - } - - if (WaitForSingleObject(hProcess, INFINITE) != 0xFFFFFFFF) - { - unsigned long exit_code; - if (GetExitCodeProcess(hProcess, &exit_code)) - exitcode = int(exit_code); - else - exitcode = -2; - } - - if (aBa0Atom) - GlobalDeleteAtom(aBa0Atom); - - if (iconizetask) - { - TTemp_window tw(TASK_WIN); - if (was_maximized) - tw.maximize(); - else - os_restore_window(tw.win()); - tw.activate(); -// do_events(); non si puo fare qui'" - } - } - else - exitcode = 0; - CloseHandle(pi.hThread); - CloseHandle(hProcess); - } - else - { - exitcode = GetLastError(); - error_box("Impossibile eseguire '%s': %d", (const char*)path, exitcode); - } - - return exitcode; -} - -int os_get_printer_names(TToken_string& t) -{ - char* buf = t.get_buffer(4096); // ammazzao' - GetProfileString("devices", NULL, "", buf, t.size()); - for (int i = 0; i < t.size(); i++) - { - if (buf[i] == '\0') - { - if (buf[i+1] != '\0') - buf[i] = t.separator(); - else - break; - } - } - return t.items(); -} - -bool os_set_default_printer(const char* name) -{ - CHECK(name && *name > ' ', "Null printer name"); - TString pdev(name); - if (pdev.find(',') < 0) - { - TString szDevice(256); - GetProfileString ("devices", pdev, "", szDevice.get_buffer(), szDevice.size()); - pdev << ',' << szDevice; - } - bool ok = WriteProfileString("windows", "device", pdev) != 0; - return ok; -} - -bool os_get_default_printer(TString& name) -{ - char* buf = name.get_buffer(256); - bool ok = GetProfileString ("windows", "device", ",,,", buf, name.size()) != 0; - return ok; -} - -bool os_spawn_by_menu() -{ - bool ok = true; -#ifndef DBG - TString16 str = main_app().name(); - ok = str == "ba0100"; - if (!ok) - { - str.insert("ba0100->", 0); - ok = GlobalFindAtom(str) != NULL; - } -#endif - return ok; -} - -void os_iconize_window(WINDOW win) -{ - HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); - ShowWindow(hwnd, SW_MINIMIZE); -} - -void os_maximize_window(WINDOW win) -{ - HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); - HWND twin = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW); - if (hwnd != twin) - { - HWND pare = GetParent(hwnd); - RECT rct; GetClientRect(pare, &rct); - if (pare == twin) - rct.bottom -= 24; - SetWindowPos(hwnd, pare, - rct.left, rct.top, rct.right, rct.bottom, - SWP_NOZORDER); - } - else - ShowWindow(hwnd, SW_SHOWMAXIMIZED); -} - -void os_restore_window(WINDOW win) -{ - HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); - ShowWindow(hwnd, SW_NORMAL); -} - -bool os_dongle_server_running() -{ - ATOM a = GlobalFindAtom("DONGLE_SERVER_ATOM"); - return a != 0; -} - -HIDDEN const char* _file_to_find = NULL; - -struct TFindWindowInfo -{ - HINSTANCE _instance; - TFilename _file; - HWND _hwnd; - - TFindWindowInfo() : _instance(NULL), _hwnd(NULL) { } -}; - -BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - TFindWindowInfo* w = (TFindWindowInfo*)lParam; - - HINSTANCE inst = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE); - if (inst == w->_instance) - { - const LONG style = GetWindowLong(hwnd, GWL_STYLE); - if ((style & WS_CAPTION) != 0) // Ha la caption? - { - w->_hwnd = hwnd; - return FALSE; - } - return TRUE; - } - - TString256 str; - GetWindowText(hwnd, str.get_buffer(), str.size()); - str.upper(); - if (str.find(w->_file) >= 0) - { - w->_hwnd = hwnd; - return FALSE; - } - - return TRUE; -} - -unsigned long os_execute_in_window(const TFilename& path, WINDOW win) -{ - const unsigned long exitcode = WinExec(path, SW_SHOWNORMAL); - if (exitcode < 32) - return 0; - - TFindWindowInfo w; - w._instance = (HINSTANCE) exitcode; - - const int space = path.find(' '); - if (space > 0) - w._file = path.mid(space+1); - else - w._file = path; - w._file = w._file.name(); - w._file.ext(""); - w._file.upper(); - - const clock_t start = clock(); - while (w._hwnd == NULL && (clock() - start) < 10*CLOCKS_PER_SEC) - { - xvt_app_process_pending_events(); - EnumWindows(EnumWindowsProc, LPARAM(&w)); - } - - if (w._hwnd != NULL) // L'ho trovata! - { - RCT rct; xvt_vobj_get_client_rect(win, &rct); - HWND nat = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); - SetParent(w._hwnd, nat); -// LONG style = GetWindowLong(w._hwnd, GWL_STYLE); -// style |= WS_CHILD; -// SetWindowLong(w._hwnd, GWL_STYLE, style); - const int fx = GetSystemMetrics(SM_CXFRAME); - const int fy = GetSystemMetrics(SM_CYFRAME); - int cy = GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYBORDER); - if (GetMenu(w._hwnd) != NULL) - cy += GetSystemMetrics(SM_CYMENU); - SetWindowPos(w._hwnd, nat, -fx, -fy-cy, rct.right+2*fx, rct.bottom+cy+2*fy, SWP_NOZORDER); - } - - return (unsigned long) w._hwnd; -} - diff --git a/include/window.cpp b/include/window.cpp index 26551547a..ebf69d1fd 100755 --- a/include/window.cpp +++ b/include/window.cpp @@ -553,6 +553,11 @@ void TWindow::maximize() const xvt_vobj_maximize(win()); } +void TWindow::minimize() const +{ + xvt_vobj_minimize(win()); +} + void TWindow::set_background_color(COLOR col) { XI_OBJ* itf = xi_get_itf((XinWindow)win()); diff --git a/include/window.h b/include/window.h index 511afcebb..e177fe794 100755 --- a/include/window.h +++ b/include/window.h @@ -185,6 +185,8 @@ public: // @cmember Massimizza la finestra void maximize() const; + // @cmember Minimizza (iconizza) la finestra + void minimize() const; // @cmember Attiva/disattiva la finestra virtual void activate(bool = TRUE); // @cmember Disattiva la finestra (chiama )