Exemplo n.º 1
0
void ConsoleLogFrame::OnMoveAround( wxMoveEvent& evt )
{
	if( IsBeingDeleted() || !IsVisible() || IsIconized() ) return;

	// Docking check!  If the window position is within some amount
	// of the main window, enable docking.

	if( wxWindow* main = GetParent() )
	{
		wxPoint topright( main->GetRect().GetTopRight() );
		wxRect snapzone( topright - wxSize( 8,8 ), wxSize( 16,16 ) );

		m_conf.AutoDock = snapzone.Contains( GetPosition() );
		//Console.WriteLn( "DockCheck: %d", g_Conf->ConLogBox.AutoDock );
		if( m_conf.AutoDock )
		{
			SetPosition( topright + wxSize( 1,0 ) );
			m_conf.AutoDock = true;
		}
	}
	if (!IsMaximized())
		m_conf.DisplayPosition = GetPosition();
	evt.Skip();
}
Exemplo n.º 2
0
void CDockManager::OnMinMaxInfo(LPMINMAXINFO pMMI, BOOL /*bMain*/)
{
	if (IsMaximized())
	{
   		CSize sizeMin = GetMinMaximizedSize();
		CRect rWork = GetWorkArea();
		
		if (m_nDockPos == DMP_BELOW)
		{
			pMMI->ptMinTrackSize.y = sizeMin.cy;
			pMMI->ptMaxTrackSize.y = rWork.Height() - sizeMin.cy;
		}
		else
		{
			pMMI->ptMinTrackSize.x = sizeMin.cx;
			pMMI->ptMaxTrackSize.x = rWork.Width() - sizeMin.cx;
		}
	}
	else
	{
   		CSize sizeMin;
		if (m_nDockPos == DMP_BELOW)
		{
			sizeMin.cx = max(m_sizeMainMin.cx, m_sizeDockMin.cx);
			sizeMin.cy = m_sizeDockMin.cy;
		}
		else
		{
			sizeMin.cx = m_sizeDockMin.cx;
			sizeMin.cy = max(m_sizeMainMin.cy, m_sizeDockMin.cy);
		}
		
		pMMI->ptMinTrackSize.y = max(sizeMin.cy, pMMI->ptMinTrackSize.y);
		pMMI->ptMinTrackSize.x = max(sizeMin.cx, pMMI->ptMinTrackSize.x);
	}
}
Exemplo n.º 3
0
void GSFrame::OnResize( wxSizeEvent& evt )
{
	if( IsBeingDeleted() ) return;

	if( !IsFullScreen() && !IsMaximized() && IsVisible() )
	{
		g_Conf->GSWindow.WindowSize	= GetClientSize();
	}

	if( wxStaticText* label = GetLabel_OutputDisabled() )
		label->CentreOnParent();

	if( GSPanel* gsPanel = GetViewport() )
	{
		gsPanel->DoResize();
		gsPanel->SetFocus();
	}

	//wxPoint hudpos = wxPoint(-10,-10) + (GetClientSize() - m_hud->GetSize());
	//m_hud->SetPosition( hudpos ); //+ GetScreenPosition() + GetClientAreaOrigin() );

	// if we skip, the panel is auto-sized to fit our window anyway, which we do not want!
	//evt.Skip();
}
Exemplo n.º 4
0
void BrowserFrameWin::UpdateDWMFrame()
{
    // Nothing to do yet, or we're not showing a DWM frame.
    if(!GetWidget()->client_view() || !browser_frame_->ShouldUseNativeFrame())
    {
        return;
    }

    MARGINS margins = { 0 };
    if(browser_view_->IsBrowserTypeNormal())
    {
        // In fullscreen mode, we don't extend glass into the client area at all,
        // because the GDI-drawn text in the web content composited over it will
        // become semi-transparent over any glass area.
        if(!IsMaximized() && !IsFullscreen())
        {
            margins.cxLeftWidth = kClientEdgeThickness + 1;
            margins.cxRightWidth = kClientEdgeThickness + 1;
            margins.cyBottomHeight = kClientEdgeThickness + 1;
            margins.cyTopHeight = kClientEdgeThickness + 1;
        }
        // In maximized mode, we only have a titlebar strip of glass, no side/bottom
        // borders.
        if(!browser_view_->IsFullscreen())
        {
            gfx::Rect tabstrip_bounds(
                browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip()));
            margins.cyTopHeight = tabstrip_bounds.bottom() + kDWMFrameTopOffset;
        }
    }
    else
    {
        // For popup and app windows we want to use the default margins.
    }
    DwmExtendFrameIntoClientArea(GetNativeView(), &margins);
}
Exemplo n.º 5
0
void SetPos(CefWindowHandle handle, int x, int y, int width, int height) {
  GtkWindow* window = GetWindow(handle);
  GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window));

  // Make sure the window isn't minimized or maximized.
  if (IsMaximized(window))
    gtk_window_unmaximize(window);
  else
    gtk_window_present(window);

  // Retrieve information about the display that contains the window.
  GdkScreen* screen = gdk_screen_get_default();
  gint monitor = gdk_screen_get_monitor_at_window(screen, gdk_window);
  GdkRectangle rect;
  gdk_screen_get_monitor_geometry(screen, monitor, &rect);

  // Make sure the window is inside the display.
  CefRect display_rect(rect.x, rect.y, rect.width, rect.height);
  CefRect window_rect(x, y, width, height);
  ModifyBounds(display_rect, window_rect);

  gdk_window_move_resize(gdk_window, window_rect.x, window_rect.y,
                         window_rect.width, window_rect.height);
}
Exemplo n.º 6
0
void File_Open(LPTSTR pszFile, int nLineFeedType)
{
    MDICREATESTRUCT mcs;
    HWND hwndChild, hwndEdit, hwndPrev;
    HCURSOR hOldCursor;
//  LPEDITVIEW lpew;
    FILEINFO fi;
    int i;

    // FIXME: TEMP
    INITSTRUCT(fi, FALSE);

    SetCapture(g_hwndMain);
    hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));

    EnumChildWindows(g_hwndMDIClient, FindOpenFileEnumProc, (LPARAM)pszFile);

    if (s_bOpen)
    {
        HWND hwnd;
        TCHAR szMsg[MAX_PATH + 30];

        s_bOpen = FALSE;

        hwnd = Main_GetFileInfoByFileName(pszFile, &fi);

        ASSERT(!(fi.dwFileType & FI_TYPE_MASK_EDIT));

        MDI_Activate(g_hwndMDIClient, hwnd);

        // FIXME: Should only be done if modified
        _stprintf(szMsg, String_LoadString(IDS_FORMAT_FILE_ALREADYOPEN), pszFile);
        if (MessageBox(g_hwndMain, szMsg, g_szAppName, MB_YESNO | MB_ICONQUESTION) == IDYES)
        {
            File_ReloadFile(pszFile);
        }

        goto err_return;
    }

    hwndPrev = MDI_MyGetActive(FALSE);

    mcs.szTitle = pszFile;
    mcs.szClass = g_szEditChild; // g_szHexChild
    mcs.hOwner  = g_hInstance;
    mcs.x = mcs.cx = CW_USEDEFAULT;
    mcs.y = mcs.cy = CW_USEDEFAULT;
    mcs.style = MDIS_ALLCHILDSTYLES | WS_CLIPCHILDREN;

    // a messy way of setting the file to open for the edit control
    if (String_Equal(pszFile, _T("Edit"), TRUE))
    {
        s_nNumEdits++;

        fi.dwFileType   |= FI_TYPE_MASK_EDIT;
        _stprintf(fi.szFileName, _T("Edit%d"), s_nNumEdits);
    }
    else
    {
        ASSERT(Path_FileExists(pszFile));

        fi.dwFileType   = FI_TYPE_TEXT;
        _tcscpy(fi.szFileName, pszFile);
    }

    mcs.lParam  = (LPARAM)&fi;

    if ((!IsWindow(hwndPrev) &&
        g_WindowSettings.nMDIWinState == MDISTATE_MAXIMIZED) || 
        (IsWindow(hwndPrev) && IsMaximized(hwndPrev)))
    {
        mcs.style |= WS_MAXIMIZE;
        g_WindowSettings.nMDIWinState = MDISTATE_MAXIMIZED;
    }

    hwndChild = MDI_Create(g_hwndMDIClient, &mcs);

    ASSERT(hwndChild != NULL);

    hwndEdit = GetDlgItem(hwndChild, IDC_EDIT_MDICHILD);

    if ((_tcscmp(pszFile, _T("Edit"))) == 0)
    {
        File_Addify(hwndChild, hwndEdit, fi.szFileName);

        goto normal_return;
    }
    else
    {
        TCHAR szText[MAX_PATH];
        TC_ITEM tci;
        FILEINFO fi;

        tci.mask = TCIF_TEXT | TCIF_PARAM;
        tci.pszText = szText;
        tci.cchTextMax = MAX_PATH;
        if (TabCtrl_GetItem(g_hwndTabWindowBar, 0, &tci))
        {
            ASSERT(IsWindow((HWND)tci.lParam));
                
            Main_GetFileInfo((HWND)tci.lParam, &fi);
            
            if ((fi.dwFileType & FI_TYPE_MASK_FIRST) &&
                !EditView_GetModify(GetDlgItem((HWND)tci.lParam, IDC_EDIT_MDICHILD)))
            {
                Window_Close((HWND)tci.lParam);
            }
        }
    }

    File_Addify(hwndChild, hwndEdit, pszFile);

    FileNotify_AddFile(&s_fns, pszFile, FN_NOTIFY_DEFAULT);
    FileNotify_StartMonitoring(&s_fns);

    MRU_Write(_T("File MRU"), pszFile, g_MRUSettings.nFileMax);
    for (i = IDM_RECENTFILES; DeleteMenu(g_hMenuRecentFiles, i, MF_BYCOMMAND); i++)
        ; /* empty body */
    MRU_SetMenu(g_hMenuRecentFiles, _T("File MRU"), g_MRUSettings.nFileMax, IDM_RECENTFILES);

normal_return:
//  lpew = MDI_GetEditView(NULL);
/// TextBuffer_SetCRLFMode(lpew->lpes, (nLineFeedType == CRLF_STYLE_AUTOMATIC) ? TextBuffer_GetCRLFMode(lpew->lpes) : nLineFeedType);
//  EditChild_SetLineFeed(lpew->hwnd, TextBuffer_GetCRLFMode(lpew->lpes));
err_return:
    SetCursor(hOldCursor);
    ReleaseCapture();
}
Exemplo n.º 7
0
//************************************************************************
// update's the screens objects ( sizes, fonts etc)
//************************************************************************
void CChatScreen::UpdateObjects()
{
	m_bHideTitle = false;
	m_bHideLabels = !CConfig::GetBoolSetting(SHOW_LABELS);
	
	if(IsMaximized())
	{
		if(!m_bHideTitle && !CConfig::GetBoolSetting(MAXIMIZED_TITLE))
			m_bHideTitle = true;

		if(!m_bHideLabels && !CConfig::GetBoolSetting(MAXIMIZED_LABELS))
			m_bHideLabels = true;
	}

	// Fonts
	m_TextLog.SetFont(CConfig::GetFont(FONT_SESSION));
	m_Input.SetFont(CConfig::GetFont(FONT_SESSION));
	m_InfoText.SetFont(CConfig::GetFont(FONT_SESSION));

	m_UserName.SetFont(CConfig::GetFont(FONT_TITLE));
	m_UserStatus.SetFont(CConfig::GetFont(FONT_TITLE));
	m_UserProto.SetFont(CConfig::GetFont(FONT_TITLE));
		
	int w = GetWidth() - 8;
	// Sizes
	m_UserName.SetSize(w*0.4, CConfig::GetFontHeight(FONT_TITLE));
	m_UserStatus.SetSize(w*0.25, CConfig::GetFontHeight(FONT_TITLE));
	m_UserProto.SetSize(w*0.3, CConfig::GetFontHeight(FONT_TITLE));
	
	int iHeight =GetHeight();
	iHeight -= m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2;
	iHeight -= m_bHideLabels?0:5;

	m_Input.SetSize(GetWidth()-5, iHeight);
	m_TextLog.SetSize(GetWidth()-5, iHeight);
	
	m_InfoText.SetSize(160, 28);
	m_InfoText.SetOrigin(0,(iHeight-CConfig::GetFontHeight(FONT_SESSION))/2);

	// Origins
	
	m_UserName.SetOrigin(8+w*0.25, 0);
	m_UserStatus.SetOrigin(8, 0);
	m_UserProto.SetOrigin(GetWidth()-w*0.3, 0);
	
	m_TextLog.SetOrigin(0, m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2);
	m_Input.SetOrigin(0,m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2);
	
	m_InfoText.SetOrigin(0, 10);
	
	m_UserName.Show(!m_bHideTitle);
	m_UserStatus.Show(!m_bHideTitle);
	m_UserProto.Show(!m_bHideTitle);

	m_Scrollbar.SetOrigin(GetWidth()-4,(m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2));
	m_Scrollbar.SetSize(4,iHeight);

	// other options
	m_TextLog.SetLogSize(CConfig::GetIntSetting(SESSION_LOGSIZE));
		
	m_Input.SetBreakKeys(CConfig::GetBoolSetting(SESSION_SENDRETURN)?KEYS_RETURN:KEYS_CTRL_RETURN);
	m_Input.ShowSymbols(CConfig::GetBoolSetting(SESSION_SYMBOLS));

	ShowButtons(!m_bHideLabels);
}
int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line, int show_code)
{
    timer::init();

    QueryPerformanceCounter((LARGE_INTEGER *)&mem.profile);
    timer::start(Timer_Startup);

    mem.is_running = true;

    // Set current path to this executable's path
    {
        HMODULE module = GetModuleHandleA(NULL);
        char path_string[MAX_PATH];
        uint32 path_len = GetModuleFileNameA(module, path_string, MAX_PATH);
        if (path_len != -1) {
            char *last_slash = strrchr(path_string, '\\');
            if (last_slash) { *last_slash = '\0'; }
            SetCurrentDirectoryA(path_string);
        }
    }

    HWND window;
    // Create window
    {
        WNDCLASSA window_class = {};
        window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
        window_class.lpfnWndProc = Win32MainWindowCallback;
        window_class.hInstance = instance;
        const char* ico_path = "papaya.ico";
        window_class.hIcon = (HICON)LoadImage(0, ico_path, IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED);
        window_class.lpszClassName = "PapayaWindowClass";

        if (!RegisterClassA(&window_class)) {
            // TODO: Log: Register window class failed
            return 0;
        }

        window =
            CreateWindowExA(
            0,                                                          // Extended window style
            window_class.lpszClassName,                                  // Class name,
            "Papaya",                                                   // Name,
            WS_POPUP | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE,    // window style
            CW_USEDEFAULT,                                              // X,
            CW_USEDEFAULT,                                              // Y,
            CW_USEDEFAULT,                                              // width,
            CW_USEDEFAULT,                                              // height,
            0,                                                          // window Parent,
            0,                                                          // Menu,
            instance,                                                   // Handle to the instance,
            0);                                                         // lpParam

        if (!window) {
            // TODO: Log: Create window failed
            return 0;
        }

        SystemParametersInfo(SPI_GETWORKAREA, 0, &windows_work_area, 0);

#ifdef PAPAYARELEASE

        SetWindowPos(window, HWND_TOP, 0, 0, 600, 600, NULL);
        ShowWindow(window, SW_MAXIMIZE);
#else
        uint32 screen_width = GetSystemMetrics(SM_CXSCREEN);
        uint32 screen_height = GetSystemMetrics(SM_CYSCREEN);

        mem.window.width = (uint32)((float)screen_width * 0.5);
        mem.window.height = (uint32)((float)screen_height * 0.8);

        uint32 window_x = (screen_width - mem.window.width) / 2;
        uint32 window_y = (screen_height - mem.window.height) / 2;

        SetWindowPos(window, HWND_TOP, window_x, window_y, mem.window.width, mem.window.height, NULL);
#endif // PAPAYARELEASE

        // Get window size
        {
            RECT window_rect = { 0 };
            BOOL foo = GetClientRect(window, &window_rect);
            mem.window.width = window_rect.right - window_rect.left;
            mem.window.height = window_rect.bottom - window_rect.top;
        }
    }

    // Initialize OpenGL
    {
        device_context = GetDC(window);

        // Setup pixel format
        {
            PIXELFORMATDESCRIPTOR pixel_format_desc = { 0 };
            // TODO: Program seems to work perfectly fine without all other params except dwFlags.
            //       Can we skip other params for the sake of brevity?
            pixel_format_desc.nSize = sizeof(PIXELFORMATDESCRIPTOR);
            pixel_format_desc.nVersion = 1;
            pixel_format_desc.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER;
            pixel_format_desc.iPixelType = PFD_TYPE_RGBA;
            pixel_format_desc.cColorBits = 32;
            pixel_format_desc.cDepthBits = 32;
            pixel_format_desc.dwLayerMask = PFD_MAIN_PLANE;
            //

            int32 pixel_format = ChoosePixelFormat(device_context, &pixel_format_desc);
            if (!pixel_format) { exit(1); } // TODO: Log: Choose pixel format failed
            if (!SetPixelFormat(device_context, pixel_format, &pixel_format_desc)) { exit(1); } // TODO: Log: Set pixel format failed
        }

        // Create rendering context
        {
            // TODO: Create "proper" context?
            //       https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)#Proper_Context_Creation

            HGLRC rendering_context = wglCreateContext(device_context);
            wglMakeCurrent(device_context, rendering_context);

            if (!gl_lite_init()) { exit(1); }

            glGetIntegerv(GL_MAJOR_VERSION, &mem.system.gl_version[0]);
            glGetIntegerv(GL_MINOR_VERSION, &mem.system.gl_version[1]);
        }

        // Disable vsync
        //if (wglewIsSupported("WGL_EXT_swap_control")) { wglSwapIntervalEXT(0); }
    }

    // Initialize tablet
    EasyTab_Load(window);

    core::init(&mem);

    // Initialize ImGui
    {
        ImGuiIO& io = ImGui::GetIO();
        io.KeyMap[ImGuiKey_Tab] = VK_TAB;          // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
        io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
        io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
        io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
        io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
        io.KeyMap[ImGuiKey_Home] = VK_HOME;
        io.KeyMap[ImGuiKey_End] = VK_END;
        io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
        io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
        io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
        io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
        io.KeyMap[ImGuiKey_A] = 'A';
        io.KeyMap[ImGuiKey_C] = 'C';
        io.KeyMap[ImGuiKey_V] = 'V';
        io.KeyMap[ImGuiKey_X] = 'X';
        io.KeyMap[ImGuiKey_Y] = 'Y';
        io.KeyMap[ImGuiKey_Z] = 'Z';

        io.RenderDrawListsFn = core::render_imgui;
        io.ImeWindowHandle = window;
    }

    mem.window.menu_horizontal_offset = 32;
    mem.window.title_bar_buttons_width = 109;
    mem.window.title_bar_height = 30;

    timer::stop(Timer_Startup);

    // Handle command line arguments (if present)
    if (strlen(cmd_line)) {
        // Remove double quotes from string if present
        char* ptr_read  = cmd_line;
        char* ptr_write = cmd_line;
        while (*ptr_read) 
        {
            *ptr_write = *ptr_read++;
            if (*ptr_write != '\"') { ptr_write++; }
        }
        *ptr_write = '\0';
        core::open_doc(cmd_line, &mem); 
    }

#ifdef PAPAYA_DEFAULT_IMAGE
    core::open_doc(PAPAYA_DEFAULT_IMAGE, &mem);
#endif // PAPAYA_DEFAULT_IMAGE

    while (mem.is_running) {
        timer::start(Timer_Frame);

        // Windows message handling
        {
            MSG msg;
            while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
            {
                if (msg.message == WM_QUIT) {
                    mem.is_running = false;
                }

                TranslateMessage(&msg);
                DispatchMessageA(&msg);
            }
        }

        // Tablet input // TODO: Put this in papaya.cpp
        {
            mem.tablet.pressure = EasyTab->Pressure;
            mem.tablet.pos.x = EasyTab->PosX;
            mem.tablet.pos.y = EasyTab->PosY;
            mem.tablet.buttons = EasyTab->Buttons;
        }

        BOOL is_maximized = IsMaximized(window);
        if (IsIconic(window)) { goto EndOfFrame; }

        // Start new ImGui frame
        {
            ImGuiIO& io = ImGui::GetIO();

            // Setup display size (every frame to accommodate for window resizing)
            RECT rect;
            GetClientRect(window, &rect);
            io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));

            // Read keyboard modifiers inputs
            io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
            io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
            io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;

            // Setup time step
            INT64 current_time;
            QueryPerformanceCounter((LARGE_INTEGER *)&current_time);
            io.DeltaTime = (float)(current_time - mem.profile.current_time) * 
                           (float)timer::get_freq() / 1000.0f;
            mem.profile.current_time = current_time; // TODO: Move Imgui timers from Debug to their own struct

            // Hide OS mouse cursor if ImGui is drawing it
            //SetCursor(io.MouseDrawCursor ? NULL : LoadCursor(NULL, IDC_ARROW));

            // Start the frame
            ImGui::NewFrame();
        }

        // Title Bar Icon
        {
            ImGui::SetNextWindowSize(ImVec2((float)mem.window.menu_horizontal_offset,(float)mem.window.title_bar_height));
            ImGui::SetNextWindowPos(ImVec2(1.0f, 1.0f));

            ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
            ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(2,2));
            ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
            ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0,0));
            ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));

            ImGui::PushStyleColor(ImGuiCol_WindowBg, mem.colors[PapayaCol_Transparent]);

            bool bTrue = true;
            ImGui::Begin("Title Bar Icon", &bTrue, mem.window.default_imgui_flags);

            #define CALCUV(X, Y) ImVec2((float)X/256.0f, (float)Y/256.0f)
            ImGui::Image((void*)(intptr_t)mem.textures[PapayaTex_UI], ImVec2(28,28), CALCUV(0,200), CALCUV(28,228));
            #undef CALCUV

            ImGui::End();

            ImGui::PopStyleColor(1);
            ImGui::PopStyleVar(5);
        }

        // Title Bar Buttons
        {
            ImGui::SetNextWindowSize(ImVec2((float)mem.window.title_bar_buttons_width,24.0f));
            ImGui::SetNextWindowPos(ImVec2((float)mem.window.width - mem.window.title_bar_buttons_width, 0.0f));

            ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
            ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0,0));
            ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
            ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0,0));
            ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));

            ImGui::PushStyleColor(ImGuiCol_Button, mem.colors[PapayaCol_Transparent]);
            ImGui::PushStyleColor(ImGuiCol_ButtonHovered, mem.colors[PapayaCol_ButtonHover]);
            ImGui::PushStyleColor(ImGuiCol_ButtonActive, mem.colors[PapayaCol_ButtonActive]);
            ImGui::PushStyleColor(ImGuiCol_WindowBg, mem.colors[PapayaCol_Transparent]);

            bool bTrue = true;

            #define CALCUV(X, Y) ImVec2((float)X/256.0f, (float)Y/256.0f)
            ImGui::Begin("Title Bar Buttons", &bTrue, mem.window.default_imgui_flags);

            ImGui::PushID(0);
            if(ImGui::ImageButton((void*)(size_t)mem.textures[PapayaTex_UI], 
                                  ImVec2(34,26), CALCUV(62,200), CALCUV(96,226),
                                  1, ImVec4(0,0,0,0))) {
                ShowWindow(window, SW_MINIMIZE);
            }

            ImVec2 start_uv = is_maximized ? CALCUV(28,226) : CALCUV(62,226);
            ImVec2 end_uv = is_maximized ? CALCUV(62,252) : CALCUV(96,252);

            ImGui::PopID();
            ImGui::SameLine();
            ImGui::PushID(1);

            if(ImGui::ImageButton((void*)(size_t)mem.textures[PapayaTex_UI],
                                  ImVec2(34,26), start_uv, end_uv,
                                  1, ImVec4(0,0,0,0))) {
                if (is_maximized) {
                    ShowWindow(window, SW_RESTORE);
                } else {
                    ShowWindow(window, SW_MAXIMIZE);
                }
            }

            ImGui::PopID();
            ImGui::SameLine();
            ImGui::PushID(2);

            if(ImGui::ImageButton((void*)(size_t)mem.textures[PapayaTex_UI],
                                  ImVec2(34,26), CALCUV(28,200), CALCUV(62,226),
                                  1, ImVec4(0,0,0,0))) {
                SendMessage(window, WM_CLOSE, 0, 0);
            }

            ImGui::PopID();
            ImGui::End();
            #undef CALCUV

            ImGui::PopStyleVar(5);
            ImGui::PopStyleColor(4);
        }

        // ImGui::ShowTestWindow();
        core::update(&mem);
        SwapBuffers(device_context);

    EndOfFrame:
        timer::stop(Timer_Frame);
        double frame_rate = (mem.current_tool == PapayaTool_Brush && mem.mouse.is_down[0]) ?
                           500.0 : 60.0;
        double frame_time = 1000.0 / frame_rate;
        double sleep_time = frame_time - timers[Timer_Frame].elapsed_ms;
        timers[Timer_Sleep].elapsed_ms = sleep_time;
        if (sleep_time > 0) { Sleep((int32)sleep_time); }
    }

    core::destroy(&mem);

    EasyTab_Unload();

    return 0;
}
LRESULT ZLWin32ApplicationWindow::mainLoopCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	switch (uMsg) {
		case MY_WM_FULLSCREEN:
			setFullscreen(true);
			return 0;
		case WM_MEASUREITEM:
			if (!myPopupMenu.isNull()) {
				myPopupMenu->measureItem(*(MEASUREITEMSTRUCT*)lParam);
			}
			return 1;
		case WM_DRAWITEM:
			if (!myPopupMenu.isNull()) {
				myPopupMenu->drawItem(*(DRAWITEMSTRUCT*)lParam);
			}
			return 1;
		case WM_MOUSEWHEEL:
			if (!mouseEventsAreBlocked()) {
				application().doActionByKey(
					((short)HIWORD(wParam) > 0) ?
						ZLApplication::MouseScrollUpKey :
						ZLApplication::MouseScrollDownKey
				);
			}
			return 0;
		case WM_PAINT:
		{
			LRESULT code = DefWindowProc(hWnd, uMsg, wParam, lParam);
			updateWindowToolbarInfo();
			updateFullscreenToolbarSize();
			return code;
		}
		case WM_TIMER:
			((ZLWin32TimeManager&)ZLTimeManager::instance()).execute(wParam);
			return 0;
		case WM_CREATE:
			myMainWindow = hWnd;
			ZLApplicationWindow::init();
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
		case WM_KEYDOWN:
		case WM_SYSKEYDOWN:
			if (wParam == 0x10) {
				myKeyboardModifierMask |= 0x1;
			} else if (wParam == 0x11) {
				myKeyboardModifierMask |= 0x2;
			} else if (wParam == 0x12) {
				myKeyboardModifierMask |= 0x4;
			} else {
				application().doActionByKey(ZLKeyUtil::keyName(wParam, wParam, myKeyboardModifierMask));
				myKeyboardModifierMask = 0;
			}
			return 0;
		case WM_KEYUP:
		case WM_SYSKEYUP:
			if (wParam == 0x10) {
				myKeyboardModifierMask &= ~0x1;
			} else if (wParam == 0x11) {
				myKeyboardModifierMask &= ~0x2;
			} else if (wParam == 0x12) {
				myKeyboardModifierMask &= ~0x4;
			}
			return 0;
		case WM_SIZE:
		{
			RECT rebarRect;
			GetWindowRect(myRebar, &rebarRect);
			int offset = rebarRect.bottom - rebarRect.top - 1;
			MoveWindow(myRebar, 0, 0, LOWORD(lParam), rebarRect.bottom - rebarRect.top, true);
			if (myFullScreen) {
				offset = 0;
			}
			MoveWindow(myWin32ViewWidget->handle(), 0, offset, LOWORD(lParam), HIWORD(lParam) - offset, true);
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
		}
		case WM_CLOSE:
			if (myFullScreen) {
				myWindowStateOption.setValue(FULLSCREEN);
			} else if (IsMaximized(myMainWindow)) {
				myWindowStateOption.setValue(MAXIMIZED);
			} else {
				myWindowStateOption.setValue(NORMAL);
				RECT rectangle;
				GetWindowRect(myMainWindow, &rectangle);
				myXOption.setValue(rectangle.left);
				myYOption.setValue(rectangle.top);
				myWidthOption.setValue(rectangle.right - rectangle.left + 1);
				myHeightOption.setValue(rectangle.bottom - rectangle.top + 1);
			}
			application().closeView();
			return 0;
		case WM_DESTROY:
			PostQuitMessage(0);
			return 0;
		case WM_COMMAND:
			onToolbarButtonRelease(LOWORD(wParam));
			return 0;
		case WM_NOTIFY:
		{
			const NMHDR *notificationHeader = (const NMHDR*)lParam;
			switch (notificationHeader->code) {
				case TTN_NEEDTEXT:
					setTooltip(*(TOOLTIPTEXT*)lParam);
					break;
				case NM_CUSTOMDRAW:
					updateParameters();
					break;
				case TBN_DROPDOWN:
					runPopup(*(const NMTOOLBAR*)lParam);
					break;
				case RBN_CHEVRONPUSHED:
					processChevron(*(const NMREBARCHEVRON*)lParam);
					break;
			}
			return 0;
		}
		default:
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
}
Exemplo n.º 10
0
void wxTopLevelWindowMac::Maximize(bool maximize)
{
    if ( IsMaximized() != maximize )
        m_nowpeer->Maximize(maximize);
}
Exemplo n.º 11
0
bool CCamFrame::Destroy()
{
	// Before anything else let's set Document::Current and DocView::Current properly...
	// This "event" doesn't refer to any particular doc or view so we'll set them both NULL
	Document::SetNoCurrent();
	DocView::SetNoCurrent();

	// Update the window position and state preferences
	// This doesn't work as well as in Xtreme due to the lack of GetWindowPlacement
	// GetRect returns the current size of the window even when maximised or iconised
	// so some effort will be needed to correctly save the normal position
	bool bMin = IsIconized();
	bool bMax = IsMaximized();
	wxSize ScreenSize = wxGetDisplaySize();
	CCamApp::MainWndPosString._MakeMsg(
			_T("#1%d #2%d #3%d #4%d #5%d #6%d"),
			m_WndRect.x,
			m_WndRect.y,
			m_WndRect.width,
			m_WndRect.height,
			ScreenSize.x,
			ScreenSize.y
				);
	CCamApp::MainWndMaximized = bMax ? TRUE : FALSE;
	CCamApp::MainWndMinimized = bMin ? TRUE : FALSE;

PORTNOTE("other","Removed WindowPlacement saving")
#if !defined(EXCLUDE_FROM_XARALX)
#ifndef EXCLUDE_FROM_RALPH
	// lets write out our non-maximised window position to the .ini file
	WINDOWPLACEMENT wPlace;
	wPlace.length = sizeof(WINDOWPLACEMENT);
	if (GetWindowPlacement( &wPlace ))
	{
		
		// we must save last normal position if in full screen mode 
		if (FullScreenMode)
		{
			wPlace = NormalModePlace;
		}

		CCamApp::MainWndPosString._MakeMsg(
				"#1%d #2%d #3%d #4%d #5%d #6%d",
				wPlace.rcNormalPosition.left,
				wPlace.rcNormalPosition.top,
				wPlace.rcNormalPosition.right - wPlace.rcNormalPosition.left,
				wPlace.rcNormalPosition.bottom - wPlace.rcNormalPosition.top,
				GetSystemMetrics( SM_CXSCREEN ),
				GetSystemMetrics( SM_CYSCREEN )
					);
		CCamApp::MainWndMaximized = (wPlace.showCmd == SW_SHOWMAXIMIZED) ? TRUE : FALSE;
		CCamApp::MainWndMinimized = (wPlace.showCmd == SW_SHOWMINIMIZED) ? TRUE : FALSE;
	}
	else
	{
		CCamApp::MainWndPosString = "";							// so uses default next time
		CCamApp::MainWndMaximized = FALSE;
		CCamApp::MainWndMinimized = FALSE;

	}
#endif // EXCLUDE_FROM_RALPH
#endif

	// Make sure that the currently selected tool is "de-initialised" before the
	// main window is destroyed, or it will try to use a dead info bar.
	// NB. Docs say that this function can be safely called more than once.
	Tool::DeinitTools();

   	// DeathMsg is the last message sent before camelot shuts down
	BROADCAST_TO_ALL(DeathMsg());

PORTNOTE("other","Removed ExternalClipboard usage")
#if !defined(EXCLUDE_FROM_XARALX)
#ifndef EXCLUDE_FROM_RALPH
	// And make sure we're no longer on the clipboard viewer chain
	ChangeClipboardChain(NextClipboardViewer);
#endif
#endif

	return wxDocMDIParentFrame::Destroy();
}
Exemplo n.º 12
0
/* This function creates the out-basket window.
 */
