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/builder.hxx>
24 :
25 0 : SdHtmlAttrPreview::SdHtmlAttrPreview( vcl::Window* pParent, WinBits nStyle )
26 0 : :Control( pParent, nStyle )
27 : {
28 0 : }
29 :
30 0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSdHtmlAttrPreview(vcl::Window *pParent, VclBuilder::stringmap &rMap)
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 : return new SdHtmlAttrPreview(pParent, nWinStyle);
39 : }
40 :
41 0 : SdHtmlAttrPreview::~SdHtmlAttrPreview()
42 : {
43 0 : }
44 :
45 0 : void SdHtmlAttrPreview::Paint( const Rectangle& rRect )
46 : {
47 0 : DecorationView aDecoView( this );
48 :
49 0 : Rectangle aTextRect;
50 0 : aTextRect.SetSize(GetOutputSize());
51 :
52 0 : SetLineColor(m_aBackColor);
53 0 : SetFillColor(m_aBackColor);
54 0 : DrawRect(rRect);
55 0 : SetFillColor();
56 :
57 0 : int nHeight = (aTextRect.Bottom() - aTextRect.Top()) >> 2;
58 0 : aTextRect.Bottom() = nHeight + aTextRect.Top();
59 :
60 0 : SetTextColor(m_aTextColor);
61 : DrawText( aTextRect, SD_RESSTR(STR_HTMLATTR_TEXT),
62 0 : TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER );
63 :
64 0 : aTextRect.Move(0,nHeight);
65 0 : SetTextColor(m_aLinkColor);
66 : DrawText( aTextRect, SD_RESSTR(STR_HTMLATTR_LINK),
67 0 : TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER );
68 :
69 0 : aTextRect.Move(0,nHeight);
70 0 : SetTextColor(m_aALinkColor);
71 : DrawText( aTextRect, SD_RESSTR(STR_HTMLATTR_ALINK),
72 0 : TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER );
73 :
74 0 : aTextRect.Move(0,nHeight);
75 0 : SetTextColor(m_aVLinkColor);
76 : DrawText( aTextRect, SD_RESSTR(STR_HTMLATTR_VLINK),
77 0 : TEXT_DRAW_CENTER|TEXT_DRAW_VCENTER );
78 0 : }
79 :
80 0 : void SdHtmlAttrPreview::SetColors( Color& aBack, Color& aText, Color& aLink,
81 : Color& aVLink, Color& aALink )
82 : {
83 0 : m_aBackColor = aBack;
84 0 : m_aTextColor = aText;
85 0 : m_aLinkColor = aLink;
86 0 : m_aVLinkColor = aVLink;
87 0 : m_aALinkColor = aALink;
88 0 : }
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|