// Paint this widget in response to an "Expose" event. protected override void OnPaint(Graphics graphics) { XPixmap pixmap; if((flags & CaptionWidget.CaptionFlags.HasClose) != 0) { pixmap = graphics.dpy.bitmaps.Close; } else if((flags & CaptionWidget.CaptionFlags.HasRestore) != 0) { pixmap = graphics.dpy.bitmaps.Restore; } else { pixmap = graphics.dpy.bitmaps.Minimize; } int x = (width - 9) / 2; int y = (height - 9) / 2; if(pressed && entered) { graphics.DrawEffect(0, 0, width, height, Effect.CaptionButtonIndented); ++x; ++y; } else { graphics.DrawEffect(0, 0, width, height, Effect.CaptionButtonRaised); } graphics.DrawBitmap(x, y, 9, 9, pixmap); }
// Draw a caption button. Returns the width of the button. private static int DrawCaptionButton (Graphics graphics, Rectangle rect, int subtract, bool pressed, bool draw, XPixmap buttonPixmap) { int buttonSize = rect.height - 4; int x = rect.x + rect.width - subtract - buttonSize; int y = rect.y + 2; if(draw) { if(pressed) { graphics.DrawEffect(x, y, buttonSize, buttonSize, Effect.CaptionButtonIndented); ++x; ++y; } else { graphics.DrawEffect(x, y, buttonSize, buttonSize, Effect.CaptionButtonRaised); } x += (buttonSize - 9) / 2; y += (buttonSize - 9) / 2; graphics.DrawBitmap(x, y, 9, 9, buttonPixmap); } return buttonSize; }