font cache is no longer public.

This commit is contained in:
michaelp%netscape.com 1998-09-30 18:59:31 +00:00
Родитель 6b3518d778
Коммит 9520dad117
7 изменённых файлов: 31 добавлений и 703 удалений

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

@ -18,7 +18,6 @@
#include "nsWindow.h" #include "nsWindow.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIFontCache.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsIRenderingContext.h" #include "nsIRenderingContext.h"
#include "nsIDeviceContext.h" #include "nsIDeviceContext.h"
@ -689,24 +688,17 @@ nsIFontMetrics* nsWindow::GetFont(void)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP nsWindow::SetFont(const nsFont &aFont) NS_IMETHODIMP nsWindow::SetFont(const nsFont &aFont)
{ {
if (mContext == nsnull) { if (mContext == nsnull) {
return NS_OK; return NS_OK;
} }
nsIFontCache* fontCache = nsnull; nsIFontMetrics* metrics;
mContext->GetFontCache(fontCache); mContext->GetMetricsFor(aFont, metrics);
if (fontCache != nsnull) { if (metrics != nsnull) {
nsIFontMetrics* metrics;
fontCache->GetMetricsFor(aFont, metrics);
if (metrics != nsnull) {
NS_RELEASE(metrics); NS_RELEASE(metrics);
} else { } else {
printf("****** Error: Metrics is NULL!\n"); printf("****** Error: Metrics is NULL!\n");
} }
NS_RELEASE(fontCache);
} else {
printf("****** Error: FontCache is NULL!\n");
}
return NS_OK; return NS_OK;
} }

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

@ -18,7 +18,6 @@
#include "nsWindow.h" #include "nsWindow.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIFontCache.h"
#include "nsFont.h" #include "nsFont.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsIRenderingContext.h" #include "nsIRenderingContext.h"
@ -848,38 +847,30 @@ NS_METHOD nsWindow::SetFont(const nsFont &aFont)
if (mContext == nsnull) { if (mContext == nsnull) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsIFontCache* fontCache; nsIFontMetrics* metrics;
mContext->GetFontCache(fontCache); mContext->GetMetricsFor(aFont, metrics);
if (fontCache != nsnull) { if (metrics != nsnull) {
nsIFontMetrics* metrics;
fontCache->GetMetricsFor(aFont, metrics);
if (metrics != nsnull) {
XmFontList fontList = NULL; XmFontList fontList = NULL;
XmFontListEntry entry = NULL; XmFontListEntry entry = NULL;
nsFontHandle fontHandle; nsFontHandle fontHandle;
metrics->GetFontHandle(fontHandle); metrics->GetFontHandle(fontHandle);
XFontStruct * fontStruct = XQueryFont(XtDisplay(mWidget), (XID)fontHandle); XFontStruct * fontStruct = XQueryFont(XtDisplay(mWidget), (XID)fontHandle);
if (fontStruct != NULL) { if (fontStruct != NULL) {
entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
XmFONT_IS_FONT, fontStruct); XmFONT_IS_FONT, fontStruct);
fontList = XmFontListAppendEntry(NULL, entry); fontList = XmFontListAppendEntry(NULL, entry);
XtVaSetValues(mWidget, XmNfontList, fontList, NULL); XtVaSetValues(mWidget, XmNfontList, fontList, NULL);
XmFontListEntryFree(&entry); XmFontListEntryFree(&entry);
XmFontListFree(fontList); XmFontListFree(fontList);
}
NS_RELEASE(metrics);
} else {
printf("****** Error: Metrics is NULL!\n");
return NS_ERROR_FAILURE;
} }
NS_RELEASE(fontCache);
NS_RELEASE(metrics);
} else { } else {
printf("****** Error: FontCache is NULL!\n"); printf("****** Error: Metrics is NULL!\n");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

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

@ -1,195 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsDialog.h"
#include "nsToolkit.h"
#include "nsColor.h"
#include "nsGUIEvent.h"
#include "nsString.h"
#include "nsStringUtil.h"
#include <windows.h>
#include "nsIAppShell.h"
#include "nsIFontMetrics.h"
#include "nsIFontCache.h"
#include "nsGUIEvent.h"
#include "nsIRenderingContext.h"
#include "nsIDeviceContext.h"
#include "nsRect.h"
#include "nsTransform2D.h"
#include "nsStringUtil.h"
#include <windows.h>
#include "nsGfxCIID.h"
#include "resource.h"
#include <commctrl.h>
NS_IMPL_ADDREF(nsDialog)
NS_IMPL_RELEASE(nsDialog)
//-------------------------------------------------------------------------
//
// nsDialog constructor
//
//-------------------------------------------------------------------------
nsDialog::nsDialog() : nsWindow(), nsIDialog()
{
NS_INIT_REFCNT();
}
//-------------------------------------------------------------------------
//
// Create the proper widget
//
//-------------------------------------------------------------------------
NS_METHOD nsDialog::Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
return nsWindow::Create(aParent,aRect,aHandleEventFunction,aContext,aAppShell,aToolkit,aInitData);
}
//-------------------------------------------------------------------------
//
// nsDialog destructor
//
//-------------------------------------------------------------------------
nsDialog::~nsDialog()
{
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsDialog::SetLabel(const nsString& aText)
{
NS_ALLOC_STR_BUF(label, aText, 256);
VERIFY(::SetWindowText(mWnd, label));
NS_FREE_STR_BUF(label);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsDialog::GetLabel(nsString& aBuffer)
{
int actualSize = ::GetWindowTextLength(mWnd)+1;
NS_ALLOC_CHAR_BUF(label, 256, actualSize);
::GetWindowText(mWnd, label, actualSize);
aBuffer.SetLength(0);
aBuffer.Append(label);
NS_FREE_CHAR_BUF(label);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Query interface implementation
//
//-------------------------------------------------------------------------
nsresult nsDialog::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr);
static NS_DEFINE_IID(kInsDialogIID, NS_IDIALOG_IID);
if (result == NS_NOINTERFACE && aIID.Equals(kInsDialogIID)) {
*aInstancePtr = (void*) ((nsIDialog*)this);
NS_ADDREF_THIS();
result = NS_OK;
}
return result;
}
//-------------------------------------------------------------------------
//
// move, paint, resizes message - ignore
//
//-------------------------------------------------------------------------
PRBool nsDialog::OnMove(PRInt32, PRInt32)
{
return PR_FALSE;
}
PRBool nsDialog::OnPaint()
{
return nsWindow::OnPaint();
}
PRBool nsDialog::OnResize(nsRect &aWindowRect)
{
return nsWindow::OnResize(aWindowRect);
}
//-------------------------------------------------------------------------
//
// return the window class name and initialize the class if needed
//
//-------------------------------------------------------------------------
LPCTSTR nsDialog::WindowClass()
{
return nsWindow::WindowClass();
}
//-------------------------------------------------------------------------
//
// return window styles
//
//-------------------------------------------------------------------------
DWORD nsDialog::WindowStyle()
{
//return DS_MODALFRAME;
return WS_CAPTION | WS_SYSMENU;
}
//-------------------------------------------------------------------------
//
// return window extended styles
//
//-------------------------------------------------------------------------
DWORD nsDialog::WindowExStyle()
{
//return WS_EX_DLGMODALFRAME;
return WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
}
//-------------------------------------------------------------------------
//
// get position/dimensions
//
//-------------------------------------------------------------------------
NS_METHOD nsDialog::GetBounds(nsRect &aRect)
{
return nsWindow::GetBounds(aRect);
}

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

@ -21,7 +21,6 @@
#include "nspr.h" #include "nspr.h"
#include "nsIButton.h" #include "nsIButton.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIFontCache.h"
#include "nsIDeviceContext.h" #include "nsIDeviceContext.h"
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
@ -894,11 +893,8 @@ void nsImageButton::PerformAlignment(const nsRect & aRect,
// set up initial text size // set up initial text size
if (mShowText) { if (mShowText) {
nsIFontCache* fontCache;
mContext->GetFontCache(fontCache);
nsIFontMetrics* metrics; nsIFontMetrics* metrics;
fontCache->GetMetricsFor(mFont, metrics); mContext->GetMetricsFor(mFont, metrics);
NS_RELEASE(fontCache);
metrics->GetHeight(string_height); metrics->GetHeight(string_height);
metrics->GetWidth(aText, string_width); metrics->GetWidth(aText, string_width);

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

@ -23,7 +23,6 @@
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsString.h" #include "nsString.h"
#include "nsStringUtil.h" #include "nsStringUtil.h"
#include "nsIFontCache.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIDeviceContext.h" #include "nsIDeviceContext.h"
#include <windows.h> #include <windows.h>
@ -199,12 +198,8 @@ NS_METHOD nsLabel::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
{ {
//nsIFontMetrics * fm = GetFont();; //nsIFontMetrics * fm = GetFont();;
// mDeviceContext->GetMetricsFor(mFont, &fm); // mDeviceContext->GetMetricsFor(mFont, &fm);
nsIFontCache* fontCache;
mContext->GetFontCache(fontCache);
nsIFontMetrics* metrics; nsIFontMetrics* metrics;
fontCache->GetMetricsFor(*mFont, metrics); mContext->GetMetricsFor(*mFont, metrics);
NS_RELEASE(fontCache);
nsString text; nsString text;
GetLabel(text); GetLabel(text);

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

@ -1,447 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsMenuButton.h"
#include "nsWidgetsCID.h"
#include "nspr.h"
#include "nsIFontMetrics.h"
#include "nsIFontCache.h"
#include "nsIDeviceContext.h"
#include "nsWidgetsCID.h"
#include "nsRepository.h"
#include "nsIWidget.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kCMenuButtonCID, NS_MENUBUTTON_CID);
static NS_DEFINE_IID(kCIMenuButtonIID, NS_IMENUBUTTON_IID);
static NS_DEFINE_IID(kIPopUpMenuIID, NS_IPOPUPMENU_IID);
static NS_DEFINE_IID(kPopUpMenuCID, NS_POPUPMENU_CID);
static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID);
static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID);
NS_IMPL_ADDREF(nsMenuButton)
NS_IMPL_RELEASE(nsMenuButton)
//------------------------------------------------------------
nsMenuButton::nsMenuButton() : nsImageButton(), nsIMenuButton()
{
NS_INIT_REFCNT();
mPopUpMenu = nsnull;
mMenuIsPoppedUp = PR_FALSE;
}
//------------------------------------------------------------
nsMenuButton::~nsMenuButton()
{
NS_IF_RELEASE(mPopUpMenu);
}
//------------------------------------------------------------
nsresult nsMenuButton::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, kCMenuButtonCID);
if (aIID.Equals(kCIMenuButtonIID)) {
*aInstancePtr = (void*) (nsIMenuButton *)this;
AddRef();
return NS_OK;
}
if (aIID.Equals(kClassIID)) {
*aInstancePtr = (void*) (nsMenuButton *)this;
AddRef();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) (this);
AddRef();
return NS_OK;
}
return (nsImageButton::QueryInterface(aIID, aInstancePtr));
}
//------------------------------------------------------------
void nsMenuButton::CreatePopUpMenu()
{
if (nsnull != mPopUpMenu) {
return;
}
// Create and place back button
nsresult rv = nsRepository::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID,
(void**)&mPopUpMenu);
if (NS_OK == rv) {
nsIWidget * menuParentWidget;
if (NS_OK != this->QueryInterface(kIWidgetIID,(void**)&menuParentWidget)) {
return;
}
nsIWidget * popupWidget;
nsRect rect;
if (NS_OK == mPopUpMenu->QueryInterface(kIWidgetIID,(void**)&popupWidget)) {
popupWidget->Create(menuParentWidget, rect, nsnull, nsnull);
NS_RELEASE(popupWidget);
}
NS_RELEASE(menuParentWidget);
}
return;
}
//------------------------------------------------------------
NS_METHOD nsMenuButton::GetPopUpMenu(nsIPopUpMenu *& aPopUpMenu)
{
CreatePopUpMenu();
NS_ADDREF(mPopUpMenu);
aPopUpMenu = mPopUpMenu;
return NS_OK;
}
//------------------------------------------------------------
NS_METHOD nsMenuButton::AddMenuItem(const nsString& aMenuLabel, PRInt32 aCommand)
{
CreatePopUpMenu();
nsIMenuItem * menuItem = nsnull;
nsresult rv = nsRepository::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem);
menuItem->Create(mPopUpMenu, aMenuLabel, aCommand);
if (NS_OK == rv) {
mPopUpMenu->AddItem(menuItem);
NS_RELEASE(menuItem);
}
return NS_OK;
}
//------------------------------------------------------------
NS_METHOD nsMenuButton::InsertMenuItem(const nsString& aMenuLabel, PRInt32 aCommand, PRInt32 aPos)
{
CreatePopUpMenu();
return NS_OK;
}
//------------------------------------------------------------
NS_METHOD nsMenuButton::RemovesMenuItem(PRInt32 aPos)
{
CreatePopUpMenu();
return NS_OK;
}
//------------------------------------------------------------
NS_METHOD nsMenuButton::RemoveAllMenuItems(PRInt32 aPos)
{
CreatePopUpMenu();
return NS_OK;
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::OnLeftButtonDown(nsGUIEvent *aEvent)
{
mState |= eButtonState_pressed;
Invalidate(PR_TRUE);
nsRect rect;
GetBounds(rect);
if (mPopUpMenu) {
mMenuIsPoppedUp = PR_TRUE;
mPopUpMenu->ShowMenu(0, rect.height);
mMenuIsPoppedUp = PR_FALSE;
}
return nsEventStatus_eIgnore;
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::PaintBorder(nsIRenderingContext & aRenderingContext,
const nsRect & aDirtyRect,
const nsRect & aEntireRect)
{
nsRect rect(aEntireRect);
if ((mState == eButtonState_up || (mState & eButtonState_disabled)) && !mAlwaysShowBorder && !mMenuIsPoppedUp) {
return nsEventStatus_eConsumeNoDefault;
}
rect.x = 0;
rect.y = 0;
rect.width--;
rect.height--;
if (mShowButtonBorder) {
aRenderingContext.SetColor(NS_RGB(0,0,0));
aRenderingContext.DrawRect(0,0, rect.width, rect.height);
rect.x++;
rect.y++;
rect.width -= 2;
rect.height -= 2;
}
if ((mState & eButtonState_pressed) || mMenuIsPoppedUp) {
aRenderingContext.SetColor(mHighlightColor);
} else {
aRenderingContext.SetColor(mShadowColor);
}
aRenderingContext.DrawLine(rect.x, rect.height, rect.width, rect.height);
aRenderingContext.DrawLine(rect.width, rect.y, rect.width, rect.height);
if ((mState & eButtonState_pressed) || mMenuIsPoppedUp) {
aRenderingContext.SetColor(mShadowColor);
} else {
aRenderingContext.SetColor(mHighlightColor);
}
aRenderingContext.DrawLine(rect.x,rect.y, rect.width,rect.y);
aRenderingContext.DrawLine(rect.x,rect.y, rect.x, rect.height);
return nsEventStatus_eConsumeNoDefault;
}
//------------------------------------------------------------
nsresult nsMenuButton::SetBounds(const nsRect &aBounds)
{
return nsImageButton::SetBounds(aBounds);
}
//------------------------------------------------------------
nsEventStatus nsMenuButton::OnPaint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
return nsImageButton::OnPaint(aRenderingContext, aDirtyRect);
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::OnMouseMove(nsGUIEvent *aEvent)
{
return nsImageButton::OnMouseMove(aEvent);
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::OnMouseEnter(nsGUIEvent *aEvent)
{
return nsImageButton::OnMouseEnter(aEvent);
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::OnMouseExit(nsGUIEvent *aEvent)
{
return nsImageButton::OnMouseExit(aEvent);
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::OnLeftButtonUp(nsGUIEvent *aEvent)
{
return nsImageButton::OnLeftButtonUp(aEvent);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::GetLabel(nsString & aString)
{
return nsImageButton::GetLabel(aString);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::SetLabel(const nsString& aString)
{
return nsImageButton::SetLabel(aString);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::GetRollOverDesc(nsString & aString)
{
return nsImageButton::GetRollOverDesc(aString);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::SetRollOverDesc(const nsString& aString)
{
return nsImageButton::SetRollOverDesc(aString);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::GetCommand(PRInt32 & aCommand)
{
return nsImageButton::GetCommand(aCommand);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::SetCommand(PRInt32 aCommand)
{
return nsImageButton::SetCommand(aCommand);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::GetHighlightColor(nscolor &aColor)
{
return nsImageButton::GetHighlightColor(aColor);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::SetHighlightColor(const nscolor &aColor)
{
return nsImageButton::SetHighlightColor(aColor);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::GetShadowColor(nscolor &aColor)
{
return nsImageButton::GetShadowColor(aColor);
}
//-----------------------------------------------------------------------------
NS_METHOD nsMenuButton::SetShadowColor(const nscolor &aColor)
{
return nsImageButton::SetShadowColor(aColor);
}
//-----------------------------------------------------------------------------
nsEventStatus nsMenuButton::HandleEvent(nsGUIEvent *aEvent)
{
return nsImageButton::HandleEvent(aEvent);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight)
{
return nsImageButton::SetImageDimensions(aWidth, aHeight);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetImageURLs(const nsString& aUpURL,
const nsString& aPressedURL,
const nsString& aDisabledURL,
const nsString& aRollOverURL)
{
return nsImageButton::SetImageURLs(aUpURL, aPressedURL, aDisabledURL, aRollOverURL);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetShowBorder(PRBool aState)
{
return nsImageButton::SetShowBorder(aState);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetAlwaysShowBorder(PRBool aState)
{
return nsImageButton::SetAlwaysShowBorder(aState);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SwapHighlightShadowColors()
{
return nsImageButton::SwapHighlightShadowColors();
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetShowButtonBorder(PRBool aState)
{
return nsImageButton::SetShowButtonBorder(aState);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetBorderWidth(PRInt32 aWidth)
{
return nsImageButton::SetBorderWidth(aWidth);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetBorderOffset(PRInt32 aOffset)
{
return nsImageButton::SetBorderOffset(aOffset);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetShowText(PRBool aState)
{
return nsImageButton::SetShowText(aState);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetShowImage(PRBool aState)
{
return nsImageButton::SetShowImage(aState);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetImageVerticalAlignment(nsButtonVerticalAligment aAlign)
{
return nsImageButton::SetImageVerticalAlignment(aAlign);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign)
{
return nsImageButton::SetImageHorizontalAlignment(aAlign);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetTextVerticalAlignment(nsButtonVerticalAligment aAlign)
{
return nsImageButton::SetTextVerticalAlignment(aAlign);
}
//----------------------------------------------------------------
NS_METHOD nsMenuButton::SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign)
{
return nsImageButton::SetTextHorizontalAlignment(aAlign);
}
//-------------------------------------------------------------------------
NS_METHOD nsMenuButton::AddListener(nsIImageButtonListener * aListener)
{
return nsImageButton::AddListener(aListener);
}
//-------------------------------------------------------------------------
NS_METHOD nsMenuButton::RemoveListener(nsIImageButtonListener * aListener)
{
return nsImageButton::RemoveListener(aListener);
}
//-------------------------------------------------------------------------
NS_METHOD nsMenuButton::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
{
return nsImageButton::GetPreferredSize(aWidth, aHeight);
}
//-------------------------------------------------------------------------
NS_METHOD nsMenuButton::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
{
return nsImageButton::SetPreferredSize(aWidth, aHeight);
}
//-------------------------------------------------------------------------
NS_METHOD nsMenuButton::Enable(PRBool aState)
{
return nsImageButton::Enable(aState);
}

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

@ -19,7 +19,6 @@
#include "nsWindow.h" #include "nsWindow.h"
#include "nsIAppShell.h" #include "nsIAppShell.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIFontCache.h"
#include "nsFont.h" #include "nsFont.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsIRenderingContext.h" #include "nsIRenderingContext.h"
@ -886,10 +885,8 @@ nsIFontMetrics* nsWindow::GetFont(void)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsWindow::SetFont(const nsFont &aFont) NS_METHOD nsWindow::SetFont(const nsFont &aFont)
{ {
nsIFontCache* fontCache;
mContext->GetFontCache(fontCache);
nsIFontMetrics* metrics; nsIFontMetrics* metrics;
fontCache->GetMetricsFor(aFont, metrics); mContext->GetMetricsFor(aFont, metrics);
nsFontHandle fontHandle; nsFontHandle fontHandle;
metrics->GetFontHandle(fontHandle); metrics->GetFontHandle(fontHandle);
HFONT hfont = (HFONT)fontHandle; HFONT hfont = (HFONT)fontHandle;
@ -897,7 +894,6 @@ NS_METHOD nsWindow::SetFont(const nsFont &aFont)
// Draw in the new font // Draw in the new font
::SendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0); ::SendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0);
NS_RELEASE(metrics); NS_RELEASE(metrics);
NS_RELEASE(fontCache);
// XXX Temporary, should not be caching the font // XXX Temporary, should not be caching the font
if (mFont == nsnull) { if (mFont == nsnull) {