• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • platform
  • graphics
IntSize.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef IntSize_h
27 #define IntSize_h
28 
29 #include <wtf/Platform.h>
30 
31 #if PLATFORM(CG)
32 typedef struct CGSize CGSize;
33 #endif
34 
35 #if PLATFORM(MAC)
36 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
37 typedef struct CGSize NSSize;
38 #else
39 typedef struct _NSSize NSSize;
40 #endif
41 #endif
42 
43 #if PLATFORM(WIN)
44 typedef struct tagSIZE SIZE;
45 #elif PLATFORM(QT)
46 #include <qglobal.h>
47 QT_BEGIN_NAMESPACE
48 class QSize;
49 QT_END_NAMESPACE
50 #endif
51 #if PLATFORM(SYMBIAN)
52 class TSize;
53 #endif
54 
55 namespace WebCore {
56 
57 class IntSize {
58 public:
59  IntSize() : m_width(0), m_height(0) { }
60  IntSize(int width, int height) : m_width(width), m_height(height) { }
61 
62  int width() const { return m_width; }
63  int height() const { return m_height; }
64 
65  void setWidth(int width) { m_width = width; }
66  void setHeight(int height) { m_height = height; }
67 
68  bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
69 
70  IntSize expandedTo(const IntSize& other) const
71  {
72  return IntSize(m_width > other.m_width ? m_width : other.m_width,
73  m_height > other.m_height ? m_height : other.m_height);
74  }
75 
76  IntSize shrunkTo(const IntSize& other) const
77  {
78  return IntSize(m_width < other.m_width ? m_width : other.m_width,
79  m_height < other.m_height ? m_height : other.m_height);
80  }
81 
82  void clampNegativeToZero()
83  {
84  *this = expandedTo(IntSize());
85  }
86 
87 #if PLATFORM(CG)
88  explicit IntSize(const CGSize&); // don't do this implicitly since it's lossy
89  operator CGSize() const;
90 #endif
91 
92 #if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
93  explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
94  operator NSSize() const;
95 #endif
96 
97 #if PLATFORM(WIN)
98  IntSize(const SIZE&);
99  operator SIZE() const;
100 #endif
101 
102 #if PLATFORM(QT)
103  IntSize(const QSize&);
104  operator QSize() const;
105 #endif
106 #if PLATFORM(SYMBIAN)
107  IntSize(const TSize&);
108  operator TSize() const;
109 #endif
110 
111 
112 private:
113  int m_width, m_height;
114 };
115 
116 inline IntSize& operator+=(IntSize& a, const IntSize& b)
117 {
118  a.setWidth(a.width() + b.width());
119  a.setHeight(a.height() + b.height());
120  return a;
121 }
122 
123 inline IntSize& operator-=(IntSize& a, const IntSize& b)
124 {
125  a.setWidth(a.width() - b.width());
126  a.setHeight(a.height() - b.height());
127  return a;
128 }
129 
130 inline IntSize operator+(const IntSize& a, const IntSize& b)
131 {
132  return IntSize(a.width() + b.width(), a.height() + b.height());
133 }
134 
135 inline IntSize operator-(const IntSize& a, const IntSize& b)
136 {
137  return IntSize(a.width() - b.width(), a.height() - b.height());
138 }
139 
140 inline IntSize operator-(const IntSize& size)
141 {
142  return IntSize(-size.width(), -size.height());
143 }
144 
145 inline bool operator==(const IntSize& a, const IntSize& b)
146 {
147  return a.width() == b.width() && a.height() == b.height();
148 }
149 
150 inline bool operator!=(const IntSize& a, const IntSize& b)
151 {
152  return a.width() != b.width() || a.height() != b.height();
153 }
154 
155 } // namespace WebCore
156 
157 #endif // IntSize_h
WebCore::IntSize::shrunkTo
IntSize shrunkTo(const IntSize &other) const
Definition: IntSize.h:76
WebCore::IntSize::height
int height() const
Definition: IntSize.h:63
WebCore::IntSize::IntSize
IntSize()
Definition: IntSize.h:59
WebCore::IntSize
Definition: IntSize.h:57
WebCore::IntSize::IntSize
IntSize(int width, int height)
Definition: IntSize.h:60
WebCore::operator!=
bool operator!=(const FloatPoint &a, const FloatPoint &b)
Definition: FloatPoint.h:135
WebCore::operator-
FloatSize operator-(const FloatPoint &a, const FloatPoint &b)
Definition: FloatPoint.h:120
WebCore::operator+
FloatPoint operator+(const FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:115
WebCore::operator==
bool operator==(const FloatPoint &a, const FloatPoint &b)
Definition: FloatPoint.h:130
WebCore::IntSize::width
int width() const
Definition: IntSize.h:62
WebCore::operator-=
FloatPoint & operator-=(FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:109
WebCore::IntSize::isEmpty
bool isEmpty() const
Definition: IntSize.h:68
QSize
WebCore::IntSize::setHeight
void setHeight(int height)
Definition: IntSize.h:66
WebCore::IntSize::expandedTo
IntSize expandedTo(const IntSize &other) const
Definition: IntSize.h:70
WebCore::IntSize::setWidth
void setWidth(int width)
Definition: IntSize.h:65
WebCore::operator+=
FloatPoint & operator+=(FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:103
WebCore::IntSize::clampNegativeToZero
void clampNegativeToZero()
Definition: IntSize.h:82
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal