PageRenderTime 246ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/opensource.apple.com/source/WebCore/WebCore-1298.39/platform/gtk/WidgetGtk.cpp

#
C++ | 167 lines | 120 code | 23 blank | 24 comment | 0 complexity | f6c10e454db9093bef24358ae6df62d6 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0, BSD-3-Clause, GPL-3.0, MPL-2.0, LGPL-2.0, LGPL-2.1, CC-BY-SA-3.0, IPL-1.0, ISC, AGPL-1.0, AGPL-3.0, JSON, Apache-2.0, 0BSD
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>WidgetGtk.cpp</title>
  6. <style type="text/css">
  7. .enscript-comment { font-style: italic; color: rgb(178,34,34); }
  8. .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
  9. .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
  10. .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
  11. .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
  12. .enscript-string { font-weight: bold; color: rgb(188,143,143); }
  13. .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
  14. .enscript-type { font-weight: bold; color: rgb(34,139,34); }
  15. .enscript-highlight { text-decoration: underline; color: 0; }
  16. </style>
  17. </head>
  18. <body id="top">
  19. <h1 style="margin:8px;" id="f1">WidgetGtk.cpp&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
  20. <hr/>
  21. <div></div>
  22. <pre>
  23. <span class="enscript-comment">/*
  24. * Copyright (C) 2006 Michael Emmel <a href="mailto:mike.emmel@gmail.com">mike.emmel@gmail.com</a>
  25. * Copyright (C) 2007, 2009 Holger Hans Peter Freyther
  26. * All rights reserved.
  27. *
  28. * Redistribution and use in source and binary forms, with or without
  29. * modification, are permitted provided that the following conditions
  30. * are met:
  31. * 1. Redistributions of source code must retain the above copyright
  32. * notice, this list of conditions and the following disclaimer.
  33. * 2. Redistributions in binary form must reproduce the above copyright
  34. * notice, this list of conditions and the following disclaimer in the
  35. * documentation and/or other materials provided with the distribution.
  36. *
  37. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  38. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  39. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  40. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  41. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  42. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  43. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  44. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  45. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  46. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  47. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  48. */</span>
  49. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;config.h&quot;</span>
  50. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;Widget.h&quot;</span>
  51. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;Chrome.h&quot;</span>
  52. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;Cursor.h&quot;</span>
  53. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;Frame.h&quot;</span>
  54. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;FrameView.h&quot;</span>
  55. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;GraphicsContext.h&quot;</span>
  56. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;GtkVersioning.h&quot;</span>
  57. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;HostWindow.h&quot;</span>
  58. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;IntRect.h&quot;</span>
  59. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;Page.h&quot;</span>
  60. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;RenderObject.h&quot;</span>
  61. #<span class="enscript-reference">include</span> <span class="enscript-string">&lt;gdk/gdk.h&gt;</span>
  62. #<span class="enscript-reference">include</span> <span class="enscript-string">&lt;gtk/gtk.h&gt;</span>
  63. namespace WebCore {
  64. <span class="enscript-function-name">Widget::Widget</span>(PlatformWidget widget)
  65. {
  66. init(widget);
  67. }
  68. <span class="enscript-function-name">Widget::~Widget</span>()
  69. {
  70. ASSERT(!parent());
  71. releasePlatformWidget();
  72. }
  73. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setFocus</span>(<span class="enscript-type">bool</span> focused)
  74. {
  75. <span class="enscript-keyword">if</span> (!focused)
  76. <span class="enscript-keyword">return</span>;
  77. GtkWidget* widget = platformWidget() ? platformWidget() : root()-&gt;hostWindow()-&gt;platformPageClient();
  78. <span class="enscript-keyword">if</span> (widget) {
  79. gtk_widget_grab_focus(widget);
  80. <span class="enscript-keyword">return</span>;
  81. }
  82. <span class="enscript-comment">// We are running WK2.
  83. </span> <span class="enscript-keyword">if</span> (Frame* frame = Frame::frameForWidget(<span class="enscript-keyword">this</span>))
  84. frame-&gt;page()-&gt;chrome()-&gt;focus();
  85. }
  86. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setCursor</span>(<span class="enscript-type">const</span> Cursor&amp; cursor)
  87. {
  88. ScrollView* view = root();
  89. <span class="enscript-keyword">if</span> (!view)
  90. <span class="enscript-keyword">return</span>;
  91. view-&gt;hostWindow()-&gt;setCursor(cursor);
  92. }
  93. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::show</span>()
  94. {
  95. setSelfVisible(true);
  96. <span class="enscript-keyword">if</span> (isParentVisible() &amp;&amp; platformWidget())
  97. gtk_widget_show(platformWidget());
  98. }
  99. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::hide</span>()
  100. {
  101. setSelfVisible(false);
  102. <span class="enscript-keyword">if</span> (isParentVisible() &amp;&amp; platformWidget())
  103. gtk_widget_hide(platformWidget());
  104. }
  105. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::paint</span>(GraphicsContext* context, <span class="enscript-type">const</span> IntRect&amp; rect)
  106. {
  107. }
  108. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setIsSelected</span>(<span class="enscript-type">bool</span> isSelected)
  109. {
  110. <span class="enscript-keyword">if</span> (!platformWidget())
  111. <span class="enscript-keyword">return</span>;
  112. <span class="enscript-comment">// See if the platformWidget has a webkit-widget-is-selected property
  113. </span> <span class="enscript-comment">// and set it afterwards.
  114. </span> GParamSpec* spec = g_object_class_find_property(G_OBJECT_GET_CLASS(platformWidget()),
  115. <span class="enscript-string">&quot;webkit-widget-is-selected&quot;</span>);
  116. <span class="enscript-keyword">if</span> (!spec)
  117. <span class="enscript-keyword">return</span>;
  118. g_object_set(platformWidget(), <span class="enscript-string">&quot;webkit-widget-is-selected&quot;</span>, isSelected, NULL);
  119. }
  120. IntRect <span class="enscript-function-name">Widget::frameRect</span>() <span class="enscript-type">const</span>
  121. {
  122. <span class="enscript-keyword">return</span> m_frame;
  123. }
  124. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setFrameRect</span>(<span class="enscript-type">const</span> IntRect&amp; rect)
  125. {
  126. m_frame = rect;
  127. frameRectsChanged();
  128. }
  129. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::releasePlatformWidget</span>()
  130. {
  131. <span class="enscript-keyword">if</span> (!platformWidget())
  132. <span class="enscript-keyword">return</span>;
  133. g_object_unref(platformWidget());
  134. }
  135. <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::retainPlatformWidget</span>()
  136. {
  137. <span class="enscript-keyword">if</span> (!platformWidget())
  138. <span class="enscript-keyword">return</span>;
  139. g_object_ref_sink(platformWidget());
  140. }
  141. }
  142. </pre>
  143. <hr />
  144. </body></html>