public void DrawWindowFrame(Gtk.Widget w, string caption, int x, int y, int width, int height) { Gdk.Drawable drawable = w.GdkWindow; Gdk.Pixmap pix = new Gdk.Pixmap(drawable, width, height, drawable.Depth); Gdk.GC gcc = new Gdk.GC(pix); gcc.Foreground = w.Style.Backgrounds [(int)Gtk.StateType.Normal]; pix.DrawRectangle(gcc, true, 0, 0, width, height); IntPtr hdc = gdk_win32_hdc_get(pix.Handle, gcc.Handle, 0); RECT r = new RECT(0, 0, width, height); SIZE size; GetThemePartSize(hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, 1, out size); r.Bottom = size.cy; DrawThemeBackground(hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, ref r); RECT rf = new RECT(FrameBorder, FrameBorder, width - FrameBorder * 2, size.cy); LOGFONT lf = new LOGFONT(); GetThemeSysFont(hTheme, TMT_CAPTIONFONT, ref lf); IntPtr titleFont = CreateFontIndirect(ref lf); IntPtr oldFont = SelectObject(hdc, titleFont); SetBkMode(hdc, 1 /*TRANSPARENT*/); DrawThemeText(hTheme, hdc, WP_CAPTION, CS_ACTIVE, caption, -1, DT_LEFT | DT_SINGLELINE | DT_WORD_ELLIPSIS, 0, ref rf); SelectObject(hdc, oldFont); DeleteObject(titleFont); int ny = r.Bottom; r = new RECT(0, ny, width, height); DrawThemeBackground(hTheme, hdc, WP_FRAMEBOTTOM, 0, ref r, ref r); gdk_win32_hdc_release(pix.Handle, gcc.Handle, 0); Gdk.Pixbuf img = Gdk.Pixbuf.FromDrawable(pix, pix.Colormap, 0, 0, 0, 0, width, height); drawable.DrawPixbuf(new Gdk.GC(drawable), img, 0, 0, x, y, width, height, Gdk.RgbDither.None, 0, 0); drawable.DrawRectangle(w.Style.BackgroundGC(Gtk.StateType.Normal), true, x + FrameBorder, y + size.cy, width - FrameBorder * 2, height - FrameBorder - size.cy); }
public void DrawWindowFrame (Gtk.Widget w, string caption, int x, int y, int width, int height) { Gdk.Drawable drawable = w.GdkWindow; Gdk.Pixmap pix = new Gdk.Pixmap (drawable, width, height, drawable.Depth); Gdk.GC gcc = new Gdk.GC (pix); gcc.Foreground = w.Style.Backgrounds [(int)Gtk.StateType.Normal]; pix.DrawRectangle (gcc, true, 0, 0, width, height); IntPtr hdc = gdk_win32_hdc_get (pix.Handle, gcc.Handle, 0); RECT r = new RECT (0, 0, width, height); SIZE size; GetThemePartSize (hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, 1, out size); r.Bottom = size.cy; DrawThemeBackground (hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, ref r); RECT rf = new RECT (FrameBorder, FrameBorder, width - FrameBorder * 2, size.cy); LOGFONT lf = new LOGFONT (); GetThemeSysFont (hTheme, TMT_CAPTIONFONT, ref lf); IntPtr titleFont = CreateFontIndirect (ref lf); IntPtr oldFont = SelectObject (hdc, titleFont); SetBkMode (hdc, 1 /*TRANSPARENT*/); DrawThemeText (hTheme, hdc, WP_CAPTION, CS_ACTIVE, caption, -1, DT_LEFT | DT_SINGLELINE | DT_WORD_ELLIPSIS, 0, ref rf); SelectObject (hdc, oldFont); DeleteObject (titleFont); int ny = r.Bottom; r = new RECT (0, ny, width, height); DrawThemeBackground (hTheme, hdc, WP_FRAMEBOTTOM, 0, ref r, ref r); gdk_win32_hdc_release (pix.Handle, gcc.Handle, 0); Gdk.Pixbuf img = Gdk.Pixbuf.FromDrawable (pix, pix.Colormap, 0, 0, 0, 0, width, height); drawable.DrawPixbuf (new Gdk.GC (drawable), img, 0, 0, x, y, width, height, Gdk.RgbDither.None, 0, 0); drawable.DrawRectangle (w.Style.BackgroundGC (Gtk.StateType.Normal), true, x + FrameBorder, y + size.cy, width - FrameBorder * 2, height - FrameBorder - size.cy); }
static extern IntPtr CreateFontIndirect([In] ref LOGFONT lplf);
extern static Int32 GetThemeSysFont(IntPtr hTheme, int iFontId, ref LOGFONT plf);
extern static Int32 GetThemeSysFont (IntPtr hTheme, int iFontId, ref LOGFONT plf);