BOOL FASTCALL CreateOutBasket( HWND hwnd )
{
   DWORD dwState;
   RECT rc;

   /* If outbasket window already open, bring it to the front
    * and display it.
    */
   if( hwndOutBasket )
      {
      Adm_MakeMDIWindowActive( hwndOutBasket );
      return( TRUE );
      }

   /* Register the out-basket window class if we have
    * not already done so.
    */
   if( !fRegistered )
      {
      WNDCLASS wc;

      wc.style          = CS_HREDRAW | CS_VREDRAW;
      wc.lpfnWndProc    = OutBasketWndProc;
      wc.hIcon          = LoadIcon( hRscLib, MAKEINTRESOURCE(IDI_OUTBASKET) );
      wc.hCursor        = LoadCursor( NULL, IDC_ARROW );
      wc.lpszMenuName   = NULL;
      wc.cbWndExtra     = MWE_EXTRA;
      wc.cbClsExtra     = 0;
      wc.hbrBackground  = NULL;
      wc.lpszClassName  = szOutBaskWndClass;
      wc.hInstance      = hInst;
      if( !RegisterClass( &wc ) )
         return( FALSE );
      fRegistered = TRUE;
      }

   /* The default position of the out-basket.
    */
   GetClientRect( hwndMDIClient, &rc );
   rc.left = rc.right / 3;
   InflateRect( &rc, -5, -5 );
   dwState = 0;

   /* Load the out-basket bitmaps.
    */
   hbmpOutBasket = LoadBitmap( hRscLib, MAKEINTRESOURCE(IDB_OUTBASKETBMPS) );

   /* Get the actual window size, position and state.
    */
   ReadProperWindowState( szOutBaskWndName, &rc, &dwState );

   if( hwndActive && IsMaximized( hwndActive ) )
      dwState = WS_MAXIMIZE;

         
   /* Create the window.
    */
   hwndOutBasket = Adm_CreateMDIWindow( szOutBaskWndName, szOutBaskWndClass, hInst, &rc, dwState, 0L );
   if( NULL == hwndOutBasket )
      return( FALSE );
   UpdateWindow( hwndOutBasket );

   /* Set the initial focus.
    */
   OutBasket_OnSetFocus( hwndOutBasket, NULL );
   UpdateOutBasketStatus();
   return( TRUE );

}
Exemplo n.º 13
0
LRESULT CDockManager::ScWindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp)
{
	switch (msg)
	{
	case WM_MOVE:
		if (IsDocked())
		{
			LRESULT lr = ScDefault(hRealWnd);

			if (m_bResizeUpdate)
				UpdateMainWindowPos();

			return lr;
		}
		break;

	case WM_SIZE:
		if (IsDocked())
		{
			LRESULT lr = ScDefault(hRealWnd);

			if (m_bResizeUpdate)
				UpdateMainWindowPos();

			// save dock width
			if (m_bSizeUpdate && ::IsWindowVisible(ScGetHwnd()))
			{
				CRect rDock;
				::GetWindowRect(ScGetHwnd(), rDock);

				if (IsMaximized())
				{
					if (m_nDockPos == DMP_BELOW)
						m_nHeightDockedMax = rDock.Height();
					else
						m_nWidthDockedMax = rDock.Width();
				}
				else
				{
					if (m_nDockPos == DMP_BELOW)
						m_nHeightDocked = rDock.Height();
					else
						m_nWidthDocked = rDock.Width();
				}
			}
			
			return lr;
		}
		break;

	case WM_SYSCOMMAND:
		if (IsDocked())
		{
			switch (wp)
			{
			// hide system menu
			case SC_KEYMENU:
			case SC_MOUSEMENU:
				return 0;
			
			// don't allow docked window to be minimized or maximized directly
			// instead, send the message to the main window
			case SC_MAXIMIZE:
			case SC_MINIMIZE:
				return SendMessage(msg, wp, lp);

			// if the dock window is being closed and the main window is maximized
			// then readjust the main window rect
			case SC_CLOSE:
				if (IsMaximized())
				{
					LRESULT lr = ScDefault(hRealWnd);

					OnMaximize();

					return lr;
				}
				break;
			}
		}
		break;

	case WM_NCRBUTTONDOWN:
		// if this is in the caption then eat it
		if (IsDocked() && wp == HTCAPTION)
		{
			// activate the window first
			ScSendMessage(WM_ACTIVATE, WA_CLICKACTIVE, NULL);
			return 0;
		}
		break;

	case WM_NCLBUTTONDOWN:
		// if this is in the caption and the main window in maxed
		// then eat
		if (IsDocked() && wp == HTCAPTION && IsMaximized())
		{
			// activate the window first
			ScSendMessage(WM_ACTIVATE, WA_CLICKACTIVE, NULL);
			return 0;
		}
		break;

	case WM_NCLBUTTONDBLCLK:
		if (wp == HTCAPTION)
		{
			// toggle the docked state
			if (IsDocked())
				UnDock();
			else
				Dock(m_nLastDockPos);

			// and eat the message
			return 0;
		}
		break;

	case WM_NCHITTEST:
		if (IsDocked())
		{
			UINT nHitTest = ScDefault(hRealWnd);

			// if the main window is _not_ unmaximized then don't let the 
			// docked window be resized on it's docked edge
			// because its not intuitive and causes no end of trouble :)
			if (!IsMaximized())
			{
				switch (m_nDockPos)
				{
				case DMP_LEFT:
					if (nHitTest == HTRIGHT || nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT)
						nHitTest = HTCLIENT;
					break;

				case DMP_RIGHT:
					if (nHitTest == HTLEFT || nHitTest == HTTOPLEFT || nHitTest == HTBOTTOMLEFT)
						nHitTest = HTCLIENT;
					break;

				case DMP_BELOW:
					if (nHitTest == HTTOP || nHitTest == HTTOPLEFT || nHitTest == HTTOPRIGHT)
						nHitTest = HTCLIENT;
					break;

				default:
					ASSERT(0);
					break;
				}
			}
			// else main window is maximized so _only_ let it be resized on its
			// docked edge and resize the main window afterwards
			else 
			{
				switch (m_nDockPos)
				{
				case DMP_LEFT:
					if (nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT ||
						nHitTest == HTLEFT || nHitTest == HTTOPLEFT || 
						nHitTest == HTBOTTOMLEFT ||	nHitTest == HTTOP || nHitTest == HTBOTTOM)
					{
						nHitTest = HTCLIENT;
					}
					break;

				case DMP_RIGHT:
					if (nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT ||
						nHitTest == HTRIGHT || nHitTest == HTTOPLEFT || 
						nHitTest == HTBOTTOMLEFT ||	nHitTest == HTTOP || nHitTest == HTBOTTOM)
					{
						nHitTest = HTCLIENT;
					}
					break;

				case DMP_BELOW:
					if (nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT ||
						nHitTest == HTRIGHT || nHitTest == HTTOPLEFT || 
						nHitTest == HTBOTTOMLEFT ||	nHitTest == HTLEFT || nHitTest == HTBOTTOM)
					{
						nHitTest = HTCLIENT;
					}
					break;

				default:
					ASSERT(0);
					break;
				}
			}

			return nHitTest;
		}
		break;

	case WM_GETMINMAXINFO:
		if (IsDocked())
		{
			LRESULT lr = ScDefault(hRealWnd);

			// save off our last min size
			LPMINMAXINFO pMMI = (LPMINMAXINFO)lp;
			m_sizeDockMin = pMMI->ptMinTrackSize;

			OnMinMaxInfo(pMMI, FALSE);
			return lr;
		}

	case WM_WINDOWPOSCHANGED:
		// if the dock window is being shown/hidden and the main window is maximized 
		// then adjust the main window rect
		if (IsDocked() && IsMaximized())
		{
			LPWINDOWPOS lpwp = (LPWINDOWPOS)lp;

			BOOL bVisible = ::IsWindowVisible(hRealWnd);
			BOOL bWantHide = (lpwp->flags & SWP_HIDEWINDOW);
			//BOOL bWantShow = (lpwp->flags & SWP_SHOWWINDOW);

			if (bVisible && bWantHide) // special case
			{
				CAutoFlag af(m_bResizeUpdate, FALSE);
				LRESULT lr = ScDefault(hRealWnd);

				CRect rMain = GetWorkArea();
				MoveWindow(GetCWnd(), rMain);
				
				return lr;

			}
			else //if (!bVisible && bWantShow)
			{
				LRESULT lr = ScDefault(hRealWnd);
				OnMaximize();
				
				return lr;
			}
		}
		break;
	}

	return ScDefault(hRealWnd);
}
Exemplo n.º 14
0
LRESULT CDockManager::WindowProc(HWND /*hRealWnd*/, UINT msg, WPARAM wp, LPARAM lp)
{
	if (!IsDocked())
		return Default();

	switch (msg)
	{
	case WM_MOVE:
		{
			LRESULT lr = Default();

			if (m_bResizeUpdate)
				UpdateDockWindowPos();

			return lr;
		}
		break;

	case WM_SIZE:
		{
			LRESULT lr = Default();

			if (m_bResizeUpdate)
				UpdateDockWindowPos();

			return lr;
		}
		break;

	case WM_SYSCOMMAND:
		if (wp == SC_MAXIMIZE || wp == SC_RESTORE)
		{
			CAutoFlag af(m_bResizeUpdate, FALSE);
			LRESULT lr = Default();

			if (wp == SC_MAXIMIZE)
				OnMaximize();
			else
				OnRestore();
			
			return lr;
		}
		break;

	case WM_NCLBUTTONDBLCLK:
		if (wp == HTCAPTION)
		{
			CAutoFlag af(m_bResizeUpdate, FALSE);
			BOOL bIsZoomed = IsMaximized();

			LRESULT lr = Default();

			if (!bIsZoomed)
				OnMaximize();
			else
				OnRestore();

			return lr;
		}
		break;

	case WM_NCLBUTTONDOWN:
		// if this is in the caption and the main window in maxed
		// then eat
		if (wp == HTCAPTION && IsMaximized())
		{
			// activate the window first
			SendMessage(WM_ACTIVATE, WA_CLICKACTIVE, NULL);
			return 0;
		}
		break;
		
	case WM_GETMINMAXINFO:
		{
			// if the main window is zoomed then don't restrict how far
			// the docked window can be resized
			LRESULT lr = Default();

			// save off our last min size
			LPMINMAXINFO pMMI = (LPMINMAXINFO)lp;
			m_sizeMainMin = pMMI->ptMinTrackSize;

			OnMinMaxInfo(pMMI, TRUE);
			return lr;
		}

	}

	return Default();
}
Exemplo n.º 15
0
void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize)
{
    if (!IsMaximized() && !IsFullScreen())
        GetCachedDecorSize() = decorSize;
    if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize)))
    {
        m_useCachedClientSize = false;
        const wxSize diff(
            decorSize.left - m_decorSize.left + decorSize.right - m_decorSize.right,
            decorSize.top - m_decorSize.top + decorSize.bottom - m_decorSize.bottom);
        m_decorSize = decorSize;
        bool resized = false;
        if (m_minWidth > 0 || m_minHeight > 0 || m_maxWidth > 0 || m_maxHeight > 0)
        {
            // update size hints, they depend on m_decorSize
            if (!m_deferShow)
            {
                // if size hints match old size, assume hints were set to
                // maintain current client size, and adjust hints accordingly
                if (m_minWidth == m_height) m_minWidth += diff.x;
                if (m_maxWidth == m_height) m_maxWidth += diff.x;
                if (m_minHeight == m_height) m_minHeight += diff.y;
                if (m_maxHeight == m_height) m_maxHeight += diff.y;
            }
            DoSetSizeHints(m_minWidth, m_minHeight, m_maxWidth, m_maxHeight, m_incWidth, m_incHeight);
        }
        if (m_deferShow)
        {
            // keep overall size unchanged by shrinking m_widget
            int w, h;
            GTKDoGetSize(&w, &h);
            // but not if size would be less than minimum, it won't take effect
            if (w >= m_minWidth - (decorSize.left + decorSize.right) &&
                    h >= m_minHeight - (decorSize.top + decorSize.bottom))
            {
                gtk_window_resize(GTK_WINDOW(m_widget), w, h);
                if (!gtk_window_get_resizable(GTK_WINDOW(m_widget)))
                    gtk_widget_set_size_request(GTK_WIDGET(m_widget), w, h);
                resized = true;
            }
        }
        if (!resized)
        {
            // adjust overall size to match change in frame extents
            m_width  += diff.x;
            m_height += diff.y;
            if (m_width  < 1) m_width  = 1;
            if (m_height < 1) m_height = 1;
            m_clientWidth = 0;
            gtk_widget_queue_resize(m_wxwindow);
        }
    }
    if (m_deferShow)
    {
        // gtk_widget_show() was deferred, do it now
        m_deferShow = false;
        DoGetClientSize(&m_clientWidth, &m_clientHeight);
        wxSizeEvent sizeEvent(GetSize(), GetId());
        sizeEvent.SetEventObject(this);
        HandleWindowEvent(sizeEvent);

#ifdef __WXGTK3__
        GTKSizeRevalidate();
#endif
        gtk_widget_show(m_widget);

        wxShowEvent showEvent(GetId(), true);
        showEvent.SetEventObject(this);
        HandleWindowEvent(showEvent);
    }
}
Exemplo n.º 16
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      return;

   if (IsIconized())
      return;
   
   // Get the position and size of the window first
   #ifdef __WXMAC__
      Integer screenWidth  = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
      Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
   #else
      Integer screenWidth;
      Integer screenHeight;
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
      // Since GmatMainFrame::GetActualClientSize() subtracts one, add one here (LOJ: 2012.07.23)
      screenWidth++;
      screenHeight++;
   #endif

   bool isMinimized = IsIconized(), isMaximized = IsMaximized();
   if (isMinimized)	
	  Iconize(false);
   else if (isMaximized)
	  Maximize(false);

   int tmpX = -1, tmpY = -1;
   int tmpW = -1, tmpH = -1;
   GetPosition(&tmpX, &tmpY);
   GetSize(&tmpW, &tmpH);
   Rvector upperLeft(2, ((Real) tmpX /(Real)  screenWidth), ((Real) tmpY /(Real)  screenHeight));
   Rvector childSize(2,  ((Real) tmpW /(Real)  screenWidth), ((Real) tmpH /(Real)  screenHeight));

   if (isMinimized)	
	  Iconize();
   else if (isMaximized)
	  Maximize();


   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage("*** Size of SCREEN %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, screenWidth, screenHeight);
   MessageInterface::ShowMessage("Position of View plot %s is: x = %d, y = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpX, tmpY);
   MessageInterface::ShowMessage("Size of View plot %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpW, tmpH);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  ||
       (mItemType == GmatTree::OUTPUT_CCSDS_OEM_FILE ) ||
       (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) ||
       (mItemType == GmatTree::OUTPUT_XY_PLOT) ||
       (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)
       // We'll want to add the event reports eventually, but they are not subscriber based
       //|| (mItemType == GmatTree::EVENT_REPORT)
       )
   {
      GmatBase *obj = theGuiInterpreter->GetConfiguredObject(mChildName.c_str());
      
      #ifdef DEBUG_FUNCTION
      // Check if child name is the configured object name
      MessageInterface::ShowMessage
         ("GmatMdiChildFrame::SaveChildPositionAndSize() the child '%s' %s a "
          "configured object, obj = <%p>[%s]'%s'\n", mChildName.WX_TO_C_STRING,
          obj ? "is" : "is not", obj, obj ? obj->GetTypeName().c_str() : "NULL",
          obj ? obj->GetName().c_str() : "NULL");
      #endif
      
      if (!obj)
      {
         // Just return if child is not a configured subscriber,ie,
         // plotting from GMAT function (LOJ: 2015.06.26)
         #ifdef DEBUG_FUNCTION
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "will not save position and size for unconfigured subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         return;
      }
      else if (!obj->IsOfType("Subscriber"))
      {
         #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "cannot not save position and size for non-subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         SubscriberException se;
         se.SetDetails("Cannot set position and size for non-subscriber '%s'");
         throw se;
      }
      
      Subscriber *sub = (Subscriber*) obj;
      
      #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str());
         MessageInterface::ShowMessage("       Upper left             = %12.10f   %12.10f\n", upperLeft[0], upperLeft[1]);
         MessageInterface::ShowMessage("       Size                   = %12.10f   %12.10f\n", childSize[0], childSize[1]);
         MessageInterface::ShowMessage("       RelativeZOrder         = %d\n", relativeZOrder);
      #endif
      sub->SetRvectorParameter(sub->GetParameterID("UpperLeft"), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID("Size"), childSize);
      sub->SetIntegerParameter(sub->GetParameterID("RelativeZOrder"), relativeZOrder);
      sub->SetBooleanParameter(sub->GetParameterID("Maximized"), isMaximized);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/MissionTree/UpperLeft", location.str().c_str());
      pConfig->Write("/MissionTree/Size", size.str().c_str());
      pConfig->Write("/MissionTree/IsMaximized", isMaximized);
      pConfig->Write("/MissionTree/IsMinimized", isMinimized);
   }
   else if (mItemType == GmatTree::SCRIPT_FILE)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/ScriptEditor/UpperLeft", location.str().c_str());
      pConfig->Write("/ScriptEditor/Size", size.str().c_str());
      pConfig->Write("/ScriptEditor/IsMaximized", isMaximized);
      pConfig->Write("/ScriptEditor/IsMinimized", isMinimized);
   }
}
Exemplo n.º 17
0
void ConsoleLogFrame::OnResize( wxSizeEvent& evt )
{
	if (!IsMaximized())
		m_conf.DisplaySize = GetSize();
	evt.Skip();
}
Exemplo n.º 18
0
void CDockManager::UpdateDockWindowPos()
{
	ASSERT (IsDocked());

	if (!IsDocked())
		return;

	CRect rMain, rDock;

	GetWindowRect(rMain);
	::GetWindowRect(ScGetHwnd(), rDock);

	if (IsMaximized())
	{
		CRect rWorkArea = GetWorkArea();

		switch (m_nDockPos)
		{
		case DMP_LEFT:
			rDock.top = rMain.top;
			rDock.bottom = rMain.bottom;
			rDock.left = rWorkArea.left;
			rDock.right = rMain.left;
			break;

		case DMP_RIGHT:
			rDock.top = rMain.top;
			rDock.bottom = rMain.bottom;
			rDock.right = rWorkArea.right;
			rDock.left = rMain.right;
			break;

		case DMP_BELOW:
			rDock.left = rMain.left;
			rDock.right = rMain.right;
			rDock.bottom = rWorkArea.bottom;
			rDock.top = rMain.bottom;
			break;

		default:
			ASSERT(0);
			return;
		}
	}
	else // not maximized
	{
		switch (m_nDockPos)
		{
		case DMP_LEFT:
			rDock.top = rMain.top;
			rDock.bottom = rMain.bottom;
			rDock.left = rMain.left - rDock.Width();
			rDock.right = rMain.left;
			break;

		case DMP_RIGHT:
			rDock.top = rMain.top;
			rDock.bottom = rMain.bottom;
			rDock.right = rMain.right + rDock.Width();
			rDock.left = rMain.right;
			break;

		case DMP_BELOW:
			rDock.left = rMain.left;
			rDock.right = rMain.right;
			rDock.bottom = rMain.bottom + rDock.Height();
			rDock.top = rMain.bottom;
			break;

		default:
			ASSERT(0);
			return;
		}
	}

	MoveWindow(ScGetCWnd(), rDock);
}
Exemplo n.º 19
0
void CDockManager::UpdateMainWindowPos()
{
	ASSERT (IsDocked());

	if (!IsDocked())
		return;

	CRect rMain, rDock;

	GetWindowRect(rMain);
	::GetWindowRect(ScGetHwnd(), rDock);

	// if the main window is maximized then shrink/enlarge
	// the window
	if (IsMaximized())
	{
		rMain = GetWorkArea();

		switch (m_nDockPos)
		{
		case DMP_LEFT:
			rMain.left = rDock.right;
			break;

		case DMP_RIGHT:
			rMain.right = rDock.left;
			break;

		case DMP_BELOW:
			rMain.bottom = rDock.top;
			break;

		default:
			ASSERT(0);
			return;
		}
	}
	// else just move the main window
	else
	{
		switch (m_nDockPos)
		{
		case DMP_LEFT:
			rMain.top = rDock.top;
			rMain.bottom = rDock.bottom;
			rMain.right = rDock.right + rMain.Width();
			rMain.left = rDock.right;
			break;

		case DMP_RIGHT:
			rMain.top = rDock.top;
			rMain.bottom = rDock.bottom;
			rMain.left = rDock.left - rMain.Width();
			rMain.right = rDock.left;
			break;

		case DMP_BELOW:
			rMain.left = rDock.left;
			rMain.right = rDock.right;
			rMain.top = rDock.top - rMain.Height();
			rMain.bottom = rDock.top;
			break;

		default:
			ASSERT(0);
			return;
		}
	}

	MoveWindow(GetCWnd(), rMain);
}
Exemplo n.º 20
0
// Pass true to show full screen, false to restore.
bool wxFrame::ShowFullScreen( bool bShow, long lStyle )
{
    if (bShow)
    {
        if (IsFullScreen())
            return false;

        m_bFsIsShowing = true;
        m_lFsStyle = lStyle;

#if wxUSE_TOOLBAR
        wxToolBar*                  pTheToolBar = GetToolBar();
#endif //wxUSE_TOOLBAR

#if wxUSE_STATUSBAR
        wxStatusBar*                pTheStatusBar = GetStatusBar();
#endif //wxUSE_STATUSBAR

        int                         nDummyWidth;

#if wxUSE_TOOLBAR
        if (pTheToolBar)
            pTheToolBar->GetSize(&nDummyWidth, &m_nFsToolBarHeight);
#endif //wxUSE_TOOLBAR

#if wxUSE_STATUSBAR
        if (pTheStatusBar)
            pTheStatusBar->GetSize(&nDummyWidth, &m_nFsStatusBarHeight);
#endif //wxUSE_STATUSBAR

#if wxUSE_TOOLBAR
        //
        // Zap the toolbar, menubar, and statusbar
        //
        if ((lStyle & wxFULLSCREEN_NOTOOLBAR) && pTheToolBar)
        {
            pTheToolBar->SetSize(wxDefaultCoord,0);
            pTheToolBar->Show(false);
        }
#endif //wxUSE_TOOLBAR

        if (lStyle & wxFULLSCREEN_NOMENUBAR)
        {
            ::WinSetParent(m_hMenu, m_hFrame, FALSE);
            ::WinSetOwner(m_hMenu, m_hFrame);
            ::WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
        }

#if wxUSE_STATUSBAR
        //
        // Save the number of fields in the statusbar
        //
        if ((lStyle & wxFULLSCREEN_NOSTATUSBAR) && pTheStatusBar)
        {
            m_nFsStatusBarFields = pTheStatusBar->GetFieldsCount();
            SetStatusBar(NULL);
            delete pTheStatusBar;
        }
        else
            m_nFsStatusBarFields = 0;
#endif //wxUSE_STATUSBAR

        //
        // Zap the frame borders
        //

        //
        // Save the 'normal' window style
        //
        m_lFsOldWindowStyle = ::WinQueryWindowULong(m_hFrame, QWL_STYLE);

        //
        // Save the old position, width & height, maximize state
        //
        m_vFsOldSize = GetRect();
        m_bFsIsMaximized = IsMaximized();

        //
        // Decide which window style flags to turn off
        //
        LONG lNewStyle = m_lFsOldWindowStyle;
        LONG lOffFlags = 0;

        if (lStyle & wxFULLSCREEN_NOBORDER)
            lOffFlags |= FCF_BORDER;
        if (lStyle & wxFULLSCREEN_NOCAPTION)
            lOffFlags |= (FCF_TASKLIST | FCF_SYSMENU);

        lNewStyle &= (~lOffFlags);

        //
        // Change our window style to be compatible with full-screen mode
        //
        ::WinSetWindowULong((HWND)m_hFrame, QWL_STYLE, (ULONG)lNewStyle);

        //
        // Resize to the size of the desktop
        int                         nWidth;
        int                         nHeight;

        RECTL                       vRect;

        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
        nWidth = vRect.xRight - vRect.xLeft;
        //
        // Remember OS/2 is backwards!
        //
        nHeight = vRect.yTop - vRect.yBottom;

        SetSize( nWidth, nHeight);

        //
        // Now flush the window style cache and actually go full-screen
        //
        ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
                          ,HWND_TOP
                          ,0
                          ,0
                          ,nWidth
                          ,nHeight
                          ,SWP_SIZE | SWP_SHOW
                         );

        wxSize sz( nWidth, nHeight );
        wxSizeEvent vEvent( sz, GetId() );

        HandleWindowEvent(vEvent);
        return true;
    }
    else
    {
        if (!IsFullScreen())
            return false;

        m_bFsIsShowing = false;

#if wxUSE_TOOLBAR
        wxToolBar*                  pTheToolBar = GetToolBar();

        //
        // Restore the toolbar, menubar, and statusbar
        //
        if (pTheToolBar && (m_lFsStyle & wxFULLSCREEN_NOTOOLBAR))
        {
            pTheToolBar->SetSize(wxDefaultCoord, m_nFsToolBarHeight);
            pTheToolBar->Show(true);
        }
#endif //wxUSE_TOOLBAR

#if wxUSE_STATUSBAR
        if ((m_lFsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_nFsStatusBarFields > 0))
        {
            CreateStatusBar(m_nFsStatusBarFields);
//          PositionStatusBar();
        }
#endif //wxUSE_STATUSBAR

        if ((m_lFsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
        {
            ::WinSetParent(m_hMenu, m_hFrame, FALSE);
            ::WinSetOwner(m_hMenu, m_hFrame);
            ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
        }
        Maximize(m_bFsIsMaximized);

        ::WinSetWindowULong( m_hFrame
                            ,QWL_STYLE
                            ,(ULONG)m_lFsOldWindowStyle
                           );
        ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
                          ,HWND_TOP
                          ,m_vFsOldSize.x
                          ,m_vFsOldSize.y
                          ,m_vFsOldSize.width
                          ,m_vFsOldSize.height
                          ,SWP_SIZE | SWP_SHOW
                         );
    }
    return wxFrameBase::ShowFullScreen(bShow, lStyle);
} // end of wxFrame::ShowFullScreen
Exemplo n.º 21
0
void wxSettlersFrame::OnMaximize(wxMaximizeEvent&)
{
	mWasMaximized = IsMaximized();
}
Exemplo n.º 22
0
void wxTopLevelWindowBase::DoCentre(int dir)
{
    // on some platforms centering top level windows is impossible
    // because they are always maximized by guidelines or limitations
    //
    // and centering a maximized window doesn't make sense as its position
    // can't change
    if ( IsAlwaysMaximized() || IsMaximized() )
        return;

    // we need the display rect anyhow so store it first: notice that we should
    // be centered on the same display as our parent window, the display of
    // this window itself is not really defined yet
    int nDisplay = wxDisplay::GetFromWindow(GetParent() ? GetParent() : this);
    wxDisplay dpy(nDisplay == wxNOT_FOUND ? 0 : nDisplay);
    const wxRect rectDisplay(dpy.GetClientArea());

    // what should we centre this window on?
    wxRect rectParent;
    if ( !(dir & wxCENTRE_ON_SCREEN) && GetParent() )
    {
        // centre on parent window: notice that we need screen coordinates for
        // positioning this TLW
        rectParent = GetParent()->GetScreenRect();

        // if the parent is entirely off screen (happens at least with MDI
        // parent frame under Mac but could happen elsewhere too if the frame
        // was hidden/moved away for some reason), don't use it as otherwise
        // this window wouldn't be visible at all
        if ( !rectParent.Intersects(rectDisplay) )
        {
            // just centre on screen then
            rectParent = rectDisplay;
        }
    }
    else
    {
        // we were explicitly asked to centre this window on the entire screen
        // or if we have no parent anyhow and so can't centre on it
        rectParent = rectDisplay;
    }

    if ( !(dir & wxBOTH) )
        dir |= wxBOTH; // if neither is specified, center in both directions

    // the new window rect candidate
    wxRect rect = GetRect().CentreIn(rectParent, dir & ~wxCENTRE_ON_SCREEN);

    // we don't want to place the window off screen if Centre() is called as
    // this is (almost?) never wanted and it would be very difficult to prevent
    // it from happening from the user code if we didn't check for it here
    if ( !rectDisplay.Contains(rect.GetTopLeft()) )
    {
        // move the window just enough to make the corner visible
        int dx = rectDisplay.GetLeft() - rect.GetLeft();
        int dy = rectDisplay.GetTop() - rect.GetTop();
        rect.Offset(dx > 0 ? dx : 0, dy > 0 ? dy : 0);
    }

    if ( !rectDisplay.Contains(rect.GetBottomRight()) )
    {
        // do the same for this corner too
        int dx = rectDisplay.GetRight() - rect.GetRight();
        int dy = rectDisplay.GetBottom() - rect.GetBottom();
        rect.Offset(dx < 0 ? dx : 0, dy < 0 ? dy : 0);
    }

    // the window top left and bottom right corner are both visible now and
    // although the window might still be not entirely on screen (with 2
    // staggered displays for example) we wouldn't be able to improve the
    // layout much in such case, so we stop here

    // -1 could be valid coordinate here if there are several displays
    SetSize(rect, wxSIZE_ALLOW_MINUS_ONE);
}
Exemplo n.º 23
0
internal LRESULT CALLBACK Win32MainWindowCallback(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam)
{
    if (EasyTab_HandleEvent(Window, Message, LParam, WParam) == EASYTAB_OK)
    {
        return true;  // Tablet input
    }

    LRESULT Result = 0;
    ImGuiIO& io = ImGui::GetIO();

    switch (Message)
    {
        // Mouse

        case WM_LBUTTONDOWN:
        {
            io.MouseDown[0] = true;
            return true;
        } break;

        case WM_LBUTTONUP:
        {
            io.MouseDown[0] = false;
            return true;
        } break;

        case WM_RBUTTONDOWN:
        {
            io.MouseDown[1] = true;
            return true;
        } break;
        case WM_RBUTTONUP:
        {
            io.MouseDown[1] = false;
            return true;
        } break;

        case WM_MBUTTONDOWN:
        {
            io.MouseDown[2] = true;
            return true;
        } break;

        case WM_MBUTTONUP:
        {
            io.MouseDown[2] = false;
            return true;
        } break;

        case WM_MOUSEWHEEL:
        {
            io.MouseWheel += GET_WHEEL_DELTA_WPARAM(WParam) > 0 ? +1.0f : -1.0f;
            return true;
        } break;

        case WM_MOUSEMOVE:
        {
            TRACKMOUSEEVENT TrackParam = {};
            TrackParam.dwFlags |= TME_LEAVE;
            TrackParam.hwndTrack = Window;
            TrackParam.cbSize = sizeof(TrackParam);
            TrackMouseEvent(&TrackParam);
            io.MousePos.x = (signed short)(LParam);
            io.MousePos.y = (signed short)(LParam >> 16);
            return true;
        } break;

        case WM_MOUSELEAVE:
        {
            ImGui::GetIO().MouseDown[0] = false;
            ImGui::GetIO().MouseDown[1] = false;
            ImGui::GetIO().MouseDown[2] = false;
            return true;
        } break;


        // Keyboard

        case WM_KEYDOWN:
        {
            if (WParam < 256)
                io.KeysDown[WParam] = 1;
            return true;
        } break;

        case WM_KEYUP:
        {
            if (WParam < 256)
                io.KeysDown[WParam] = 0;
            return true;
        } break;

        case WM_CHAR:
        {
            // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
            if (WParam > 0 && WParam < 0x10000)
                io.AddInputCharacter((unsigned short)WParam);
            return true;
        } break;


        // Window handling

        case WM_DESTROY:
        {
            Mem.IsRunning = false;
            if (RenderingContext)
            {
                wglMakeCurrent(NULL, NULL);
                wglDeleteContext(RenderingContext);
            }
            ReleaseDC(Window, DeviceContext);
            PostQuitMessage(0);
        } break;

        case WM_PAINT:
        {
            PAINTSTRUCT Paint;
            BeginPaint(Window, &Paint);
            // TODO: Redraw here
            EndPaint(Window, &Paint);
        } break;

        case WM_CLOSE:
        {
            // TODO: Handle this with a message to the user?
            Mem.IsRunning = false;
        } break;

        case WM_SIZE:
        {
            int32 Width, Height;

            if (WParam == SIZE_MAXIMIZED)
            {
                int32 WorkAreaWidth = WindowsWorkArea.right - WindowsWorkArea.left;
                int32 WorkAreaHeight = WindowsWorkArea.bottom - WindowsWorkArea.top;
                SetWindowPos(Window, HWND_TOP, WindowsWorkArea.left, WindowsWorkArea.top, WorkAreaWidth, WorkAreaHeight, NULL);
                Width = WorkAreaWidth;
                Height = WorkAreaHeight;
            }
            else
            {
                Width = (int32) LOWORD(LParam);
                Height = (int32) HIWORD(LParam);
            }

            Core::OnWindowResize(&Mem, Width, Height);

            // Clear and swap buffers
            {
                if (Mem.Colors[PapayaCol_Clear])
                {
                    glClearBufferfv(GL_COLOR, 0, (GLfloat*)&Mem.Colors[PapayaCol_Clear]);
                }
                SwapBuffers(DeviceContext);
            }
        } break;

        // WM_NCHITTEST

        case WM_NCHITTEST:
        {
            const LONG BorderWidth = 8; //in pixels
            RECT WindowRect;
            GetWindowRect(Window, &WindowRect);
            long X = GET_X_LPARAM(LParam);
            long Y = GET_Y_LPARAM(LParam);

            if (!IsMaximized(Window))
            {
                //bottom left corner
                if (X >= WindowRect.left && X < WindowRect.left + BorderWidth &&
                    Y < WindowRect.bottom && Y >= WindowRect.bottom - BorderWidth)
                {
                    return HTBOTTOMLEFT;
                }
                //bottom right corner
                if (X < WindowRect.right && X >= WindowRect.right - BorderWidth &&
                    Y < WindowRect.bottom && Y >= WindowRect.bottom - BorderWidth)
                {
                    return HTBOTTOMRIGHT;
                }
                //top left corner
                if (X >= WindowRect.left && X < WindowRect.left + BorderWidth &&
                    Y >= WindowRect.top && Y < WindowRect.top + BorderWidth)
                {
                    return HTTOPLEFT;
                }
                //top right corner
                if (X < WindowRect.right && X >= WindowRect.right - BorderWidth &&
                    Y >= WindowRect.top && Y < WindowRect.top + BorderWidth)
                {
                    return HTTOPRIGHT;
                }
                //left border
                if (X >= WindowRect.left && X < WindowRect.left + BorderWidth)
                {
                    return HTLEFT;
                }
                //right border
                if (X < WindowRect.right && X >= WindowRect.right - BorderWidth)
                {
                    return HTRIGHT;
                }
                //bottom border
                if (Y < WindowRect.bottom && Y >= WindowRect.bottom - BorderWidth)
                {
                    return HTBOTTOM;
                }
                //top border
                if (Y >= WindowRect.top && Y < WindowRect.top + BorderWidth)
                {
                    return HTTOP;
                }
            }

            if (Y - WindowRect.top <= (float)Mem.Window.TitleBarHeight &&
                X > WindowRect.left + 200.0f &&
                X < WindowRect.right - (float)(Mem.Window.TitleBarButtonsWidth + 10))
            {
                return HTCAPTION;
            }

            SetCursor(LoadCursor(NULL, IDC_ARROW));
            return HTCLIENT;
        } break;

        default:
        {
            Result = DefWindowProcA(Window, Message, WParam, LParam);
        } break;
    }

    return(Result);
}
Exemplo n.º 24
0
bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
{
    if ( show == IsFullScreen() )
    {
        // nothing to do
        return true;
    }

    m_fsIsShowing = show;

    if ( show )
    {
        m_fsStyle = style;

        // zap the frame borders

        // save the 'normal' window style
        m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE);

        // save the old position, width & height, maximize state
        m_fsOldSize = GetRect();
        m_fsIsMaximized = IsMaximized();

        // decide which window style flags to turn off
        LONG newStyle = m_fsOldWindowStyle;
        LONG offFlags = 0;

        if (style & wxFULLSCREEN_NOBORDER)
        {
            offFlags |= WS_BORDER;
#ifndef __WXWINCE__
            offFlags |= WS_THICKFRAME;
#endif
        }
        if (style & wxFULLSCREEN_NOCAPTION)
            offFlags |= WS_CAPTION | WS_SYSMENU;

        newStyle &= ~offFlags;

        // Full screen windows should logically be popups as they don't have
        // decorations (and are definitely not children) and while not using
        // this style doesn't seem to make any difference for most windows, it
        // breaks wxGLCanvas in some cases, see #15434, so just always use it.
        newStyle |= WS_POPUP;

        // change our window style to be compatible with full-screen mode
        ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);

        wxRect rect;
