LibreOffice Module vcl (master)  1
fixed.hxx
Go to the documentation of this file.
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 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
25 
26 #include <vcl/dllapi.h>
27 #include <vcl/toolkit/edit.hxx>
28 #include <vcl/ctrl.hxx>
29 #include <vcl/image.hxx>
30 
32 {
33 private:
34  sal_Int32 m_nMaxWidthChars;
35  sal_Int32 m_nMinWidthChars;
37 
39  using Window::ImplInit;
40  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
41  SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
42  SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, SystemTextColorFlags nSystemTextColorFlags,
43  const Point& rPos, const Size& rSize, bool bFillLayout = false ) const;
44 public:
45  SAL_DLLPRIVATE static DrawTextFlags ImplGetTextStyle( WinBits nWinBits );
46 protected:
47  virtual void FillLayoutData() const override;
48  virtual const vcl::Font&
49  GetCanonicalFont( const StyleSettings& _rStyle ) const override;
50  virtual const Color&
51  GetCanonicalTextColor( const StyleSettings& _rStyle ) const override;
52 
53  virtual vcl::Window* getAccessibleRelationLabelFor() const override;
54 
55 public:
56  explicit FixedText( vcl::Window* pParent, WinBits nStyle = 0 );
57  virtual ~FixedText() override;
58  virtual void dispose() override;
59 
60  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
61 
62  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
63  virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
64  virtual void Resize() override;
65  virtual void StateChanged( StateChangedType nType ) override;
66  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
67 
68  void setMaxWidthChars(sal_Int32 nWidth);
69  void setMinWidthChars(sal_Int32 nWidth);
70  static Size CalcMinimumTextSize(Control const* pControl, tools::Long nMaxWidth = 0x7fffffff);
71  static Size getTextDimensions(Control const *pControl, const OUString &rTxt, tools::Long nMaxWidth);
72  Size CalcMinimumSize(tools::Long nMaxWidth = 0x7fffffff) const;
73  virtual Size GetOptimalSize() const override;
74  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
75  void set_mnemonic_widget(vcl::Window *pWindow);
76  vcl::Window* get_mnemonic_widget() const { return m_pMnemonicWindow; }
77 };
78 
79 class SelectableFixedText final : public Edit
80 {
81 public:
82  explicit SelectableFixedText( vcl::Window* pParent, WinBits nStyle );
83 
84  virtual void LoseFocus() override;
85  virtual void ApplySettings(vcl::RenderContext&) override;
86 };
87 
88 class VCL_DLLPUBLIC FixedLine final : public Control
89 {
90 private:
92  using Window::ImplInit;
93  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
94  SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
95  SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext);
96 
97  virtual void FillLayoutData() const override;
98  virtual const vcl::Font&
99  GetCanonicalFont( const StyleSettings& _rStyle ) const override;
100  virtual const Color&
101  GetCanonicalTextColor( const StyleSettings& _rStyle ) const override;
102 
103 public:
104  explicit FixedLine( vcl::Window* pParent, WinBits nStyle = WB_HORZ );
105 
106  virtual void ApplySettings(vcl::RenderContext&) override;
107 
108  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
109  virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
110  virtual void Resize() override;
111  virtual void StateChanged( StateChangedType nType ) override;
112  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
113 
114  virtual Size GetOptimalSize() const override;
115  virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
116 };
117 
118 class VCL_DLLPUBLIC FixedBitmap final : public Control
119 {
120 private:
122 
124  using Window::ImplInit;
125  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
126  SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
127  SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, const Point& rPos, const Size& rSize );
128 
129 public:
130  explicit FixedBitmap( vcl::Window* pParent, WinBits nStyle = 0 );
131 
132  virtual void ApplySettings(vcl::RenderContext&) override;
133 
134  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
135  virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
136  virtual void Resize() override;
137  virtual void StateChanged( StateChangedType nType ) override;
138  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
139 
140  void SetBitmap( const BitmapEx& rBitmap );
141 };
142 
144 {
145 private:
147 
148 private:
150  using Window::ImplInit;
151  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
152  SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
153 
154 protected:
155  SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev,
156  const Point& rPos, const Size& rSize );
157 public:
158  explicit FixedImage( vcl::Window* pParent, WinBits nStyle = 0 );
159 
160  virtual void ApplySettings(vcl::RenderContext&) override;
161 
162  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
163  virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
164  virtual void Resize() override;
165  virtual void StateChanged( StateChangedType nType ) override;
166  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
167  virtual Size GetOptimalSize() const override;
168 
169  void SetImage( const Image& rImage );
170  const Image& GetImage() const { return maImage; }
171 
172  const Image& GetModeImage( ) const { return maImage;}
173  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
174 
175  static Image loadThemeImage(const OUString &rFileName);
176 
177  void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
178 };
179 
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
const Image & GetImage() const
Definition: fixed.hxx:170
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:255
virtual void FillLayoutData() const
Definition: ctrl.cxx:79
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const
Definition: ctrl.cxx:407
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:412
DrawTextFlags
StateChangedType
Definition: window.hxx:289
const Image & GetModeImage() const
Definition: fixed.hxx:172
virtual void Draw(::OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags)
Definition: window.cxx:1826
sal_Int64 WinBits
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3355
SystemTextColorFlags
BitmapEx maBitmap
Definition: fixed.hxx:121
Definition: edit.hxx:55
sal_Int32 m_nMinWidthChars
Definition: fixed.hxx:35
virtual vcl::Window * getAccessibleRelationLabelFor() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:445
VclPtr< vcl::Window > m_pMnemonicWindow
Definition: fixed.hxx:36
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:57
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1439
SelectableFixedText(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:433
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:368
virtual void Resize() override
Definition: ctrl.cxx:73
sal_Int32 m_nMaxWidthChars
Definition: fixed.hxx:34
Definition: ctrl.hxx:81
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const
Definition: ctrl.cxx:402
virtual void LoseFocus() override
Definition: fixed.cxx:450
Definition: image.hxx:39
QPRO_FUNC_TYPE nType
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1041
vcl::Window * get_mnemonic_widget() const
Definition: fixed.hxx:76
void ImplInitSettings()
Definition: ctrl.cxx:422
WinBits const WB_HORZ
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
Image maImage
Definition: fixed.hxx:146