[not part of build] This version arranges things so that the menu item drawn is drawn against the appropriate edge of the imaginary menu that contains the item. Therefore if attop or atbottom are true, the appropriate

This commit is contained in:
beard%netscape.com 2000-11-28 07:19:58 +00:00
Родитель ceb73e004b
Коммит 7f68875e28
1 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -37,6 +37,12 @@
*/ */
typedef map<string, string> Arguments; typedef map<string, string> Arguments;
/**
* Extra space to use to draw borders on menus correctly
*/
static const PRInt8 mMenuDrawingBufferExtension = 6;
static nsresult parseArguments(const string& path, Arguments& args) static nsresult parseArguments(const string& path, Arguments& args)
{ {
// str should be of the form: widget?name1=value1&...&nameN=valueN // str should be of the form: widget?name1=value1&...&nameN=valueN
@ -362,6 +368,7 @@ static nsresult drawThemeMenuItem(Arguments& args, nsIInputStream **result, PRIn
nsresult rv = NS_ERROR_OUT_OF_MEMORY; nsresult rv = NS_ERROR_OUT_OF_MEMORY;
OSStatus status; OSStatus status;
PRInt8 yOffset;
ThemeMenuState state = (isActive ? (isSelected? kThemeMenuSelected : kThemeMenuActive) : kThemeMenuDisabled); ThemeMenuState state = (isActive ? (isSelected? kThemeMenuSelected : kThemeMenuActive) : kThemeMenuDisabled);
ThemeMenuItemType type = (hasSubMenu ? kThemeMenuItemHierarchical : kThemeMenuItemPlain); ThemeMenuItemType type = (hasSubMenu ? kThemeMenuItemHierarchical : kThemeMenuItemPlain);
@ -370,8 +377,12 @@ static nsresult drawThemeMenuItem(Arguments& args, nsIInputStream **result, PRIn
if (isAtTop) { if (isAtTop) {
type += kThemeMenuItemAtTop; type += kThemeMenuItemAtTop;
yOffset=0;
} else if (isAtBottom) { } else if (isAtBottom) {
type += kThemeMenuItemAtBottom; type += kThemeMenuItemAtBottom;
yOffset = mMenuDrawingBufferExtension;
} else {
yOffset = mMenuDrawingBufferExtension/2;
} }
if (isInSubMenu) { if (isInSubMenu) {
@ -394,15 +405,18 @@ static nsresult drawThemeMenuItem(Arguments& args, nsIInputStream **result, PRIn
width += extraWidth; width += extraWidth;
height += extraHeight; height += extraHeight;
} }
Rect itemBounds = { height / 2, 0, 3 * height / 2 , width };
Rect menuBounds = { 0, 0, 2*height, width }; //make an imaginary menu a little bigger than the item, then position the item within this
TempGWorld world(menuBounds); //menu so that the right edge effects are included when attop or atbottom is true (see above)
Rect itemBounds = { yOffset, 0, height + yOffset, width };
Rect menuBounds = { 0, 0, height + mMenuDrawingBufferExtension, width };
TempGWorld world(itemBounds);
if (world.valid()) { if (world.valid()) {
// initialize the GWorld with all black, alpha=0xFF. // initialize the GWorld with all black, alpha=0xFF.
world.fill(0xFF000000); world.fill(0xFF000000);
status = ::DrawThemeMenuItem(&menuBounds, &itemBounds, 0, 2*height, state, type, status = ::DrawThemeMenuItem(&menuBounds, &itemBounds, 0,
NULL, NULL); height+mMenuDrawingBufferExtension, state, type, NULL, NULL);
// now, for all pixels that aren't 0xFF000000, turn on the alpha channel, // now, for all pixels that aren't 0xFF000000, turn on the alpha channel,
// otherwise turn it off on the pixels that weren't touched. // otherwise turn it off on the pixels that weren't touched.