2005-08-20 11:11:46 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2002
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2005-08-20 11:13:39 +04:00
|
|
|
* Brian Ryner <bryner@brianryner.com> (Original Author)
|
2007-06-05 07:26:43 +04:00
|
|
|
* Michael Ventnor <m.ventnor@gmail.com>
|
2007-12-05 04:09:29 +03:00
|
|
|
* Teune van Steeg <t.vansteeg@gmail.com>
|
2008-07-25 03:01:59 +04:00
|
|
|
* Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
|
2005-08-20 11:11:46 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsNativeThemeGTK.h"
|
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "gtkdrawing.h"
|
|
|
|
|
2005-08-20 11:13:34 +04:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2005-08-20 11:11:46 +04:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIContent.h"
|
2005-08-20 11:12:57 +04:00
|
|
|
#include "nsIViewManager.h"
|
2005-08-20 11:11:46 +04:00
|
|
|
#include "nsINameSpaceManager.h"
|
2005-08-23 06:11:54 +04:00
|
|
|
#include "nsGfxCIID.h"
|
2005-08-20 11:11:46 +04:00
|
|
|
#include "nsTransform2D.h"
|
2011-07-11 18:05:07 +04:00
|
|
|
#include "nsMenuFrame.h"
|
2005-08-20 11:13:04 +04:00
|
|
|
#include "prlink.h"
|
2006-02-23 04:01:29 +03:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2011-10-14 22:11:22 +04:00
|
|
|
#include "nsGkAtoms.h"
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 20:59:13 +04:00
|
|
|
#include "mozilla/Services.h"
|
2005-08-20 11:11:46 +04:00
|
|
|
|
|
|
|
#include <gdk/gdkprivate.h>
|
2007-11-13 11:43:03 +03:00
|
|
|
#include <gtk/gtk.h>
|
2005-08-20 11:13:14 +04:00
|
|
|
|
2005-10-06 08:02:10 +04:00
|
|
|
#include "gfxContext.h"
|
2005-11-29 23:12:29 +03:00
|
|
|
#include "gfxPlatformGtk.h"
|
2008-08-07 00:48:55 +04:00
|
|
|
#include "gfxGdkNativeRenderer.h"
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2010-11-13 11:19:38 +03:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED2(nsNativeThemeGTK, nsNativeTheme, nsITheme,
|
|
|
|
nsIObserver)
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
static int gLastGdkError;
|
2005-08-20 11:12:59 +04:00
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
nsNativeThemeGTK::nsNativeThemeGTK()
|
|
|
|
{
|
2005-08-20 11:13:04 +04:00
|
|
|
if (moz_gtk_init() != MOZ_GTK_SUCCESS) {
|
|
|
|
memset(mDisabledWidgetTypes, 0xff, sizeof(mDisabledWidgetTypes));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:34 +04:00
|
|
|
// We have to call moz_gtk_shutdown before the event loop stops running.
|
|
|
|
nsCOMPtr<nsIObserverService> obsServ =
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 20:59:13 +04:00
|
|
|
mozilla::services::GetObserverService();
|
2011-10-03 11:56:21 +04:00
|
|
|
obsServ->AddObserver(this, "xpcom-shutdown", false);
|
2005-08-20 11:13:34 +04:00
|
|
|
|
2005-08-20 11:12:57 +04:00
|
|
|
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
|
2005-08-20 11:13:43 +04:00
|
|
|
memset(mSafeWidgetStates, 0, sizeof(mSafeWidgetStates));
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsNativeThemeGTK::~nsNativeThemeGTK() {
|
2005-08-20 11:13:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeGTK::Observe(nsISupports *aSubject, const char *aTopic,
|
|
|
|
const PRUnichar *aData)
|
|
|
|
{
|
2005-09-14 02:06:41 +04:00
|
|
|
if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
|
2005-08-20 11:13:34 +04:00
|
|
|
moz_gtk_shutdown();
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("unexpected topic");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:14:11 +04:00
|
|
|
void
|
|
|
|
nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame)
|
2005-08-20 11:11:46 +04:00
|
|
|
{
|
2005-08-20 11:14:11 +04:00
|
|
|
nsIPresShell *shell = GetPresShell(aFrame);
|
2005-08-20 11:12:57 +04:00
|
|
|
if (!shell)
|
|
|
|
return;
|
|
|
|
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIViewManager* vm = shell->GetViewManager();
|
2005-08-20 11:12:57 +04:00
|
|
|
if (!vm)
|
|
|
|
return;
|
|
|
|
|
2011-12-24 07:52:25 +04:00
|
|
|
vm->InvalidateAllViews();
|
2005-08-20 11:12:57 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, PRUint32 aNamespace)
|
2009-06-02 07:58:06 +04:00
|
|
|
{
|
2009-06-02 08:18:25 +04:00
|
|
|
nsIContent *content = aFrame ? aFrame->GetContent() : nsnull;
|
2009-06-02 07:58:06 +04:00
|
|
|
if (!content)
|
|
|
|
return false;
|
2009-08-25 00:02:07 +04:00
|
|
|
return content->IsInNamespace(aNamespace);
|
2009-06-02 07:58:06 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsWidgetTypeDisabled(PRUint8* aDisabledVector, PRUint8 aWidgetType) {
|
2008-09-16 04:00:09 +04:00
|
|
|
return (aDisabledVector[aWidgetType >> 3] & (1 << (aWidgetType & 7))) != 0;
|
2005-08-20 11:12:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SetWidgetTypeDisabled(PRUint8* aDisabledVector, PRUint8 aWidgetType) {
|
|
|
|
aDisabledVector[aWidgetType >> 3] |= (1 << (aWidgetType & 7));
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:43 +04:00
|
|
|
static inline PRUint16
|
|
|
|
GetWidgetStateKey(PRUint8 aWidgetType, GtkWidgetState *aWidgetState)
|
|
|
|
{
|
|
|
|
return (aWidgetState->active |
|
|
|
|
aWidgetState->focused << 1 |
|
|
|
|
aWidgetState->inHover << 2 |
|
|
|
|
aWidgetState->disabled << 3 |
|
|
|
|
aWidgetState->isDefault << 4 |
|
|
|
|
aWidgetType << 5);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsWidgetStateSafe(PRUint8* aSafeVector,
|
2005-08-20 11:13:43 +04:00
|
|
|
PRUint8 aWidgetType,
|
|
|
|
GtkWidgetState *aWidgetState)
|
|
|
|
{
|
|
|
|
PRUint8 key = GetWidgetStateKey(aWidgetType, aWidgetState);
|
2008-09-16 04:00:09 +04:00
|
|
|
return (aSafeVector[key >> 3] & (1 << (key & 7))) != 0;
|
2005-08-20 11:13:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SetWidgetStateSafe(PRUint8 *aSafeVector,
|
|
|
|
PRUint8 aWidgetType,
|
|
|
|
GtkWidgetState *aWidgetState)
|
|
|
|
{
|
|
|
|
PRUint8 key = GetWidgetStateKey(aWidgetType, aWidgetState);
|
|
|
|
aSafeVector[key >> 3] |= (1 << (key & 7));
|
|
|
|
}
|
|
|
|
|
2007-12-14 10:26:03 +03:00
|
|
|
static GtkTextDirection GetTextDirection(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame)
|
|
|
|
return GTK_TEXT_DIR_NONE;
|
|
|
|
|
|
|
|
switch (aFrame->GetStyleVisibility()->mDirection) {
|
|
|
|
case NS_STYLE_DIRECTION_RTL:
|
|
|
|
return GTK_TEXT_DIR_RTL;
|
|
|
|
case NS_STYLE_DIRECTION_LTR:
|
|
|
|
return GTK_TEXT_DIR_LTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GTK_TEXT_DIR_NONE;
|
|
|
|
}
|
|
|
|
|
2010-07-15 02:31:41 +04:00
|
|
|
// Returns positive for negative margins (otherwise 0).
|
|
|
|
gint
|
|
|
|
nsNativeThemeGTK::GetTabMarginPixels(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nscoord margin =
|
|
|
|
IsBottomTab(aFrame) ? aFrame->GetUsedMargin().top
|
|
|
|
: aFrame->GetUsedMargin().bottom;
|
|
|
|
|
2011-06-02 16:56:50 +04:00
|
|
|
return NS_MIN<gint>(MOZ_GTK_TAB_MARGIN_MASK,
|
|
|
|
NS_MAX(0,
|
2010-07-15 02:31:41 +04:00
|
|
|
aFrame->PresContext()->AppUnitsToDevPixels(-margin)));
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-08-20 11:13:04 +04:00
|
|
|
nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
|
|
|
GtkThemeWidgetType& aGtkWidgetType,
|
|
|
|
GtkWidgetState* aState,
|
|
|
|
gint* aWidgetFlags)
|
2005-08-20 11:11:46 +04:00
|
|
|
{
|
2005-08-20 11:13:04 +04:00
|
|
|
if (aState) {
|
|
|
|
if (!aFrame) {
|
2005-08-20 11:13:14 +04:00
|
|
|
// reset the entire struct to zero
|
|
|
|
memset(aState, 0, sizeof(GtkWidgetState));
|
2005-08-20 11:13:04 +04:00
|
|
|
} else {
|
2005-08-20 11:13:48 +04:00
|
|
|
|
2005-08-20 11:13:51 +04:00
|
|
|
// For XUL checkboxes and radio buttons, the state of the parent
|
|
|
|
// determines our state.
|
2006-01-09 06:46:18 +03:00
|
|
|
nsIFrame *stateFrame = aFrame;
|
2008-11-03 16:12:59 +03:00
|
|
|
if (aFrame && ((aWidgetFlags && (aWidgetType == NS_THEME_CHECKBOX ||
|
|
|
|
aWidgetType == NS_THEME_RADIO)) ||
|
2006-01-09 06:46:18 +03:00
|
|
|
aWidgetType == NS_THEME_CHECKBOX_LABEL ||
|
|
|
|
aWidgetType == NS_THEME_RADIO_LABEL)) {
|
|
|
|
|
|
|
|
nsIAtom* atom = nsnull;
|
2009-08-25 00:02:07 +04:00
|
|
|
if (IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) {
|
2006-01-09 06:46:18 +03:00
|
|
|
if (aWidgetType == NS_THEME_CHECKBOX_LABEL ||
|
|
|
|
aWidgetType == NS_THEME_RADIO_LABEL) {
|
|
|
|
// Adjust stateFrame so GetContentState finds the correct state.
|
|
|
|
stateFrame = aFrame = aFrame->GetParent()->GetParent();
|
|
|
|
} else {
|
|
|
|
// GetContentState knows to look one frame up for radio/checkbox
|
|
|
|
// widgets, so don't adjust stateFrame here.
|
|
|
|
aFrame = aFrame->GetParent();
|
2005-08-20 11:13:51 +04:00
|
|
|
}
|
2006-02-23 04:01:29 +03:00
|
|
|
if (aWidgetFlags) {
|
|
|
|
if (!atom) {
|
2008-11-03 16:12:59 +03:00
|
|
|
atom = (aWidgetType == NS_THEME_CHECKBOX ||
|
2011-10-14 22:11:22 +04:00
|
|
|
aWidgetType == NS_THEME_CHECKBOX_LABEL) ? nsGkAtoms::checked
|
|
|
|
: nsGkAtoms::selected;
|
2006-02-23 04:01:29 +03:00
|
|
|
}
|
|
|
|
*aWidgetFlags = CheckBooleanAttr(aFrame, atom);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aWidgetFlags) {
|
2009-06-02 07:58:06 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> inputElt(do_QueryInterface(aFrame->GetContent()));
|
2009-01-22 03:07:44 +03:00
|
|
|
*aWidgetFlags = 0;
|
2006-02-23 04:01:29 +03:00
|
|
|
if (inputElt) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHTMLChecked;
|
2006-02-23 04:01:29 +03:00
|
|
|
inputElt->GetChecked(&isHTMLChecked);
|
2009-01-22 03:07:44 +03:00
|
|
|
if (isHTMLChecked)
|
|
|
|
*aWidgetFlags |= MOZ_GTK_WIDGET_CHECKED;
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:19:41 +03:00
|
|
|
if (GetIndeterminate(aFrame))
|
|
|
|
*aWidgetFlags |= MOZ_GTK_WIDGET_INCONSISTENT;
|
2006-01-09 06:46:18 +03:00
|
|
|
}
|
2005-08-20 11:13:51 +04:00
|
|
|
}
|
2008-01-27 07:32:31 +03:00
|
|
|
} else if (aWidgetType == NS_THEME_TOOLBAR_BUTTON_DROPDOWN ||
|
2010-07-27 18:57:47 +04:00
|
|
|
aWidgetType == NS_THEME_TREEVIEW_HEADER_SORTARROW ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_NEXT ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_UP ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_DOWN) {
|
|
|
|
// The state of an arrow comes from its parent.
|
|
|
|
stateFrame = aFrame = aFrame->GetParent();
|
2005-08-20 11:13:51 +04:00
|
|
|
}
|
2005-08-20 11:13:14 +04:00
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
nsEventStates eventState = GetContentState(stateFrame, aWidgetType);
|
2005-08-20 11:13:14 +04:00
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
aState->disabled = IsDisabled(aFrame, eventState) || IsReadOnly(aFrame);
|
2010-10-20 15:26:32 +04:00
|
|
|
aState->active = eventState.HasState(NS_EVENT_STATE_ACTIVE);
|
|
|
|
aState->focused = eventState.HasState(NS_EVENT_STATE_FOCUS);
|
|
|
|
aState->inHover = eventState.HasState(NS_EVENT_STATE_HOVER);
|
2007-09-02 20:38:54 +04:00
|
|
|
aState->isDefault = IsDefaultButton(aFrame);
|
2005-08-20 11:13:48 +04:00
|
|
|
aState->canDefault = FALSE; // XXX fix me
|
2007-12-03 12:14:18 +03:00
|
|
|
aState->depressed = FALSE;
|
2007-06-26 08:13:30 +04:00
|
|
|
|
2009-08-25 00:02:07 +04:00
|
|
|
if (IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) {
|
2007-06-27 10:38:51 +04:00
|
|
|
// For these widget types, some element (either a child or parent)
|
|
|
|
// actually has element focus, so we check the focused attribute
|
|
|
|
// to see whether to draw in the focused state.
|
|
|
|
if (aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
|
|
|
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
|
2007-12-21 14:30:00 +03:00
|
|
|
aWidgetType == NS_THEME_SPINNER_TEXTFIELD ||
|
2007-06-27 10:38:51 +04:00
|
|
|
aWidgetType == NS_THEME_RADIO_CONTAINER ||
|
|
|
|
aWidgetType == NS_THEME_RADIO_LABEL) {
|
|
|
|
aState->focused = IsFocused(aFrame);
|
2008-11-03 16:12:59 +03:00
|
|
|
} else if (aWidgetType == NS_THEME_RADIO ||
|
|
|
|
aWidgetType == NS_THEME_CHECKBOX) {
|
2007-06-27 10:38:51 +04:00
|
|
|
// In XUL, checkboxes and radios shouldn't have focus rings, their labels do
|
|
|
|
aState->focused = FALSE;
|
|
|
|
}
|
2008-02-10 11:30:05 +03:00
|
|
|
|
2007-06-27 10:38:51 +04:00
|
|
|
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
|
|
|
|
// for scrollbars we need to go up two to go from the thumb to
|
|
|
|
// the slider to the actual scrollbar object
|
|
|
|
nsIFrame *tmpFrame = aFrame->GetParent()->GetParent();
|
2007-06-26 08:13:30 +04:00
|
|
|
|
2011-10-14 22:11:22 +04:00
|
|
|
aState->curpos = CheckIntAttr(tmpFrame, nsGkAtoms::curpos, 0);
|
|
|
|
aState->maxpos = CheckIntAttr(tmpFrame, nsGkAtoms::maxpos, 100);
|
2007-06-27 02:16:07 +04:00
|
|
|
}
|
2007-06-26 08:13:30 +04:00
|
|
|
|
2007-06-27 10:38:51 +04:00
|
|
|
if (aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_DOWN ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT) {
|
2008-02-07 12:26:22 +03:00
|
|
|
// set the state to disabled when the scrollbar is scrolled to
|
|
|
|
// the beginning or the end, depending on the button type.
|
2011-10-14 22:11:22 +04:00
|
|
|
PRInt32 curpos = CheckIntAttr(aFrame, nsGkAtoms::curpos, 0);
|
|
|
|
PRInt32 maxpos = CheckIntAttr(aFrame, nsGkAtoms::maxpos, 100);
|
2008-02-07 12:26:22 +03:00
|
|
|
if ((curpos == 0 && (aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT)) ||
|
|
|
|
(curpos == maxpos &&
|
|
|
|
(aWidgetType == NS_THEME_SCROLLBAR_BUTTON_DOWN ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT)))
|
2011-10-03 11:56:21 +04:00
|
|
|
aState->disabled = true;
|
2008-02-07 12:26:22 +03:00
|
|
|
|
|
|
|
// In order to simulate native GTK scrollbar click behavior,
|
|
|
|
// we set the active attribute on the element to true if it's
|
|
|
|
// pressed with any mouse button.
|
|
|
|
// This allows us to show that it's active without setting :active
|
2011-10-14 22:11:22 +04:00
|
|
|
else if (CheckBooleanAttr(aFrame, nsGkAtoms::active))
|
2011-10-03 11:56:21 +04:00
|
|
|
aState->active = true;
|
2008-01-13 07:13:50 +03:00
|
|
|
|
|
|
|
if (aWidgetFlags) {
|
|
|
|
*aWidgetFlags = GetScrollbarButtonType(aFrame);
|
|
|
|
if (aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP < 2)
|
|
|
|
*aWidgetFlags |= MOZ_GTK_STEPPER_VERTICAL;
|
|
|
|
}
|
2007-06-27 02:16:07 +04:00
|
|
|
}
|
2007-06-26 08:13:30 +04:00
|
|
|
|
2007-06-27 10:38:51 +04:00
|
|
|
// menu item state is determined by the attribute "_moz-menuactive",
|
|
|
|
// and not by the mouse hovering (accessibility). as a special case,
|
|
|
|
// menus which are children of a menu bar are only marked as prelight
|
|
|
|
// if they are open, not on normal hover.
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_MENUITEM ||
|
|
|
|
aWidgetType == NS_THEME_CHECKMENUITEM ||
|
2007-11-29 01:45:21 +03:00
|
|
|
aWidgetType == NS_THEME_RADIOMENUITEM ||
|
2007-12-11 12:09:09 +03:00
|
|
|
aWidgetType == NS_THEME_MENUSEPARATOR ||
|
2007-11-29 01:45:21 +03:00
|
|
|
aWidgetType == NS_THEME_MENUARROW) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isTopLevel = false;
|
2011-07-11 18:05:07 +04:00
|
|
|
nsMenuFrame *menuFrame = do_QueryFrame(aFrame);
|
2007-06-27 10:38:51 +04:00
|
|
|
if (menuFrame) {
|
2007-07-04 19:49:38 +04:00
|
|
|
isTopLevel = menuFrame->IsOnMenuBar();
|
2007-06-27 10:38:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTopLevel) {
|
2007-07-04 19:49:38 +04:00
|
|
|
aState->inHover = menuFrame->IsOpen();
|
2007-12-04 09:28:34 +03:00
|
|
|
*aWidgetFlags |= MOZ_TOPLEVEL_MENU_ITEM;
|
2007-06-27 10:38:51 +04:00
|
|
|
} else {
|
2011-10-14 22:11:22 +04:00
|
|
|
aState->inHover = CheckBooleanAttr(aFrame, nsGkAtoms::menuactive);
|
2007-12-04 09:28:34 +03:00
|
|
|
*aWidgetFlags &= ~MOZ_TOPLEVEL_MENU_ITEM;
|
2007-06-27 10:38:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aState->active = FALSE;
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_CHECKMENUITEM ||
|
|
|
|
aWidgetType == NS_THEME_RADIOMENUITEM) {
|
2009-06-02 07:58:06 +04:00
|
|
|
*aWidgetFlags = 0;
|
|
|
|
if (aFrame && aFrame->GetContent()) {
|
|
|
|
*aWidgetFlags = aFrame->GetContent()->
|
2011-10-14 22:11:22 +04:00
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::checked,
|
|
|
|
nsGkAtoms::_true, eIgnoreCase);
|
2009-06-02 07:58:06 +04:00
|
|
|
}
|
2007-06-27 10:38:51 +04:00
|
|
|
}
|
2008-02-10 11:30:05 +03:00
|
|
|
}
|
2007-12-03 12:14:18 +03:00
|
|
|
|
|
|
|
// A button with drop down menu open or an activated toggle button
|
|
|
|
// should always appear depressed.
|
|
|
|
if (aWidgetType == NS_THEME_BUTTON ||
|
|
|
|
aWidgetType == NS_THEME_TOOLBAR_BUTTON ||
|
2008-01-13 05:56:01 +03:00
|
|
|
aWidgetType == NS_THEME_TOOLBAR_DUAL_BUTTON ||
|
2008-01-27 07:32:31 +03:00
|
|
|
aWidgetType == NS_THEME_TOOLBAR_BUTTON_DROPDOWN ||
|
2008-01-27 08:11:15 +03:00
|
|
|
aWidgetType == NS_THEME_DROPDOWN ||
|
|
|
|
aWidgetType == NS_THEME_DROPDOWN_BUTTON) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool menuOpen = IsOpenButton(aFrame);
|
2007-12-03 12:14:18 +03:00
|
|
|
aState->depressed = IsCheckedButton(aFrame) || menuOpen;
|
|
|
|
// we must not highlight buttons with open drop down menus on hover.
|
|
|
|
aState->inHover = aState->inHover && !menuOpen;
|
|
|
|
}
|
2008-02-10 11:30:04 +03:00
|
|
|
|
|
|
|
// When the input field of the drop down button has focus, some themes
|
|
|
|
// should draw focus for the drop down button as well.
|
|
|
|
if (aWidgetType == NS_THEME_DROPDOWN_BUTTON && aWidgetFlags) {
|
2011-10-14 22:11:22 +04:00
|
|
|
*aWidgetFlags = CheckBooleanAttr(aFrame, nsGkAtoms::parentfocused);
|
2008-02-10 11:30:04 +03:00
|
|
|
}
|
2005-08-20 11:13:48 +04:00
|
|
|
}
|
2005-08-20 11:13:04 +04:00
|
|
|
}
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
2005-08-20 11:12:57 +04:00
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
switch (aWidgetType) {
|
2005-08-20 11:11:47 +04:00
|
|
|
case NS_THEME_BUTTON:
|
2005-08-20 11:12:11 +04:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON:
|
2005-08-20 11:14:07 +04:00
|
|
|
case NS_THEME_TOOLBAR_DUAL_BUTTON:
|
2005-08-20 11:13:04 +04:00
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = (aWidgetType == NS_THEME_BUTTON) ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE;
|
|
|
|
aGtkWidgetType = MOZ_GTK_BUTTON;
|
2005-08-20 11:11:46 +04:00
|
|
|
break;
|
|
|
|
case NS_THEME_CHECKBOX:
|
2005-08-20 11:12:15 +04:00
|
|
|
case NS_THEME_RADIO:
|
2008-11-03 16:12:59 +03:00
|
|
|
aGtkWidgetType = (aWidgetType == NS_THEME_RADIO) ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON;
|
2005-08-20 11:13:04 +04:00
|
|
|
break;
|
2005-08-20 11:11:47 +04:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_SCROLLBAR_BUTTON;
|
2005-08-20 11:11:47 +04:00
|
|
|
break;
|
2005-08-20 11:12:11 +04:00
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
2005-08-20 11:13:14 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_VERTICAL;
|
|
|
|
break;
|
2005-08-20 11:12:11 +04:00
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
2005-08-20 11:13:14 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL;
|
2005-08-20 11:12:11 +04:00
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
2005-08-20 11:13:14 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL;
|
|
|
|
break;
|
2005-08-20 11:12:11 +04:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
2005-08-20 11:13:14 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
|
2005-08-20 11:12:11 +04:00
|
|
|
break;
|
2007-12-21 14:30:29 +03:00
|
|
|
case NS_THEME_SPINNER:
|
|
|
|
aGtkWidgetType = MOZ_GTK_SPINBUTTON;
|
|
|
|
break;
|
2006-07-13 21:40:49 +04:00
|
|
|
case NS_THEME_SPINNER_UP_BUTTON:
|
|
|
|
aGtkWidgetType = MOZ_GTK_SPINBUTTON_UP;
|
|
|
|
break;
|
|
|
|
case NS_THEME_SPINNER_DOWN_BUTTON:
|
|
|
|
aGtkWidgetType = MOZ_GTK_SPINBUTTON_DOWN;
|
|
|
|
break;
|
2007-12-21 14:30:29 +03:00
|
|
|
case NS_THEME_SPINNER_TEXTFIELD:
|
|
|
|
aGtkWidgetType = MOZ_GTK_SPINBUTTON_ENTRY;
|
|
|
|
break;
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = GTK_ORIENTATION_HORIZONTAL;
|
|
|
|
aGtkWidgetType = MOZ_GTK_SCALE_HORIZONTAL;
|
|
|
|
break;
|
|
|
|
case NS_THEME_SCALE_THUMB_HORIZONTAL:
|
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = GTK_ORIENTATION_HORIZONTAL;
|
|
|
|
aGtkWidgetType = MOZ_GTK_SCALE_THUMB_HORIZONTAL;
|
|
|
|
break;
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = GTK_ORIENTATION_VERTICAL;
|
|
|
|
aGtkWidgetType = MOZ_GTK_SCALE_VERTICAL;
|
|
|
|
break;
|
2007-12-03 12:13:29 +03:00
|
|
|
case NS_THEME_TOOLBAR_SEPARATOR:
|
|
|
|
aGtkWidgetType = MOZ_GTK_TOOLBAR_SEPARATOR;
|
|
|
|
break;
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_THUMB_VERTICAL:
|
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = GTK_ORIENTATION_VERTICAL;
|
|
|
|
aGtkWidgetType = MOZ_GTK_SCALE_THUMB_VERTICAL;
|
|
|
|
break;
|
2005-08-20 11:12:11 +04:00
|
|
|
case NS_THEME_TOOLBAR_GRIPPER:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_GRIPPER;
|
2005-08-20 11:12:11 +04:00
|
|
|
break;
|
2007-11-09 10:32:54 +03:00
|
|
|
case NS_THEME_RESIZER:
|
|
|
|
aGtkWidgetType = MOZ_GTK_RESIZER;
|
|
|
|
break;
|
2005-08-20 11:12:17 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_ENTRY;
|
2005-08-20 11:12:17 +04:00
|
|
|
break;
|
2008-06-23 12:50:52 +04:00
|
|
|
case NS_THEME_TEXTFIELD_CARET:
|
|
|
|
aGtkWidgetType = MOZ_GTK_ENTRY_CARET;
|
|
|
|
break;
|
2007-11-07 12:14:58 +03:00
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
|
|
|
aGtkWidgetType = MOZ_GTK_TREEVIEW;
|
|
|
|
break;
|
|
|
|
case NS_THEME_TREEVIEW_HEADER_CELL:
|
2008-03-18 22:35:23 +03:00
|
|
|
if (aWidgetFlags) {
|
|
|
|
// In this case, the flag denotes whether the header is the sorted one or not
|
|
|
|
if (GetTreeSortDirection(aFrame) == eTreeSortDirection_Natural)
|
2011-10-03 11:56:21 +04:00
|
|
|
*aWidgetFlags = false;
|
2008-03-18 22:35:23 +03:00
|
|
|
else
|
2011-10-03 11:56:21 +04:00
|
|
|
*aWidgetFlags = true;
|
2008-03-18 22:35:23 +03:00
|
|
|
}
|
2007-11-07 12:14:58 +03:00
|
|
|
aGtkWidgetType = MOZ_GTK_TREE_HEADER_CELL;
|
|
|
|
break;
|
2007-11-13 11:43:03 +03:00
|
|
|
case NS_THEME_TREEVIEW_HEADER_SORTARROW:
|
|
|
|
if (aWidgetFlags) {
|
|
|
|
switch (GetTreeSortDirection(aFrame)) {
|
|
|
|
case eTreeSortDirection_Ascending:
|
|
|
|
*aWidgetFlags = GTK_ARROW_DOWN;
|
|
|
|
break;
|
|
|
|
case eTreeSortDirection_Descending:
|
|
|
|
*aWidgetFlags = GTK_ARROW_UP;
|
|
|
|
break;
|
|
|
|
case eTreeSortDirection_Natural:
|
|
|
|
default:
|
|
|
|
/* GTK_ARROW_NONE is implemented since GTK 2.10
|
|
|
|
* This prevents the treecolums from getting smaller
|
|
|
|
* and wider when switching sort direction off and on
|
|
|
|
* */
|
|
|
|
#if GTK_CHECK_VERSION(2,10,0)
|
|
|
|
*aWidgetFlags = GTK_ARROW_NONE;
|
|
|
|
#else
|
2011-10-03 11:56:21 +04:00
|
|
|
return false; // Don't draw when we shouldn't
|
2007-11-13 11:43:03 +03:00
|
|
|
#endif // GTK_CHECK_VERSION(2,10,0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aGtkWidgetType = MOZ_GTK_TREE_HEADER_SORTARROW;
|
|
|
|
break;
|
2007-11-15 06:47:16 +03:00
|
|
|
case NS_THEME_TREEVIEW_TWISTY:
|
2008-01-03 10:07:32 +03:00
|
|
|
aGtkWidgetType = MOZ_GTK_TREEVIEW_EXPANDER;
|
2007-11-15 06:47:16 +03:00
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = GTK_EXPANDER_COLLAPSED;
|
|
|
|
break;
|
|
|
|
case NS_THEME_TREEVIEW_TWISTY_OPEN:
|
2008-01-03 10:07:32 +03:00
|
|
|
aGtkWidgetType = MOZ_GTK_TREEVIEW_EXPANDER;
|
2007-11-15 06:47:16 +03:00
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = GTK_EXPANDER_EXPANDED;
|
|
|
|
break;
|
2005-08-20 11:14:05 +04:00
|
|
|
case NS_THEME_DROPDOWN:
|
|
|
|
aGtkWidgetType = MOZ_GTK_DROPDOWN;
|
2008-03-25 03:34:27 +03:00
|
|
|
if (aWidgetFlags)
|
2009-08-25 00:02:07 +04:00
|
|
|
*aWidgetFlags = IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML);
|
2005-08-20 11:14:05 +04:00
|
|
|
break;
|
|
|
|
case NS_THEME_DROPDOWN_TEXT:
|
2011-10-03 11:56:21 +04:00
|
|
|
return false; // nothing to do, but prevents the bg from being drawn
|
2008-01-14 14:12:29 +03:00
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD:
|
|
|
|
aGtkWidgetType = MOZ_GTK_DROPDOWN_ENTRY;
|
|
|
|
break;
|
2005-08-20 11:12:17 +04:00
|
|
|
case NS_THEME_DROPDOWN_BUTTON:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_DROPDOWN_ARROW;
|
2005-08-20 11:12:17 +04:00
|
|
|
break;
|
2008-01-17 13:24:31 +03:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
|
2010-07-27 18:57:47 +04:00
|
|
|
case NS_THEME_BUTTON_ARROW_DOWN:
|
|
|
|
case NS_THEME_BUTTON_ARROW_UP:
|
|
|
|
case NS_THEME_BUTTON_ARROW_NEXT:
|
|
|
|
case NS_THEME_BUTTON_ARROW_PREVIOUS:
|
2008-01-17 13:24:31 +03:00
|
|
|
aGtkWidgetType = MOZ_GTK_TOOLBARBUTTON_ARROW;
|
2010-07-27 18:57:47 +04:00
|
|
|
if (aWidgetFlags) {
|
|
|
|
*aWidgetFlags = GTK_ARROW_DOWN;
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_BUTTON_ARROW_UP)
|
|
|
|
*aWidgetFlags = GTK_ARROW_UP;
|
|
|
|
else if (aWidgetType == NS_THEME_BUTTON_ARROW_NEXT)
|
|
|
|
*aWidgetFlags = GTK_ARROW_RIGHT;
|
|
|
|
else if (aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS)
|
|
|
|
*aWidgetFlags = GTK_ARROW_LEFT;
|
|
|
|
}
|
2008-01-17 13:24:31 +03:00
|
|
|
break;
|
2005-08-20 11:12:19 +04:00
|
|
|
case NS_THEME_CHECKBOX_CONTAINER:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_CHECKBUTTON_CONTAINER;
|
|
|
|
break;
|
2005-08-20 11:12:19 +04:00
|
|
|
case NS_THEME_RADIO_CONTAINER:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_RADIOBUTTON_CONTAINER;
|
2005-08-20 11:12:22 +04:00
|
|
|
break;
|
2005-08-20 11:14:00 +04:00
|
|
|
case NS_THEME_CHECKBOX_LABEL:
|
|
|
|
aGtkWidgetType = MOZ_GTK_CHECKBUTTON_LABEL;
|
|
|
|
break;
|
|
|
|
case NS_THEME_RADIO_LABEL:
|
|
|
|
aGtkWidgetType = MOZ_GTK_RADIOBUTTON_LABEL;
|
|
|
|
break;
|
2005-08-20 11:13:48 +04:00
|
|
|
case NS_THEME_TOOLBAR:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_TOOLBAR;
|
2005-08-20 11:12:19 +04:00
|
|
|
break;
|
2005-08-20 11:12:27 +04:00
|
|
|
case NS_THEME_TOOLTIP:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_TOOLTIP;
|
2005-08-20 11:12:27 +04:00
|
|
|
break;
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_STATUSBAR_PANEL:
|
2007-11-15 10:35:41 +03:00
|
|
|
case NS_THEME_STATUSBAR_RESIZER_PANEL:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_FRAME;
|
2005-08-20 11:12:28 +04:00
|
|
|
break;
|
2005-08-20 11:12:29 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_PROGRESSBAR;
|
2005-08-20 11:12:29 +04:00
|
|
|
break;
|
|
|
|
case NS_THEME_PROGRESSBAR_CHUNK:
|
|
|
|
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
|
2011-05-05 17:11:35 +04:00
|
|
|
{
|
|
|
|
nsIFrame* stateFrame = aFrame->GetParent();
|
|
|
|
nsEventStates eventStates = GetContentState(stateFrame, aWidgetType);
|
|
|
|
|
|
|
|
aGtkWidgetType = IsIndeterminateProgress(stateFrame, eventStates)
|
2011-05-16 14:59:10 +04:00
|
|
|
? (stateFrame->GetStyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL)
|
|
|
|
? MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE
|
|
|
|
: MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE
|
2011-05-05 17:11:35 +04:00
|
|
|
: MOZ_GTK_PROGRESS_CHUNK;
|
|
|
|
}
|
2005-08-20 11:12:29 +04:00
|
|
|
break;
|
2008-02-15 08:28:44 +03:00
|
|
|
case NS_THEME_TAB_SCROLLARROW_BACK:
|
|
|
|
case NS_THEME_TAB_SCROLLARROW_FORWARD:
|
|
|
|
if (aWidgetFlags)
|
|
|
|
*aWidgetFlags = aWidgetType == NS_THEME_TAB_SCROLLARROW_BACK ?
|
|
|
|
GTK_ARROW_LEFT : GTK_ARROW_RIGHT;
|
|
|
|
aGtkWidgetType = MOZ_GTK_TAB_SCROLLARROW;
|
|
|
|
break;
|
2005-08-20 11:12:31 +04:00
|
|
|
case NS_THEME_TAB_PANELS:
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_TABPANELS;
|
2005-08-20 11:12:31 +04:00
|
|
|
break;
|
2005-08-20 11:12:30 +04:00
|
|
|
case NS_THEME_TAB:
|
|
|
|
{
|
2005-08-20 11:13:04 +04:00
|
|
|
if (aWidgetFlags) {
|
2007-12-21 14:51:48 +03:00
|
|
|
/* First bits will be used to store max(0,-bmargin) where bmargin
|
|
|
|
* is the bottom margin of the tab in pixels (resp. top margin,
|
|
|
|
* for bottom tabs). */
|
|
|
|
if (IsBottomTab(aFrame)) {
|
|
|
|
*aWidgetFlags = MOZ_GTK_TAB_BOTTOM;
|
|
|
|
} else {
|
|
|
|
*aWidgetFlags = 0;
|
|
|
|
}
|
|
|
|
|
2010-07-15 02:31:41 +04:00
|
|
|
*aWidgetFlags |= GetTabMarginPixels(aFrame);
|
2005-08-20 11:12:32 +04:00
|
|
|
|
2007-12-21 14:51:48 +03:00
|
|
|
if (IsSelectedTab(aFrame))
|
2005-08-20 11:13:04 +04:00
|
|
|
*aWidgetFlags |= MOZ_GTK_TAB_SELECTED;
|
2005-08-20 11:12:32 +04:00
|
|
|
|
2007-12-21 14:51:48 +03:00
|
|
|
if (IsFirstTab(aFrame))
|
2005-08-20 11:13:33 +04:00
|
|
|
*aWidgetFlags |= MOZ_GTK_TAB_FIRST;
|
2005-08-20 11:13:04 +04:00
|
|
|
}
|
2005-08-20 11:12:30 +04:00
|
|
|
|
2005-08-20 11:13:04 +04:00
|
|
|
aGtkWidgetType = MOZ_GTK_TAB;
|
2005-08-20 11:12:30 +04:00
|
|
|
}
|
2005-08-20 11:13:04 +04:00
|
|
|
break;
|
2007-12-21 14:17:01 +03:00
|
|
|
case NS_THEME_SPLITTER:
|
|
|
|
if (IsHorizontal(aFrame))
|
|
|
|
aGtkWidgetType = MOZ_GTK_SPLITTER_VERTICAL;
|
|
|
|
else
|
|
|
|
aGtkWidgetType = MOZ_GTK_SPLITTER_HORIZONTAL;
|
|
|
|
break;
|
2005-08-20 11:13:48 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
aGtkWidgetType = MOZ_GTK_MENUBAR;
|
|
|
|
break;
|
|
|
|
case NS_THEME_MENUPOPUP:
|
|
|
|
aGtkWidgetType = MOZ_GTK_MENUPOPUP;
|
|
|
|
break;
|
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
aGtkWidgetType = MOZ_GTK_MENUITEM;
|
|
|
|
break;
|
2007-12-11 12:09:09 +03:00
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
aGtkWidgetType = MOZ_GTK_MENUSEPARATOR;
|
|
|
|
break;
|
2007-11-29 01:45:21 +03:00
|
|
|
case NS_THEME_MENUARROW:
|
|
|
|
aGtkWidgetType = MOZ_GTK_MENUARROW;
|
|
|
|
break;
|
2005-08-20 11:14:21 +04:00
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
aGtkWidgetType = MOZ_GTK_CHECKMENUITEM;
|
|
|
|
break;
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
|
|
|
aGtkWidgetType = MOZ_GTK_RADIOMENUITEM;
|
|
|
|
break;
|
2005-08-20 11:13:45 +04:00
|
|
|
case NS_THEME_WINDOW:
|
|
|
|
case NS_THEME_DIALOG:
|
|
|
|
aGtkWidgetType = MOZ_GTK_WINDOW;
|
|
|
|
break;
|
2005-08-20 11:13:04 +04:00
|
|
|
default:
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2005-08-20 11:13:04 +04:00
|
|
|
}
|
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
class ThemeRenderer : public gfxGdkNativeRenderer {
|
2006-02-23 04:01:29 +03:00
|
|
|
public:
|
|
|
|
ThemeRenderer(GtkWidgetState aState, GtkThemeWidgetType aGTKWidgetType,
|
2007-12-14 10:26:03 +03:00
|
|
|
gint aFlags, GtkTextDirection aDirection,
|
|
|
|
const GdkRectangle& aGDKRect, const GdkRectangle& aGDKClip)
|
2006-02-23 04:01:29 +03:00
|
|
|
: mState(aState), mGTKWidgetType(aGTKWidgetType), mFlags(aFlags),
|
2007-12-14 10:26:03 +03:00
|
|
|
mDirection(aDirection), mGDKRect(aGDKRect), mGDKClip(aGDKClip) {}
|
2010-07-02 08:04:09 +04:00
|
|
|
nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX, gint offsetY,
|
|
|
|
GdkRectangle * clipRects, PRUint32 numClipRects);
|
2006-02-23 04:01:29 +03:00
|
|
|
private:
|
|
|
|
GtkWidgetState mState;
|
|
|
|
GtkThemeWidgetType mGTKWidgetType;
|
|
|
|
gint mFlags;
|
2007-12-14 10:26:03 +03:00
|
|
|
GtkTextDirection mDirection;
|
2006-02-23 04:01:29 +03:00
|
|
|
GdkWindow* mWindow;
|
|
|
|
const GdkRectangle& mGDKRect;
|
|
|
|
const GdkRectangle& mGDKClip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
2010-07-02 08:04:09 +04:00
|
|
|
ThemeRenderer::DrawWithGDK(GdkDrawable * drawable, gint offsetX,
|
|
|
|
gint offsetY, GdkRectangle * clipRects, PRUint32 numClipRects)
|
2006-02-23 04:01:29 +03:00
|
|
|
{
|
|
|
|
GdkRectangle gdk_rect = mGDKRect;
|
|
|
|
gdk_rect.x += offsetX;
|
|
|
|
gdk_rect.y += offsetY;
|
|
|
|
|
|
|
|
GdkRectangle gdk_clip = mGDKClip;
|
|
|
|
gdk_clip.x += offsetX;
|
|
|
|
gdk_clip.y += offsetY;
|
2010-07-23 02:25:19 +04:00
|
|
|
|
|
|
|
GdkRectangle surfaceRect;
|
|
|
|
surfaceRect.x = 0;
|
|
|
|
surfaceRect.y = 0;
|
|
|
|
gdk_drawable_get_size(drawable, &surfaceRect.width, &surfaceRect.height);
|
|
|
|
gdk_rectangle_intersect(&gdk_clip, &surfaceRect, &gdk_clip);
|
2006-02-23 04:01:29 +03:00
|
|
|
|
2006-04-13 01:58:14 +04:00
|
|
|
NS_ASSERTION(numClipRects == 0, "We don't support clipping!!!");
|
2008-08-07 00:48:55 +04:00
|
|
|
moz_gtk_widget_paint(mGTKWidgetType, drawable, &gdk_rect, &gdk_clip,
|
|
|
|
&mState, mFlags, mDirection);
|
2006-02-23 04:01:29 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-07-15 02:31:41 +04:00
|
|
|
nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, PRUint8 aWidgetType,
|
|
|
|
nsIntMargin* aExtra)
|
2006-02-23 04:01:29 +03:00
|
|
|
{
|
|
|
|
*aExtra = nsIntMargin(0,0,0,0);
|
|
|
|
// Allow an extra one pixel above and below the thumb for certain
|
|
|
|
// GTK2 themes (Ximian Industrial, Bluecurve, Misty, at least);
|
2010-07-15 02:29:54 +04:00
|
|
|
// We modify the frame's overflow area. See bug 297508.
|
2006-02-23 04:01:29 +03:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
|
|
|
aExtra->top = aExtra->bottom = 1;
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2006-02-23 04:01:29 +03:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
aExtra->left = aExtra->right = 1;
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2008-03-07 20:58:11 +03:00
|
|
|
|
|
|
|
// Include the indicator spacing (the padding around the control).
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
|
|
|
{
|
|
|
|
gint indicator_size, indicator_spacing;
|
|
|
|
|
2008-11-03 16:12:59 +03:00
|
|
|
if (aWidgetType == NS_THEME_CHECKBOX) {
|
2008-03-07 20:58:11 +03:00
|
|
|
moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
|
|
|
|
} else {
|
|
|
|
moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
|
|
|
|
}
|
|
|
|
|
|
|
|
aExtra->top = indicator_spacing;
|
|
|
|
aExtra->right = indicator_spacing;
|
|
|
|
aExtra->bottom = indicator_spacing;
|
|
|
|
aExtra->left = indicator_spacing;
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2008-03-07 20:58:11 +03:00
|
|
|
}
|
2009-06-15 01:56:37 +04:00
|
|
|
case NS_THEME_BUTTON :
|
|
|
|
{
|
2010-07-15 02:31:41 +04:00
|
|
|
if (IsDefaultButton(aFrame)) {
|
2009-07-04 14:01:16 +04:00
|
|
|
// Some themes draw a default indicator outside the widget,
|
|
|
|
// include that in overflow
|
|
|
|
gint top, left, bottom, right;
|
|
|
|
moz_gtk_button_get_default_overflow(&top, &left, &bottom, &right);
|
|
|
|
aExtra->top = top;
|
|
|
|
aExtra->right = right;
|
|
|
|
aExtra->bottom = bottom;
|
|
|
|
aExtra->left = left;
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2009-07-04 14:01:16 +04:00
|
|
|
}
|
2009-06-15 01:56:37 +04:00
|
|
|
}
|
2010-07-15 02:31:41 +04:00
|
|
|
case NS_THEME_TAB :
|
|
|
|
{
|
|
|
|
if (!IsSelectedTab(aFrame))
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2010-07-15 02:31:41 +04:00
|
|
|
|
|
|
|
gint gap_height = moz_gtk_get_tab_thickness();
|
|
|
|
|
|
|
|
PRInt32 extra = gap_height - GetTabMarginPixels(aFrame);
|
|
|
|
if (extra <= 0)
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2010-07-15 02:31:41 +04:00
|
|
|
|
|
|
|
if (IsBottomTab(aFrame)) {
|
|
|
|
aExtra->top = extra;
|
|
|
|
} else {
|
|
|
|
aExtra->bottom = extra;
|
|
|
|
}
|
|
|
|
}
|
2006-02-23 04:01:29 +03:00
|
|
|
default:
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2006-02-23 04:01:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:04 +04:00
|
|
|
NS_IMETHODIMP
|
2011-04-08 05:04:40 +04:00
|
|
|
nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
|
2005-08-20 11:13:04 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRUint8 aWidgetType,
|
|
|
|
const nsRect& aRect,
|
2008-07-25 03:01:59 +04:00
|
|
|
const nsRect& aDirtyRect)
|
2005-08-20 11:13:04 +04:00
|
|
|
{
|
|
|
|
GtkWidgetState state;
|
|
|
|
GtkThemeWidgetType gtkWidgetType;
|
2007-12-14 10:26:03 +03:00
|
|
|
GtkTextDirection direction = GetTextDirection(aFrame);
|
2005-08-20 11:13:04 +04:00
|
|
|
gint flags;
|
|
|
|
if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state,
|
|
|
|
&flags))
|
|
|
|
return NS_OK;
|
2006-02-23 04:01:29 +03:00
|
|
|
|
2008-07-25 03:01:59 +04:00
|
|
|
gfxContext* ctx = aContext->ThebesContext();
|
|
|
|
nsPresContext *presContext = aFrame->PresContext();
|
|
|
|
|
|
|
|
gfxRect rect = presContext->AppUnitsToGfxUnits(aRect);
|
|
|
|
gfxRect dirtyRect = presContext->AppUnitsToGfxUnits(aDirtyRect);
|
|
|
|
|
|
|
|
// Align to device pixels where sensible
|
|
|
|
// to provide crisper and faster drawing.
|
|
|
|
// Don't snap if it's a non-unit scale factor. We're going to have to take
|
|
|
|
// slow paths then in any case.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool snapXY = ctx->UserToDevicePixelSnapped(rect);
|
2008-07-25 03:01:59 +04:00
|
|
|
if (snapXY) {
|
|
|
|
// Leave rect in device coords but make dirtyRect consistent.
|
|
|
|
dirtyRect = ctx->UserToDevice(dirtyRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Translate the dirty rect so that it is wrt the widget top-left.
|
2011-04-19 07:07:21 +04:00
|
|
|
dirtyRect.MoveBy(-rect.TopLeft());
|
2008-07-25 03:01:59 +04:00
|
|
|
// Round out the dirty rect to gdk pixels to ensure that gtk draws
|
|
|
|
// enough pixels for interpolation to device pixels.
|
|
|
|
dirtyRect.RoundOut();
|
|
|
|
|
|
|
|
// GTK themes can only draw an integer number of pixels
|
|
|
|
// (even when not snapped).
|
|
|
|
nsIntRect widgetRect(0, 0, NS_lround(rect.Width()), NS_lround(rect.Height()));
|
2010-07-15 02:25:41 +04:00
|
|
|
nsIntRect overflowRect(widgetRect);
|
|
|
|
nsIntMargin extraSize;
|
2010-07-15 02:31:41 +04:00
|
|
|
if (GetExtraSizeForWidget(aFrame, aWidgetType, &extraSize)) {
|
2010-07-15 02:25:41 +04:00
|
|
|
overflowRect.Inflate(extraSize);
|
|
|
|
}
|
2008-07-25 03:01:59 +04:00
|
|
|
|
|
|
|
// This is the rectangle that will actually be drawn, in gdk pixels
|
|
|
|
nsIntRect drawingRect(PRInt32(dirtyRect.X()),
|
|
|
|
PRInt32(dirtyRect.Y()),
|
|
|
|
PRInt32(dirtyRect.Width()),
|
|
|
|
PRInt32(dirtyRect.Height()));
|
2010-07-15 02:25:41 +04:00
|
|
|
if (widgetRect.IsEmpty()
|
|
|
|
|| !drawingRect.IntersectRect(overflowRect, drawingRect))
|
2008-07-25 03:01:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// gdk rectangles are wrt the drawing rect.
|
|
|
|
|
2009-07-04 14:01:16 +04:00
|
|
|
// The gdk_clip is just advisory here, meaning "you don't
|
2008-07-25 03:01:59 +04:00
|
|
|
// need to draw outside this rect if you don't feel like it!"
|
|
|
|
GdkRectangle gdk_clip = {0, 0, drawingRect.width, drawingRect.height};
|
|
|
|
|
|
|
|
GdkRectangle gdk_rect = {-drawingRect.x, -drawingRect.y,
|
|
|
|
widgetRect.width, widgetRect.height};
|
2006-02-23 04:01:29 +03:00
|
|
|
|
2008-07-25 03:01:59 +04:00
|
|
|
ThemeRenderer renderer(state, gtkWidgetType, flags, direction,
|
|
|
|
gdk_rect, gdk_clip);
|
|
|
|
|
|
|
|
// Some themes (e.g. Clearlooks) just don't clip properly to any
|
|
|
|
// clip rect we provide, so we cannot advertise support for clipping within
|
|
|
|
// the widget bounds.
|
2010-07-02 08:04:09 +04:00
|
|
|
PRUint32 rendererFlags = 0;
|
2010-06-18 05:19:21 +04:00
|
|
|
if (GetWidgetTransparency(aFrame, aWidgetType) == eOpaque) {
|
|
|
|
rendererFlags |= gfxGdkNativeRenderer::DRAW_IS_OPAQUE;
|
|
|
|
}
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2006-02-23 04:01:29 +03:00
|
|
|
// translate everything so (0,0) is the top left of the drawingRect
|
2008-07-25 03:01:59 +04:00
|
|
|
gfxContextAutoSaveRestore autoSR(ctx);
|
|
|
|
if (snapXY) {
|
|
|
|
// Rects are in device coords.
|
|
|
|
ctx->IdentityMatrix();
|
|
|
|
}
|
2011-04-19 07:07:21 +04:00
|
|
|
ctx->Translate(rect.TopLeft() + gfxPoint(drawingRect.x, drawingRect.y));
|
2005-10-06 08:02:10 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(!IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType),
|
|
|
|
"Trying to render an unsafe widget!");
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool safeState = IsWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
|
2005-10-06 08:02:10 +04:00
|
|
|
if (!safeState) {
|
2008-08-07 00:48:55 +04:00
|
|
|
gLastGdkError = 0;
|
|
|
|
gdk_error_trap_push ();
|
2005-10-06 08:02:10 +04:00
|
|
|
}
|
|
|
|
|
2010-07-02 08:04:09 +04:00
|
|
|
// GtkStyles (used by the widget drawing backend) are created for a
|
|
|
|
// particular colormap/visual.
|
|
|
|
GdkColormap* colormap = moz_gtk_widget_get_colormap();
|
|
|
|
|
|
|
|
renderer.Draw(ctx, drawingRect.Size(), rendererFlags, colormap);
|
2005-10-06 08:02:10 +04:00
|
|
|
|
|
|
|
if (!safeState) {
|
|
|
|
gdk_flush();
|
2008-08-07 00:48:55 +04:00
|
|
|
gLastGdkError = gdk_error_trap_pop ();
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
if (gLastGdkError) {
|
2005-10-06 08:02:10 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("GTK theme failed for widget type %d, error was %d, state was "
|
2007-04-26 10:57:37 +04:00
|
|
|
"[active=%d,focused=%d,inHover=%d,disabled=%d]\n",
|
2008-08-07 00:48:55 +04:00
|
|
|
aWidgetType, gLastGdkError, state.active, state.focused,
|
2005-10-06 08:02:10 +04:00
|
|
|
state.inHover, state.disabled);
|
|
|
|
#endif
|
|
|
|
NS_WARNING("GTK theme failed; disabling unsafe widget");
|
|
|
|
SetWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType);
|
|
|
|
// force refresh of the window, because the widget was not
|
|
|
|
// successfully drawn it must be redrawn using the default look
|
|
|
|
RefreshWidgetWindow(aFrame);
|
|
|
|
} else {
|
|
|
|
SetWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
|
|
|
|
}
|
|
|
|
}
|
2005-08-20 11:12:57 +04:00
|
|
|
|
2011-05-05 17:11:35 +04:00
|
|
|
// Indeterminate progress bar are animated.
|
2011-05-16 14:59:10 +04:00
|
|
|
if (gtkWidgetType == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
|
|
|
|
gtkWidgetType == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
|
2011-05-05 17:11:35 +04:00
|
|
|
if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 30)) {
|
|
|
|
NS_WARNING("unable to animate widget!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
|
2009-01-15 06:27:09 +03:00
|
|
|
PRUint8 aWidgetType, nsIntMargin* aResult)
|
2005-08-20 11:11:46 +04:00
|
|
|
{
|
2007-12-21 14:51:48 +03:00
|
|
|
GtkTextDirection direction = GetTextDirection(aFrame);
|
2007-06-05 07:26:43 +04:00
|
|
|
aResult->top = aResult->left = aResult->right = aResult->bottom = 0;
|
2005-08-20 11:13:05 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
2005-08-20 11:12:11 +04:00
|
|
|
{
|
2005-08-20 11:14:00 +04:00
|
|
|
MozGtkScrollbarMetrics metrics;
|
|
|
|
moz_gtk_get_scrollbar_metrics(&metrics);
|
2007-06-05 07:26:43 +04:00
|
|
|
aResult->top = aResult->left = aResult->right = aResult->bottom = metrics.trough_border;
|
2005-08-20 11:13:05 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_THEME_TOOLBOX:
|
|
|
|
// gtk has no toolbox equivalent. So, although we map toolbox to
|
|
|
|
// gtk's 'toolbar' for purposes of painting the widget background,
|
|
|
|
// we don't use the toolbar border for toolbox.
|
|
|
|
break;
|
2005-08-20 11:14:07 +04:00
|
|
|
case NS_THEME_TOOLBAR_DUAL_BUTTON:
|
|
|
|
// TOOLBAR_DUAL_BUTTON is an interesting case. We want a border to draw
|
|
|
|
// around the entire button + dropdown, and also an inner border if you're
|
|
|
|
// over the button part. But, we want the inner button to be right up
|
|
|
|
// against the edge of the outer button so that the borders overlap.
|
|
|
|
// To make this happen, we draw a button border for the outer button,
|
|
|
|
// but don't reserve any space for it.
|
|
|
|
break;
|
2007-12-21 14:51:48 +03:00
|
|
|
case NS_THEME_TAB:
|
|
|
|
// Top tabs have no bottom border, bottom tabs have no top border
|
|
|
|
moz_gtk_get_widget_border(MOZ_GTK_TAB, &aResult->left, &aResult->top,
|
|
|
|
&aResult->right, &aResult->bottom, direction,
|
|
|
|
FALSE);
|
|
|
|
if (IsBottomTab(aFrame))
|
|
|
|
aResult->top = 0;
|
|
|
|
else
|
|
|
|
aResult->bottom = 0;
|
|
|
|
break;
|
2011-06-25 01:00:50 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
|
|
|
// For regular menuitems, we will be using GetWidgetPadding instead of
|
|
|
|
// GetWidgetBorder to pad up the widget's internals; other menuitems
|
|
|
|
// will need to fall through and use the default case as before.
|
|
|
|
if (IsRegularMenuItem(aFrame))
|
|
|
|
break;
|
2005-08-20 11:13:05 +04:00
|
|
|
default:
|
|
|
|
{
|
2005-08-20 11:13:04 +04:00
|
|
|
GtkThemeWidgetType gtkWidgetType;
|
|
|
|
if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nsnull,
|
2011-06-25 01:00:50 +04:00
|
|
|
nsnull)) {
|
2007-06-05 07:26:43 +04:00
|
|
|
moz_gtk_get_widget_border(gtkWidgetType, &aResult->left, &aResult->top,
|
2007-12-14 10:26:03 +03:00
|
|
|
&aResult->right, &aResult->bottom, direction,
|
2009-08-25 00:02:07 +04:00
|
|
|
IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML));
|
2011-06-25 01:00:50 +04:00
|
|
|
}
|
2005-08-20 11:12:11 +04:00
|
|
|
}
|
2005-08-20 11:13:05 +04:00
|
|
|
}
|
2005-08-20 11:11:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
|
2005-08-20 11:14:07 +04:00
|
|
|
nsIFrame* aFrame, PRUint8 aWidgetType,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin* aResult)
|
2005-08-20 11:14:07 +04:00
|
|
|
{
|
2008-03-07 20:57:34 +03:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_BUTTON_FOCUS:
|
|
|
|
case NS_THEME_TOOLBAR_BUTTON:
|
|
|
|
case NS_THEME_TOOLBAR_DUAL_BUTTON:
|
2008-03-11 11:55:54 +03:00
|
|
|
case NS_THEME_TAB_SCROLLARROW_BACK:
|
2008-03-07 20:57:34 +03:00
|
|
|
case NS_THEME_TAB_SCROLLARROW_FORWARD:
|
2008-03-11 11:55:54 +03:00
|
|
|
case NS_THEME_DROPDOWN_BUTTON:
|
2010-07-27 18:57:47 +04:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
|
|
|
|
case NS_THEME_BUTTON_ARROW_UP:
|
|
|
|
case NS_THEME_BUTTON_ARROW_DOWN:
|
|
|
|
case NS_THEME_BUTTON_ARROW_NEXT:
|
|
|
|
case NS_THEME_BUTTON_ARROW_PREVIOUS:
|
2008-03-07 20:57:34 +03:00
|
|
|
// Radios and checkboxes return a fixed size in GetMinimumWidgetSize
|
|
|
|
// and have a meaningful baseline, so they can't have
|
|
|
|
// author-specified padding.
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
|
|
|
aResult->SizeTo(0, 0, 0, 0);
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2011-06-25 01:00:46 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
|
|
|
{
|
|
|
|
// Menubar and menulist have their padding specified in CSS.
|
|
|
|
if (!IsRegularMenuItem(aFrame))
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2011-06-25 01:00:46 +04:00
|
|
|
|
2011-06-25 01:00:50 +04:00
|
|
|
aResult->SizeTo(0, 0, 0, 0);
|
|
|
|
GtkThemeWidgetType gtkWidgetType;
|
|
|
|
if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nsnull,
|
|
|
|
nsnull)) {
|
|
|
|
moz_gtk_get_widget_border(gtkWidgetType, &aResult->left, &aResult->top,
|
|
|
|
&aResult->right, &aResult->bottom, GetTextDirection(aFrame),
|
|
|
|
IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML));
|
|
|
|
}
|
|
|
|
|
2011-06-25 01:00:46 +04:00
|
|
|
gint horizontal_padding;
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_MENUITEM)
|
|
|
|
moz_gtk_menuitem_get_horizontal_padding(&horizontal_padding);
|
|
|
|
else
|
|
|
|
moz_gtk_checkmenuitem_get_horizontal_padding(&horizontal_padding);
|
2011-06-25 01:00:50 +04:00
|
|
|
|
|
|
|
aResult->left += horizontal_padding;
|
|
|
|
aResult->right += horizontal_padding;
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2011-06-25 01:00:46 +04:00
|
|
|
}
|
2005-08-20 11:14:07 +04:00
|
|
|
}
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2005-08-20 11:14:07 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeGTK::GetWidgetOverflow(nsDeviceContext* aContext,
|
2005-09-01 01:00:52 +04:00
|
|
|
nsIFrame* aFrame, PRUint8 aWidgetType,
|
2008-04-02 03:34:20 +04:00
|
|
|
nsRect* aOverflowRect)
|
2005-09-01 01:00:52 +04:00
|
|
|
{
|
2008-01-09 10:40:21 +03:00
|
|
|
nsMargin m;
|
|
|
|
PRInt32 p2a;
|
2010-07-15 02:31:41 +04:00
|
|
|
nsIntMargin extraSize;
|
|
|
|
if (!GetExtraSizeForWidget(aFrame, aWidgetType, &extraSize))
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2008-01-09 10:40:21 +03:00
|
|
|
|
2010-07-15 02:31:41 +04:00
|
|
|
p2a = aContext->AppUnitsPerDevPixel();
|
|
|
|
m = nsMargin(NSIntPixelsToAppUnits(extraSize.left, p2a),
|
|
|
|
NSIntPixelsToAppUnits(extraSize.top, p2a),
|
|
|
|
NSIntPixelsToAppUnits(extraSize.right, p2a),
|
|
|
|
NSIntPixelsToAppUnits(extraSize.bottom, p2a));
|
2007-12-21 14:51:48 +03:00
|
|
|
|
2008-04-02 03:34:20 +04:00
|
|
|
aOverflowRect->Inflate(m);
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2005-09-01 01:00:52 +04:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
NS_IMETHODIMP
|
2011-04-08 05:04:40 +04:00
|
|
|
nsNativeThemeGTK::GetMinimumWidgetSize(nsRenderingContext* aContext,
|
2005-08-20 11:12:22 +04:00
|
|
|
nsIFrame* aFrame, PRUint8 aWidgetType,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIntSize* aResult, bool* aIsOverridable)
|
2005-08-20 11:11:46 +04:00
|
|
|
{
|
|
|
|
aResult->width = aResult->height = 0;
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = true;
|
2005-08-20 11:11:48 +04:00
|
|
|
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
|
|
|
{
|
2005-08-20 11:14:00 +04:00
|
|
|
MozGtkScrollbarMetrics metrics;
|
|
|
|
moz_gtk_get_scrollbar_metrics(&metrics);
|
2005-08-20 11:12:11 +04:00
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
aResult->width = metrics.slider_width;
|
|
|
|
aResult->height = metrics.stepper_size;
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:11:48 +04:00
|
|
|
}
|
|
|
|
break;
|
2005-08-20 11:14:20 +04:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
|
|
|
{
|
|
|
|
MozGtkScrollbarMetrics metrics;
|
|
|
|
moz_gtk_get_scrollbar_metrics(&metrics);
|
|
|
|
|
|
|
|
aResult->width = metrics.stepper_size;
|
|
|
|
aResult->height = metrics.slider_width;
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:14:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2007-12-21 14:17:01 +03:00
|
|
|
case NS_THEME_SPLITTER:
|
|
|
|
{
|
|
|
|
gint metrics;
|
|
|
|
if (IsHorizontal(aFrame)) {
|
|
|
|
moz_gtk_splitter_get_metrics(GTK_ORIENTATION_HORIZONTAL, &metrics);
|
|
|
|
aResult->width = metrics;
|
|
|
|
aResult->height = 0;
|
|
|
|
} else {
|
|
|
|
moz_gtk_splitter_get_metrics(GTK_ORIENTATION_VERTICAL, &metrics);
|
|
|
|
aResult->width = 0;
|
|
|
|
aResult->height = metrics;
|
|
|
|
}
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2007-12-21 14:17:01 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-05-16 07:28:01 +04:00
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
|
|
|
{
|
|
|
|
/* While we enforce a minimum size for the thumb, this is ignored
|
|
|
|
* for the some scrollbars if buttons are hidden (bug 513006) because
|
|
|
|
* the thumb isn't a direct child of the scrollbar, unlike the buttons
|
|
|
|
* or track. So add a minimum size to the track as well to prevent a
|
|
|
|
* 0-width scrollbar. */
|
|
|
|
MozGtkScrollbarMetrics metrics;
|
|
|
|
moz_gtk_get_scrollbar_metrics(&metrics);
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_SCROLLBAR_TRACK_VERTICAL)
|
|
|
|
aResult->width = metrics.slider_width;
|
|
|
|
else
|
|
|
|
aResult->height = metrics.slider_width;
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2011-05-16 07:28:01 +04:00
|
|
|
}
|
|
|
|
break;
|
2005-08-20 11:11:48 +04:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
2005-08-20 11:12:13 +04:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
2005-08-20 11:11:48 +04:00
|
|
|
{
|
2005-08-20 11:14:00 +04:00
|
|
|
MozGtkScrollbarMetrics metrics;
|
|
|
|
moz_gtk_get_scrollbar_metrics(&metrics);
|
2005-08-20 11:11:48 +04:00
|
|
|
|
2008-01-24 10:28:35 +03:00
|
|
|
nsRect rect = aFrame->GetParent()->GetRect();
|
|
|
|
PRInt32 p2a = aFrame->PresContext()->DeviceContext()->
|
|
|
|
AppUnitsPerDevPixel();
|
|
|
|
nsMargin margin;
|
|
|
|
|
|
|
|
/* Get the available space, if that is smaller then the minimum size,
|
|
|
|
* adjust the mininum size to fit into it.
|
2011-10-03 11:56:21 +04:00
|
|
|
* Setting aIsOverridable to true has no effect for thumbs. */
|
2008-01-24 10:28:35 +03:00
|
|
|
aFrame->GetMargin(margin);
|
|
|
|
rect.Deflate(margin);
|
|
|
|
aFrame->GetParent()->GetBorderAndPadding(margin);
|
|
|
|
rect.Deflate(margin);
|
|
|
|
|
2005-08-20 11:12:13 +04:00
|
|
|
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL) {
|
2005-08-20 11:14:00 +04:00
|
|
|
aResult->width = metrics.slider_width;
|
2011-06-02 16:56:50 +04:00
|
|
|
aResult->height = NS_MIN(NSAppUnitsToIntPixels(rect.height, p2a),
|
2008-01-24 10:28:35 +03:00
|
|
|
metrics.min_slider_size);
|
2005-08-20 11:12:13 +04:00
|
|
|
} else {
|
2005-08-20 11:14:00 +04:00
|
|
|
aResult->height = metrics.slider_width;
|
2011-06-02 16:56:50 +04:00
|
|
|
aResult->width = NS_MIN(NSAppUnitsToIntPixels(rect.width, p2a),
|
2008-01-24 10:28:35 +03:00
|
|
|
metrics.min_slider_size);
|
2005-08-20 11:12:13 +04:00
|
|
|
}
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:11:48 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_THUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_THUMB_VERTICAL:
|
|
|
|
{
|
|
|
|
gint thumb_length, thumb_height;
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_SCALE_THUMB_VERTICAL) {
|
|
|
|
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_length, &thumb_height);
|
|
|
|
aResult->width = thumb_height;
|
|
|
|
aResult->height = thumb_length;
|
|
|
|
} else {
|
|
|
|
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_length, &thumb_height);
|
|
|
|
aResult->width = thumb_length;
|
|
|
|
aResult->height = thumb_height;
|
|
|
|
}
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
|
|
|
break;
|
2008-02-15 08:28:44 +03:00
|
|
|
case NS_THEME_TAB_SCROLLARROW_BACK:
|
|
|
|
case NS_THEME_TAB_SCROLLARROW_FORWARD:
|
|
|
|
{
|
|
|
|
moz_gtk_get_tab_scroll_arrow_size(&aResult->width, &aResult->height);
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2008-02-15 08:28:44 +03:00
|
|
|
}
|
|
|
|
break;
|
2005-08-20 11:12:17 +04:00
|
|
|
case NS_THEME_DROPDOWN_BUTTON:
|
|
|
|
{
|
2008-03-12 13:54:22 +03:00
|
|
|
moz_gtk_get_combo_box_entry_button_size(&aResult->width,
|
|
|
|
&aResult->height);
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2007-12-11 12:09:10 +03:00
|
|
|
}
|
|
|
|
break;
|
2007-12-11 12:09:09 +03:00
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
{
|
|
|
|
gint separator_height;
|
|
|
|
|
|
|
|
moz_gtk_get_menu_separator_height(&separator_height);
|
|
|
|
aResult->height = separator_height;
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2007-12-11 12:09:09 +03:00
|
|
|
}
|
|
|
|
break;
|
2005-08-20 11:12:22 +04:00
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
|
|
|
{
|
|
|
|
gint indicator_size, indicator_spacing;
|
2005-08-20 11:14:00 +04:00
|
|
|
|
2008-11-03 16:12:59 +03:00
|
|
|
if (aWidgetType == NS_THEME_CHECKBOX) {
|
2005-08-20 11:13:04 +04:00
|
|
|
moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
|
2005-08-20 11:14:00 +04:00
|
|
|
} else {
|
2005-08-20 11:13:04 +04:00
|
|
|
moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
|
2005-08-20 11:14:00 +04:00
|
|
|
}
|
2005-08-20 11:12:37 +04:00
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
// Include space for the indicator and the padding around it.
|
2008-03-07 20:58:11 +03:00
|
|
|
aResult->width = indicator_size;
|
|
|
|
aResult->height = indicator_size;
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:12:17 +04:00
|
|
|
}
|
2005-08-20 11:12:19 +04:00
|
|
|
break;
|
2008-03-12 20:27:03 +03:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
|
2010-07-27 18:57:47 +04:00
|
|
|
case NS_THEME_BUTTON_ARROW_UP:
|
|
|
|
case NS_THEME_BUTTON_ARROW_DOWN:
|
|
|
|
case NS_THEME_BUTTON_ARROW_NEXT:
|
|
|
|
case NS_THEME_BUTTON_ARROW_PREVIOUS:
|
2008-03-12 20:27:03 +03:00
|
|
|
{
|
2010-07-27 18:57:47 +04:00
|
|
|
moz_gtk_get_arrow_size(&aResult->width, &aResult->height);
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2008-03-12 20:27:03 +03:00
|
|
|
}
|
|
|
|
break;
|
2005-08-20 11:14:00 +04:00
|
|
|
case NS_THEME_CHECKBOX_CONTAINER:
|
|
|
|
case NS_THEME_RADIO_CONTAINER:
|
|
|
|
case NS_THEME_CHECKBOX_LABEL:
|
|
|
|
case NS_THEME_RADIO_LABEL:
|
2005-08-20 11:14:07 +04:00
|
|
|
case NS_THEME_BUTTON:
|
2008-03-17 00:05:46 +03:00
|
|
|
case NS_THEME_DROPDOWN:
|
2005-08-20 11:14:07 +04:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON:
|
2007-11-07 12:14:58 +03:00
|
|
|
case NS_THEME_TREEVIEW_HEADER_CELL:
|
2005-08-20 11:14:00 +04:00
|
|
|
{
|
|
|
|
// Just include our border, and let the box code augment the size.
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin border;
|
2011-04-08 05:04:40 +04:00
|
|
|
nsNativeThemeGTK::GetWidgetBorder(aContext->DeviceContext(),
|
|
|
|
aFrame, aWidgetType, &border);
|
2005-08-20 11:14:00 +04:00
|
|
|
aResult->width = border.left + border.right;
|
|
|
|
aResult->height = border.top + border.bottom;
|
|
|
|
}
|
|
|
|
break;
|
2007-12-03 12:13:29 +03:00
|
|
|
case NS_THEME_TOOLBAR_SEPARATOR:
|
|
|
|
{
|
|
|
|
gint separator_width;
|
|
|
|
|
|
|
|
moz_gtk_get_toolbar_separator_width(&separator_width);
|
|
|
|
|
|
|
|
aResult->width = separator_width;
|
|
|
|
}
|
|
|
|
break;
|
2007-12-21 14:30:29 +03:00
|
|
|
case NS_THEME_SPINNER:
|
|
|
|
// hard code these sizes
|
|
|
|
aResult->width = 14;
|
|
|
|
aResult->height = 26;
|
|
|
|
break;
|
2007-11-13 11:43:03 +03:00
|
|
|
case NS_THEME_TREEVIEW_HEADER_SORTARROW:
|
2006-07-13 21:40:49 +04:00
|
|
|
case NS_THEME_SPINNER_UP_BUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWN_BUTTON:
|
|
|
|
// hard code these sizes
|
|
|
|
aResult->width = 14;
|
|
|
|
aResult->height = 13;
|
|
|
|
break;
|
2007-12-11 13:08:35 +03:00
|
|
|
case NS_THEME_RESIZER:
|
|
|
|
// same as Windows to make our lives easier
|
|
|
|
aResult->width = aResult->height = 15;
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2007-12-11 13:08:35 +03:00
|
|
|
break;
|
2007-11-15 06:47:16 +03:00
|
|
|
case NS_THEME_TREEVIEW_TWISTY:
|
|
|
|
case NS_THEME_TREEVIEW_TWISTY_OPEN:
|
|
|
|
{
|
|
|
|
gint expander_size;
|
|
|
|
|
2008-01-03 10:07:32 +03:00
|
|
|
moz_gtk_get_treeview_expander_size(&expander_size);
|
2007-11-15 06:47:16 +03:00
|
|
|
aResult->width = aResult->height = expander_size;
|
2011-10-03 11:56:21 +04:00
|
|
|
*aIsOverridable = false;
|
2007-11-15 06:47:16 +03:00
|
|
|
}
|
|
|
|
break;
|
2005-08-20 11:11:48 +04:00
|
|
|
}
|
2005-08-20 11:11:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIAtom* aAttribute, bool* aShouldRepaint)
|
2005-08-20 11:11:46 +04:00
|
|
|
{
|
|
|
|
// Some widget types just never change state.
|
2005-08-20 11:13:04 +04:00
|
|
|
if (aWidgetType == NS_THEME_TOOLBOX ||
|
|
|
|
aWidgetType == NS_THEME_TOOLBAR ||
|
|
|
|
aWidgetType == NS_THEME_STATUSBAR ||
|
|
|
|
aWidgetType == NS_THEME_STATUSBAR_PANEL ||
|
2005-08-20 11:11:46 +04:00
|
|
|
aWidgetType == NS_THEME_STATUSBAR_RESIZER_PANEL ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR_CHUNK ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
|
2005-08-20 11:13:48 +04:00
|
|
|
aWidgetType == NS_THEME_MENUBAR ||
|
|
|
|
aWidgetType == NS_THEME_MENUPOPUP ||
|
2005-08-20 11:13:45 +04:00
|
|
|
aWidgetType == NS_THEME_TOOLTIP ||
|
2007-12-11 12:09:09 +03:00
|
|
|
aWidgetType == NS_THEME_MENUSEPARATOR ||
|
2005-08-20 11:13:45 +04:00
|
|
|
aWidgetType == NS_THEME_WINDOW ||
|
|
|
|
aWidgetType == NS_THEME_DIALOG) {
|
2011-10-03 11:56:21 +04:00
|
|
|
*aShouldRepaint = false;
|
2005-08-20 11:11:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-07 12:26:22 +03:00
|
|
|
if ((aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_DOWN ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT) &&
|
2011-10-14 22:11:22 +04:00
|
|
|
(aAttribute == nsGkAtoms::curpos ||
|
|
|
|
aAttribute == nsGkAtoms::maxpos)) {
|
2011-10-03 11:56:21 +04:00
|
|
|
*aShouldRepaint = true;
|
2008-02-07 12:26:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
// XXXdwh Not sure what can really be done here. Can at least guess for
|
|
|
|
// specific widgets that they're highly unlikely to have certain states.
|
|
|
|
// For example, a toolbar doesn't care about any states.
|
|
|
|
if (!aAttribute) {
|
|
|
|
// Hover/focus/active changed. Always repaint.
|
2011-10-03 11:56:21 +04:00
|
|
|
*aShouldRepaint = true;
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Check the attribute to see if it's relevant.
|
|
|
|
// disabled, checked, dlgtype, default, etc.
|
2011-10-03 11:56:21 +04:00
|
|
|
*aShouldRepaint = false;
|
2011-10-14 22:11:22 +04:00
|
|
|
if (aAttribute == nsGkAtoms::disabled ||
|
|
|
|
aAttribute == nsGkAtoms::checked ||
|
|
|
|
aAttribute == nsGkAtoms::selected ||
|
|
|
|
aAttribute == nsGkAtoms::focused ||
|
|
|
|
aAttribute == nsGkAtoms::readonly ||
|
|
|
|
aAttribute == nsGkAtoms::_default ||
|
|
|
|
aAttribute == nsGkAtoms::menuactive ||
|
|
|
|
aAttribute == nsGkAtoms::open ||
|
|
|
|
aAttribute == nsGkAtoms::parentfocused)
|
2011-10-03 11:56:21 +04:00
|
|
|
*aShouldRepaint = true;
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeGTK::ThemeChanged()
|
|
|
|
{
|
2011-04-17 05:22:42 +04:00
|
|
|
nsDeviceContext::ClearCachedSystemFonts();
|
2005-08-20 11:14:15 +04:00
|
|
|
|
2005-08-20 11:12:57 +04:00
|
|
|
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
|
2005-08-20 11:11:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2005-08-20 11:14:04 +04:00
|
|
|
nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
|
2005-08-20 11:12:55 +04:00
|
|
|
nsIFrame* aFrame,
|
2005-08-20 11:11:46 +04:00
|
|
|
PRUint8 aWidgetType)
|
|
|
|
{
|
2005-08-20 11:12:57 +04:00
|
|
|
if (IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType))
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2005-08-20 11:12:57 +04:00
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_BUTTON:
|
2005-08-20 11:14:07 +04:00
|
|
|
case NS_THEME_BUTTON_FOCUS:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_RADIO:
|
2005-08-20 11:11:46 +04:00
|
|
|
case NS_THEME_CHECKBOX:
|
2005-08-20 11:13:48 +04:00
|
|
|
case NS_THEME_TOOLBOX: // N/A
|
|
|
|
case NS_THEME_TOOLBAR:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON:
|
|
|
|
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
|
2008-01-17 13:24:31 +03:00
|
|
|
case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
|
2010-07-27 18:57:47 +04:00
|
|
|
case NS_THEME_BUTTON_ARROW_UP:
|
|
|
|
case NS_THEME_BUTTON_ARROW_DOWN:
|
|
|
|
case NS_THEME_BUTTON_ARROW_NEXT:
|
|
|
|
case NS_THEME_BUTTON_ARROW_PREVIOUS:
|
2007-12-03 12:13:29 +03:00
|
|
|
case NS_THEME_TOOLBAR_SEPARATOR:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_TOOLBAR_GRIPPER:
|
|
|
|
case NS_THEME_STATUSBAR:
|
|
|
|
case NS_THEME_STATUSBAR_PANEL:
|
2007-11-15 10:35:41 +03:00
|
|
|
case NS_THEME_STATUSBAR_RESIZER_PANEL:
|
2007-12-11 13:08:35 +03:00
|
|
|
case NS_THEME_RESIZER:
|
2007-06-12 22:29:51 +04:00
|
|
|
case NS_THEME_LISTBOX:
|
2005-08-20 11:12:28 +04:00
|
|
|
// case NS_THEME_LISTBOX_LISTITEM:
|
2007-11-07 12:14:58 +03:00
|
|
|
case NS_THEME_TREEVIEW:
|
2005-08-20 11:12:28 +04:00
|
|
|
// case NS_THEME_TREEVIEW_TREEITEM:
|
2007-11-15 06:47:16 +03:00
|
|
|
case NS_THEME_TREEVIEW_TWISTY:
|
2005-08-20 11:12:28 +04:00
|
|
|
// case NS_THEME_TREEVIEW_LINE:
|
|
|
|
// case NS_THEME_TREEVIEW_HEADER:
|
2007-11-07 12:14:58 +03:00
|
|
|
case NS_THEME_TREEVIEW_HEADER_CELL:
|
2007-11-13 11:43:03 +03:00
|
|
|
case NS_THEME_TREEVIEW_HEADER_SORTARROW:
|
2007-11-15 06:47:16 +03:00
|
|
|
case NS_THEME_TREEVIEW_TWISTY_OPEN:
|
2005-08-20 11:12:29 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_CHUNK:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
|
|
|
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
|
2005-08-20 11:12:30 +04:00
|
|
|
case NS_THEME_TAB:
|
2005-08-20 11:12:28 +04:00
|
|
|
// case NS_THEME_TAB_PANEL:
|
2005-08-20 11:12:31 +04:00
|
|
|
case NS_THEME_TAB_PANELS:
|
2008-02-15 08:28:44 +03:00
|
|
|
case NS_THEME_TAB_SCROLLARROW_BACK:
|
|
|
|
case NS_THEME_TAB_SCROLLARROW_FORWARD:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_TOOLTIP:
|
2007-12-21 14:30:29 +03:00
|
|
|
case NS_THEME_SPINNER:
|
2006-07-13 21:40:49 +04:00
|
|
|
case NS_THEME_SPINNER_UP_BUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWN_BUTTON:
|
2007-12-21 14:30:29 +03:00
|
|
|
case NS_THEME_SPINNER_TEXTFIELD:
|
2005-08-20 11:12:30 +04:00
|
|
|
// case NS_THEME_SCROLLBAR: (n/a for gtk)
|
2007-07-14 01:46:28 +04:00
|
|
|
// case NS_THEME_SCROLLBAR_SMALL: (n/a for gtk)
|
2005-08-20 11:11:47 +04:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
2005-08-20 11:11:48 +04:00
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
2005-08-20 11:11:48 +04:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
2005-08-20 11:12:17 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2008-06-23 12:50:52 +04:00
|
|
|
case NS_THEME_TEXTFIELD_CARET:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD:
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_THUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
|
|
|
case NS_THEME_SCALE_THUMB_VERTICAL:
|
|
|
|
// case NS_THEME_SCALE_THUMB_START:
|
|
|
|
// case NS_THEME_SCALE_THUMB_END:
|
|
|
|
// case NS_THEME_SCALE_TICK:
|
2005-08-20 11:12:28 +04:00
|
|
|
case NS_THEME_CHECKBOX_CONTAINER:
|
|
|
|
case NS_THEME_RADIO_CONTAINER:
|
2005-08-20 11:14:00 +04:00
|
|
|
case NS_THEME_CHECKBOX_LABEL:
|
|
|
|
case NS_THEME_RADIO_LABEL:
|
2005-08-20 11:13:48 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
case NS_THEME_MENUPOPUP:
|
|
|
|
case NS_THEME_MENUITEM:
|
2007-11-29 01:45:21 +03:00
|
|
|
case NS_THEME_MENUARROW:
|
2007-12-11 12:09:09 +03:00
|
|
|
case NS_THEME_MENUSEPARATOR:
|
2005-08-20 11:14:21 +04:00
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
2007-12-21 14:17:01 +03:00
|
|
|
case NS_THEME_SPLITTER:
|
2005-08-20 11:13:45 +04:00
|
|
|
case NS_THEME_WINDOW:
|
|
|
|
case NS_THEME_DIALOG:
|
2005-08-20 11:14:05 +04:00
|
|
|
case NS_THEME_DROPDOWN:
|
|
|
|
case NS_THEME_DROPDOWN_TEXT:
|
2005-08-20 11:14:11 +04:00
|
|
|
return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
|
2007-10-26 00:23:13 +04:00
|
|
|
|
|
|
|
case NS_THEME_DROPDOWN_BUTTON:
|
|
|
|
// "Native" dropdown buttons cause padding and margin problems, but only
|
|
|
|
// in HTML so allow them in XUL.
|
2009-08-25 00:02:07 +04:00
|
|
|
return (!aFrame || IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) &&
|
2007-10-26 00:23:13 +04:00
|
|
|
!IsWidgetStyled(aPresContext, aFrame, aWidgetType);
|
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2005-08-20 11:11:46 +04:00
|
|
|
nsNativeThemeGTK::WidgetIsContainer(PRUint8 aWidgetType)
|
|
|
|
{
|
|
|
|
// XXXdwh At some point flesh all of this out.
|
2008-02-15 08:28:44 +03:00
|
|
|
if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
|
2008-11-03 16:12:59 +03:00
|
|
|
aWidgetType == NS_THEME_RADIO ||
|
|
|
|
aWidgetType == NS_THEME_CHECKBOX ||
|
2008-02-15 08:28:44 +03:00
|
|
|
aWidgetType == NS_THEME_TAB_SCROLLARROW_BACK ||
|
2010-07-27 18:57:47 +04:00
|
|
|
aWidgetType == NS_THEME_TAB_SCROLLARROW_FORWARD ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_UP ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_DOWN ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_NEXT ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON_ARROW_PREVIOUS)
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
|
|
|
return true;
|
2005-08-20 11:11:46 +04:00
|
|
|
}
|
2007-02-16 04:53:43 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-02-16 04:53:43 +03:00
|
|
|
nsNativeThemeGTK::ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType)
|
2007-05-18 07:04:05 +04:00
|
|
|
{
|
2007-06-05 07:26:43 +04:00
|
|
|
if (aWidgetType == NS_THEME_DROPDOWN ||
|
2007-11-07 12:14:58 +03:00
|
|
|
aWidgetType == NS_THEME_BUTTON ||
|
|
|
|
aWidgetType == NS_THEME_TREEVIEW_HEADER_CELL)
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2007-06-05 07:26:43 +04:00
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2007-05-18 07:04:05 +04:00
|
|
|
}
|
2007-05-18 07:04:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-05-18 07:04:04 +04:00
|
|
|
nsNativeThemeGTK::ThemeNeedsComboboxDropmarker()
|
|
|
|
{
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2007-05-18 07:04:04 +04:00
|
|
|
}
|
2010-06-18 05:19:21 +04:00
|
|
|
|
|
|
|
nsITheme::Transparency
|
|
|
|
nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, PRUint8 aWidgetType)
|
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
|
|
|
// These widgets always draw a default background.
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
|
|
|
case NS_THEME_TOOLBAR:
|
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
case NS_THEME_MENUPOPUP:
|
|
|
|
case NS_THEME_WINDOW:
|
|
|
|
case NS_THEME_DIALOG:
|
2010-08-09 06:17:32 +04:00
|
|
|
// Tooltips use gtk_paint_flat_box().
|
|
|
|
case NS_THEME_TOOLTIP:
|
2010-06-18 05:19:21 +04:00
|
|
|
return eOpaque;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eUnknownTransparency;
|
|
|
|
}
|