/src/libreoffice/toolkit/source/hatchwindow/ipwin.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <tools/gen.hxx> |
23 | | #include <vcl/window.hxx> |
24 | | #include <array> |
25 | | |
26 | | /********************** SvResizeHelper *********************************** |
27 | | *************************************************************************/ |
28 | | class SvResizeHelper |
29 | | { |
30 | | Size aBorder; |
31 | | tools::Rectangle aOuter; |
32 | | short nGrab; // -1 no Grab, 0 - 7, 8 = Move, see FillHandle... |
33 | | Point aSelPos; |
34 | | /// Initial width/height ratio when starting drag |
35 | | std::optional<double> mofStartingRatio; |
36 | | public: |
37 | | SvResizeHelper(); |
38 | | |
39 | | short GetGrab() const |
40 | 0 | { |
41 | 0 | return nGrab; |
42 | 0 | } |
43 | | void SetBorderPixel(const Size & rBorderP) |
44 | 0 | { |
45 | 0 | aBorder = rBorderP; |
46 | 0 | } |
47 | | void SetOuterRectPixel(const tools::Rectangle& rRect) |
48 | 0 | { |
49 | 0 | aOuter = rRect; |
50 | 0 | } |
51 | | // Clockwise, start at upper left |
52 | | |
53 | | std::array<tools::Rectangle,8> FillHandleRectsPixel() const; |
54 | | std::array<tools::Rectangle,4> FillMoveRectsPixel() const; |
55 | | void Draw(vcl::RenderContext& rRenderContext); |
56 | | void InvalidateBorder( vcl::Window * ); |
57 | | bool SelectBegin( vcl::Window *, const Point & rPos, const bool bShiftPressed ); |
58 | | short SelectMove( vcl::Window * pWin, const Point & rPos, const bool bShiftPressed ); |
59 | | Point GetTrackPosPixel( const tools::Rectangle & rRect ) const; |
60 | | tools::Rectangle GetTrackRectPixel( const Point & rTrackPos, const bool bShiftPressed ) const; |
61 | | void ValidateRect( tools::Rectangle & rValidate ) const; |
62 | | bool SelectRelease( vcl::Window *, const Point & rPos, tools::Rectangle & rOutPosSize, const bool bShiftPressed ); |
63 | | void Release( vcl::Window * pWin ); |
64 | | }; |
65 | | |
66 | | /********************** SvResizeWindow *********************************** |
67 | | *************************************************************************/ |
68 | | class VCLXHatchWindow; |
69 | | class SvResizeWindow : public vcl::Window |
70 | | { |
71 | | PointerStyle m_aOldPointer; |
72 | | short m_nMoveGrab; // last pointer type |
73 | | SvResizeHelper m_aResizer; |
74 | | bool m_bActive; |
75 | | |
76 | | VCLXHatchWindow* m_pWrapper; |
77 | | public: |
78 | | SvResizeWindow( vcl::Window* pParent, VCLXHatchWindow* pWrapper ); |
79 | | |
80 | | void SetHatchBorderPixel( const Size & rSize ); |
81 | | |
82 | | void SelectMouse( const Point & rPos, const bool bShiftPressed ); |
83 | | virtual void MouseButtonUp( const MouseEvent & rEvt ) override; |
84 | | virtual void MouseMove( const MouseEvent & rEvt ) override; |
85 | | virtual void MouseButtonDown( const MouseEvent & rEvt ) override; |
86 | | virtual void KeyInput( const KeyEvent & rEvt ) override; |
87 | | virtual void Resize() override; |
88 | | virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle & ) override; |
89 | | virtual bool EventNotify( NotifyEvent& rNEvt ) override; |
90 | | virtual bool PreNotify( NotifyEvent& rNEvt ) override; |
91 | | }; |
92 | | |
93 | | |
94 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |