met->GetWidth(str, w); met->GetHeight(h); cx->DrawString(str, 2, (bounds.width - w) >> 1, (bounds.height - h) >> 1, 0); NS_RELEASE(met);
if (nsnull != met) { met->GetWidth(str, w); met->GetHeight(h); cx->DrawString(str, 2, (bounds.width - w) >> 1, (bounds.height - h) >> 1, 0); NS_RELEASE(met); }
HandleThrobberEvent(nsGUIEvent *aEvent){  nsThrobber* throbber = FindThrobberFor(aEvent->widget);  if (nsnull == throbber) {    return nsEventStatus_eIgnore;  }  switch (aEvent->message)  {    case NS_PAINT:    {      nsPaintEvent *pe = (nsPaintEvent *)aEvent;      nsIRenderingContext *cx = pe->renderingContext;      nsRect bounds;      nsIImageRequest *imgreq;      nsIImage *img;         pe->widget->GetBounds(bounds);      cx->SetClipRect(*pe->rect, nsClipCombine_kReplace);      cx->SetColor(NS_RGB(255, 255, 255));      cx->DrawLine(0, bounds.height - 1, 0, 0);      cx->DrawLine(0, 0, bounds.width, 0);      cx->SetColor(NS_RGB(128, 128, 128));      cx->DrawLine(bounds.width - 1, 1, bounds.width - 1, bounds.height - 1);      cx->DrawLine(bounds.width - 1, bounds.height - 1, 0, bounds.height - 1);      imgreq = (nsIImageRequest *)        throbber->mImages->ElementAt(throbber->mIndex);      if ((nsnull == imgreq) || (nsnull == (img = imgreq->GetImage())))      {        char str[10];        nsFont tfont = nsFont("monospace", 0, 0, 0, 0, 10);        nsIFontMetrics *met;        nscoord w, h;        cx->SetColor(NS_RGB(0, 0, 0));        cx->FillRect(1, 1, bounds.width - 2, bounds.height - 2);        PR_snprintf(str, sizeof(str), "%02d", throbber->mIndex);        cx->SetColor(NS_RGB(255, 255, 255));        cx->SetFont(tfont);        met = cx->GetFontMetrics();        met->GetWidth(str, w);        met->GetHeight(h);        cx->DrawString(str, 2, (bounds.width - w) >> 1, (bounds.height - h) >> 1, 0);        NS_RELEASE(met);      }      else      {        cx->DrawImage(img, 1, 1);        NS_RELEASE(img);      }      break;    }    case NS_MOUSE_LEFT_BUTTON_UP:      // XXX wire up to API      //gTheViewer->GoTo(nsString("http://www.mozilla.org"));      break;    case NS_MOUSE_ENTER:      aEvent->widget->SetCursor(eCursor_hyperlink);      break;    case NS_MOUSE_EXIT:      aEvent->widget->SetCursor(eCursor_standard);      break;  }  return nsEventStatus_eIgnore;}