From e6631a0f7fdc8d3383927bac49f521791cddcc9c Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 12 Mar 2016 22:24:20 +0000 Subject: Moved the Fl_Window::decorated_*() functions teh Window_Driver git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11356 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx') diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx index 01f5225bd..6e7d546da 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -19,6 +19,7 @@ #include "../../config_lib.h" #include +#include #include #include #include @@ -47,6 +48,57 @@ Fl_WinAPI_Window_Driver::~Fl_WinAPI_Window_Driver() } } + +// --- private + +RECT Fl_WinAPI_Window_Driver::border_width_title_bar_height(int &bx, int &by, int &bt) +{ + Fl_Window *win = pWindow; + RECT r = {0,0,0,0}; + bx = by = bt = 0; + if (win->shown() && !win->parent() && win->border() && win->visible()) { + static HMODULE dwmapi_dll = LoadLibrary("dwmapi.dll"); + typedef HRESULT (WINAPI* DwmGetWindowAttribute_type)(HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute); + static DwmGetWindowAttribute_type DwmGetWindowAttribute = dwmapi_dll ? + (DwmGetWindowAttribute_type)GetProcAddress(dwmapi_dll, "DwmGetWindowAttribute") : NULL; + int need_r = 1; + if (DwmGetWindowAttribute) { + const DWORD DWMWA_EXTENDED_FRAME_BOUNDS = 9; + if ( DwmGetWindowAttribute(fl_xid(win), DWMWA_EXTENDED_FRAME_BOUNDS, &r, sizeof(RECT)) == S_OK ) { + need_r = 0; + } + } + if (need_r) { + GetWindowRect(fl_xid(win), &r); + } + bx = (r.right - r.left - win->w())/2; + by = bx; + bt = r.bottom - r.top - win->h() - 2*by; + } + return RECT(r); +} + + +// --- window data + +int Fl_WinAPI_Window_Driver::decorated_w() +{ + int bt, bx, by; + border_width_title_bar_height(bx, by, bt); + return pWindow->w() + 2 * bx; +} + +int Fl_WinAPI_Window_Driver::decorated_h() +{ + int bt, bx, by; + border_width_title_bar_height(bx, by, bt); + return pWindow->h() + bt + 2 * by; +} + + + + + void Fl_WinAPI_Window_Driver::shape_bitmap_(Fl_Image* b) { shape_data_->shape_ = b; } -- cgit v1.2.3