#if wxUSE_DISPLAY
        // resize to the size of the display containing us
        int dpy = wxDisplay::GetFromWindow(this);
        if ( dpy != wxNOT_FOUND )
        {
            rect = wxDisplay(dpy).GetGeometry();
        }
        else // fall back to the main desktop
#endif // wxUSE_DISPLAY
        {
            // resize to the size of the desktop
            wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
#ifdef __WXWINCE__
            // FIXME: size of the bottom menu (toolbar)
            // should be taken in account
            rect.height += rect.y;
            rect.y       = 0;
#endif
        }

        SetSize(rect);

        // now flush the window style cache and actually go full-screen
        long flags = SWP_FRAMECHANGED;

        // showing the frame full screen should also show it if it's still
        // hidden
        if ( !IsShown() )
        {
            // don't call wxWindow version to avoid flicker from calling
            // ::ShowWindow() -- we're going to show the window at the correct
            // location directly below -- but do call the wxWindowBase version
            // to sync the internal m_isShown flag
            wxWindowBase::Show();

            flags |= SWP_SHOWWINDOW;
        }

        SetWindowPos(GetHwnd(), HWND_TOP,
                     rect.x, rect.y, rect.width, rect.height,
                     flags);

#if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
        ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
#endif

        // finally send an event allowing the window to relayout itself &c
        wxSizeEvent event(rect.GetSize(), GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);
    }
    else // stop showing full screen
    {
#if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
        ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON);
