Fix:Win32:Clean up Win32 gui, remove duplicate of win32_gui.h and make gui_win32...
authorhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 14 May 2009 06:44:12 +0000 (06:44 +0000)
committerhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 14 May 2009 06:44:12 +0000 (06:44 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2269 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/graphics/win32/graphics_win32.c
navit/navit/graphics/win32/graphics_win32.h [moved from navit/navit/graphics/win32/win32_gui.h with 98% similarity]
navit/navit/gui/win32/gui_win32.c
navit/navit/gui/win32/win32_gui.h [deleted file]
navit/navit/util.h

index 351cdd9..b740b8d 100644 (file)
@@ -14,7 +14,7 @@
 #include "plugin.h"
 #include "item.h"
 #include "window.h"
-#include "win32_gui.h"
+#include "graphics_win32.h"
 #include "xpm2bmp.h"
 #include "support/win32/ConvertUTF.h"
 
@@ -331,12 +331,16 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
                break;
 
                case WM_LBUTTONDOWN:
+               {
                        dbg(1, "LBUTTONDOWN\n");
                        HandleButtonClick( gra_priv, 1, 1, lParam);
+               }
                break;
                case WM_LBUTTONUP:
+               {
                        dbg(1, "LBUTTONUP\n");
                        HandleButtonClick( gra_priv, 0, 1, lParam);
+               }
                break;
                case WM_RBUTTONDOWN:
                        HandleButtonClick( gra_priv, 1, 3,lParam );
@@ -400,7 +404,7 @@ static HANDLE CreateGraphicsWindows( struct graphics_priv* gr )
                                TEXT(""),
 #ifdef HAVE_API_WIN32_CE
                                WS_VISIBLE,
-#elif 0
+#elif 1
                                WS_CHILD,
 #else
                                WS_OVERLAPPEDWINDOW,
@@ -409,12 +413,12 @@ static HANDLE CreateGraphicsWindows( struct graphics_priv* gr )
                                0,
                                gr->width,
                                gr->height,
-#if 0
+#if 1
                                gr->wnd_parent_handle,
 #else
                                NULL,
 #endif
-#if 0
+#if 1
                                (HMENU)ID_CHILD_GFX,
 #else
                                NULL,
@@ -637,14 +641,14 @@ static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
 
 static void * get_data(struct graphics_priv *this_, char *type)
 {
-       if ( strcmp( "wnd_parent_handle_ptr", type ) == 0 ) {
-               return &( this_->wnd_parent_handle );
-       }
-       if ( strcmp( "START_CLIENT", type ) == 0 ) {
-               CreateGraphicsWindows( this_ );
-               return NULL;
-       }
-       if (!strcmp(type, "window")) {
+    if ( strcmp( "wnd_parent_handle_ptr", type ) == 0 ) {
+       return &( this_->wnd_parent_handle );
+    }
+    if ( strcmp( "START_CLIENT", type ) == 0 ) {
+       CreateGraphicsWindows( this_ );
+       return NULL;
+    }
+    if (!strcmp(type, "window")) {
 #ifdef HAVE_API_WIN32_CE
        WNDCLASS wc;
 #else
@@ -674,42 +678,32 @@ static void * get_data(struct graphics_priv *this_, char *type)
        if(!RegisterClassEx(&wc))
 #endif
        {
-               ErrorExit( TEXT("Window Registration Failed!") );
-               return NULL;
+           ErrorExit( TEXT("Window Registration Failed!") );
+           return NULL;
        }
 
        callback_list_call_attr_2(this_->cbl, attr_resize, (void *)this_->width, (void *)this_->height);
 
        g_hwnd = hwnd = CreateWindow(g_szClassName,
-                               TEXT(""),
+               TEXT(""),
 #ifdef HAVE_API_WIN32_CE
-                               WS_VISIBLE,
-#elif 0
-                               WS_CHILD,
+               WS_VISIBLE,
 #else
-                               WS_OVERLAPPEDWINDOW,
+               WS_OVERLAPPEDWINDOW,
 #endif
-                               0,
-                               0,
-                               this_->width,
-                               this_->height,
-#if 0
-                               this_->wnd_parent_handle,
-#else
-                               NULL,
-#endif
-#if 0
-                               (HMENU)ID_CHILD_GFX,
-#else
-                               NULL,
-#endif
-                               GetModuleHandle(NULL),
-                               NULL);
+               0,
+               0,
+               this_->width,
+               this_->height,
+               this_->wnd_parent_handle,
+               NULL,
+               GetModuleHandle(NULL),
+               NULL);
 
        if(hwnd == NULL)
        {
-               ErrorExit( TEXT("Window Creation Failed!") );
-               return NULL;
+           ErrorExit( TEXT("Window Creation Failed!") );
+           return NULL;
        }
        this_->wnd_handle = hwnd;
 
@@ -721,10 +715,10 @@ static void * get_data(struct graphics_priv *this_, char *type)
 
        PostMessage( this_->wnd_parent_handle, WM_USER + 1, 0, 0 );
 
-               this_->window.priv=this_;
-               return &this_->window;
-       }
-       return NULL;
+       this_->window.priv=this_;
+       return &this_->window;
+    }
+    return NULL;
 }
 
 
