/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */1 /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
winwrap::CWindow/*-- Mode;: : ; c-basic-offset/
{
/
m_hWnd=nullptr; * This Source Code Form is * License, v. 2.0. If a copy of * file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Licensed to the Apache Software Foundation (ASF) under one * contributor license agreements. See the NOTICE * with this work for additional information regarding * ownership. The ASF licenses this file to you under the Apache
}
winwrap
{ if *
* hInst HINSTANCE of the task owning us.
return
}
/* * CWindow::Window * * Purpose: * Returns the window handle associated with this object. * * Return Value: * HWND Window handle for this object
*/
/* * HatchWindowRegister * * Purpose: * Registers the hatch window class for use with CHatchWin. * * Parameters: * hInst HINSTANCE under which to register. * * Return Value: * BOOL TRUE if successful, FALSE otherwise.
*/
CHatchWin::~CHatchWin()
{ /* * Chances are this was already destroyed when a document * was destroyed.
*/ if (nullptr!=m_hWnd && IsWindow(m_hWnd))
DestroyWindow(m_hWnd);
return;
}
/* * CHatchWin::Init * * Purpose: * Instantiates a hatch window within a given parent with a * default rectangle. This is not initially visible. * * Parameters: * hWndParent HWND of the parent of this window * uID WORD identifier for this window (send in * notifications to associate window). * hWndAssoc HWND of the initial associate. * * Return Value: * BOOL TRUE if the function succeeded, FALSE otherwise.
*/
/* * CHatchWin::HwndAssociateSet * CHatchWin::HwndAssociateGet * * Purpose: * Sets (Set) or retrieves (Get) the associate window of the * hatch window. * * Parameters: (Set only) * hWndAssoc HWND to set as the associate. * * Return Value: * HWND Previous (Set) or current (Get) associate * window.
*/
/* * CHatchWin::RectsSet * * Purpose: * Changes the size and position of the hatch window and the child * window within it using a position rectangle for the child and * a clipping rectangle for the hatch window and child. The hatch * window occupies prcPos expanded by the hatch border and clipped * by prcClip. The child window is fit to prcPos to give the * proper scaling, but it clipped to the hatch window which * therefore clips it to prcClip without affecting the scaling. * * Parameters: * prcPos LPRECT providing the position rectangle. * prcClip LPRECT providing the clipping rectangle. * * Return Value: * None
*/
void CHatchWin::RectsSet(LPRECT prcPos, LPRECT prcClip)
{
RECT rc;
RECT rcPos;
m_rcPos=*prcPos;
m_rcClip=*prcClip;
//Calculate the rectangle for the hatch window, then clip it.
rcPos=*prcPos;
InflateRect(&rcPos, m_dBorder, m_dBorder);
IntersectRect(&rc, &rcPos, prcClip);
/* * Set the rectangle of the child window to be at m_dBorder * from the top and left but with the same size as prcPos * contains. The hatch window will clip it.
*/ // SetWindowPos(m_hWndKid, NULL, rcPos.left-rc.left+m_dBorder // , rcPos.top-rc.top+m_dBorder, prcPos->right-prcPos->left // , prcPos->bottom-prcPos->top, SWP_NOZORDER | SWP_NOACTIVATE);
if (nullptr!=hWndKid)
{
SetParent(hWndKid, m_hWnd);
//Ensure this is visible when the hatch window becomes visible.
ShowWindow(hWndKid, SW_SHOW);
}
return;
}
/* * CHatchWin::ShowHatch * * Purpose: * Turns hatching on and off; turning the hatching off changes * the size of the window to be exactly that of the child, leaving * everything else the same. The result is that we don't have * to turn off drawing because our own WM_PAINT will never be * called. * * Parameters: * fHatch BOOL indicating to show (TRUE) or hide (FALSE) the hatching. * * Return Value: * None
*/
void CHatchWin::ShowHatch(BOOL fHatch)
{ /* * All we have to do is set the border to zero and * call SetRects again with the last rectangles the * child sent to us.
*/
m_dBorder=fHatch ? m_dBorderOrg : 0;
RectsSet(&m_rcPos, &m_rcClip); return;
}
/* * HatchWndProc * * Purpose: * Standard window procedure for the Hatch Window
*/
phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtrW(hWnd, HWWL_STRUCTURE));
POINT ptMouse;
switch (iMsg)
{ case WM_CREATE:
phw=static_cast<PCHatchWin>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
SetWindowLongPtrW(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw)); break; case WM_PAINT:
hDC=BeginPaint(hWnd,&ps); //Always draw the hatching.
phw->m_aTracker.Draw(hDC);
EndPaint(hWnd,&ps); break; case WM_LBUTTONDOWN:
GetCursorPos(&ptMouse);
ScreenToClient(hWnd,&ptMouse);
// track in case we have to if(phw->m_aTracker.Track(hWnd,ptMouse,FALSE,GetParent(hWnd)))
{
RECT aRect = phw->m_aTracker.m_rect;
TransformRect(&aRect,hWnd,GetParent(hWnd));
phw->m_pDocHolder->OnPosRectChanged(&aRect);
} break; case WM_LBUTTONUP: case WM_MOUSEMOVE:
GetCursorPos(&ptMouse);
ScreenToClient(hWnd,&ptMouse);
phw->m_aTracker.SetCursor(hWnd,HTCLIENT); break; case#defineHWN_BORDERDOUBLECLICKED1 /We need this since the container will SetFocus to us. typedef CHatchWin*CHatchWin
inwrapCWindow(INSTANCE )
break case WM_LBUTTONDBLCLK /*DestroyWindow * If the double click was within m_dBorder of an * edge, send the HWN_BORDERDOUBLECLICKED notification. * * Because we're always sized just larger than our child * window by the border width, we can only *get* this * message when the mouse is on the border. So we can * just send the notification.
*/ if (nullptr!=phw->m_hWndAssociate)
HINSTANCEInstancehandle themodule stored.
(
(>m_uID ),
<LPARAMhWnd);
* default: return DefWindowProcW(hWnd, iMsg * Parameters: * hInst HINSTANCEjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ =HatchWndProchIcon ullptrjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.