#endif
        Maximize(m_fsIsMaximized);
        SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
        SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
            m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
    }

    return true;
}
int APIENTRY _tWinMain(
    HINSTANCE handleToInstance,
    HINSTANCE handleToPreviousInstance,
    LPTSTR    commandLine,
    int       showCommand)
{
    LPTSTR commandLineReader = commandLine;

    int argc = 0;
    while (*commandLineReader)
    {
        if (*commandLineReader == _T(' ')) argc++;
        commandLineReader++;
    }

    /*if (argc < 2)
    {
        return 0;
    }*/
    
    TCHAR targetExecutableBuffer[MaxExeNameLength];
    _tcscpy_s<MaxExeNameLength>(targetExecutableBuffer, commandLine);
    LPTSTR targetExecutable = targetExecutableBuffer;

    if (*targetExecutable == TEXT('"'))
    {
        targetExecutable++;
        *_tcschr(targetExecutable, TEXT('"')) = TEXT('\0');
    }

    // See if the app is already running; if so, activate it
    
    // Get all running process ids

    DWORD processIds[MaxProcessIds];
    DWORD bytesNeeded;

    EnumProcesses(processIds, MaxProcessIds * sizeof(DWORD), &bytesNeeded);
    DWORD processCount = bytesNeeded / sizeof(DWORD);
    
    for (DWORD i = 0; i < processCount; i++)
    {
        // Get the image name of the process

        TCHAR exeName[MaxExeNameLength];
        DWORD length = MaxExeNameLength * sizeof(TCHAR);
        HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processIds[i]);
        BOOL result = QueryFullProcessImageName(processHandle, 0, exeName, &length);
        CloseHandle(processHandle);

        // If the image name is the same as the one we are trying to start

        if (result && _tcsicmp(targetExecutable, exeName) == 0)
        {
            // Get its window handle

            targetProcessId = processIds[i];
            EnumWindows(EnumWindowsProc, 0);

            // Restore the window if it is minimized
            BOOL isMinimized = !IsMaximized(targetWindowHandle);
            if (isMinimized)
            {
                ShowWindow(targetWindowHandle, SW_RESTORE);
            }

            // Bring the window to the front (activate it)

            DWORD currentThreadId = GetCurrentThreadId();
            DWORD targetThreadId = GetWindowThreadProcessId(targetWindowHandle, NULL);

            AttachThreadInput(currentThreadId, targetThreadId, TRUE);

            SetActiveWindow(targetWindowHandle);

            AttachThreadInput(currentThreadId, targetThreadId, FALSE);

            return 0;
        }
    }

    // App wasn't found, so start it

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));

    CreateProcess(
        NULL,
        commandLine,
        NULL,
        NULL,
        FALSE,
        0,
        NULL,
        NULL,
        &si,
        &pi);

    return 0;
}
Exemplo n.º 26
0
/* BrowserWindow::~BrowserWindow
 * BrowserWindow class destructor
 *******************************************************************/
BrowserWindow::~BrowserWindow()
{
	browser_maximised = IsMaximized();
	if (!IsMaximized())
		Misc::setWindowInfo("browser", GetSize().x, GetSize().y, GetPosition().x, GetPosition().y);
}
Exemplo n.º 27
0
internal LRESULT CALLBACK Win32MainWindowCallback(HWND window, UINT msg, WPARAM w_param, LPARAM l_param)
{
    if (EasyTab_HandleEvent(window, msg, l_param, w_param) == EASYTAB_OK) {
        return true;  // Tablet input
    }

    LRESULT result = 0;
    ImGuiIO& io = ImGui::GetIO();

    switch (msg) {
        // Mouse
        case WM_LBUTTONDOWN: {
            io.MouseDown[0] = true;
            return true;
        } break;

        case WM_LBUTTONUP: {
            io.MouseDown[0] = false;
            return true;
        } break;

        case WM_RBUTTONDOWN: {
            io.MouseDown[1] = true;
            return true;
        } break;

        case WM_RBUTTONUP: {
            io.MouseDown[1] = false;
            return true;
        } break;

        case WM_MBUTTONDOWN: {
            io.MouseDown[2] = true;
            return true;
        } break;

        case WM_MBUTTONUP: {
            io.MouseDown[2] = false;
            return true;
        } break;

        case WM_MOUSEWHEEL: {
            io.MouseWheel += GET_WHEEL_DELTA_WPARAM(w_param) > 0 ? +1.0f : -1.0f;
            return true;
        } break;

        case WM_MOUSEMOVE: {
            TRACKMOUSEEVENT track_param = {};
            track_param.dwFlags |= TME_LEAVE;
            track_param.hwndTrack = window;
            track_param.cbSize = sizeof(track_param);
            TrackMouseEvent(&track_param);
            io.MousePos.x = (signed short)(l_param);
            io.MousePos.y = (signed short)(l_param >> 16);
            return true;
        } break;

        case WM_MOUSELEAVE: {
            ImGui::GetIO().MouseDown[0] = false;
            ImGui::GetIO().MouseDown[1] = false;
            ImGui::GetIO().MouseDown[2] = false;
            return true;
        } break;

        // Keyboard
        case WM_KEYDOWN: {
            if (w_param < 256)
                io.KeysDown[w_param] = 1;
            return true;
        } break;

        case WM_KEYUP: {
            if (w_param < 256)
                io.KeysDown[w_param] = 0;
            return true;
        } break;

        case WM_CHAR: {
            // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
            if (w_param > 0 && w_param < 0x10000)
                io.AddInputCharacter((unsigned short)w_param);
            return true;
        } break;


        // window handling
        case WM_DESTROY: {
            mem.is_running = false;
            if (rendering_context)
            {
                wglMakeCurrent(NULL, NULL);
                wglDeleteContext(rendering_context);
            }
            ReleaseDC(window, device_context);
            PostQuitMessage(0);
        } break;

        case WM_PAINT: {
            PAINTSTRUCT paint;
            BeginPaint(window, &paint);
            // TODO: Redraw here
            EndPaint(window, &paint);
        } break;

        case WM_CLOSE: {
            // TODO: Handle this with a message to the user?
            mem.is_running = false;
        } break;

        case WM_SIZE: {
            int32 width, height;

            if (w_param == SIZE_MAXIMIZED) {
                int32 work_area_width = windows_work_area.right - windows_work_area.left;
                int32 work_area_height = windows_work_area.bottom - windows_work_area.top;
                SetWindowPos(window, HWND_TOP, windows_work_area.left, windows_work_area.top, work_area_width, work_area_height, NULL);
                width = work_area_width;
                height = work_area_height;
            }
            else
            {
                width = (int32) LOWORD(l_param);
                height = (int32) HIWORD(l_param);
            }

            core::resize(&mem, width, height);

            // Clear and swap buffers
            {
                if (mem.colors[PapayaCol_Clear]) {
                    glClearBufferfv(GL_COLOR, 0, (GLfloat*)&mem.colors[PapayaCol_Clear]);
                }
                SwapBuffers(device_context);
            }
        } break;

        // WM_NCHITTEST

        case WM_NCHITTEST: {
            const LONG border_width = 8; //in pixels
            RECT window_rect;
            GetWindowRect(window, &window_rect);
            long X = GET_X_LPARAM(l_param);
            long Y = GET_Y_LPARAM(l_param);

            if (!IsMaximized(window))
            {
                //bottom left corner
                if (X >= window_rect.left && X < window_rect.left + border_width &&
                    Y < window_rect.bottom && Y >= window_rect.bottom - border_width) {
                    return HTBOTTOMLEFT;
                }
                //bottom right corner
                if (X < window_rect.right && X >= window_rect.right - border_width &&
                    Y < window_rect.bottom && Y >= window_rect.bottom - border_width) {
                    return HTBOTTOMRIGHT;
                }
                //top left corner
                if (X >= window_rect.left && X < window_rect.left + border_width &&
                    Y >= window_rect.top && Y < window_rect.top + border_width) {
                    return HTTOPLEFT;
                }
                //top right corner
                if (X < window_rect.right && X >= window_rect.right - border_width &&
                    Y >= window_rect.top && Y < window_rect.top + border_width) {
                    return HTTOPRIGHT;
                }
                //left border
                if (X >= window_rect.left && X < window_rect.left + border_width) {
                    return HTLEFT;
                }
                //right border
                if (X < window_rect.right && X >= window_rect.right - border_width) {
                    return HTRIGHT;
                }
                //bottom border
                if (Y < window_rect.bottom && Y >= window_rect.bottom - border_width) {
                    return HTBOTTOM;
                }
                //top border
                if (Y >= window_rect.top && Y < window_rect.top + border_width) {
                    return HTTOP;
                }
            }

            if (Y - window_rect.top <= (float)mem.window.title_bar_height &&
                X > window_rect.left + 200.0f &&
                X < window_rect.right - (float)(mem.window.title_bar_buttons_width + 10)) {
                return HTCAPTION;
            }

            SetCursor(LoadCursor(NULL, IDC_ARROW));
            return HTCLIENT;
        } break;

        default: {
            result = DefWindowProcA(window, msg, w_param, l_param);
        } break;
    }

    return(result);
}