Bug 290255, add xul scale widget, r=mconnor,roc sr=neil,roc

This commit is contained in:
enndeakin%sympatico.ca 2006-05-30 13:50:48 +00:00
parent d1e3a3dcb3
commit 31f554baac
37 changed files with 1391 additions and 104 deletions

View File

@ -463,6 +463,7 @@ GK_ATOM(meta, "meta")
GK_ATOM(method, "method")
GK_ATOM(middle, "middle")
GK_ATOM(minheight, "minheight")
GK_ATOM(minpos, "minpos")
GK_ATOM(minusSign, "minus-sign")
GK_ATOM(minwidth, "minwidth")
GK_ATOM(mod, "mod")
@ -700,6 +701,7 @@ GK_ATOM(sizetopopup, "sizetopopup")
GK_ATOM(slider, "slider")
GK_ATOM(small, "small")
GK_ATOM(smooth, "smooth")
GK_ATOM(snap, "snap")
GK_ATOM(sort, "sort")
GK_ATOM(sortActive, "sortActive")
GK_ATOM(sortDirection, "sortDirection")

View File

@ -166,18 +166,20 @@
#define NS_THEME_DROPDOWN_TEXTFIELD 104
// A slider
#define NS_THEME_SLIDER 111
#define NS_THEME_SCALE_HORIZONTAL 111
#define NS_THEME_SCALE_VERTICAL 112
// A slider's thumb
#define NS_THEME_SLIDER_THUMB 112
#define NS_THEME_SCALE_THUMB_HORIZONTAL 113
#define NS_THEME_SCALE_THUMB_VERTICAL 114
// If the platform supports it, the left/right chunks
// of the slider thumb
#define NS_THEME_SLIDER_THUMB_START 113
#define NS_THEME_SLIDER_THUMB_END 114
#define NS_THEME_SCALE_THUMB_START 115
#define NS_THEME_SCALE_THUMB_END 116
// The ticks for a slider.
#define NS_THEME_SLIDER_TICK 115
#define NS_THEME_SCALE_TICK 117
// A generic container that always repaints on state
// changes. This is a hack to make checkboxes and

View File

@ -518,11 +518,13 @@ CSS_KEY(menulist, menulist)
CSS_KEY(menulist-button, menulistbutton)
CSS_KEY(menulist-text, menulisttext)
CSS_KEY(menulist-textfield, menulisttextfield)
CSS_KEY(slider, slider)
CSS_KEY(sliderthumb, sliderthumb)
CSS_KEY(sliderthumbstart, sliderthumbstart)
CSS_KEY(sliderthumbend, sliderthumbend)
CSS_KEY(sliderthumbtick, sliderthumbtick)
CSS_KEY(scale-horizontal, scale_horizontal)
CSS_KEY(scale-vertical, scale_vertical)
CSS_KEY(scalethumb-horizontal, scalethumb_horizontal)
CSS_KEY(scalethumb-vertical, scalethumb_vertical)
CSS_KEY(scalethumbstart, scalethumbstart)
CSS_KEY(scalethumbend, scalethumbend)
CSS_KEY(scalethumbtick, scalethumbtick)
CSS_KEY(checkbox-container, checkboxcontainer)
CSS_KEY(radio-container, radiocontainer)
CSS_KEY(checkbox-label, checkboxlabel)

View File

@ -235,11 +235,13 @@ const PRInt32 nsCSSProps::kAppearanceKTable[] = {
eCSSKeyword_menulistbutton, NS_THEME_DROPDOWN_BUTTON,
eCSSKeyword_menulisttext, NS_THEME_DROPDOWN_TEXT,
eCSSKeyword_menulisttextfield, NS_THEME_DROPDOWN_TEXTFIELD,
eCSSKeyword_slider, NS_THEME_SLIDER,
eCSSKeyword_sliderthumb, NS_THEME_SLIDER_THUMB,
eCSSKeyword_sliderthumbstart, NS_THEME_SLIDER_THUMB_START,
eCSSKeyword_sliderthumbend, NS_THEME_SLIDER_THUMB_END,
eCSSKeyword_sliderthumbtick, NS_THEME_SLIDER_TICK,
eCSSKeyword_scale_horizontal, NS_THEME_SCALE_HORIZONTAL,
eCSSKeyword_scale_vertical, NS_THEME_SCALE_VERTICAL,
eCSSKeyword_scalethumb_horizontal, NS_THEME_SCALE_THUMB_HORIZONTAL,
eCSSKeyword_scalethumb_vertical, NS_THEME_SCALE_THUMB_VERTICAL,
eCSSKeyword_scalethumbstart, NS_THEME_SCALE_THUMB_START,
eCSSKeyword_scalethumbend, NS_THEME_SCALE_THUMB_END,
eCSSKeyword_scalethumbtick, NS_THEME_SCALE_TICK,
eCSSKeyword_checkboxcontainer, NS_THEME_CHECKBOX_CONTAINER,
eCSSKeyword_radiocontainer, NS_THEME_RADIO_CONTAINER,
eCSSKeyword_checkboxlabel, NS_THEME_CHECKBOX_LABEL,

View File

@ -180,6 +180,12 @@ nsSliderFrame::GetCurrentPosition(nsIContent* content)
return GetIntegerAttribute(content, nsXULAtoms::curpos, 0);
}
PRInt32
nsSliderFrame::GetMinPosition(nsIContent* content)
{
return GetIntegerAttribute(content, nsXULAtoms::minpos, 0);
}
PRInt32
nsSliderFrame::GetMaxPosition(nsIContent* content)
{
@ -228,18 +234,20 @@ nsSliderFrame::AttributeChanged(PRInt32 aNameSpaceID,
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to change position");
if (NS_FAILED(rv))
return rv;
} else if (aAttribute == nsXULAtoms::maxpos) {
} else if (aAttribute == nsXULAtoms::minpos ||
aAttribute == nsXULAtoms::maxpos) {
// bounds check it.
nsIBox* scrollbarBox = GetScrollbar();
nsCOMPtr<nsIContent> scrollbar;
scrollbar = GetContentOfBox(scrollbarBox);
PRInt32 current = GetCurrentPosition(scrollbar);
PRInt32 min = GetMinPosition(scrollbar);
PRInt32 max = GetMaxPosition(scrollbar);
if (current < 0 || current > max)
if (current < min || current > max)
{
if (current < 0)
current = 0;
if (current < min || max < min)
current = min;
else if (current > max)
current = max;
@ -259,7 +267,8 @@ nsSliderFrame::AttributeChanged(PRInt32 aNameSpaceID,
}
}
if (aAttribute == nsXULAtoms::maxpos ||
if (aAttribute == nsXULAtoms::minpos ||
aAttribute == nsXULAtoms::maxpos ||
aAttribute == nsXULAtoms::pageincrement ||
aAttribute == nsXULAtoms::increment) {
@ -354,18 +363,22 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
// get our current position and max position from our content node
PRInt32 curpospx = GetCurrentPosition(scrollbar);
PRInt32 minpospx = GetMinPosition(scrollbar);
PRInt32 maxpospx = GetMaxPosition(scrollbar);
PRInt32 pageIncrement = GetPageIncrement(scrollbar);
if (curpospx < 0)
curpospx = 0;
if (maxpospx < minpospx)
maxpospx = minpospx;
if (curpospx < minpospx)
curpospx = minpospx;
else if (curpospx > maxpospx)
curpospx = maxpospx;
nscoord onePixel = aState.PresContext()->IntScaledPixelsToTwips(1);
// get max pos in twips
nscoord maxpos = maxpospx*onePixel;
nscoord maxpos = (maxpospx - minpospx) * onePixel;
// get our maxpos in twips. This is the space we have left over in the scrollbar
// after the height of the thumb has been removed
@ -376,7 +389,7 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
mRatio = 1;
if ((pageIncrement + maxpospx) != 0)
if ((pageIncrement + maxpospx - minpospx) > 0)
{
// if the thumb is flexible make the thumb bigger.
nscoord flex = 0;
@ -384,7 +397,7 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
if (flex > 0)
{
mRatio = float(pageIncrement) / float(maxpospx + pageIncrement);
mRatio = float(pageIncrement) / float(maxpospx - minpospx + pageIncrement);
nscoord thumbsize = NSToCoordRound(ourmaxpos * mRatio);
// if there is more room than the thumb needs stretch the thumb
@ -395,9 +408,9 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
ourmaxpos -= thumbcoord;
if (float(maxpos) != 0)
mRatio = float(ourmaxpos)/float(maxpos);
mRatio = float(ourmaxpos) / float(maxpos);
nscoord curpos = curpospx*onePixel;
nscoord curpos = (curpospx - minpospx) * onePixel;
// set the thumbs y coord to be the current pos * the ratio.
nscoord pos = nscoord(float(curpos)*mRatio);
@ -416,8 +429,9 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
#ifdef DEBUG_SLIDER
PRInt32 c = GetCurrentPosition(scrollbar);
PRInt32 m = GetMaxPosition(scrollbar);
printf("Current=%d, max=%d\n", c, m);
PRInt32 min = GetMinPosition(scrollbar);
PRInt32 max = GetMaxPosition(scrollbar);
printf("Current=%d, min=%d, max=%d\n", c, min, max);
#endif
// redraw only if thumb changed size.
@ -500,6 +514,14 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
// convert to our internal coordinate system
pospx = nscoord(pospx/mRatio);
// if snap="true", then the slider may only be set to min + (increment * x).
// Otherwise, the slider may be set to any positive integer.
if (mContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::snap,
nsXULAtoms::_true, eCaseMatters)) {
PRInt32 increment = GetIncrement(scrollbar);
pospx = NSToCoordRound(pospx / (float)increment) * increment;
}
// set it
SetCurrentPosition(scrollbar, thumbFrame, pospx, PR_FALSE);
@ -605,7 +627,8 @@ nsSliderFrame::PageUpDown(nsIFrame* aThumbFrame, nscoord change)
nscoord pageIncrement = GetPageIncrement(scrollbar);
PRInt32 curpos = GetCurrentPosition(scrollbar);
SetCurrentPosition(scrollbar, aThumbFrame, curpos + change*pageIncrement, PR_TRUE);
PRInt32 minpos = GetMinPosition(scrollbar);
SetCurrentPosition(scrollbar, aThumbFrame, curpos - minpos + change*pageIncrement, PR_TRUE);
}
// called when the current position changed and we need to update the thumb's location
@ -625,17 +648,18 @@ nsSliderFrame::CurrentPositionChanged(nsPresContext* aPresContext)
if (mCurPos == curpos)
return NS_OK;
// get our current position and max position from our content node
// get our current min and max position from our content node
PRInt32 minpos = GetMinPosition(scrollbar);
PRInt32 maxpos = GetMaxPosition(scrollbar);
if (curpos < 0)
curpos = 0;
else if (curpos > maxpos)
if (curpos < minpos || maxpos < minpos)
curpos = minpos;
else if (curpos > maxpos)
curpos = maxpos;
// convert to pixels
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord curpospx = curpos*onePixel;
nscoord curpospx = (curpos - minpos) * onePixel;
// get the thumb's rect
nsIFrame* thumbFrame = mFrames.FirstChild();
@ -688,23 +712,27 @@ static void UpdateAttribute(nsIContent* aScrollbar, nscoord aNewPos, PRBool aNot
}
}
// newpos should be passed to this function as a position as if the minpos is 0.
// That is, the minpos will be added to the position by this function.
void
nsSliderFrame::SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame, nscoord newpos, PRBool aIsSmooth)
{
// get our current position and max position from our content node
// get our current, min and max position from our content node
PRInt32 minpos = GetMinPosition(scrollbar);
PRInt32 maxpos = GetMaxPosition(scrollbar);
newpos += minpos;
// get the new position and make sure it is in bounds
if (newpos > maxpos)
if (newpos < minpos || maxpos < minpos)
newpos = minpos;
else if (newpos > maxpos)
newpos = maxpos;
else if (newpos < 0)
newpos = 0;
nsIBox* scrollbarBox = GetScrollbar();
nsCOMPtr<nsIScrollbarFrame> scrollbarFrame(do_QueryInterface(scrollbarBox));
if (scrollbarFrame) {
// See if we have a mediator.
nsCOMPtr<nsIScrollbarMediator> mediator;
@ -761,6 +789,10 @@ nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent)
{
//printf("Begin dragging\n");
if (mContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::disabled,
nsXULAtoms::_true, eCaseMatters))
return NS_OK;
PRBool isHorizontal = IsHorizontal();
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
@ -919,6 +951,10 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext,
nsIFrame* thumbFrame = mFrames.FirstChild();
if (!thumbFrame) // display:none?
return NS_OK;
if (mContent->AttrValueIs(kNameSpaceID_None, nsHTMLAtoms::disabled,
nsXULAtoms::_true, eCaseMatters))
return NS_OK;
nsRect thumbRect = thumbFrame->GetRect();

View File

@ -184,6 +184,7 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
static PRInt32 GetCurrentPosition(nsIContent* content);
static PRInt32 GetMinPosition(nsIContent* content);
static PRInt32 GetMaxPosition(nsIContent* content);
static PRInt32 GetIncrement(nsIContent* content);
static PRInt32 GetPageIncrement(nsIContent* content);

View File

@ -0,0 +1,88 @@
/* ***** 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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Neil Deakin (enndeakin@sympatico.ca)
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
/* ===== scale.css =================================================
== Styles used by XUL scale elements.
======================================================================= */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: scale ::::: */
.scale-slider {
-moz-appearance: scale-horizontal;
background: url("chrome://global/skin/scale/scale-tray-horiz.gif") 0% 50% repeat-x;
margin: 2px 4px;
width: 100px;
}
.scale-slider[orient="vertical"]
{
-moz-appearance: scale-vertical;
background: url("chrome://global/skin/scale/scale-tray-vert.gif") 50% 0% repeat-y;
margin: 4px 2px;
width: auto;
height: 100px;
}
/* ::::: scale thumb ::::: */
.scale-thumb {
-moz-appearance: scalethumb-horizontal;
border: 2px solid;
-moz-border-top-colors: ThreeDLightShadow ThreeDHighlight;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-left-colors: ThreeDLightShadow ThreeDHighlight;
background-color: -moz-Dialog;
min-width: 30px;
min-height: 15px;
}
.scale-thumb[orient="vertical"] {
-moz-appearance: scalethumb-vertical;
min-width: 15px;
min-height: 30px;
}
.scale-thumb[disabled="true"] {
-moz-border-top-colors: ThreeDHighlight ThreeDLightShadow !important;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow !important;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow !important;
-moz-border-left-colors: ThreeDHighlight ThreeDLightShadow !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

View File

@ -311,6 +311,7 @@ classic.jar:
skin/classic/global/nativescrollbars.css (global/mac/nativescrollbars.css)
# chrome://global/skin/xulscrollbars.css is used on non-Mac platforms
skin/classic/global/xulscrollbars.css (global/win/scrollbars.css)
skin/classic/global/scale.css (global/win/scale.css)
skin/classic/global/filepicker/blank.gif (global/filepicker/blank.gif)
skin/classic/global/filepicker/dir-closed.gif (global/filepicker/dir-closed.gif)
skin/classic/global/filepicker/dir-open.gif (global/filepicker/dir-open.gif)
@ -351,6 +352,8 @@ classic.jar:
skin/classic/global/toolbar/tbgrip-arrow-clps.gif (global/toolbar/tbgrip-arrow-clps.gif)
skin/classic/global/toolbar/tbgrip-texture.gif (global/toolbar/tbgrip-texture.gif)
skin/classic/global/toolbar/chevron.gif (global/toolbar/chevron.gif)
skin/classic/global/scale/scale-tray-horiz.gif (global/win/scale/scale-tray-horiz.gif)
skin/classic/global/scale/scale-tray-vert.gif (global/win/scale/scale-tray-vert.gif)
skin/classic/global/splitter/grip-vrt-after.gif (global/splitter/grip-vrt-after.gif)
skin/classic/global/splitter/grip-vrt-before.gif (global/splitter/grip-vrt-before.gif)
skin/classic/global/splitter/grip-hrz-after.gif (global/splitter/grip-hrz-after.gif)

View File

@ -0,0 +1,92 @@
/* ***** 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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Neil Deakin (enndeakin@sympatico.ca)
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
/* ===== scale.css =================================================
== Styles used by XUL scale elements.
======================================================================= */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: scale ::::: */
.scale-slider {
background: url("chrome://global/skin/scrollbar/slider-hrz.gif") repeat-x;
border-left: 1px solid black;
border-right: 1px solid black;
margin: 2px 4px;
width: 100px;
height: 15px;
}
.scale-slider[orient="vertical"]
{
background: url("chrome://global/skin/scrollbar/slider-vrt.gif") repeat-y;
border-left: none;
border-right: none;
border-top: 1px solid black;
border-bottom: 1px solid black;
margin: 4px 2px;
width: 15px;
height: 100px;
}
/* ::::: scale thumb ::::: */
.scale-thumb {
border: 3px solid;
-moz-border-top-colors: #000000 #E4EBF2 #C3CAD2;
-moz-border-right-colors: #000000 #8F9DAD #A4AFBB;
-moz-border-bottom-colors: #000000 #8F9DAD #A4AFBB;
-moz-border-left-colors: #000000 #E4EBF2 #C3CAD2;
background-image: url("chrome://global/skin/scrollbar/thumb-hrz-grip.gif");
min-width: 18px;
}
.scale-thumb[orient="vertical"] {
background-image: url("chrome://global/skin/scrollbar/thumb-vrt-grip.gif");
min-height: 18px;
min-width: none;
}
.scale-thumb[disabled="true"] {
-moz-border-top-colors: #000000 #708092 #939FAD;
-moz-border-right-colors: #000000 #718193 #9EA9B5;
-moz-border-bottom-colors: #000000 #8795A4 #929EAC;
-moz-border-left-colors: #000000 #ADB6C0 #9EA9B5;
background: #9CA8B4;
}

View File

@ -177,6 +177,7 @@ modern.jar:
skin/modern/global/autocomplete.css (global/autocomplete.css)
skin/modern/global/global.css (global/global.css)
skin/modern/global/popup.css (global/popup.css)
skin/modern/global/scale.css (global/scale.css)
skin/modern/global/splitter.css (global/splitter.css)
skin/modern/global/tabbox.css (global/tabbox.css)
skin/modern/global/textbox.css (global/textbox.css)

View File

@ -54,6 +54,7 @@ toolkit.jar:
*+ content/global/bindings/progressmeter.xml (widgets/progressmeter.xml)
*+ content/global/bindings/radio.xml (widgets/radio.xml)
*+ content/global/bindings/richlistbox.xml (widgets/richlistbox.xml)
*+ content/global/bindings/scale.xml (widgets/scale.xml)
*+ content/global/bindings/scrollbar.xml (widgets/scrollbar.xml)
*+ content/global/bindings/scrollbox.xml (widgets/scrollbox.xml)
*+ content/global/bindings/splitter.xml (widgets/splitter.xml)

View File

@ -0,0 +1,168 @@
<?xml version="1.0"?>
<bindings id="scaleBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="scalethumb" extends="xul:button">
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
</binding>
<binding id="scaleslider" display="xul:slider"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
</binding>
<binding id="scale"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
<content align="center" pack="center">
<xul:slider anonid="slider" class="scale-slider" snap="true" flex="1"
xbl:inherits="disabled,orient,curpos=value,minpos=min,maxpos=max,increment,pageincrement">
<xul:thumb class="scale-thumb" xbl:inherits="disabled,orient"/>
</xul:slider>
</content>
<implementation>
<property name="value" onget="return this._getIntegerAttribute('curpos', 0);"
onset="return this._setIntegerAttribute('curpos', val);"/>
<property name="min" onget="return this._getIntegerAttribute('minpos', 0);"
onset="return this._setIntegerAttribute('minpos', val);"/>
<property name="max" onget="return this._getIntegerAttribute('maxpos', 100);"
onset="return this._setIntegerAttribute('maxpos', val);"/>
<property name="increment" onget="return this._getIntegerAttribute('increment', 1);"
onset="return this._setIntegerAttribute('increment', val);"/>
<property name="pageIncrement" onget="return this._getIntegerAttribute('pageincrement', 10);"
onset="return this._setIntegerAttribute('pageincrement', val);"/>
<field name="_sliderElement"/>
<property name="_slider" readonly="true">
<getter>
if (!this._sliderElement)
this._sliderElement = document.getAnonymousElementByAttribute(this, "anonid", "slider");
return this._sliderElement;
</getter>
</property>
<method name="_getIntegerAttribute">
<parameter name="aAttr"/>
<parameter name="aDefaultValue"/>
<body>
var value = this._slider.getAttribute(aAttr);
var intvalue = parseInt(value, 10);
if (!isNaN(intvalue))
return intvalue;
return aDefaultValue;
</body>
</method>
<method name="_setIntegerAttribute">
<parameter name="aAttr"/>
<parameter name="aValue"/>
<body>
var intvalue = parseInt(aValue, 10);
if (!isNaN(intvalue)) this._slider.setAttribute(aAttr, intvalue);
return aValue;
</body>
</method>
<method name="decrease">
<body>
<![CDATA[
var newpos = this.value - this.increment;
var startpos = this.min;
this.value = (newpos > startpos) ? newpos : startpos;
]]>
</body>
</method>
<method name="increase">
<body>
<![CDATA[
var newpos = this.value + this.increment;
var endpos = this.max;
this.value = (newpos < endpos) ? newpos : endpos;
]]>
</body>
</method>
<method name="decreasePage">
<body>
<![CDATA[
var newpos = this.value - this.pageIncrement;
var startpos = this.min;
this.value = (newpos > startpos) ? newpos : startpos;
]]>
</body>
</method>
<method name="increasePage">
<body>
<![CDATA[
var newpos = this.value + this.pageIncrement;
var endpos = this.max;
this.value = (newpos < endpos) ? newpos : endpos;
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="DOMAttrModified">
if (event.originalTarget != this._slider)
return;
switch (event.attrName) {
case "curpos":
this.setAttribute("value", event.newValue);
var changeEvent = document.createEvent("Events");
changeEvent.initEvent("change", false, true);
this.dispatchEvent(changeEvent);
break;
case "minpos":
this.setAttribute("min", event.newValue);
break;
case "maxpos":
this.setAttribute("max", event.newValue);
break;
}
</handler>
<handler event="keypress" keycode="VK_UP" preventdefault="true">
this.decrease();
</handler>
<handler event="keypress" keycode="VK_LEFT" preventdefault="true">
this.decrease();
</handler>
<handler event="keypress" keycode="VK_DOWN" preventdefault="true">
this.increase();
</handler>
<handler event="keypress" keycode="VK_RIGHT" preventdefault="true">
this.increase();
</handler>
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true">
this.decreasePage();
</handler>
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true">
this.increasePage();
</handler>
<handler event="keypress" keycode="VK_HOME" preventdefault="true">
this.value = this.min;
</handler>
<handler event="keypress" keycode="VK_END" preventdefault="true">
this.value = this.max;
</handler>
</handlers>
</binding>
</bindings>

View File

@ -82,7 +82,7 @@ iframe {
-moz-user-focus: normal;
}
menulist[editable] {
menulist[editable="true"] {
-moz-user-focus: ignore;
}
@ -841,7 +841,7 @@ menulist {
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist");
}
menulist[editable] {
menulist[editable="true"] {
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist-editable");
}
@ -886,13 +886,16 @@ scrollbar {
direction: ltr;
}
thumb
{
thumb {
-moz-binding: url(chrome://global/content/bindings/scrollbar.xml#thumb);
display: -moz-box !important;
}
scrollbar, scrollbarbutton, scrollcorner, slider, thumb {
.scale-thumb {
-moz-binding: url(chrome://global/content/bindings/scale.xml#scalethumb);
}
scrollbar, scrollbarbutton, scrollcorner, slider, thumb, scale {
-moz-user-select: none;
}
@ -908,6 +911,15 @@ scrollbar[value="hidden"] {
visibility: hidden;
}
scale {
-moz-binding: url(chrome://global/content/bindings/scale.xml#scale);
}
.scale-slider {
-moz-binding: url(chrome://global/content/bindings/scale.xml#scaleslider);
-moz-user-focus: normal;
}
/******** scrollbox ********/
scrollbox {

View File

@ -44,6 +44,7 @@ classic.jar:
+ skin/classic/global/nativescrollbars.css
# chrome://global/skin/xulscrollbars.css is used on non-Mac platforms
+ skin/classic/global/xulscrollbars.css (../../winstripe/global/xulscrollbars.css)
*+ skin/classic/global/scale.css
+ skin/classic/global/scrollbox.css
+ skin/classic/global/spinbuttons.css
+ skin/classic/global/splitter.css
@ -128,6 +129,8 @@ classic.jar:
+ skin/classic/global/menulist/menulist-arrow-act.gif (menulist/menulist-arrow-act.gif)
+ skin/classic/global/menulist/menulist-arrow-dis.gif (menulist/menulist-arrow-dis.gif)
+ skin/classic/global/menulist/menulist-arrow.gif (menulist/menulist-arrow.gif)
+ skin/classic/global/scale/scale-tray-horiz.gif (scale/scale-tray-horiz.gif)
+ skin/classic/global/scale/scale-tray-vert.gif (scale/scale-tray-vert.gif)
+ skin/classic/global/splitter/dimple.png (splitter/dimple.png)
+ skin/classic/global/tabDragDrop/tabDragIndicator.png (tabDragDrop/tabDragIndicator.png)
+ skin/classic/global/toolbar/Lighten.png (toolbar/Lighten.png)

View File

@ -0,0 +1,46 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: scale ::::: */
.scale-slider {
-moz-appearance: scale-horizontal;
background: url("chrome://global/skin/scale/scale-tray-horiz.gif") 0% 50% repeat-x;
margin: 2px 4px;
width: 100px;
}
.scale-slider[orient="vertical"]
{
-moz-appearance: scale-vertical;
background: url("chrome://global/skin/scale/scale-tray-vert.gif") 50% 0% repeat-y;
margin: 4px 2px;
width: auto;
height: 100px;
}
/* ::::: scale thumb ::::: */
.scale-thumb {
-moz-appearance: scalethumb-horizontal;
border: 2px solid;
-moz-border-top-colors: ThreeDLightShadow ThreeDHighlight;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-left-colors: ThreeDLightShadow ThreeDHighlight;
background-color: -moz-Dialog;
min-width: 30px;
min-height: 15px;
}
.scale-thumb[orient="vertical"] {
-moz-appearance: scalethumb-vertical;
min-width: 15px;
min-height: 30px;
}
.scale-thumb[disabled="true"] {
-moz-border-top-colors: ThreeDHighlight ThreeDLightShadow !important;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow !important;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow !important;
-moz-border-left-colors: ThreeDHighlight ThreeDLightShadow !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

View File

@ -34,6 +34,7 @@ classic.jar:
# chrome://global/skin/xulscrollbars.css is used on non-Mac platforms
skin/classic/global/xulscrollbars.css
skin/classic/global/scrollbox.css
* skin/classic/global/scale.css
skin/classic/global/spinbuttons.css
skin/classic/global/splitter.css
skin/classic/global/tabbox.css
@ -98,6 +99,8 @@ classic.jar:
skin/classic/global/menu/menu-radio-hover.gif (menu/menu-radio-hover.gif)
skin/classic/global/radio/radio-check.gif (radio/radio-check.gif)
skin/classic/global/radio/radio-check-dis.gif (radio/radio-check-dis.gif)
skin/classic/global/scale/scale-tray-horiz.gif (scale/scale-tray-horiz.gif)
skin/classic/global/scale/scale-tray-vert.gif (scale/scale-tray-vert.gif)
skin/classic/global/scrollbar/slider.gif (scrollbar/slider.gif)
skin/classic/global/tabDragDrop/tabDragIndicator.png (tabDragDrop/tabDragIndicator.png)
skin/classic/global/toolbar/chevron.gif (toolbar/chevron.gif)

View File

@ -0,0 +1,46 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: scale ::::: */
.scale-slider {
-moz-appearance: scale-horizontal;
background: url("chrome://global/skin/scale/scale-tray-horiz.gif") 0% 50% repeat-x;
margin: 2px 4px;
width: 100px;
}
.scale-slider[orient="vertical"]
{
-moz-appearance: scale-vertical;
background: url("chrome://global/skin/scale/scale-tray-vert.gif") 50% 0% repeat-y;
margin: 4px 2px;
width: auto;
height: 100px;
}
/* ::::: scale thumb ::::: */
.scale-thumb {
-moz-appearance: scalethumb-horizontal;
border: 2px solid;
-moz-border-top-colors: ThreeDLightShadow ThreeDHighlight;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-left-colors: ThreeDLightShadow ThreeDHighlight;
background-color: -moz-Dialog;
min-width: 30px;
min-height: 15px;
}
.scale-thumb[orient="vertical"] {
-moz-appearance: scalethumb-vertical;
min-width: 15px;
min-height: 30px;
}
.scale-thumb[disabled="true"] {
-moz-border-top-colors: ThreeDHighlight ThreeDLightShadow !important;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow !important;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow !important;
-moz-border-left-colors: ThreeDHighlight ThreeDLightShadow !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

View File

@ -50,6 +50,8 @@ static GtkWidget* gButtonWidget;
static GtkWidget* gProtoWindow;
static GtkWidget* gCheckboxWidget;
static GtkWidget* gScrollbarWidget;
static GtkWidget* gHScaleWidget;
static GtkWidget* gVScaleWidget;
static GtkWidget* gEntryWidget;
static GtkWidget* gArrowWidget;
static GtkWidget* gDropdownButtonWidget;
@ -126,6 +128,20 @@ ensure_scrollbar_widget()
return MOZ_GTK_SUCCESS;
}
static gint
ensure_scale_widget()
{
if (!gHScaleWidget) {
gHScaleWidget = gtk_hscale_new(NULL);
setup_widget_prototype(gHScaleWidget);
}
if (!gVScaleWidget) {
gVScaleWidget = gtk_vscale_new(NULL);
setup_widget_prototype(gVScaleWidget);
}
return MOZ_GTK_SUCCESS;
}
static gint
ensure_entry_widget()
{
@ -514,6 +530,79 @@ moz_gtk_scrollbar_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
return MOZ_GTK_SUCCESS;
}
static gint
moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state,
GtkOrientation flags)
{
gint x = 0, y = 0;
GtkStateType state_type = ConvertGtkState(state);
GtkStyle* style;
GtkWidget* widget;
ensure_scale_widget();
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
style = widget->style;
if (flags == GTK_ORIENTATION_HORIZONTAL) {
x = style->klass->xthickness;
y++;
}
else {
x++;
y = style->klass->ythickness;
}
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
cliprect, rect->x, rect->y,
rect->width, rect->height);
gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
widget, "trough", rect->x + x, rect->y + y,
rect->width - 2*x, rect->height - 2*y);
if (state->focused)
gtk_paint_focus(style, drawable, cliprect, widget, "trough",
rect->x, rect->y, rect->width, rect->height);
return MOZ_GTK_SUCCESS;
}
static gint
moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state,
GtkOrientation flags)
{
GtkStateType state_type = ConvertGtkState(state);
GtkStyle* style;
GtkWidget* widget;
gint thumb_width, thumb_height, x, y;
ensure_scale_widget();
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
style = widget->style;
/* determine the thumb size, and position the thumb in the center in the opposite axis */
if (flags == GTK_ORIENTATION_HORIZONTAL) {
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
x = rect->x;
y = rect->y + (rect->height - thumb_height) / 2;
}
else {
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
x = rect->x + (rect->width - thumb_width) / 2;
y = rect->y;
}
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
rect->x, rect->y, thumb_width, thumb_height, flags);
return MOZ_GTK_SUCCESS;
}
static gint
moz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state)
@ -847,6 +936,14 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
ensure_progress_widget();
w = gProgressWidget;
break;
case MOZ_GTK_SCALE_HORIZONTAL:
ensure_scale_widget();
w = gHScaleWidget;
break;
case MOZ_GTK_SCALE_VERTICAL:
ensure_scale_widget();
w = gVScaleWidget;
break;
case MOZ_GTK_FRAME:
ensure_frame_widget();
w = gFrameWidget;
@ -871,6 +968,8 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
case MOZ_GTK_SCALE_THUMB_VERTICAL:
case MOZ_GTK_GRIPPER:
case MOZ_GTK_TOOLTIP:
case MOZ_GTK_PROGRESS_CHUNK:
@ -910,6 +1009,42 @@ moz_gtk_get_dropdown_arrow_size(gint* width, gint* height)
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
{
GtkRangeClass* rangeklass;
GtkScaleClass* scaleklass;
GtkStyle* style;
GtkWidget* widget;
ensure_scale_widget();
widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
rangeklass = GTK_RANGE_CLASS(GTK_OBJECT(widget)->klass);
scaleklass = GTK_SCALE_CLASS(GTK_OBJECT(widget)->klass);
style = widget->style;
if (style_prop_func) {
/*
* This API is supported only in GTK+ >= 1.2.9, and gives per-theme values.
*/
*thumb_length = style_prop_func(style, "GtkRange::slider_length",
scaleklass->slider_length);
*thumb_height = style_prop_func(style, "GtkRange::slider_width",
rangeklass->slider_width);
} else {
/*
* This is the older method, which gives per-engine values.
*/
*thumb_length = scaleklass->slider_length;
*thumb_height = rangeklass->slider_width;
}
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
{
@ -982,6 +1117,14 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
return moz_gtk_scrollbar_thumb_paint(drawable, rect, cliprect, state);
break;
case MOZ_GTK_SCALE_HORIZONTAL:
case MOZ_GTK_SCALE_VERTICAL:
return moz_gtk_scale_paint(drawable, rect, cliprect, state, (GtkOrientation) flags);
break;
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
case MOZ_GTK_SCALE_THUMB_VERTICAL:
return moz_gtk_scale_thumb_paint(drawable, rect, cliprect, state, (GtkOrientation) flags);
break;
case MOZ_GTK_GRIPPER:
return moz_gtk_gripper_paint(drawable, rect, cliprect, state);
break;

View File

@ -112,6 +112,12 @@ typedef enum {
/* Paints the slider (thumb) of a GtkScrollbar. */
MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
/* Paints a GtkScale. */
MOZ_GTK_SCALE_HORIZONTAL,
MOZ_GTK_SCALE_VERTICAL,
/* Paints a GtkScale thumb. */
MOZ_GTK_SCALE_THUMB_HORIZONTAL,
MOZ_GTK_SCALE_THUMB_VERTICAL,
/* Paints the gripper of a GtkHandleBox. */
MOZ_GTK_GRIPPER,
/* Paints a GtkEntry. */
@ -248,6 +254,17 @@ gint
moz_gtk_radio_get_focus(gboolean* interior_focus,
gint* focus_width, gint* focus_pad);
/**
* Get the desired size of a GtkScale thumb
* orient: [IN] the scale orientation
* thumb_length: [OUT] the length of the thumb
* thumb_height: [OUT] the height of the thumb
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
/**
* Get the desired metrics for a GtkScrollbar
* metrics: [IN] struct which will contain the metrics

View File

@ -311,6 +311,26 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
break;
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;
case NS_THEME_SCALE_THUMB_VERTICAL:
if (aWidgetFlags)
*aWidgetFlags = GTK_ORIENTATION_VERTICAL;
aGtkWidgetType = MOZ_GTK_SCALE_THUMB_VERTICAL;
break;
case NS_THEME_TOOLBAR_GRIPPER:
aGtkWidgetType = MOZ_GTK_GRIPPER;
break;
@ -612,6 +632,24 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext,
*aIsOverridable = PR_FALSE;
}
break;
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;
}
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_DROPDOWN_BUTTON:
{
moz_gtk_get_dropdown_arrow_size(&aResult->width, &aResult->height);
@ -782,11 +820,13 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
// case NS_THEME_TEXTFIELD_CARET:
case NS_THEME_DROPDOWN_BUTTON:
case NS_THEME_DROPDOWN_TEXTFIELD:
// case NS_THEME_SLIDER:
// case NS_THEME_SLIDER_THUMB:
// case NS_THEME_SLIDER_THUMB_START:
// case NS_THEME_SLIDER_THUMB_END:
// case NS_THEME_SLIDER_TICK:
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:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
case NS_THEME_CHECKBOX_LABEL:

View File

@ -59,6 +59,8 @@ static GtkWidget* gCheckboxWidget;
static GtkWidget* gRadiobuttonWidget;
static GtkWidget* gHorizScrollbarWidget;
static GtkWidget* gVertScrollbarWidget;
static GtkWidget* gHScaleWidget;
static GtkWidget* gVScaleWidget;
static GtkWidget* gEntryWidget;
static GtkWidget* gArrowWidget;
static GtkWidget* gOptionMenuWidget;
@ -158,6 +160,20 @@ ensure_scrollbar_widget()
return MOZ_GTK_SUCCESS;
}
static gint
ensure_scale_widget()
{
if (!gHScaleWidget) {
gHScaleWidget = gtk_hscale_new(NULL);
setup_widget_prototype(gHScaleWidget);
}
if (!gVScaleWidget) {
gVScaleWidget = gtk_vscale_new(NULL);
setup_widget_prototype(gVScaleWidget);
}
return MOZ_GTK_SUCCESS;
}
static gint
ensure_entry_widget()
{
@ -793,6 +809,79 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget,
return MOZ_GTK_SUCCESS;
}
static gint
moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state,
GtkOrientation flags)
{
gint x = 0, y = 0;
GtkStateType state_type = ConvertGtkState(state);
GtkStyle* style;
GtkWidget* widget;
ensure_scale_widget();
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
style = widget->style;
if (flags == GTK_ORIENTATION_HORIZONTAL) {
x = XTHICKNESS(style);
y++;
}
else {
x++;
y = YTHICKNESS(style);
}
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
cliprect, rect->x, rect->y,
rect->width, rect->height);
gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
widget, "trough", rect->x + x, rect->y + y,
rect->width - 2*x, rect->height - 2*y);
if (state->focused)
gtk_paint_focus(style, drawable, state_type, cliprect, widget, "trough",
rect->x, rect->y, rect->width, rect->height);
return MOZ_GTK_SUCCESS;
}
static gint
moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state,
GtkOrientation flags)
{
GtkStateType state_type = ConvertGtkState(state);
GtkStyle* style;
GtkWidget* widget;
gint thumb_width, thumb_height, x, y;
ensure_scale_widget();
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
style = widget->style;
/* determine the thumb size, and position the thumb in the center in the opposite axis */
if (flags == GTK_ORIENTATION_HORIZONTAL) {
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
x = rect->x;
y = rect->y + (rect->height - thumb_height) / 2;
}
else {
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
x = rect->x + (rect->width - thumb_width) / 2;
y = rect->y;
}
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
x, y, thumb_width, thumb_height, flags);
return MOZ_GTK_SUCCESS;
}
static gint
moz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state)
@ -1442,6 +1531,14 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
ensure_progress_widget();
w = gProgressWidget;
break;
case MOZ_GTK_SCALE_HORIZONTAL:
ensure_scale_widget();
w = gHScaleWidget;
break;
case MOZ_GTK_SCALE_VERTICAL:
ensure_scale_widget();
w = gVScaleWidget;
break;
case MOZ_GTK_FRAME:
ensure_frame_widget();
w = gFrameWidget;
@ -1522,6 +1619,8 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
case MOZ_GTK_SCALE_THUMB_VERTICAL:
case MOZ_GTK_GRIPPER:
case MOZ_GTK_PROGRESS_CHUNK:
case MOZ_GTK_TAB:
@ -1561,6 +1660,22 @@ moz_gtk_get_dropdown_arrow_size(gint* width, gint* height)
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
{
GtkWidget* widget;
ensure_scale_widget();
widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
gtk_widget_style_get (widget,
"slider_length", thumb_length,
"slider_width", thumb_height,
NULL);
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
{
@ -1610,6 +1725,14 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
return moz_gtk_scrollbar_thumb_paint(widget, drawable, rect,
cliprect, state);
break;
case MOZ_GTK_SCALE_HORIZONTAL:
case MOZ_GTK_SCALE_VERTICAL:
return moz_gtk_scale_paint(drawable, rect, cliprect, state, (GtkOrientation) flags);
break;
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
case MOZ_GTK_SCALE_THUMB_VERTICAL:
return moz_gtk_scale_thumb_paint(drawable, rect, cliprect, state, (GtkOrientation) flags);
break;
case MOZ_GTK_GRIPPER:
return moz_gtk_gripper_paint(drawable, rect, cliprect, state);
break;
@ -1701,6 +1824,8 @@ moz_gtk_shutdown()
gRadiobuttonWidget = NULL;
gHorizScrollbarWidget = NULL;
gVertScrollbarWidget = NULL;
gHScaleWidget = NULL;
gVScaleWidget = NULL;
gEntryWidget = NULL;
gArrowWidget = NULL;
gDropdownButtonWidget = NULL;

View File

@ -112,6 +112,12 @@ typedef enum {
/* Paints the slider (thumb) of a GtkScrollbar. */
MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
/* Paints a GtkScale. */
MOZ_GTK_SCALE_HORIZONTAL,
MOZ_GTK_SCALE_VERTICAL,
/* Paints a GtkScale thumb. */
MOZ_GTK_SCALE_THUMB_HORIZONTAL,
MOZ_GTK_SCALE_THUMB_VERTICAL,
/* Paints the gripper of a GtkHandleBox. */
MOZ_GTK_GRIPPER,
/* Paints a GtkEntry. */
@ -248,6 +254,17 @@ gint
moz_gtk_radio_get_focus(gboolean* interior_focus,
gint* focus_width, gint* focus_pad);
/**
* Get the desired size of a GtkScale thumb
* orient: [IN] the scale orientation
* thumb_length: [OUT] the length of the thumb
* thumb_height: [OUT] the height of the thumb
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
/**
* Get the desired metrics for a GtkScrollbar
* metrics: [IN] struct which will contain the metrics

View File

@ -323,6 +323,26 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
break;
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;
case NS_THEME_SCALE_THUMB_VERTICAL:
if (aWidgetFlags)
*aWidgetFlags = GTK_ORIENTATION_VERTICAL;
aGtkWidgetType = MOZ_GTK_SCALE_THUMB_VERTICAL;
break;
case NS_THEME_TOOLBAR_GRIPPER:
aGtkWidgetType = MOZ_GTK_GRIPPER;
break;
@ -791,6 +811,24 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext,
*aIsOverridable = PR_FALSE;
}
break;
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;
}
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_DROPDOWN_BUTTON:
{
moz_gtk_get_dropdown_arrow_size(&aResult->width, &aResult->height);
@ -960,11 +998,13 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
// case NS_THEME_TEXTFIELD_CARET:
case NS_THEME_DROPDOWN_BUTTON:
case NS_THEME_DROPDOWN_TEXTFIELD:
// case NS_THEME_SLIDER:
// case NS_THEME_SLIDER_THUMB:
// case NS_THEME_SLIDER_THUMB_START:
// case NS_THEME_SLIDER_THUMB_END:
// case NS_THEME_SLIDER_TICK:
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:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
case NS_THEME_CHECKBOX_LABEL:

View File

@ -114,6 +114,9 @@ nsNativeThemeMac::nsNativeThemeMac()
}
mMenuActiveAtom = do_GetAtom("_moz-menuactive");
mCurPosAtom = do_GetAtom("curpos");
mMinPosAtom = do_GetAtom("minpos");
mMaxPosAtom = do_GetAtom("maxpos");
}
nsNativeThemeMac::~nsNativeThemeMac()
@ -193,7 +196,6 @@ nsNativeThemeMac::DrawButton ( ThemeButtonKind inKind, const Rect& inBoxRect, PR
::DrawThemeButton ( &inBoxRect, inKind, &info, nsnull, mEraseProc, nsnull, 0L );
}
void
nsNativeThemeMac::DrawToolbar ( const Rect& inBoxRect )
{
@ -272,6 +274,31 @@ nsNativeThemeMac::DrawSeparator ( const Rect& inBoxRect, PRBool inIsDisabled )
}
void
nsNativeThemeMac::DrawScale ( const Rect& inBoxRect, PRBool inIsDisabled, PRInt32 inState,
PRBool inIsVertical, PRInt32 inCurrentValue,
PRInt32 inMinValue, PRInt32 inMaxValue )
{
ThemeTrackDrawInfo info;
info.kind = kThemeMediumSlider;
info.bounds = inBoxRect;
info.min = inMinValue;
info.max = inMaxValue;
info.value = inCurrentValue;
info.attributes = kThemeTrackShowThumb;
if (!inIsVertical)
info.attributes |= kThemeTrackHorizontal;
if (inState & NS_EVENT_STATE_FOCUS)
info.attributes |= kThemeTrackHasFocus;
info.enableState = (inIsDisabled ? kThemeTrackDisabled : kThemeTrackActive);
info.trackInfo.slider.thumbDir = kThemeThumbPlain;
info.trackInfo.slider.pressState = 0;
::DrawThemeTrack(&info, nsnull, nsnull, 0);
}
void
nsNativeThemeMac::DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRBool inTabBottom, PRInt32 inState )
@ -412,7 +439,7 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame*
case NS_THEME_BUTTON_SMALL:
DrawButton ( kThemePushButton, macRect, IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOn, kThemeAdornmentNone, eventState );
break;
break;
case NS_THEME_BUTTON_BEVEL:
DrawButton ( kThemeMediumBevelButton, macRect, IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOff, kThemeAdornmentNone, eventState );
@ -483,6 +510,27 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame*
case NS_THEME_TREEVIEW_LINE:
// do nothing, these lines don't exist on macos
break;
case NS_THEME_SCALE_HORIZONTAL:
case NS_THEME_SCALE_VERTICAL:
{
PRInt32 curpos = CheckIntAttr(aFrame, mCurPosAtom);
PRInt32 minpos = CheckIntAttr(aFrame, mMinPosAtom);
PRInt32 maxpos = CheckIntAttr(aFrame, mMaxPosAtom);
if (!maxpos)
maxpos = 100;
DrawScale(macRect, IsDisabled(aFrame), eventState,
(aWidgetType == NS_THEME_SCALE_VERTICAL),
curpos, minpos, maxpos);
break;
}
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
// do nothing, drawn by scale
break;
case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
@ -581,7 +629,7 @@ nsNativeThemeMac::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
// XXX we should probably cache some of these metrics
aResult->SizeTo(0,0);
*aIsOverridable = PR_TRUE;
switch ( aWidgetType ) {
case NS_THEME_BUTTON:
@ -599,7 +647,7 @@ nsNativeThemeMac::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
aResult->SizeTo(kAquaSmallPushButtonEndcaps*2, buttonHeight);
break;
}
case NS_THEME_CHECKBOX:
{
SInt32 boxHeight = 0, boxWidth = 0;
@ -695,6 +743,24 @@ nsNativeThemeMac::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
aResult->SizeTo(0, headerHeight);
break;
}
case NS_THEME_SCALE_HORIZONTAL:
{
SInt32 scaleHeight = 0;
::GetThemeMetric(kThemeMetricHSliderHeight, &scaleHeight);
aResult->SizeTo(scaleHeight, scaleHeight);
*aIsOverridable = PR_FALSE;
break;
}
case NS_THEME_SCALE_VERTICAL:
{
SInt32 scaleWidth = 0;
::GetThemeMetric(kThemeMetricVSliderWidth, &scaleWidth);
aResult->SizeTo(scaleWidth, scaleWidth);
*aIsOverridable = PR_FALSE;
break;
}
case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_BUTTON_UP:
@ -796,7 +862,7 @@ nsNativeThemeMac::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFr
return PR_FALSE;
PRBool retVal = PR_FALSE;
switch ( aWidgetType ) {
case NS_THEME_DIALOG:
case NS_THEME_WINDOW:
@ -837,7 +903,12 @@ nsNativeThemeMac::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFr
case NS_THEME_TREEVIEW_HEADER_SORTARROW:
case NS_THEME_TREEVIEW_TREEITEM:
case NS_THEME_TREEVIEW_LINE:
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_SCROLLBAR:
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:

View File

@ -107,6 +107,9 @@ protected:
void DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRBool inTabBottom, PRInt32 inState ) ;
void DrawTabPanel ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
void DrawScale ( const Rect& inBoxRect, PRBool inIsDisabled, PRInt32 inState,
PRBool inDirection, PRInt32 inCurrentValue,
PRInt32 inMinValue, PRInt32 inMaxValue ) ;
void DrawSeparator ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
// void DrawScrollArrows ( const Rect& inScrollbarRect, PRBool inIsDisabled, PRInt32 inWidget, PRInt32 inState ) ;
@ -121,5 +124,8 @@ protected:
private:
ThemeEraseUPP mEraseProc;
nsCOMPtr<nsIAtom> mMenuActiveAtom;
nsCOMPtr<nsIAtom> mMenuActiveAtom;
nsCOMPtr<nsIAtom> mCurPosAtom;
nsCOMPtr<nsIAtom> mMinPosAtom;
nsCOMPtr<nsIAtom> mMaxPosAtom;
};

View File

@ -78,6 +78,10 @@
#define TS_DISABLED 4
#define TS_FOCUSED 5
// These constants are reversed for the trackbar (scale) thumb
#define TKP_FOCUSED 4
#define TKP_DISABLED 5
// Toolbarbutton constants
#define TB_CHECKED 5
#define TB_HOVER_CHECKED 6
@ -105,6 +109,12 @@
#define SP_GRIPPERHOR 8
#define SP_GRIPPERVERT 9
// Scale constants
#define TKP_TRACK 1
#define TKP_TRACKVERT 2
#define TKP_THUMB 3
#define TKP_THUMBVERT 6
// Progress bar constants
#define PP_BAR 1
#define PP_BARVERT 2
@ -184,6 +194,7 @@ nsNativeThemeWin::nsNativeThemeWin() {
mRebarTheme = NULL;
mProgressTheme = NULL;
mScrollbarTheme = NULL;
mScaleTheme = NULL;
mStatusbarTheme = NULL;
mTabTheme = NULL;
mTreeViewTheme = NULL;
@ -316,6 +327,15 @@ nsNativeThemeWin::GetTheme(PRUint8 aWidgetType)
mScrollbarTheme = openTheme(NULL, L"Scrollbar");
return mScrollbarTheme;
}
case NS_THEME_SCALE_HORIZONTAL:
case NS_THEME_SCALE_VERTICAL:
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
{
if (!mScaleTheme)
mScaleTheme = openTheme(NULL, L"Trackbar");
return mScaleTheme;
}
case NS_THEME_STATUSBAR:
case NS_THEME_STATUSBAR_PANEL:
case NS_THEME_STATUSBAR_RESIZER_PANEL:
@ -588,6 +608,38 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
}
return NS_OK;
}
case NS_THEME_SCALE_HORIZONTAL:
case NS_THEME_SCALE_VERTICAL: {
aPart = (aWidgetType == NS_THEME_SCALE_HORIZONTAL) ?
TKP_TRACK : TKP_TRACKVERT;
aState = TS_NORMAL;
return NS_OK;
}
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL: {
aPart = (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL) ?
TKP_THUMB : TKP_THUMBVERT;
if (!aFrame)
aState = TS_NORMAL;
else if (IsDisabled(aFrame)) {
aState = TKP_DISABLED;
}
else {
PRInt32 eventState = GetContentState(aFrame, aWidgetType);
if (eventState & NS_EVENT_STATE_ACTIVE) // Hover is not also a requirement for
// the thumb, since the drag is not canceled
// when you move outside the thumb.
aState = TS_ACTIVE;
else if (eventState & NS_EVENT_STATE_FOCUS)
aState = TKP_FOCUSED;
else if (eventState & NS_EVENT_STATE_HOVER)
aState = TS_HOVER;
else
aState = TS_NORMAL;
}
return NS_OK;
}
case NS_THEME_TOOLBOX:
case NS_THEME_STATUSBAR:
case NS_THEME_SCROLLBAR: {
@ -844,15 +896,44 @@ nsNativeThemeWin::DrawWidgetBackground(nsIRenderingContext* aContext,
widgetRect.bottom -= 1;
}
// widgetRect is the bounding box for a widget, yet the scale track is only
// a small portion of this size, so the edges of the scale need to be
// adjusted to the real size of the track.
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
aWidgetType == NS_THEME_SCALE_VERTICAL) {
RECT contentRect;
getThemeContentRect(theme, hdc, part, state, &widgetRect, &contentRect);
SIZE siz;
getThemePartSize(theme, hdc, part, state, &widgetRect, 1, &siz);
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL) {
PRInt32 adjustment = (contentRect.bottom - contentRect.top - siz.cy) / 2 + 1;
contentRect.top += adjustment;
contentRect.bottom -= adjustment;
}
else {
PRInt32 adjustment = (contentRect.right - contentRect.left - siz.cx) / 2 + 1;
// need to subtract one from the left position, otherwise the scale's
// border isn't visible
contentRect.left += adjustment - 1;
contentRect.right -= adjustment;
}
drawThemeBG(theme, hdc, part, state, &contentRect, &clipRect);
}
// If part is negative, the element wishes us to not render a themed
// background, instead opting to be drawn specially below.
if (part >= 0)
else if (part >= 0) {
drawThemeBG(theme, hdc, part, state, &widgetRect, &clipRect);
}
// Draw focus rectangles for XP HTML checkboxes and radio buttons
// XXX it'd be nice to draw these outside of the frame
if ((aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_RADIO)
&& aFrame->GetContent()->IsNodeOfType(nsINode::eHTML)) {
&& aFrame->GetContent()->IsNodeOfType(nsIContent::eHTML) ||
aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
aWidgetType == NS_THEME_SCALE_VERTICAL) {
PRInt32 contentState ;
contentState = GetContentState(aFrame, aWidgetType);
@ -1013,6 +1094,11 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
return ClassicGetMinimumWidgetSize(aContext, aFrame, aWidgetType, aResult, aIsOverridable);
}
if (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL ||
aWidgetType == NS_THEME_SCALE_THUMB_VERTICAL) {
*aIsOverridable = PR_FALSE;
}
PRInt32 part, state;
nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
if (NS_FAILED(rv))
@ -1090,6 +1176,10 @@ nsNativeThemeWin::CloseData()
closeTheme(mScrollbarTheme);
mScrollbarTheme = NULL;
}
if (mScaleTheme) {
closeTheme(mScaleTheme);
mScaleTheme = NULL;
}
if (mRebarTheme) {
closeTheme(mRebarTheme);
mRebarTheme = NULL;
@ -1198,6 +1288,10 @@ nsNativeThemeWin::ClassicThemeSupportsWidget(nsPresContext* aPresContext,
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
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_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
case NS_THEME_DROPDOWN_BUTTON:
case NS_THEME_SPINNER_UP_BUTTON:
case NS_THEME_SPINNER_DOWN_BUTTON:
@ -1347,6 +1441,16 @@ nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIRenderingContext* aContext, nsI
// (*aResult).height = ::GetSystemMetrics(SM_CYVTHUMB) << 1;
break;
case NS_THEME_SCALE_THUMB_HORIZONTAL:
(*aResult).width = 12;
(*aResult).height = 20;
*aIsOverridable = PR_FALSE;
break;
case NS_THEME_SCALE_THUMB_VERTICAL:
(*aResult).width = 20;
(*aResult).height = 12;
*aIsOverridable = PR_FALSE;
break;
case NS_THEME_DROPDOWN_BUTTON:
(*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
break;
@ -1541,6 +1645,10 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
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_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
case NS_THEME_STATUSBAR:
case NS_THEME_STATUSBAR_PANEL:
case NS_THEME_STATUSBAR_RESIZER_PANEL:
@ -1785,6 +1893,38 @@ static void DrawMenuImage(HDC hdc, const RECT& rc, PRInt32 aComponent, PRUint32
}
#endif
void nsNativeThemeWin::DrawCheckedRect(HDC hdc, const RECT& rc, PRInt32 fore, PRInt32 back,
HBRUSH defaultBack)
{
static WORD patBits[8] = {
0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
};
HBITMAP patBmp = ::CreateBitmap(8, 8, 1, 1, patBits);
if (patBmp) {
HBRUSH brush = (HBRUSH) ::CreatePatternBrush(patBmp);
if (brush) {
COLORREF oldForeColor = ::SetTextColor(hdc, ::GetSysColor(fore));
COLORREF oldBackColor = ::SetBkColor(hdc, ::GetSysColor(back));
#ifndef WINCE
::UnrealizeObject(brush);
#endif
::SetBrushOrgEx(hdc, rc.left, rc.top, NULL);
HBRUSH oldBrush = (HBRUSH) ::SelectObject(hdc, brush);
::FillRect(hdc, &rc, brush);
::SetTextColor(hdc, oldForeColor);
::SetBkColor(hdc, oldBackColor);
::SelectObject(hdc, oldBrush);
::DeleteObject(brush);
}
else
::FillRect(hdc, &rc, defaultBack);
::DeleteObject(patBmp);
}
}
nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(nsIRenderingContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
@ -1962,6 +2102,15 @@ nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(nsIRenderingContext* aCon
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
break;
case NS_THEME_SCALE_THUMB_VERTICAL:
case NS_THEME_SCALE_THUMB_HORIZONTAL:
::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
if (IsDisabled(aFrame)) {
DrawCheckedRect(hdc, widgetRect, COLOR_3DFACE, COLOR_3DHILIGHT,
(HBRUSH) COLOR_3DHILIGHT);
}
break;
// Draw scrollbar track background
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
@ -1980,45 +2129,33 @@ nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(nsIRenderingContext* aCon
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_SCROLLBAR+1));
else
{
// Use checkerboard pattern brush
HBRUSH brush, oldBrush = NULL;
HBITMAP patBmp = NULL;
COLORREF oldBackColor, oldForeColor;
static WORD patBits[8] = {
0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
};
patBmp = ::CreateBitmap(8, 8, 1, 1, patBits);
if (patBmp) {
brush = (HBRUSH) ::CreatePatternBrush(patBmp);
if (brush) {
oldForeColor = ::SetTextColor(hdc, ::GetSysColor(COLOR_3DHILIGHT));
oldBackColor = ::SetBkColor(hdc, color3D);
#ifndef WINCE
::UnrealizeObject(brush);
#endif
::SetBrushOrgEx(hdc, widgetRect.left, widgetRect.top, NULL);
oldBrush = (HBRUSH) ::SelectObject(hdc, brush);
::FillRect(hdc, &widgetRect, brush);
::SetTextColor(hdc, oldForeColor);
::SetBkColor(hdc, oldBackColor);
::SelectObject(hdc, oldBrush);
::DeleteObject(brush);
}
else
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_SCROLLBAR+1));
::DeleteObject(patBmp);
}
DrawCheckedRect(hdc, widgetRect, COLOR_3DHILIGHT, COLOR_3DFACE,
(HBRUSH) COLOR_SCROLLBAR+1);
}
// XXX should invert the part of the track being clicked here
// but the track is never :active
break;
}
// Draw scale track background
case NS_THEME_SCALE_VERTICAL:
case NS_THEME_SCALE_HORIZONTAL: {
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL) {
PRInt32 adjustment = (widgetRect.bottom - widgetRect.top) / 2 - 2;
widgetRect.top += adjustment;
widgetRect.bottom -= adjustment;
}
else {
PRInt32 adjustment = (widgetRect.right - widgetRect.left) / 2 - 2;
widgetRect.left += adjustment;
widgetRect.right -= adjustment;
}
::DrawEdge(hdc, &widgetRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
::FillRect(hdc, &widgetRect, (HBRUSH) GetStockObject(GRAY_BRUSH));
break;
}
case NS_THEME_PROGRESSBAR_CHUNK:
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_HIGHLIGHT+1));

View File

@ -111,6 +111,9 @@ protected:
nsIFrame* aFrame,
PRUint8 aWidgetType);
void DrawCheckedRect(HDC hdc, const RECT& rc, PRInt32 fore, PRInt32 back,
HBRUSH defaultBack);
private:
HMODULE mThemeDLL;
HANDLE mButtonTheme;
@ -120,6 +123,7 @@ private:
HANDLE mRebarTheme;
HANDLE mProgressTheme;
HANDLE mScrollbarTheme;
HANDLE mScaleTheme;
HANDLE mStatusbarTheme;
HANDLE mTabTheme;
HANDLE mTreeViewTheme;

View File

@ -150,11 +150,9 @@ class nsNativeTheme
PRInt32 CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom);
PRBool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom);
private:
PRBool GetAttr(nsIFrame* aFrame, nsIAtom* aAtom, nsAString& attrValue);
PRBool GetCheckedOrSelected(nsIFrame* aFrame, PRBool aCheckSelected);
protected:
// these are available to subclasses because they are useful in
// implementing WidgetStateChanged()
nsCOMPtr<nsIAtom> mDisabledAtom;

View File

@ -52,6 +52,7 @@ toolkit.jar:
content/global/bindings/radio.xml (resources/content/bindings/radio.xml)
content/global/bindings/scrollbar.xml (resources/content/bindings/scrollbar.xml)
content/global/bindings/nativescrollbar.xml (resources/content/bindings/nativescrollbar.xml)
content/global/bindings/scale.xml (resources/content/bindings/scale.xml)
content/global/bindings/scrollbox.xml (resources/content/bindings/scrollbox.xml)
content/global/bindings/splitter.xml (resources/content/bindings/splitter.xml)
content/global/bindings/spinbuttons.xml (resources/content/bindings/spinbuttons.xml)

View File

@ -0,0 +1,168 @@
<?xml version="1.0"?>
<bindings id="scaleBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="scalethumb" extends="xul:button">
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
</binding>
<binding id="scaleslider" display="xul:slider"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
</binding>
<binding id="scale"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
<content align="center" pack="center">
<xul:slider anonid="slider" class="scale-slider" snap="true" flex="1"
xbl:inherits="disabled,orient,curpos=value,minpos=min,maxpos=max,increment,pageincrement">
<xul:thumb class="scale-thumb" xbl:inherits="disabled,orient"/>
</xul:slider>
</content>
<implementation>
<property name="value" onget="return this._getIntegerAttribute('curpos', 0);"
onset="return this._setIntegerAttribute('curpos', val);"/>
<property name="min" onget="return this._getIntegerAttribute('minpos', 0);"
onset="return this._setIntegerAttribute('minpos', val);"/>
<property name="max" onget="return this._getIntegerAttribute('maxpos', 100);"
onset="return this._setIntegerAttribute('maxpos', val);"/>
<property name="increment" onget="return this._getIntegerAttribute('increment', 1);"
onset="return this._setIntegerAttribute('increment', val);"/>
<property name="pageIncrement" onget="return this._getIntegerAttribute('pageincrement', 10);"
onset="return this._setIntegerAttribute('pageincrement', val);"/>
<field name="_sliderElement"/>
<property name="_slider" readonly="true">
<getter>
if (!this._sliderElement)
this._sliderElement = document.getAnonymousElementByAttribute(this, "anonid", "slider");
return this._sliderElement;
</getter>
</property>
<method name="_getIntegerAttribute">
<parameter name="aAttr"/>
<parameter name="aDefaultValue"/>
<body>
var value = this._slider.getAttribute(aAttr);
var intvalue = parseInt(value, 10);
if (!isNaN(intvalue))
return intvalue;
return aDefaultValue;
</body>
</method>
<method name="_setIntegerAttribute">
<parameter name="aAttr"/>
<parameter name="aValue"/>
<body>
var intvalue = parseInt(aValue, 10);
if (!isNaN(intvalue)) this._slider.setAttribute(aAttr, intvalue);
return aValue;
</body>
</method>
<method name="decrease">
<body>
<![CDATA[
var newpos = this.value - this.increment;
var startpos = this.min;
this.value = (newpos > startpos) ? newpos : startpos;
]]>
</body>
</method>
<method name="increase">
<body>
<![CDATA[
var newpos = this.value + this.increment;
var endpos = this.max;
this.value = (newpos < endpos) ? newpos : endpos;
]]>
</body>
</method>
<method name="decreasePage">
<body>
<![CDATA[
var newpos = this.value - this.pageIncrement;
var startpos = this.min;
this.value = (newpos > startpos) ? newpos : startpos;
]]>
</body>
</method>
<method name="increasePage">
<body>
<![CDATA[
var newpos = this.value + this.pageIncrement;
var endpos = this.max;
this.value = (newpos < endpos) ? newpos : endpos;
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="DOMAttrModified">
if (event.originalTarget != this._slider)
return;
switch (event.attrName) {
case "curpos":
this.setAttribute("value", event.newValue);
var changeEvent = document.createEvent("Events");
changeEvent.initEvent("change", false, true);
this.dispatchEvent(changeEvent);
break;
case "minpos":
this.setAttribute("min", event.newValue);
break;
case "maxpos":
this.setAttribute("max", event.newValue);
break;
}
</handler>
<handler event="keypress" keycode="VK_UP" preventdefault="true">
this.decrease();
</handler>
<handler event="keypress" keycode="VK_LEFT" preventdefault="true">
this.decrease();
</handler>
<handler event="keypress" keycode="VK_DOWN" preventdefault="true">
this.increase();
</handler>
<handler event="keypress" keycode="VK_RIGHT" preventdefault="true">
this.increase();
</handler>
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true">
this.decreasePage();
</handler>
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true">
this.increasePage();
</handler>
<handler event="keypress" keycode="VK_HOME" preventdefault="true">
this.value = this.min;
</handler>
<handler event="keypress" keycode="VK_END" preventdefault="true">
this.value = this.max;
</handler>
</handlers>
</binding>
</bindings>

View File

@ -85,7 +85,7 @@ iframe {
-moz-user-focus: normal;
}
menulist[editable] {
menulist[editable="true"] {
-moz-user-focus: ignore;
}
@ -686,7 +686,7 @@ menulist {
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist");
}
menulist[editable] {
menulist[editable="true"] {
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist-editable");
}
@ -731,13 +731,16 @@ scrollbar {
direction: ltr;
}
thumb
{
thumb {
-moz-binding: url(chrome://global/content/bindings/scrollbar.xml#thumb);
display: -moz-box !important;
}
scrollbar, scrollbarbutton, scrollcorner, slider, thumb {
.scale-thumb {
-moz-binding: url(chrome://global/content/bindings/scale.xml#scalethumb);
}
scrollbar, scrollbarbutton, scrollcorner, slider, thumb, scale {
-moz-user-select: none;
}
@ -753,6 +756,15 @@ scrollbar[value="hidden"] {
visibility: hidden;
}
scale {
-moz-binding: url(chrome://global/content/bindings/scale.xml#scale);
}
.scale-slider {
-moz-binding: url(chrome://global/content/bindings/scale.xml#scaleslider);
-moz-user-focus: normal;
}
/******** scrollbox ********/
scrollbox {