similarity index 98%
rename from navit/navit/graphics/win32/win32_gui.h
rename to navit/navit/graphics/win32/graphics_win32.h
index 579da10..9aab62a 100644 (file)
@@ -23,7 +23,7 @@
 #define ID_FILE_EXIT           9001
 #define ID_STUFF_GO            9002
 
-#define _(text) gettext(text)
+//#define _(text) gettext(text)
 
 #define POPUP_MENU_OFFSET  4000
 
index a47e89f..0bdf023 100644 (file)
@@ -5,7 +5,7 @@
 #include "config.h"
 #include "plugin.h"
 #include "gui.h"
-#include "win32_gui.h"
+#include "../../graphics/win32/graphics_win32.h"
 #include "point.h"
 #include "menu.h"
 #include "item.h"
@@ -13,6 +13,8 @@
 #include "callback.h"
 #include <commctrl.h>
 #include "debug.h"
+#include "util.h"
+#include "navit.h"
 #include "navit_nls.h"
 #ifdef __CEGCC__
 #include <sipapi.h>
@@ -31,11 +33,10 @@ static GArray *popup_menu_array;
 const TCHAR g_szClassName[] = TEXT("navit_gui_class");
 
 
-static menu_id = 0;
-static POINT menu_pt;
+static UINT_PTR menu_id = 0;
 
-
-gboolean message_pump( gpointer data )
+#if 0
+static gboolean message_pump( gpointer data )
 {
     MSG messages;
 
@@ -52,11 +53,7 @@ gboolean message_pump( gpointer data )
        return TRUE;
 }
 
-
-
-//extern struct graphics_priv *g_gra;
-
-BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
+static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
 {
     LPRECT rcParent;
     int idChild;
@@ -73,6 +70,7 @@ BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
 
     return TRUE;
 }
+#endif
 
 #ifndef GET_WHEEL_DELTA_WPARAM
        #define GET_WHEEL_DELTA_WPARAM(wParam)  ((short)HIWORD(wParam))
@@ -408,7 +406,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
        return 0;
 }
 
-HANDLE CreateWin32Window( void )
+static HANDLE CreateWin32Window( void )
 {
 #ifdef HAVE_API_WIN32_CE
        WNDCLASS wc;
@@ -418,7 +416,7 @@ HANDLE CreateWin32Window( void )
        wc.hIconSm               = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
 #endif
        HWND hwnd;
-       MSG Msg;
+//     MSG Msg;
 
        wc.style                 = 0;
        wc.lpfnWndProc   = WndProc;
@@ -572,7 +570,7 @@ static void popup_deactivate( struct menu_priv *menu )
        DestroyMenu( menu->hMenu );
 }
 
-struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth)
+static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth)
 {
        struct menu_priv* ret = NULL;
 
@@ -634,7 +632,7 @@ static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *me
        this_->nav=nav;
 
        this_->hwnd = CreateWin32Window();
-       SetWindowLongPtr( this_->hwnd , DWLP_USER, this_ );
+       SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR)this_ );
 
        return this_;
 }
diff --git a/navit/navit/gui/win32/win32_gui.h b/navit/navit/gui/win32/win32_gui.h
deleted file mode 100644 (file)
index f9fb7e2..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef WIN32_GUI_INCLUDED
-#define WIN32_GUI_INCLUDED
-
-#include "resources/resource.h"
-#include "coord.h"
-#include "point.h"
-#include "graphics.h"
-
-#define ID_CHILD_GFX 100
-#define ID_CHILD_TOOLBAR (ID_CHILD_GFX + 1)
-#define ID_CHILD_1 (ID_CHILD_TOOLBAR + 1)
-#define ID_CHILD_2 (ID_CHILD_1 + 1)
-#define ID_CHILD_3 (ID_CHILD_2 + 1)
-#define ID_CHILD_4 (ID_CHILD_4 + 1)
-
-#define ID_DISPLAY_ZOOMIN              200
-#define ID_DISPLAY_ZOOMOUT             201
-#define ID_DISPLAY_REFRESH             202
-#define ID_DISPLAY_CURSOR              203
-#define ID_DISPLAY_ORIENT              204
-
-#define ID_FILE_EXIT           9001
-#define ID_STUFF_GO            9002
-
-#define _(text) gettext(text)
-
-#define POPUP_MENU_OFFSET  4000
-
-struct statusbar_methods;
-struct menu_methods;
-struct datawindow_methods;
-struct navit;
-struct callback;
-
-
-struct menu_priv {
-       HWND wnd_handle;
-       HMENU hMenu;
-       struct callback* cb;
-};
-
-struct gui_priv {
-       struct navit *nav;
-       HANDLE  hwnd;
-};
-
-
-struct graphics_priv {
-       struct point p;
-       int width;
-       int height;
-       int library_init;
-       int visible;
-       HANDLE wnd_parent_handle;
-       HANDLE wnd_handle;
-       COLORREF bg_color;
-
-
-       void (*resize_callback)(void *data, int w, int h);
-       void *resize_callback_data;
-       void (*motion_callback)(void *data, struct point *p);
-       void *motion_callback_data;
-       void (*button_callback)(void *data, int press, int button, struct point *p);
-       void *button_callback_data;
-       enum draw_mode_num mode;
-};
-
-struct menu_priv *gui_gtk_menubar_new(struct gui_priv *gui, struct menu_methods *meth);
-struct menu_priv *gui_gtk_toolbar_new(struct gui_priv *gui, struct menu_methods *meth);
-struct statusbar_priv *gui_gtk_statusbar_new(struct gui_priv *gui, struct statusbar_methods *meth);
-struct menu_priv *gui_gtk_popup_new(struct gui_priv *gui, struct menu_methods *meth);
-struct datawindow_priv *gui_gtk_datawindow_new(struct gui_priv *gui, char *name, struct callback *click, struct callback *close, struct datawindow_methods *meth);
-
-struct graphics_priv* win32_graphics_new( struct graphics_methods *meth, struct attr **attrs);
-
-#endif
index 4195101..3dd9447 100644 (file)
@@ -27,6 +27,13 @@ void strtolower(char *dest, const char *src);
 GList * g_hash_to_list(GHashTable *h);
 GList * g_hash_to_list_keys(GHashTable *h);
 gchar * g_strconcat_printf(gchar *buffer, gchar *fmt, ...);
+#if defined(_WIN32) || defined(__CEGCC__) || defined (__APPLE__)
+#if defined(_UNICODE)
+wchar_t* newSysString(const char *toconvert);
+#else
+char * newSysString(const char *toconvert);
+#endif
+#endif
 unsigned int iso8601_to_secs(char *iso8601);
 
 #endif