/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
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>WidgetGtk.cpp</title>
- <style type="text/css">
- .enscript-comment { font-style: italic; color: rgb(178,34,34); }
- .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
- .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
- .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
- .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
- .enscript-string { font-weight: bold; color: rgb(188,143,143); }
- .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
- .enscript-type { font-weight: bold; color: rgb(34,139,34); }
- .enscript-highlight { text-decoration: underline; color: 0; }
- </style>
- </head>
- <body id="top">
- <h1 style="margin:8px;" id="f1">WidgetGtk.cpp <span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
- <hr/>
- <div></div>
- <pre>
- <span class="enscript-comment">/*
- * Copyright (C) 2006 Michael Emmel <a href="mailto:mike.emmel@gmail.com">mike.emmel@gmail.com</a>
- * Copyright (C) 2007, 2009 Holger Hans Peter Freyther
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"config.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"Widget.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"Chrome.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"Cursor.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"Frame.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"FrameView.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"GraphicsContext.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"GtkVersioning.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"HostWindow.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"IntRect.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"Page.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"RenderObject.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string"><gdk/gdk.h></span>
- #<span class="enscript-reference">include</span> <span class="enscript-string"><gtk/gtk.h></span>
- namespace WebCore {
- <span class="enscript-function-name">Widget::Widget</span>(PlatformWidget widget)
- {
- init(widget);
- }
- <span class="enscript-function-name">Widget::~Widget</span>()
- {
- ASSERT(!parent());
- releasePlatformWidget();
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setFocus</span>(<span class="enscript-type">bool</span> focused)
- {
- <span class="enscript-keyword">if</span> (!focused)
- <span class="enscript-keyword">return</span>;
- GtkWidget* widget = platformWidget() ? platformWidget() : root()->hostWindow()->platformPageClient();
- <span class="enscript-keyword">if</span> (widget) {
- gtk_widget_grab_focus(widget);
- <span class="enscript-keyword">return</span>;
- }
- <span class="enscript-comment">// We are running WK2.
- </span> <span class="enscript-keyword">if</span> (Frame* frame = Frame::frameForWidget(<span class="enscript-keyword">this</span>))
- frame->page()->chrome()->focus();
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setCursor</span>(<span class="enscript-type">const</span> Cursor& cursor)
- {
- ScrollView* view = root();
- <span class="enscript-keyword">if</span> (!view)
- <span class="enscript-keyword">return</span>;
- view->hostWindow()->setCursor(cursor);
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::show</span>()
- {
- setSelfVisible(true);
- <span class="enscript-keyword">if</span> (isParentVisible() && platformWidget())
- gtk_widget_show(platformWidget());
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::hide</span>()
- {
- setSelfVisible(false);
- <span class="enscript-keyword">if</span> (isParentVisible() && platformWidget())
- gtk_widget_hide(platformWidget());
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::paint</span>(GraphicsContext* context, <span class="enscript-type">const</span> IntRect& rect)
- {
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setIsSelected</span>(<span class="enscript-type">bool</span> isSelected)
- {
- <span class="enscript-keyword">if</span> (!platformWidget())
- <span class="enscript-keyword">return</span>;
- <span class="enscript-comment">// See if the platformWidget has a webkit-widget-is-selected property
- </span> <span class="enscript-comment">// and set it afterwards.
- </span> GParamSpec* spec = g_object_class_find_property(G_OBJECT_GET_CLASS(platformWidget()),
- <span class="enscript-string">"webkit-widget-is-selected"</span>);
- <span class="enscript-keyword">if</span> (!spec)
- <span class="enscript-keyword">return</span>;
- g_object_set(platformWidget(), <span class="enscript-string">"webkit-widget-is-selected"</span>, isSelected, NULL);
- }
- IntRect <span class="enscript-function-name">Widget::frameRect</span>() <span class="enscript-type">const</span>
- {
- <span class="enscript-keyword">return</span> m_frame;
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::setFrameRect</span>(<span class="enscript-type">const</span> IntRect& rect)
- {
- m_frame = rect;
- frameRectsChanged();
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::releasePlatformWidget</span>()
- {
- <span class="enscript-keyword">if</span> (!platformWidget())
- <span class="enscript-keyword">return</span>;
- g_object_unref(platformWidget());
- }
- <span class="enscript-type">void</span> <span class="enscript-function-name">Widget::retainPlatformWidget</span>()
- {
- <span class="enscript-keyword">if</span> (!platformWidget())
- <span class="enscript-keyword">return</span>;
- g_object_ref_sink(platformWidget());
- }
- }
- </pre>
- <hr />
- </body></html>