47
49
# include <sys/time.h>
48
50
# include <unistd.h>
50
# if !defined(USE_WSOCK1)
51
# include <winsock2.h>
56
#if !defined(USE_WSOCK1)
57
# define WSCK_DLL_NAME "WS2_32.DLL"
59
# define WSCK_DLL_NAME "WSOCK32.DLL"
64
#if defined(__GNUC__) && __GNUC__ >= 3
53
#if !defined(NO_TRACK_MOUSE)
54
# include <commctrl.h> // TrackMouseEvent
55
// fabien: Ms Visual Studio >= 2003 permit embedded lib reference
56
// that makes fltk use easier as only fltk libs are now requested
57
// This idea could be extended to fltk libs themselves,
58
// implementer should then care about DLL linkage flags ...
60
# pragma comment (lib, "comctl32.lib")
65
65
# include <wchar.h>
68
// The following include files require GCC 3.x or a non-GNU compiler...
69
#if !defined(__GNUC__) || __GNUC__ >= 3
71
# include <shellapi.h>
72
#endif // !__GNUC__ || __GNUC__ >= 3
98
95
static Fl_GDI_Graphics_Driver fl_gdi_driver;
99
96
static Fl_Display_Device fl_gdi_display(&fl_gdi_driver);
100
FL_EXPORT Fl_Display_Device *fl_display_device = (Fl_Display_Device*)&fl_gdi_display; // does not change
101
97
FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = (Fl_Graphics_Driver*)&fl_gdi_driver; // the current target driver of graphics operations
102
FL_EXPORT Fl_Surface_Device *fl_surface = (Fl_Surface_Device*)fl_display_device; // the current target surface of graphics operations
98
Fl_Surface_Device* Fl_Surface_Device::_surface = (Fl_Surface_Device*)&fl_gdi_display; // the current target surface of graphics operations
99
Fl_Display_Device *Fl_Display_Device::_display = &fl_gdi_display; // the platform display
104
101
// dynamic wsock dll handling api:
105
102
#if defined(__CYGWIN__) && !defined(SOCKET)
106
103
# define SOCKET int
106
// note: winsock2.h has been #include'd in Fl.cxx
107
#define WSCK_DLL_NAME "WS2_32.DLL"
108
109
typedef int (WINAPI* fl_wsk_select_f)(int, fd_set*, fd_set*, fd_set*, const struct timeval*);
109
110
typedef int (WINAPI* fl_wsk_fd_is_set_f)(SOCKET, fd_set *);
111
112
static HMODULE s_wsock_mod = 0;
112
static fl_wsk_select_f s_wsock_select=0;
113
static fl_wsk_fd_is_set_f fl_wsk_fd_is_set=0;
113
static fl_wsk_select_f s_wsock_select = 0;
114
static fl_wsk_fd_is_set_f fl_wsk_fd_is_set = 0;
115
116
static HMODULE get_wsock_mod() {
116
117
if (!s_wsock_mod) {
750
750
{VK_DIVIDE, FL_KP+'/'},
751
751
{VK_NUMLOCK, FL_Num_Lock},
752
752
{VK_SCROLL, FL_Scroll_Lock},
753
# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0500)
754
{VK_BROWSER_BACK, FL_Back},
755
{VK_BROWSER_FORWARD, FL_Forward},
756
{VK_BROWSER_REFRESH, FL_Refresh},
757
{VK_BROWSER_STOP, FL_Stop},
758
{VK_BROWSER_SEARCH, FL_Search},
759
{VK_BROWSER_FAVORITES, FL_Favorites},
760
{VK_BROWSER_HOME, FL_Home_Page},
761
{VK_VOLUME_MUTE, FL_Volume_Mute},
762
{VK_VOLUME_DOWN, FL_Volume_Down},
763
{VK_VOLUME_UP, FL_Volume_Up},
764
{VK_MEDIA_NEXT_TRACK, FL_Media_Next},
765
{VK_MEDIA_PREV_TRACK, FL_Media_Prev},
766
{VK_MEDIA_STOP, FL_Media_Stop},
767
{VK_MEDIA_PLAY_PAUSE, FL_Media_Play},
768
{VK_LAUNCH_MAIL, FL_Mail},
1400
1432
first_class_name = class_name;
1403
const wchar_t* class_namew = L"FLTK";
1404
const wchar_t* message_namew = L"FLTK::ThreadWakeup";
1435
wchar_t class_namew[100]; // (limited) buffer for Windows class name
1437
// convert UTF-8 class_name to wchar_t for RegisterClassExW and CreateWindowExW
1439
fl_utf8toUtf16(class_name,strlen(class_name), // in
1440
(unsigned short*)class_namew, // out
1441
sizeof(class_namew)/sizeof(wchar_t)); // max. size
1405
1443
if (!class_name_list.has_name(class_name)) {
1407
1444
WNDCLASSEXW wcw;
1409
memset(&wc, 0, sizeof(wc));
1410
wc.cbSize = sizeof(WNDCLASSEX);
1411
1445
memset(&wcw, 0, sizeof(wcw));
1412
1446
wcw.cbSize = sizeof(WNDCLASSEXW);
1547
1579
w->redraw(); // force draw to happen
1549
1581
// If we've captured the mouse, we dont want to activate any
1550
// other windows from the code, or we loose the capture.
1582
// other windows from the code, or we lose the capture.
1551
1583
ShowWindow(x->xid, !showit ? SW_SHOWMINNOACTIVE :
1552
1584
(Fl::grab() || (style & WS_POPUP)) ? SW_SHOWNOACTIVATE : SW_SHOWNORMAL);
1554
// Drag-n-drop requires GCC 3.x or a non-GNU compiler...
1555
#if !defined(__GNUC__) || __GNUC__ >= 3
1556
1586
// Register all windows for potential drag'n'drop operations
1557
static char oleInitialized = 0;
1558
if (!oleInitialized) { OleInitialize(0L); oleInitialized=1; }
1560
1588
RegisterDragDrop(x->xid, flIDropTarget);
1561
1590
if (!fl_aimm) {
1562
static char been_here = 0;
1563
if (!been_here && !oleInitialized) CoInitialize(NULL);
1565
1591
CoCreateInstance(CLSID_CActiveIMM, NULL, CLSCTX_INPROC_SERVER,
1566
1592
IID_IActiveIMMApp, (void**) &fl_aimm);
1568
1594
fl_aimm->Activate(TRUE);
1571
#endif // !__GNUC__ || __GNUC__ >= 3
1573
1598
if (w->modal()) {Fl::modal_ = w; fl_fix_focus();}
1929
1954
Fl_Region XRectangleRegion(int x, int y, int w, int h) {
1930
if (Fl_Surface_Device::surface()->type() == Fl_Display_Device::device_type) return CreateRectRgn(x,y,x+w,y+h);
1955
if (Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id) return CreateRectRgn(x,y,x+w,y+h);
1931
1956
// because rotation may apply, the rectangle becomes a polygon in device coords
1932
1957
POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} };
1933
1958
LPtoDP(fl_gc, pt, 4);
1934
1959
return CreatePolygonRgn(pt, 4, ALTERNATE);
1962
Window fl_xid_(const Fl_Window *w) {
1963
Fl_X *temp = Fl_X::i(w);
1964
return temp ? temp->xid : 0;
1967
int Fl_Window::decorated_w()
1969
if (!shown() || parent() || !border() || !visible()) return w();
1970
int X, Y, bt, bx, by;
1971
Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
1972
return w() + 2 * bx;
1975
int Fl_Window::decorated_h()
1977
if (!shown() || parent() || !border() || !visible()) return h();
1978
int X, Y, bt, bx, by;
1979
Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
1980
return h() + bt + 2 * by;
1983
void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
1985
if (!win->shown() || win->parent() || !win->border() || !win->visible()) {
1986
this->print_widget(win, x_offset, y_offset);
1989
int X, Y, bt, bx, by, ww, wh; // compute the window border sizes
1990
Fl_X::fake_X_wm(win, X, Y, bt, bx, by);
1991
ww = win->w() + 2 * bx;
1992
wh = win->h() + bt + 2 * by;
1993
Fl_Display_Device::display_device()->set_current(); // make window current
1996
win->make_current();
1997
HDC save_gc = fl_gc;
1998
fl_gc = GetDC(NULL); // get the screen device context
1999
// capture the 4 window sides from screen
2000
RECT r; GetWindowRect(fl_window, &r);
2001
uchar *top_image = fl_read_image(NULL, r.left, r.top, ww, bt + by);
2002
uchar *left_image = fl_read_image(NULL, r.left, r.top, bx, wh);
2003
uchar *right_image = fl_read_image(NULL, r.right - bx, r.top, bx, wh);
2004
uchar *bottom_image = fl_read_image(NULL, r.left, r.bottom-by, ww, by);
2005
ReleaseDC(NULL, fl_gc); fl_gc = save_gc;
2006
this->set_current();
2007
// print the 4 window sides
2008
fl_draw_image(top_image, x_offset, y_offset, ww, bt + by, 3);
2009
fl_draw_image(left_image, x_offset, y_offset, bx, wh, 3);
2010
fl_draw_image(right_image, x_offset + win->w() + bx, y_offset, bx, wh, 3);
2011
fl_draw_image(bottom_image, x_offset, y_offset + win->h() + bt + by, ww, by, 3);
2013
delete[] left_image;
2014
delete[] right_image;
2015
delete[] bottom_image;
2016
// print the window inner part
2017
this->print_widget(win, x_offset + bx, y_offset + bt + by);
2018
fl_gc = GetDC(fl_xid(win));
2019
ReleaseDC(fl_xid(win), fl_gc);
1937
2022
#ifdef USE_PRINT_BUTTON
1938
2023
// to test the Fl_Printer class creating a "Print front window" button in a separate window
1939
2024
// contains also preparePrintFront call above