1 /*
2  * Copyright 2011 Vincent Sanders <vince@simtec.co.uk>
3  *
4  * This file is part of NetSurf, http://www.netsurf-browser.org/
5  *
6  * NetSurf is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * NetSurf is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef NETSURF_WINDOWS_WINDOW_H_
20 #define NETSURF_WINDOWS_WINDOW_H_
21 
22 /** The window operation function table for win32 */
23 extern struct gui_window_table *win32_window_table;
24 
25 #include "netsurf/mouse.h"
26 
27 struct browser_mouse {
28        struct gui_window *gui;
29        struct box *box;
30 
31        double pressed_x;
32        double pressed_y;
33        bool waiting;
34        browser_mouse_state state;
35 };
36 
37 struct gui_window {
38 	/* The front's private data connected to a browser window */
39 	/* currently 1<->1 gui_window<->windows window [non-tabbed] */
40 	struct browser_window *bw; /**< the browser_window */
41 
42 	HWND main; /**< handle to the actual window */
43 	HWND toolbar; /**< toolbar handle */
44 	HWND urlbar; /**< url bar handle */
45 	HWND throbber; /** throbber handle */
46 	HWND drawingarea; /**< drawing area handle */
47 	HWND statusbar; /**< status bar handle */
48 	HWND vscroll; /**< vertical scrollbar handle */
49 	HWND hscroll; /**< horizontal scrollbar handle */
50 
51 	HMENU mainmenu; /**< the main menu */
52 	HMENU rclick; /**< the right-click menu */
53 	struct nsws_localhistory *localhistory;	/**< handle to local history window */
54 	int width; /**< width of window */
55 	int height; /**< height of drawing area */
56 
57 	int toolbuttonc; /**< number of toolbar buttons */
58 	int toolbuttonsize; /**< width, height of buttons */
59 	bool throbbing; /**< whether currently throbbing */
60 
61 	struct browser_mouse *mouse; /**< mouse state */
62 
63 	HACCEL acceltable; /**< accelerators */
64 
65 	HBITMAP hPageInfo[8]; /**< page info handles */
66 
67 	int scrollx; /**< current scroll location */
68 	int scrolly; /**< current scroll location */
69 
70 	RECT *fullscreen; /**< memorize non-fullscreen area */
71 	RECT redraw; /**< Area needing redraw. */
72 	int requestscrollx, requestscrolly; /**< scolling requested. */
73 	struct gui_window *next, *prev; /**< global linked list */
74 };
75 
76 struct rect;
77 
78 /**
79  * Obtain gui window structure from window handle.
80  *
81  * \param hwnd The window handle.
82  * \return The gui window associated with the window handle.
83  */
84 struct gui_window *nsws_get_gui_window(HWND hwnd);
85 
86 /**
87  * Cause a browser window to navigate to a url
88  *
89  * \param hwnd The win32 handle to the browser window or one of its decendants.
90  * \param urltxt The URL to navigate to.
91  */
92 bool nsws_window_go(HWND hwnd, const char *urltxt);
93 
94 /**
95  * Set the scroll position of a win32 browser window.
96  *
97  * Scrolls the viewport to ensure the specified rectangle of the
98  *   content is shown. The win32 implementation scrolls the contents so
99  *   the specified point in the content is at the top of the viewport.
100  *
101  * \param gw The win32 gui window to scroll.
102  * \param rect The rectangle to ensure is shown.
103  * \return NSERROR_OK on success or apropriate error code.
104  */
105 nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect);
106 
107 /**
108  * Create the main browser window class.
109  *
110  * \param hinstance The application instance
111  * \return NSERROR_OK on success or NSERROR_INIT_FAILED if the class
112  *         creation failed.
113  */
114 nserror nsws_create_main_class(HINSTANCE hinstance);
115 
116 /**
117  * Get the main win32 window handle from a gui window
118  */
119 HWND gui_window_main_window(struct gui_window *gw);
120 
121 /**
122  * Get the localhistory win32 window handle from a gui window
123  */
124 struct nsws_localhistory *gui_window_localhistory(struct gui_window *);
125 
126 
127 #endif /* _NETSURF_WINDOWS_WINDOW_H_ */
128