forked from mkoloberdin/waze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroadmap_browser.h
175 lines (140 loc) · 5.85 KB
/
roadmap_browser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/* roadmap_browser.h - Embedded browser
*
* LICENSE:
*
* Copyright 2010 Avi R.
*
* This file is part of RoadMap.
*
* RoadMap is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* RoadMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RoadMap; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ROADMAP_BROWSER_H_
#define ROADMAP_BROWSER_H_
#include "roadmap.h"
#include "roadmap_gui.h"
#define WAZE_CMD_URL_PREFIX ("waze://")
#define WAZE_EXTERN_URL_PREFIX ("waze://?open_url=")
#define WEB_VIEW_URL_MAXSIZE (2048)
#define BROWSER_BAR_NORMAL 0
#define BROWSER_BAR_EXTENDED 1
/*
* Note if you use these flags you need to set the title attributes (callbacks and labels for the buttons)
*/
#define BROWSER_FLAG_TITLE_BTN_LEFT1 0x00000001 // Button at the title bar of the browser
#define BROWSER_FLAG_TITLE_BTN_LEFT2 0x00000002 // Button at the title bar of the browser
#define BROWSER_FLAG_TITLE_BTN_RIGHT1 0x00000004 // Button at the title bar of the browser
#define BROWSER_FLAG_TITLE_BTN_RIGHT2 0x00000008 // Button at the title bar of the browser
#define BROWSER_FLAG_BACK_BY_HW_BUTTON 0x00000010 // Use hw back button to perform "back" in browser
#define BROWSER_FLAG_WINDOW_TYPE_EXTENDED (BROWSER_FLAG_TITLE_BTN_LEFT1| \
BROWSER_FLAG_TITLE_BTN_LEFT2| \
BROWSER_FLAG_TITLE_BTN_RIGHT1|\
BROWSER_FLAG_TITLE_BTN_RIGHT2)
/*
* Browser window type flags
*/
#define BROWSER_FLAG_WINDOW_TYPE_NORMAL 0x00000000
#define BROWSER_FLAG_WINDOW_TYPE_TRANSPARENT 0x00000020
#define BROWSER_FLAG_WINDOW_TYPE_NO_SCROLL 0x00000040
#define BROWSER_FLAG_WINDOW_TYPE_EMBEDDED 0x00000080
#define BROWSER_FLAG_WINDOW_NO_TITLE_BAR 0x00000100 // Don't show title bar
#define BROWSER_FLAG_CACHE_ONLY 0x00000200 // Load page and release browser
#if ((defined IPHONE) || (defined ANDROID))
#define BROWSER_WEB_VERSION "1"
#else
#define BROWSER_WEB_VERSION "0"
#endif
typedef void(*RMBrowserCallback) (int succeeded, void* context);
/*
* Title bar button attributes
*/
typedef struct
{
const char* btn_icon_up;
const char* btn_icon_down;
const char* btn_label;
RoadMapCallback btn_cb;
} RMBrTitleBtnAttributes;
/*
* Title bar attributes
* ______ ______ _______ ______
* Title form : | Left1 | Left2 | Title text | Right1 | Right2 |
*/
typedef struct
{
const char *title;
/*
* Buttons data { Left1, Left2, Right1, Right2 }
*/
RMBrTitleBtnAttributes buttons[4];
} RMBrTitleAttributes;
/*
* Browser attributes
* Note: No duplicates - references already allocated memory
*/
typedef struct
{
/*
* Title attributes
*/
RMBrTitleAttributes title_attrs;
RoadMapCallback on_close_cb; // To be called when the browser is closed
RMBrowserCallback on_load_cb; // To be called when browser finhishes loading a page
void *data; // external caller context
} RMBrowserAttributes;
/*
* Browser context to be passed to the native control
*/
typedef struct
{
RoadMapGuiRect rect; // The rectangle defining the dimensions of the native browser control
char url[WEB_VIEW_URL_MAXSIZE]; // url to load
int flags;
RMBrowserAttributes attrs;
} RMBrowserContext;
/*
* Callback type to be called upon container window size is changed
*/
typedef void (*RMBrowserResizeCb)( const RoadMapGuiRect* context );
/*
* Simple browser view - only title text is shown
*/
void roadmap_browser_show (const char* title, const char* url, RoadMapCallback on_close_cb,
RMBrowserCallback on_load_cb, void *context, int browser_flags );
void roadmap_browser_show_embedded( RMBrowserContext* context );
void roadmap_browser_close_embedded(void);
/*
* Customized browser view - buttons are shown at the title bar
* (See RMTitleAttributes for definitions)
*/
void roadmap_browser_show_extended ( const char* url, int browser_flags, const RMBrowserAttributes* attrs );
void roadmap_browser_set_button_attrs( RMBrTitleAttributes* attrs, int flag, const char* label, RoadMapCallback cb,
const char* icon_up, const char* icon_down );
void roadmap_browser_reset_attributes( RMBrowserAttributes* attrs );
typedef void (*RMBrowserLauncherCb)( const RMBrowserContext* context );
void roadmap_browser_register_launcher( RMBrowserLauncherCb launcher_cb );
void roadmap_browser_register_close( RoadMapCallback close_cb );
void roadmap_browser_register_resize( RMBrowserResizeCb resize_cb );
BOOL roadmap_browser_url_handler( const char* url );
void roadmap_browser_init( void );
void roadmap_browser_set_show_external (void);
void roadmap_browser_preload (const char* url, RMBrowserCallback on_load_cb, void *context);
void roadmap_browser_close( void );
#ifdef IPHONE
BOOL roadmap_browser_show_preloaded (void);
void roadmap_browser_iphone_preload (const char* title, const char* url, RoadMapCallback on_close_cb,
RMBrowserCallback on_load_cb, void *context, int bar_type, int flags);
void roadmap_browser_unload (void);
#endif //IPHONE
#endif /*ROADMAP_BROWSER_H_*/