summaryrefslogtreecommitdiff
path: root/navit/gui/win32/win32_gui_notify.c
diff options
context:
space:
mode:
Diffstat (limited to 'navit/gui/win32/win32_gui_notify.c')
-rw-r--r--navit/gui/win32/win32_gui_notify.c118
1 files changed, 50 insertions, 68 deletions
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);
}