Line data Source code
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 : #include "htmlattr.hxx"
21 : #include "htmlex.hxx"
22 : #include <vcl/decoview.hxx>
23 : #include <vcl/builderfactory.hxx>
24 :
25 0 : SdHtmlAttrPreview::SdHtmlAttrPreview(vcl::Window* pParent, WinBits nStyle)
26 0 : : Control(pParent, nStyle)
27 : {
28 0 : }
29 :
30 0 : VCL_BUILDER_DECL_FACTORY(SdHtmlAttrPreview)
31 : {
32 0 : WinBits nWinStyle = 0;
33 :
34 0 : OString sBorder = VclBuilder::extractCustomProperty(rMap);
35 0 : if (!sBorder.isEmpty())
36 0 : nWinStyle |= WB_BORDER;
37 :
38 0 : rRet = VclPtr<SdHtmlAttrPreview>::Create(pParent, nWinStyle);
39 0 : }
40 :
41 0 : SdHtmlAttrPreview::~SdHtmlAttrPreview()
42 : {
43 0 : }
44 :
45 0 : void SdHtmlAttrPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
46 : {
47 0 : DecorationView aDecoView(&rRenderContext);
48 :
49 0 : Rectangle aTextRect;
50 0 : aTextRect.SetSize(GetOutputSize());
51 :
52 0 : rRenderContext.SetLineColor(m_aBackColor);
53 0 : rRenderContext.SetFillColor(m_aBackColor);
54 0 : rRenderContext.DrawRect(rRect);
55 0 : rRenderContext.SetFillColor();
56 :
57 0 : int nHeight = (aTextRect.Bottom() - aTextRect.Top()) >> 2;
58 0 : aTextRect.Bottom() = nHeight + aTextRect.Top();
59 :
60 0 : rRenderContext.SetTextColor(m_aTextColor);
61 0 : rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_TEXT), DrawTextFlags::Center | DrawTextFlags::VCenter);
62 :
63 0 : aTextRect.Move(0,nHeight);
64 0 : rRenderContext.SetTextColor(m_aLinkColor);
65 0 : rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_LINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
66 :
67 0 : aTextRect.Move(0,nHeight);
68 0 : rRenderContext.SetTextColor(m_aALinkColor);
69 0 : rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_ALINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
70 :
71 0 : aTextRect.Move(0,nHeight);
72 0 : rRenderContext.SetTextColor(m_aVLinkColor);
73 0 : rRenderContext.DrawText(aTextRect, SD_RESSTR(STR_HTMLATTR_VLINK), DrawTextFlags::Center | DrawTextFlags::VCenter);
74 0 : }
75 :
76 0 : void SdHtmlAttrPreview::SetColors(Color& aBack, Color& aText, Color& aLink,
77 : Color& aVLink, Color& aALink)
78 : {
79 0 : m_aBackColor = aBack;
80 0 : m_aTextColor = aText;
81 0 : m_aLinkColor = aLink;
82 0 : m_aVLinkColor = aVLink;
83 0 : m_aALinkColor = aALink;
84 0 : }
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|