summaryrefslogtreecommitdiff
path: root/navit/gui/win32
diff options
context:
space:
mode:
Diffstat (limited to 'navit/gui/win32')
-rw-r--r--navit/gui/win32/CMakeLists.txt2
-rw-r--r--navit/gui/win32/ceglue.c149
-rw-r--r--navit/gui/win32/ceglue.h32
-rw-r--r--navit/gui/win32/gui_win32.c865
-rw-r--r--navit/gui/win32/win32_gui_destination.c142
-rw-r--r--navit/gui/win32/win32_gui_notify.c118
6 files changed, 605 insertions, 703 deletions
diff --git a/navit/gui/win32/CMakeLists.txt b/navit/gui/win32/CMakeLists.txt
index 16b653c9f..2c5dd0923 100644
--- a/navit/gui/win32/CMakeLists.txt
+++ b/navit/gui/win32/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(gui_win32 gui_win32.c win32_gui_destination.c win32_gui_notify.c ceglue.c)
+module_add_library(gui_win32 gui_win32.c win32_gui_destination.c win32_gui_notify.c ceglue.c)
diff --git a/navit/gui/win32/ceglue.c b/navit/gui/win32/ceglue.c
index a0817f935..ff3310fb2 100644
--- a/navit/gui/win32/ceglue.c
+++ b/navit/gui/win32/ceglue.c
@@ -1,77 +1,72 @@
-#include <windows.h>
-#include "ceglue.h"
-
-BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;
-
-void InitCeGlue (void)
-{
- HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
- if (ayg != NULL) {
- SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
- GetProcAddressW (ayg, TEXT ("SHFullScreen"));
- }
-}
-
-// code to turn of screen adopted from
-// http://msdn.microsoft.com/en-us/library/ms838354.aspx
-
-// GDI Escapes for ExtEscape()
-#define QUERYESCSUPPORT 8
-
-// The following are unique to CE
-#define GETVFRAMEPHYSICAL 6144
-#define GETVFRAMELEN 6145
-#define DBGDRIVERSTAT 6146
-#define SETPOWERMANAGEMENT 6147
-#define GETPOWERMANAGEMENT 6148
-
-
-typedef enum _VIDEO_POWER_STATE {
- VideoPowerOn = 1,
- VideoPowerStandBy,
- VideoPowerSuspend,
- VideoPowerOff
-} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
-
-
-typedef struct _VIDEO_POWER_MANAGEMENT {
- ULONG Length;
- ULONG DPMSVersion;
- ULONG PowerState;
-} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
-
-
-int CeEnableBacklight(int enable)
-{
- HDC gdc;
- int iESC=SETPOWERMANAGEMENT;
-
- gdc = GetDC(NULL);
- if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
- 0, NULL)==0)
- {
- MessageBox(NULL,
- L"Sorry, your Pocket PC does not support DisplayOff",
- L"Pocket PC Display Off Feature",
- MB_OK);
- ReleaseDC(NULL, gdc);
- return FALSE;
- }
- else
- {
- VIDEO_POWER_MANAGEMENT vpm;
- vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
- vpm.DPMSVersion = 0x0001;
- if (enable) {
- vpm.PowerState = VideoPowerOn;
- } else {
- vpm.PowerState = VideoPowerOff;
- }
- // Power off the display
- ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
- 0, NULL);
- ReleaseDC(NULL, gdc);
- return TRUE;
- }
-}
-
+#include <windows.h>
+#include "ceglue.h"
+
+BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;
+
+void InitCeGlue (void) {
+ HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
+ if (ayg != NULL) {
+ SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
+ GetProcAddressW (ayg, TEXT ("SHFullScreen"));
+ }
+}
+
+// code to turn of screen adopted from
+// http://msdn.microsoft.com/en-us/library/ms838354.aspx
+
+// GDI Escapes for ExtEscape()
+#define QUERYESCSUPPORT 8
+
+// The following are unique to CE
+#define GETVFRAMEPHYSICAL 6144
+#define GETVFRAMELEN 6145
+#define DBGDRIVERSTAT 6146
+#define SETPOWERMANAGEMENT 6147
+#define GETPOWERMANAGEMENT 6148
+
+
+typedef enum _VIDEO_POWER_STATE {
+ VideoPowerOn = 1,
+ VideoPowerStandBy,
+ VideoPowerSuspend,
+ VideoPowerOff
+} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
+
+
+typedef struct _VIDEO_POWER_MANAGEMENT {
+ ULONG Length;
+ ULONG DPMSVersion;
+ ULONG PowerState;
+} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
+
+
+int CeEnableBacklight(int enable) {
+ HDC gdc;
+ int iESC=SETPOWERMANAGEMENT;
+
+ gdc = GetDC(NULL);
+ if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
+ 0, NULL)==0) {
+ MessageBox(NULL,
+ L"Sorry, your Pocket PC does not support DisplayOff",
+ L"Pocket PC Display Off Feature",
+ MB_OK);
+ ReleaseDC(NULL, gdc);
+ return FALSE;
+ } else {
+ VIDEO_POWER_MANAGEMENT vpm;
+ vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
+ vpm.DPMSVersion = 0x0001;
+ if (enable) {
+ vpm.PowerState = VideoPowerOn;
+ } else {
+ vpm.PowerState = VideoPowerOff;
+ }
+ // Power off the display
+ ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
+ 0, NULL);
+ ReleaseDC(NULL, gdc);
+ return TRUE;
+ }
+}
+
diff --git a/navit/gui/win32/ceglue.h b/navit/gui/win32/ceglue.h
index b0dc79d42..bb185dbed 100644
--- a/navit/gui/win32/ceglue.h
+++ b/navit/gui/win32/ceglue.h
@@ -1,16 +1,16 @@
-#ifndef CEGLUE_H
-#define CEGLUE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern BOOL (*SHFullScreenPtr)(HWND hwnd, DWORD state);
-void InitCeGlue (void);
-
-int CeEnableBacklight(int enable);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#ifndef CEGLUE_H
+#define CEGLUE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern BOOL (*SHFullScreenPtr)(HWND hwnd, DWORD state);
+void InitCeGlue (void);
+
+int CeEnableBacklight(int enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/navit/gui/win32/gui_win32.c b/navit/gui/win32/gui_win32.c
index 8a8cb37b9..63edd73df 100644
--- a/navit/gui/win32/gui_win32.c
+++ b/navit/gui/win32/gui_win32.c
@@ -36,459 +36,429 @@ const TCHAR g_szClassName[] = TEXT("navit_gui_class");
static UINT_PTR menu_id = 0;
#if 0
-static gboolean message_pump( gpointer data )
-{
+static gboolean message_pump( gpointer data ) {
MSG messages;
- Sleep( 1 );
+ Sleep( 1 );
- if (GetMessage (&messages, NULL, 0, 0))
- {
+ if (GetMessage (&messages, NULL, 0, 0)) {
TranslateMessage(&messages);
DispatchMessage(&messages);
+ } else {
+ exit( 0 );
}
- else{
- exit( 0 );
- }
- return TRUE;
+ return TRUE;
}
-static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
-{
+static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) {
LPRECT rcParent;
int idChild;
idChild = GetWindowLong(hwndChild, GWL_ID);
- if ( idChild == ID_CHILD_GFX )
- {
- rcParent = (LPRECT) lParam;
+ if ( idChild == ID_CHILD_GFX ) {
+ rcParent = (LPRECT) lParam;
- MoveWindow( hwndChild, 0, 0, rcParent->right, rcParent->bottom, TRUE );
- PostMessage( hwndChild, WM_USER+1, 0, 0 );
- }
+ MoveWindow( hwndChild, 0, 0, rcParent->right, rcParent->bottom, TRUE );
+ PostMessage( hwndChild, WM_USER+1, 0, 0 );
+ }
return TRUE;
}
#endif
#ifndef GET_WHEEL_DELTA_WPARAM
- #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
+#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
#endif
-static void CreateToolBar(HWND hwnd)
-{
- // Create Toolbar
- HWND hTool;
- TBBUTTON tbb[8];
- TBADDBITMAP tbab;
+static void CreateToolBar(HWND hwnd) {
+ // Create Toolbar
+ HWND hTool;
+ TBBUTTON tbb[8];
+ TBADDBITMAP tbab;
#if 0 /* def _WIN32_WCE */
- /* Have to initialize common controls under CE */
- INITCOMMONCONTROLSEX iccex;
- iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
- iccex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx (&iccex);
+ /* Have to initialize common controls under CE */
+ INITCOMMONCONTROLSEX iccex;
+ iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
+ iccex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx (&iccex);
#else
- InitCommonControls();
+ InitCommonControls();
#endif
- hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
- hwnd, (HMENU)ID_CHILD_TOOLBAR, GetModuleHandle(NULL), NULL);
-
- if(hTool == NULL)
- MessageBox(hwnd, TEXT("Could not create tool bar."), TEXT("Error"), MB_OK | MB_ICONERROR);
-
- SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
-
- tbab.hInst = GetModuleHandle(NULL);
- tbab.nID = IDB_NAVITTOOLBAR;
- int iImageOffset = SendMessage(hTool, TB_ADDBITMAP, 10, (LPARAM) &tbab);
-
- int iStr;
-
- ZeroMemory(tbb, sizeof(tbb));
-
- tbb[0].iBitmap = iImageOffset;
- tbb[0].fsState = TBSTATE_ENABLED;
- tbb[0].fsStyle = TBSTYLE_BUTTON;
- tbb[0].idCommand = ID_DISPLAY_ZOOMIN;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomIn" );
- tbb[0].iString = iStr;
-
- tbb[1].iBitmap = iImageOffset+1;
- tbb[1].fsState = TBSTATE_ENABLED;
- tbb[1].fsStyle = TBSTYLE_BUTTON;
- tbb[1].idCommand = ID_DISPLAY_ZOOMOUT;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomOut" );
- tbb[1].iString = iStr;
-
- tbb[2].iBitmap = iImageOffset+4;
- tbb[2].fsState = TBSTATE_ENABLED;
- tbb[2].fsStyle = TBSTYLE_BUTTON;
- tbb[2].idCommand = ID_DISPLAY_REFRESH;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Refresh" );
- tbb[2].iString = iStr;
-
- tbb[3].iBitmap = iImageOffset+2;
- tbb[3].fsState = TBSTATE_ENABLED;
- tbb[3].fsStyle = TBSTYLE_BUTTON;
- tbb[3].idCommand = ID_DISPLAY_ZOOMIN;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Cursor" );
- tbb[3].iString = iStr;
-
- tbb[4].iBitmap = iImageOffset+5;
- tbb[4].fsState = TBSTATE_ENABLED;
- tbb[4].fsStyle = TBSTYLE_BUTTON;
- tbb[4].idCommand = ID_DISPLAY_ORIENT;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Orientation" );
- tbb[4].iString = iStr;
-
- tbb[5].iBitmap = iImageOffset+8;
- tbb[5].fsState = TBSTATE_ENABLED;
- tbb[5].fsStyle = TBSTYLE_BUTTON;
- tbb[5].idCommand = ID_DISPLAY_ZOOMIN;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Destination" );
- tbb[5].iString = iStr;
-
- tbb[6].iBitmap = iImageOffset+3;
- tbb[6].fsState = TBSTATE_ENABLED;
- tbb[6].fsStyle = TBSTYLE_BUTTON;
- tbb[6].idCommand = ID_DISPLAY_ZOOMIN;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Roadbook" );
- tbb[6].iString = iStr;
-
- tbb[7].iBitmap = iImageOffset+9;
- tbb[7].fsState = TBSTATE_ENABLED;
- tbb[7].fsStyle = TBSTYLE_BUTTON;
- tbb[7].idCommand = ID_FILE_EXIT;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"_Quit" );
- tbb[7].iString = iStr;
-
- SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
+ hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
+ hwnd, (HMENU)ID_CHILD_TOOLBAR, GetModuleHandle(NULL), NULL);
+
+ if(hTool == NULL)
+ MessageBox(hwnd, TEXT("Could not create tool bar."), TEXT("Error"), MB_OK | MB_ICONERROR);
+
+ SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+
+ tbab.hInst = GetModuleHandle(NULL);
+ tbab.nID = IDB_NAVITTOOLBAR;
+ int iImageOffset = SendMessage(hTool, TB_ADDBITMAP, 10, (LPARAM) &tbab);
+
+ int iStr;
+
+ ZeroMemory(tbb, sizeof(tbb));
+
+ tbb[0].iBitmap = iImageOffset;
+ tbb[0].fsState = TBSTATE_ENABLED;
+ tbb[0].fsStyle = TBSTYLE_BUTTON;
+ tbb[0].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomIn" );
+ tbb[0].iString = iStr;
+
+ tbb[1].iBitmap = iImageOffset+1;
+ tbb[1].fsState = TBSTATE_ENABLED;
+ tbb[1].fsStyle = TBSTYLE_BUTTON;
+ tbb[1].idCommand = ID_DISPLAY_ZOOMOUT;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomOut" );
+ tbb[1].iString = iStr;
+
+ tbb[2].iBitmap = iImageOffset+4;
+ tbb[2].fsState = TBSTATE_ENABLED;
+ tbb[2].fsStyle = TBSTYLE_BUTTON;
+ tbb[2].idCommand = ID_DISPLAY_REFRESH;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Refresh" );
+ tbb[2].iString = iStr;
+
+ tbb[3].iBitmap = iImageOffset+2;
+ tbb[3].fsState = TBSTATE_ENABLED;
+ tbb[3].fsStyle = TBSTYLE_BUTTON;
+ tbb[3].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Cursor" );
+ tbb[3].iString = iStr;
+
+ tbb[4].iBitmap = iImageOffset+5;
+ tbb[4].fsState = TBSTATE_ENABLED;
+ tbb[4].fsStyle = TBSTYLE_BUTTON;
+ tbb[4].idCommand = ID_DISPLAY_ORIENT;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Orientation" );
+ tbb[4].iString = iStr;
+
+ tbb[5].iBitmap = iImageOffset+8;
+ tbb[5].fsState = TBSTATE_ENABLED;
+ tbb[5].fsStyle = TBSTYLE_BUTTON;
+ tbb[5].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Destination" );
+ tbb[5].iString = iStr;
+
+ tbb[6].iBitmap = iImageOffset+3;
+ tbb[6].fsState = TBSTATE_ENABLED;
+ tbb[6].fsStyle = TBSTYLE_BUTTON;
+ tbb[6].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Roadbook" );
+ tbb[6].iString = iStr;
+
+ tbb[7].iBitmap = iImageOffset+9;
+ tbb[7].fsState = TBSTATE_ENABLED;
+ tbb[7].fsStyle = TBSTYLE_BUTTON;
+ tbb[7].idCommand = ID_FILE_EXIT;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"_Quit" );
+ tbb[7].iString = iStr;
+
+ SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
}
-static void window_layout( HWND hwnd )
-{
+static void window_layout( HWND hwnd ) {
#ifndef HAVE_API_WIN32_CE
- RECT rcClient;
- RECT rcTool;
- int iToolHeight;
+ RECT rcClient;
+ RECT rcTool;
+ int iToolHeight;
- HWND hChild = GetDlgItem(hwnd, ID_CHILD_TOOLBAR);
- SendMessage(hChild, TB_AUTOSIZE, 0, 0);
+ HWND hChild = GetDlgItem(hwnd, ID_CHILD_TOOLBAR);
+ SendMessage(hChild, TB_AUTOSIZE, 0, 0);
- GetWindowRect(hChild, &rcTool);
- iToolHeight = rcTool.bottom - rcTool.top;
+ GetWindowRect(hChild, &rcTool);
+ iToolHeight = rcTool.bottom - rcTool.top;
- GetClientRect(hwnd, &rcClient);
- //printf( "BEFORE resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
+ GetClientRect(hwnd, &rcClient);
+ //printf( "BEFORE resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
- rcClient.top += iToolHeight;
+ rcClient.top += iToolHeight;
- dbg(lvl_debug, "resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
+ dbg(lvl_debug, "resize gui to: %d %d %d %d ", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
- hChild = GetDlgItem(hwnd, ID_CHILD_GFX);
- if ( hChild )
- {
- MoveWindow( hChild, rcClient.left, rcClient.top, rcClient.right- rcClient.left, rcClient.bottom - rcClient.top, TRUE );
- PostMessage( hChild, WM_USER+1, 0, 0 );
- }
+ hChild = GetDlgItem(hwnd, ID_CHILD_GFX);
+ if ( hChild ) {
+ MoveWindow( hChild, rcClient.left, rcClient.top, rcClient.right- rcClient.left, rcClient.bottom - rcClient.top, TRUE );
+ PostMessage( hChild, WM_USER+1, 0, 0 );
+ }
#endif
}
#ifdef __CEGCC__
-static void toggle_fullscreen(HWND mWnd)
-{
- if (SHFullScreenPtr) {
- if (!ce_fullscreen) {
- (*SHFullScreenPtr)(mWnd, SHFS_HIDETASKBAR |
- SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
- } else {
- (*SHFullScreenPtr)(mWnd, SHFS_HIDESIPBUTTON);
- }
- ce_fullscreen = !ce_fullscreen;
- }
+static void toggle_fullscreen(HWND mWnd) {
+ if (SHFullScreenPtr) {
+ if (!ce_fullscreen) {
+ (*SHFullScreenPtr)(mWnd, SHFS_HIDETASKBAR |
+ SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
+ } else {
+ (*SHFullScreenPtr)(mWnd, SHFS_HIDESIPBUTTON);
+ }
+ ce_fullscreen = !ce_fullscreen;
+ }
}
-static void toggle_backlight(void)
-{
- if (ce_backlight)
- if (CeEnableBacklight(FALSE))
- ce_backlight = 0;
- else
- if (CeEnableBacklight(TRUE))
- ce_backlight = 1;
+static void toggle_backlight(void) {
+ if (ce_backlight)
+ if (CeEnableBacklight(FALSE))
+ ce_backlight = 0;
+ else if (CeEnableBacklight(TRUE))
+ ce_backlight = 1;
}
#endif
-static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
RECT rcClient;
// printf( "PARENT %d %d %d \n", Message, wParam, lParam );
- switch(Message)
- {
- case WM_CREATE:
- {
- HMENU hMenu, hSubMenu;
+ switch(Message) {
+ case WM_CREATE: {
+ HMENU hMenu, hSubMenu;
- CreateToolBar( hwnd );
+ CreateToolBar( hwnd );
- hMenu = CreateMenu();
- // g_this_->hwnd = hwnd;
+ hMenu = CreateMenu();
+ // g_this_->hwnd = hwnd;
- hSubMenu = CreatePopupMenu();
+ hSubMenu = CreatePopupMenu();
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMIN, L"ZoomIn" );
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMOUT, L"ZoomOut" );
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_REFRESH, L"Refresh" );
- AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL );
- AppendMenuW(hSubMenu, MF_STRING, ID_FILE_EXIT, L"_Quit" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMIN, L"ZoomIn" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMOUT, L"ZoomOut" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_REFRESH, L"Refresh" );
+ AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL );
+ AppendMenuW(hSubMenu, MF_STRING, ID_FILE_EXIT, L"_Quit" );
- AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"Display" );
- hSubMenu = CreatePopupMenu();
- AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, TEXT("&Go"));
- AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&Stuff"));
+ AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"Display" );
+ hSubMenu = CreatePopupMenu();
+ AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, TEXT("&Go"));
+ AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&Stuff"));
#ifndef HAVE_API_WIN32_CE
- SetMenu(hwnd, hMenu);
+ SetMenu(hwnd, hMenu);
#endif
- window_layout( hwnd );
-
- }
- break;
- case WM_COMMAND:
- {
- printf( "WM_COMMAND %d\n", LOWORD(wParam) );
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
-
- switch(LOWORD(wParam))
- {
- case ID_DISPLAY_ZOOMIN:
- navit_zoom_in(gui->nav, 2, NULL);
- return 0;
- break;
- case ID_DISPLAY_ZOOMOUT:
- navit_zoom_out(gui->nav, 2, NULL);
- return 0;
- break;
- case ID_DISPLAY_REFRESH:
- navit_draw(gui->nav);
- return 0;
- break;
- case ID_DISPLAY_CURSOR:
- {
- struct attr attr;
- attr.type=attr_cursor;
- // TODO attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_cursor\n");
- }
- return 0;
- }
- break;
- case ID_DISPLAY_ORIENT:
- {
- struct attr attr;
-
- attr.type=attr_orientation;
- // attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- attr.u.num = 0; // TODO
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_orientation\n");
- }
- return 0;
- }
-
- case ID_FILE_EXIT:
- PostMessage(hwnd, WM_CLOSE, 0, 0);
- return 0;
- break;
- }
-#if HAVE_GLIB
- if ( popup_menu_array )
- {
- struct menu_priv* priv = (struct menu_priv*)g_array_index( popup_menu_array, gint, LOWORD(wParam) - POPUP_MENU_OFFSET );
-
- if ( priv )
- {
- struct callback* cb = priv->cb;
- if ( priv->cb )
- {
- callback_call_0( priv->cb );
- return 0;
- }
- }
- }
-#endif
- }
- break;
- case WM_USER+ 1:
- GetClientRect(hwnd, &rcClient);
- printf( "resize gui to: %d %d \n", rcClient.right, rcClient.bottom );
-
- window_layout( hwnd );
- //EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient);
+ window_layout( hwnd );
+
+ }
+ break;
+ case WM_COMMAND: {
+ printf( "WM_COMMAND %d\n", LOWORD(wParam) );
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+
+
+ switch(LOWORD(wParam)) {
+ case ID_DISPLAY_ZOOMIN:
+ navit_zoom_in(gui->nav, 2, NULL);
+ return 0;
+ break;
+ case ID_DISPLAY_ZOOMOUT:
+ navit_zoom_out(gui->nav, 2, NULL);
+ return 0;
+ break;
+ case ID_DISPLAY_REFRESH:
+ navit_draw(gui->nav);
+ return 0;
+ break;
+ case ID_DISPLAY_CURSOR: {
+ struct attr attr;
+ attr.type=attr_cursor;
+ // TODO attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_cursor");
+ }
return 0;
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_SIZE:
- window_layout( hwnd );
+ }
+ break;
+ case ID_DISPLAY_ORIENT: {
+ struct attr attr;
+
+ attr.type=attr_orientation;
+ // attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ attr.u.num = 0; // TODO
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_orientation");
+ }
return 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
-
- case WM_MOUSEWHEEL:
- {
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
- short delta = GET_WHEEL_DELTA_WPARAM( wParam );
- if ( delta > 0 )
- {
- navit_zoom_in(gui->nav, 2, NULL);
- }
- else{
- navit_zoom_out(gui->nav, 2, NULL);
- }
- }
- break;
+ }
+
+ case ID_FILE_EXIT:
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ return 0;
+ break;
+ }
+#if HAVE_GLIB
+ if ( popup_menu_array ) {
+ struct menu_priv* priv = (struct menu_priv*)g_array_index( popup_menu_array, gint, LOWORD(wParam) - POPUP_MENU_OFFSET );
+
+ if ( priv ) {
+ struct callback* cb = priv->cb;
+ if ( priv->cb ) {
+ callback_call_0( priv->cb );
+ return 0;
+ }
+ }
+ }
+#endif
+ }
+ break;
+ case WM_USER+ 1:
+ GetClientRect(hwnd, &rcClient);
+ printf( "resize gui to: %d %d \n", rcClient.right, rcClient.bottom );
+
+ window_layout( hwnd );
+ //EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient);
+ return 0;
+ break;
+ case WM_CLOSE:
+ DestroyWindow(hwnd);
+ break;
+ case WM_SIZE:
+ window_layout( hwnd );
+ return 0;
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+
+ case WM_MOUSEWHEEL: {
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+
+ short delta = GET_WHEEL_DELTA_WPARAM( wParam );
+ if ( delta > 0 ) {
+ navit_zoom_in(gui->nav, 2, NULL);
+ } else {
+ navit_zoom_out(gui->nav, 2, NULL);
+ }
+ }
+ break;
#ifdef HAVE_API_WIN32_CE
- case WM_KEYDOWN:
- {
- struct point p;
- int w,h;
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
- transform_get_size(navit_get_trans(gui->nav), &w, &h);
-
- if (wParam == VK_LEFT || wParam == '4') {
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_RIGHT || wParam == '6') {
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_UP || wParam == '2') {
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_DOWN || wParam == '8') {
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == '1') {
- navit_zoom_in(gui->nav, 2, NULL);
- } else if (wParam == '3') {
- navit_zoom_out(gui->nav, 2, NULL);
- } else if (wParam == '7') {
+ case WM_KEYDOWN: {
+ struct point p;
+ int w,h;
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+ transform_get_size(navit_get_trans(gui->nav), &w, &h);
+
+ if (wParam == VK_LEFT || wParam == '4') {
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_RIGHT || wParam == '6') {
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_UP || wParam == '2') {
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_DOWN || wParam == '8') {
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == '1') {
+ navit_zoom_in(gui->nav, 2, NULL);
+ } else if (wParam == '3') {
+ navit_zoom_out(gui->nav, 2, NULL);
+ } else if (wParam == '7') {
#if 0
- toggle_backlight();
+ toggle_backlight();
#endif
- } else if (wParam == '9') {
+ } else if (wParam == '9') {
#if 0
- toggle_fullscreen(hwnd);
+ toggle_fullscreen(hwnd);
#endif
- }
- }
- break;
+ }
+ }
+ break;
#endif
- default:
- return DefWindowProc(hwnd, Message, wParam, lParam);
- }
- return 0;
+ default:
+ return DefWindowProc(hwnd, Message, wParam, lParam);
+ }
+ return 0;
}
-static HANDLE CreateWin32Window( void )
-{
+static HANDLE CreateWin32Window( void ) {
#ifdef HAVE_API_WIN32_CE
- WNDCLASS wc;
+ WNDCLASS wc;
#else
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
+ WNDCLASSEX wc;
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
#endif
- HWND hwnd;
+ HWND hwnd;
// MSG Msg;
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 32;
- wc.hInstance = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = g_szClassName;
- wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
+ wc.style = 0;
+ wc.lpfnWndProc = WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 32;
+ wc.hInstance = NULL;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = g_szClassName;
+ wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
#ifdef HAVE_API_WIN32_CE
- if(!RegisterClass(&wc))
+ if(!RegisterClass(&wc))
#else
- if(!RegisterClassEx(&wc))
+ if(!RegisterClassEx(&wc))
#endif
- {
- MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
+ {
+ MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
+ return 0;
+ }
- hwnd = CreateWindowEx(
- WS_EX_CLIENTEDGE,
- g_szClassName,
- TEXT( "Navit" ),
+ hwnd = CreateWindowEx(
+ WS_EX_CLIENTEDGE,
+ g_szClassName,
+ TEXT( "Navit" ),
#ifdef HAVE_API_WIN32_CE
- WS_SYSMENU | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ WS_SYSMENU | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
#else
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
#endif
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
- if(hwnd == NULL)
- {
- MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
+ if(hwnd == NULL) {
+ MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
+ return 0;
+ }
- ShowWindow(hwnd, TRUE);
- UpdateWindow(hwnd);
+ ShowWindow(hwnd, TRUE);
+ UpdateWindow(hwnd);
#if 0
- g_idle_add (message_pump, NULL);
+ g_idle_add (message_pump, NULL);
#endif
- return hwnd;
+ return hwnd;
}
-static int win32_gui_set_graphics(struct gui_priv *this_, struct graphics *gra)
-{
- HANDLE* wndHandle_ptr = graphics_get_data(gra, "wnd_parent_handle_ptr");
- *wndHandle_ptr = this_->hwnd;
- graphics_get_data(gra, "START_CLIENT");
- return 0;
+static int win32_gui_set_graphics(struct gui_priv *this_, struct graphics *gra) {
+ HANDLE* wndHandle_ptr = graphics_get_data(gra, "wnd_parent_handle_ptr");
+ *wndHandle_ptr = this_->hwnd;
+ graphics_get_data(gra, "START_CLIENT");
+ return 0;
}
-static void win32_gui_add_bookmark_do(struct gui_priv *gui)
-{
+static void win32_gui_add_bookmark_do(struct gui_priv *gui) {
// navit_add_bookmark(gui->nav, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
// gtk_widget_destroy(gui->dialog_win);
}
-static int win32_gui_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description)
-{
- return 1;
+static int win32_gui_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description) {
+ return 1;
}
@@ -496,148 +466,135 @@ static struct menu_methods menu_methods;
static struct menu_priv *add_menu( struct menu_priv *menu,
- struct menu_methods *meth,
- char *name,
- enum menu_type type,
- struct callback *cb)
-{
- struct menu_priv* ret = NULL;
-
- ret = g_new0(struct menu_priv, 1);
-
- *ret = *menu;
- *meth = menu_methods;
-
- TCHAR *menuname = newSysString(name);
-
- if ( type == menu_type_submenu )
- {
- HMENU hSubMenu = NULL;
- hSubMenu = CreatePopupMenu();
- AppendMenu(menu->hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, menuname );
- ret->hMenu = hSubMenu;
- }
- else
- {
- AppendMenu( menu->hMenu, MF_STRING, menu_id, name );
- }
-
- // g_hash_table_insert( popup_callback_hash, GINT_TO_POINTER( menu_id ), (gpointer)cb );
+ struct menu_methods *meth,
+ char *name,
+ enum menu_type type,
+ struct callback *cb) {
+ struct menu_priv* ret = NULL;
+
+ ret = g_new0(struct menu_priv, 1);
+
+ *ret = *menu;
+ *meth = menu_methods;
+
+ TCHAR *menuname = newSysString(name);
+
+ if ( type == menu_type_submenu ) {
+ HMENU hSubMenu = NULL;
+ hSubMenu = CreatePopupMenu();
+ AppendMenu(menu->hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, menuname );
+ ret->hMenu = hSubMenu;
+ } else {
+ AppendMenu( menu->hMenu, MF_STRING, menu_id, name );
+ }
+
+ // g_hash_table_insert( popup_callback_hash, GINT_TO_POINTER( menu_id ), (gpointer)cb );
#if HAVE_GLIB
- g_array_append_val( popup_menu_array, ret );
+ g_array_append_val( popup_menu_array, ret );
#endif
- ret->cb = cb;
+ ret->cb = cb;
- menu_id++;
+ menu_id++;
- return ret;
+ return ret;
}
-static void set_toggle(struct menu_priv *menu, int active)
-{
- // gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
+static void set_toggle(struct menu_priv *menu, int active) {
+ // gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
}
-static int get_toggle(struct menu_priv *menu)
-{
- // return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
- return 0;
+static int get_toggle(struct menu_priv *menu) {
+ // return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
+ return 0;
}
static struct menu_methods menu_methods = {
- add_menu,
- set_toggle,
- get_toggle,
+ add_menu,
+ set_toggle,
+ get_toggle,
};
-static void popup_activate(struct menu_priv *menu)
-{
- POINT pnt;
- GetCursorPos( &pnt );
+static void popup_activate(struct menu_priv *menu) {
+ POINT pnt;
+ GetCursorPos( &pnt );
- if (menu->hMenu)
- {
- TrackPopupMenu( menu->hMenu, 0, pnt.x, pnt.y, 0, menu->wnd_handle, NULL );
- DestroyMenu( menu->hMenu );
- }
+ if (menu->hMenu) {
+ TrackPopupMenu( menu->hMenu, 0, pnt.x, pnt.y, 0, menu->wnd_handle, NULL );
+ DestroyMenu( menu->hMenu );
+ }
}
-static void popup_deactivate( struct menu_priv *menu )
-{
- DestroyMenu( menu->hMenu );
+static void popup_deactivate( struct menu_priv *menu ) {
+ DestroyMenu( menu->hMenu );
}
-static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth)
-{
- struct menu_priv* ret = NULL;
+static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth) {
+ struct menu_priv* ret = NULL;
- ret = g_new0(struct menu_priv, 1);
- *meth = menu_methods;
+ ret = g_new0(struct menu_priv, 1);
+ *meth = menu_methods;
- menu_id = POPUP_MENU_OFFSET;
+ menu_id = POPUP_MENU_OFFSET;
#if HAVE_GLIB
- if ( popup_menu_array )
- {
- g_array_free (popup_menu_array, TRUE);
- popup_menu_array = NULL;
- }
+ if ( popup_menu_array ) {
+ g_array_free (popup_menu_array, TRUE);
+ popup_menu_array = NULL;
+ }
- popup_menu_array = g_array_new (FALSE, FALSE, sizeof (gint));
+ popup_menu_array = g_array_new (FALSE, FALSE, sizeof (gint));
#endif
- ret->cb = NULL;
- ret->hMenu = CreatePopupMenu();
- ret->wnd_handle = this_->hwnd;
- meth->popup=popup_activate;
+ ret->cb = NULL;
+ ret->hMenu = CreatePopupMenu();
+ ret->wnd_handle = this_->hwnd;
+ meth->popup=popup_activate;
-printf( "create popup menu %d \n", ret->hMenu );
+ printf( "create popup menu %d \n", ret->hMenu );
- return ret;
+ return ret;
}
struct gui_methods win32_gui_methods = {
- NULL, // win32_gui_menubar_new,
- win32_gui_popup_new,
- win32_gui_set_graphics,
- NULL,
- NULL, // win32_gui_datawindow_new,
- win32_gui_add_bookmark,
+ NULL, // win32_gui_menubar_new,
+ win32_gui_popup_new,
+ win32_gui_set_graphics,
+ NULL,
+ NULL, // win32_gui_datawindow_new,
+ win32_gui_add_bookmark,
};
-static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *meth, struct attr **attrs)
-{
- struct gui_priv *this_;
+static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *meth, struct attr **attrs) {
+ struct gui_priv *this_;
#ifdef HAVE_API_WIN32_CE
- /* Do not run multiple instances under CE */
- HWND prev;
- prev = FindWindow(g_szClassName, NULL);
- if (prev) {
- ShowWindow(prev, SW_RESTORE);
- SetForegroundWindow(prev);
- InvalidateRect (prev, NULL, FALSE);
- exit(0);
- }
- InitCeGlue();
+ /* Do not run multiple instances under CE */
+ HWND prev;
+ prev = FindWindow(g_szClassName, NULL);
+ if (prev) {
+ ShowWindow(prev, SW_RESTORE);
+ SetForegroundWindow(prev);
+ InvalidateRect (prev, NULL, FALSE);
+ exit(0);
+ }
+ InitCeGlue();
#endif
- *meth=win32_gui_methods;
+ *meth=win32_gui_methods;
- this_=g_new0(struct gui_priv, 1);
- this_->nav=nav;
+ this_=g_new0(struct gui_priv, 1);
+ this_->nav=nav;
- this_->hwnd = CreateWin32Window();
- SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR)this_ );
+ this_->hwnd = CreateWin32Window();
+ SetWindowLongPtr( this_->hwnd, DWLP_USER, (LONG_PTR)this_ );
- return this_;
+ return this_;
}
-void plugin_init(void)
-{
- plugin_register_category_gui("win32", win32_gui_new);
+void plugin_init(void) {
+ plugin_register_category_gui("win32", win32_gui_new);
}
diff --git a/navit/gui/win32/win32_gui_destination.c b/navit/gui/win32/win32_gui_destination.c
index 115b9058b..82ff2c713 100644
--- a/navit/gui/win32/win32_gui_destination.c
+++ b/navit/gui/win32/win32_gui_destination.c
@@ -13,8 +13,7 @@
static const TCHAR g_szDestinationClassName[] = TEXT("navit_gui_destinationwindow_class");
-struct datawindow_priv
-{
+struct datawindow_priv {
HWND hwnd;
HWND hwndLabel;
HWND hwndEdit;
@@ -27,8 +26,7 @@ struct datawindow_priv
struct notify_priv *notifications;
};
-static void setlayout(struct datawindow_priv *datawindow)
-{
+static void setlayout(struct datawindow_priv *datawindow) {
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
@@ -39,22 +37,18 @@ static void setlayout(struct datawindow_priv *datawindow)
lvc.cx = (winrect.right - winrect.left) - 52 ;
lvc.fmt = LVCFMT_LEFT; // left-aligned column
- switch (datawindow->currentSearchState)
- {
- case attr_country_name:
- {
+ switch (datawindow->currentSearchState) {
+ case attr_country_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Country"));
lvc.pszText = TEXT("Country");
}
break;
- case attr_town_name:
- {
+ case attr_town_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Postal or Town"));
lvc.pszText = TEXT("Town");
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Street"));
lvc.pszText = TEXT("Street");
}
@@ -70,16 +64,14 @@ static void setlayout(struct datawindow_priv *datawindow)
SetFocus(datawindow->hwndEdit);
}
-static void notify_apply(struct datawindow_priv *datawindow, int index, int param2)
-{
+static void notify_apply(struct datawindow_priv *datawindow, int index, int param2) {
TCHAR txtBuffer[1024];
char search_string[1024];
struct attr search_attr;
struct search_list_result *res;
-
- if ( index >= 0 )
- {
+
+ if ( index >= 0 ) {
ListView_GetItemText(datawindow->hwndList, index, 1, txtBuffer, 1024);
TCHAR_TO_UTF8(txtBuffer, search_string);
@@ -91,20 +83,16 @@ static void notify_apply(struct datawindow_priv *datawindow, int index, int para
res=search_list_get_result(datawindow->sl);
}
- switch (datawindow->currentSearchState)
- {
- case attr_country_name:
- {
+ switch (datawindow->currentSearchState) {
+ case attr_country_name: {
datawindow->currentSearchState = attr_town_name;
}
break;
- case attr_town_name:
- {
+ case attr_town_name: {
datawindow->currentSearchState = attr_street_name;
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
navit_set_destination(datawindow->nav, res->c, "Mein Test", 1);
DestroyWindow(datawindow->hwnd);
}
@@ -118,19 +106,15 @@ static void notify_apply(struct datawindow_priv *datawindow, int index, int para
}
-static void notify_back(struct datawindow_priv *datawindow, int param1, int param2)
-{
- switch (datawindow->currentSearchState)
- {
+static void notify_back(struct datawindow_priv *datawindow, int param1, int param2) {
+ switch (datawindow->currentSearchState) {
case attr_country_name:
- break;
- case attr_town_name:
- {
+ break;
+ case attr_town_name: {
datawindow->currentSearchState = attr_country_name;
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
datawindow->currentSearchState = attr_town_name;
}
break;
@@ -142,14 +126,13 @@ static void notify_back(struct datawindow_priv *datawindow, int param1, int para
setlayout(datawindow);
}
-static void notify_textchange(struct datawindow_priv *datawindow, int param1, int param2)
-{
+static void notify_textchange(struct datawindow_priv *datawindow, int param1, int param2) {
struct attr search_attr;
struct search_list_result *res;
char search_string[1024];
TCHAR converted_iso2[32];
-
+
int lineLength = Edit_LineLength(datawindow->hwndEdit, 0);
TCHAR line[lineLength + 1];
@@ -178,11 +161,9 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
lvI.state = 0;
lvI.stateMask = 0;
- while ((res=search_list_get_result(datawindow->sl)) && listIndex < 50)
- {
+ while ((res=search_list_get_result(datawindow->sl)) && listIndex < 50) {
- switch (search_attr.type)
- {
+ switch (search_attr.type) {
case attr_country_name:
tcharBuffer = newSysString(res->country->name);
break;
@@ -190,12 +171,9 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
tcharBuffer = newSysString(res->town->common.town_name);
break;
case attr_street_name:
- if (res->street->name)
- {
+ if (res->street->name) {
tcharBuffer = newSysString(res->street->name);
- }
- else
- {
+ } else {
continue;
}
break;
@@ -212,24 +190,20 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
(void)ListView_InsertItem(datawindow->hwndList, &lvI);
ListView_SetItemText(datawindow->hwndList, listIndex, 1, tcharBuffer);
g_free(tcharBuffer);
- dbg(lvl_debug,"%s\n", res->country->name);
+ dbg(lvl_debug,"%s", res->country->name);
listIndex++;
}
}
-static void notify_destroy(struct datawindow_priv *datawindow, int param1, int param2)
-{
- if ( datawindow )
- {
+static void notify_destroy(struct datawindow_priv *datawindow, int param1, int param2) {
+ if ( datawindow ) {
search_list_destroy(datawindow->sl);
g_free(datawindow);
}
}
-static void notify_size(struct datawindow_priv *datawindow, int width, int height)
-{
- if (datawindow)
- {
+static void notify_size(struct datawindow_priv *datawindow, int width, int height) {
+ if (datawindow) {
MoveWindow(datawindow->hwndLabel,
0, 0, // starting x- and y-coordinates
width, // width of client area
@@ -261,8 +235,7 @@ static void notify_size(struct datawindow_priv *datawindow, int width, int heigh
}
}
-static BOOL init_lv_columns(HWND hWndListView)
-{
+static BOOL init_lv_columns(HWND hWndListView) {
// struct LVCOLUMN lvc = {LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
// LVCFMT_LEFT, 100, szText[iCol], 0, iCol, 0, 0 };
@@ -273,8 +246,7 @@ static BOOL init_lv_columns(HWND hWndListView)
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- for (iCol = 0; iCol < 2; iCol++)
- {
+ for (iCol = 0; iCol < 2; iCol++) {
lvc.iSubItem = iCol;
lvc.pszText = szText[iCol];
lvc.cx = 50; // width of column in pixels
@@ -290,8 +262,7 @@ static BOOL init_lv_columns(HWND hWndListView)
return TRUE;
}
-BOOL register_destination_window()
-{
+BOOL register_destination_window() {
WNDCLASS wc;
wc.style = 0;
@@ -305,16 +276,14 @@ BOOL register_destination_window()
wc.lpszClassName = g_szDestinationClassName;
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
- if (!RegisterClass(&wc))
- {
- dbg(lvl_error, "Window Registration Failed!\n");
+ if (!RegisterClass(&wc)) {
+ dbg(lvl_error, "Window Registration Failed!");
return FALSE;
}
return TRUE;
}
-HANDLE create_destination_window( struct navit *nav )
-{
+HANDLE create_destination_window( struct navit *nav ) {
struct datawindow_priv *this_;
@@ -337,18 +306,17 @@ HANDLE create_destination_window( struct navit *nav )
#endif
NULL, NULL, NULL, NULL);
- if (this_->hwnd == NULL)
- {
- dbg(lvl_error, "Window Creation Failed!\n");
+ if (this_->hwnd == NULL) {
+ dbg(lvl_error, "Window Creation Failed!");
return 0;
}
this_->notifications = win32_gui_notify_new(this_);
- SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR) this_->notifications );
+ SetWindowLongPtr( this_->hwnd, DWLP_USER, (LONG_PTR) this_->notifications );
this_->hwndLabel = CreateWindow(WC_STATIC, // predefined class
TEXT("Country"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -357,7 +325,7 @@ HANDLE create_destination_window( struct navit *nav )
this_->hwndEdit = CreateWindow(WC_EDIT, // predefined class
NULL, // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -366,7 +334,7 @@ HANDLE create_destination_window( struct navit *nav )
this_->hwndList = CreateWindow(WC_LISTVIEW, // predefined class
NULL, // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -374,21 +342,21 @@ HANDLE create_destination_window( struct navit *nav )
NULL); // pointer not needed
this_->hwndButtonPrev = CreateWindow(WC_BUTTON, // predefined class
- TEXT("<<"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
- 0, 0, 0, 0, // set size in WM_SIZE message
- this_->hwnd, // parent window
- NULL,//(HMENU) ID_EDITCHILD, // edit control ID
- (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
- NULL); // pointer not needed
+ TEXT("<<"), // no window title
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ this_->hwnd, // parent window
+ NULL,//(HMENU) ID_EDITCHILD, // edit control ID
+ (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
+ NULL); // pointer not needed
this_->hwndButtonNext = CreateWindow(WC_BUTTON, // predefined class
- TEXT(">>"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
- 0, 0, 0, 0, // set size in WM_SIZE message
- this_->hwnd, // parent window
- NULL,//(HMENU) ID_EDITCHILD, // edit control ID
- (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
- NULL); // pointer not needed
+ TEXT(">>"), // no window title
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ this_->hwnd, // parent window
+ NULL,//(HMENU) ID_EDITCHILD, // edit control ID
+ (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
+ NULL); // pointer not needed
#ifdef LVS_EX_FULLROWSELECT
(void)ListView_SetExtendedListViewStyle(this_->hwndList,LVS_EX_FULLROWSELECT);
#endif
diff --git a/navit/gui/win32/win32_gui_notify.c b/navit/gui/win32/win32_gui_notify.c
index c801e9da8..222a7a5a9 100644
--- a/navit/gui/win32/win32_gui_notify.c
+++ b/navit/gui/win32/win32_gui_notify.c
@@ -4,23 +4,21 @@
#include <glib.h>
#include "win32_gui_notify.h"
-struct window_data
-{
+struct window_data {
HWND hwnd;
UINT message;
void(*func)(struct datawindow_priv *parent, int param1, int param2);
};
-struct notify_priv
-{
+struct notify_priv {
GList *window_list;
struct datawindow_priv *parent;
};
-void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, void(*func)(struct datawindow_priv *parent, int param1, int param2))
-{
+void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, void(*func)(struct datawindow_priv *parent,
+ int param1, int param2)) {
struct window_data *wnd_data = g_new( struct window_data,1);
wnd_data->hwnd = hwnd;
@@ -31,97 +29,81 @@ void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, voi
}
-struct notify_priv* win32_gui_notify_new(struct datawindow_priv *parent)
-{
+struct notify_priv* win32_gui_notify_new(struct datawindow_priv *parent) {
struct notify_priv* notify = g_new0(struct notify_priv,1);
notify->parent = parent;
return notify;
}
-LRESULT CALLBACK message_handler(HWND hwnd, UINT win_message, WPARAM wParam, LPARAM lParam)
-{
+LRESULT CALLBACK message_handler(HWND hwnd, UINT win_message, WPARAM wParam, LPARAM lParam) {
enum message_id message = INVALID;
int param1 = -1;
int param2 = -1;
HWND hwndDlg = hwnd;
- switch (win_message)
- {
- case WM_CREATE:
- {
- message = WINDOW_CREATE;
+ switch (win_message) {
+ case WM_CREATE: {
+ message = WINDOW_CREATE;
+ }
+ break;
+ case WM_SIZE: {
+ message = WINDOW_SIZE;
+ param1 = LOWORD(lParam);
+ param2 = HIWORD(lParam);
+ }
+ break;
+ case WM_DESTROY: {
+ message = WINDOW_DESTROY;
+ }
+ break;
+ case WM_NOTIFY: {
+ hwndDlg = (((LPNMHDR)lParam)->hwndFrom);
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_DBLCLK: {
+ message = DBLCLICK;
+#ifdef LPNMITEMACTIVATE
+ param1 = ((LPNMITEMACTIVATE)lParam)->iItem;
+#endif
}
break;
- case WM_SIZE:
- {
- message = WINDOW_SIZE;
- param1 = LOWORD(lParam);
- param2 = HIWORD(lParam);
+ case NM_CLICK:
+ message = CLICK;
+ break;
}
- break;
- case WM_DESTROY:
- {
- message = WINDOW_DESTROY;
+ }
+ break;
+ case WM_COMMAND: {
+ hwndDlg = (HWND)lParam;
+
+ switch (HIWORD(wParam)) {
+ case EN_CHANGE: {
+ message = CHANGE;
}
break;
- case WM_NOTIFY:
- {
- hwndDlg = (((LPNMHDR)lParam)->hwndFrom);
- switch (((LPNMHDR)lParam)->code)
- {
- case NM_DBLCLK:
- {
- message = DBLCLICK;
-#ifdef LPNMITEMACTIVATE
- param1 = ((LPNMITEMACTIVATE)lParam)->iItem;
-#endif
- }
- break;
- case NM_CLICK:
- message = CLICK;
- break;
- }
+ case BN_CLICKED: {
+ message = BUTTON_CLICK;
}
break;
- case WM_COMMAND:
- {
- hwndDlg = (HWND)lParam;
-
- switch (HIWORD(wParam))
- {
- case EN_CHANGE:
- {
- message = CHANGE;
- }
- break;
- case BN_CLICKED:
- {
- message = BUTTON_CLICK;
- }
- break;
- }
}
- break;
+ }
+ break;
- default:
- return DefWindowProc(hwnd, win_message, wParam, lParam);
+ default:
+ return DefWindowProc(hwnd, win_message, wParam, lParam);
}
- struct notify_priv* notify_data = (struct notify_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
+ struct notify_priv* notify_data = (struct notify_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
- if ( message != INVALID && notify_data && notify_data->window_list )
- {
+ if ( message != INVALID && notify_data && notify_data->window_list ) {
GList* current_element = g_list_first(notify_data->window_list);
struct window_data* wnd_data = NULL;
- while (current_element != NULL)
- {
+ while (current_element != NULL) {
wnd_data = current_element->data;
- if ( (wnd_data->hwnd == hwndDlg || wnd_data->hwnd == NULL) && message == wnd_data->message)
- {
+ if ( (wnd_data->hwnd == hwndDlg || wnd_data->hwnd == NULL) && message == wnd_data->message) {
wnd_data->func(notify_data->parent, param1, param2);
}