[cairo-commit] roadster/src datasetwindow.c, 1.4, 1.5 glyph.c, 1.3,
1.4 gotowindow.c, 1.6, 1.7 gui.c, 1.5, 1.6 importwindow.c, 1.4,
1.5 locationset.h, 1.2, 1.3 main.c, 1.12, 1.13 mainwindow.c,
1.14, 1.15 mainwindow.h, 1.4, 1.5 map.c, 1.16, 1.17 map.h, 1.4,
1.5 map_draw_cairo.c, 1.1, 1.2 map_draw_gdk.c, 1.1, 1.2 road.c,
1.1, 1.2 scenemanager.h, 1.2, 1.3 searchwindow.c, 1.8,
1.9 track.c, 1.1, 1.2 util.c, 1.3, 1.4 util.h, 1.3,
1.4 welcomewindow.c, 1.3, 1.4
Ian McIntosh
commit at pdx.freedesktop.org
Fri Mar 4 01:27:29 PST 2005
Committed by: ian
Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv20042/src
Modified Files:
datasetwindow.c glyph.c gotowindow.c gui.c importwindow.c
locationset.h main.c mainwindow.c mainwindow.h map.c map.h
map_draw_cairo.c map_draw_gdk.c road.c scenemanager.h
searchwindow.c track.c util.c util.h welcomewindow.c
Log Message:
* src/*.c: Use gtk/gtk.h instead of gnome.h where possible.
* src/mainwindow.c: Added map dragging and scroll wheel zooming. Made sure all callbacks start with mainwindow_
* src/map.c: Allow draw flags to allow caller to specify which map elements get drawn.
* src/map_draw_*: Respect draw flags.
Index: datasetwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/datasetwindow.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- datasetwindow.c 28 Feb 2005 03:25:23 -0000 1.4
+++ datasetwindow.c 4 Mar 2005 09:27:26 -0000 1.5
@@ -27,7 +27,7 @@
# include <config.h>
#endif
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "util.h"
#include "datasetwindow.h"
Index: glyph.c
===================================================================
RCS file: /cvs/cairo/roadster/src/glyph.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glyph.c 4 Mar 2005 02:27:29 -0000 1.3
+++ glyph.c 4 Mar 2005 09:27:26 -0000 1.4
@@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <gnome.h>
+#include <gtk/gtk.h>
#include <cairo.h>
Index: gotowindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gotowindow.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gotowindow.c 4 Mar 2005 02:27:29 -0000 1.6
+++ gotowindow.c 4 Mar 2005 09:27:26 -0000 1.7
@@ -22,7 +22,7 @@
*/
#include <glade/glade.h>
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "mainwindow.h"
#include "gotowindow.h"
@@ -84,7 +84,7 @@
if(!util_string_to_double(pszLongitude, &(pt.m_fLongitude))) return FALSE;
mainwindow_set_centerpoint(&pt);
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_ALL);
mainwindow_statusbar_update_position();
return TRUE;
}
Index: gui.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gui.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gui.c 4 Mar 2005 04:06:35 -0000 1.5
+++ gui.c 4 Mar 2005 09:27:26 -0000 1.6
@@ -26,7 +26,7 @@
#endif
#include <glade/glade.h>
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "gui.h"
#include "db.h"
Index: importwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/importwindow.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- importwindow.c 23 Feb 2005 17:22:07 -0000 1.4
+++ importwindow.c 4 Mar 2005 09:27:26 -0000 1.5
@@ -22,7 +22,7 @@
*/
#include <glade/glade.h>
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "db.h"
#include "import.h"
#include "mainwindow.h"
@@ -132,7 +132,7 @@
// redraw map to show any potential new data (?)
// map_set_zoomlevel(7);
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_ALL);
}
//~ void importwindow_on_okbutton_clicked(GtkWidget* pWidget, gpointer pdata)
Index: locationset.h
===================================================================
RCS file: /cvs/cairo/roadster/src/locationset.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- locationset.h 3 Mar 2005 07:32:46 -0000 1.2
+++ locationset.h 4 Mar 2005 09:27:26 -0000 1.3
@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
+
#ifndef _LOCATIONSET_H
#define _LOCATIONSET_H
Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- main.c 4 Mar 2005 04:35:42 -0000 1.12
+++ main.c 4 Mar 2005 09:27:26 -0000 1.13
@@ -37,15 +37,11 @@
int main (int argc, char *argv[])
{
-
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
textdomain(PACKAGE);
#endif
-// g_thread_init(NULL);
-// gdk_threads_init();
-
gnome_program_init(PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, NULL);
if(!main_init())
@@ -61,6 +57,7 @@
{
// Initialize GLib thread system
//g_thread_init(NULL);
+ //gdk_threads_init();
if(!gnome_vfs_init()) {
g_warning("gnome_vfs_init failed\n");
@@ -89,10 +86,13 @@
g_print("initializing locationsets\n");
locationset_init();
+
g_print("initializing gpsclient\n");
gpsclient_init();
+
g_print("initializing gui\n");
gui_init();
+
g_print("initializing db\n");
db_init();
Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mainwindow.c 4 Mar 2005 04:35:42 -0000 1.14
+++ mainwindow.c 4 Mar 2005 09:27:26 -0000 1.15
@@ -25,7 +25,7 @@
# include <config.h>
#endif
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "search_road.h"
#include "gui.h"
@@ -41,9 +41,9 @@
#include "gpsclient.h"
#include "databasewindow.h"
#include "mainwindow.h"
-
#include "glyph.h"
+#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <cairo.h>
@@ -84,18 +84,19 @@
// Prototypes
static gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event);
+static gboolean mainwindow_on_mouse_motion(GtkWidget* w, GdkEventMotion *event);
+static gboolean mainwindow_on_mouse_scroll(GtkWidget* w, GdkEventScroll *event);
static gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data);
static gint mainwindow_on_configure_event(GtkWidget *pDrawingArea, GdkEventConfigure *event);
static gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
static void mainwindow_setup_selected_tool(void);
+
struct {
GtkWindow* m_pWindow;
GtkTooltips* m_pTooltips;
GtkMenu* m_pMapPopupMenu;
- screenpoint_t m_ptClickLocation;
-
// Toolbar
GtkToolbar* m_pToolbar;
GtkToolButton* m_pPointerToolButton;
@@ -125,15 +126,18 @@
GtkHBox* m_pContentBox;
// Drawing area
-// GtkWidget* m_pDrawWidget;
GtkDrawingArea* m_pDrawingArea;
map_t* m_pMap;
EToolType m_eSelectedTool;
+ gboolean m_bMouseDragging;
+ screenpoint_t m_ptClickLocation;
+
gint m_nCurrentGPSPath;
gint m_nGPSLocationGlyph;
+ gint m_nDrawPrettyTimeoutID;
} g_MainWindow = {0};
@@ -194,7 +198,6 @@
** Status bar
*/
-void mainwindow_load_locationset_list(void);
void mainwindow_init(GladeXML* pGladeXML)
{
@@ -228,6 +231,9 @@
g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "expose_event", G_CALLBACK(mainwindow_on_expose_event), NULL);
g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "configure_event", G_CALLBACK(mainwindow_on_configure_event), NULL);
g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "button_press_event", G_CALLBACK(mainwindow_on_mouse_button_click), NULL);
+ g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "button_release_event", G_CALLBACK(mainwindow_on_mouse_button_click), NULL);
+ g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "motion_notify_event", G_CALLBACK(mainwindow_on_mouse_motion), NULL);
+ g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "scroll_event", G_CALLBACK(mainwindow_on_mouse_scroll), NULL);
// Pack canvas into application window
gtk_box_pack_end(GTK_BOX(g_MainWindow.m_pContentBox), GTK_WIDGET(g_MainWindow.m_pDrawingArea),
@@ -290,8 +296,8 @@
mainwindow_statusbar_update_zoomscale();
mainwindow_statusbar_update_position();
- locationset_load_locationsets();
- mainwindow_load_locationset_list();
+// locationset_load_locationsets();
+// mainwindow_load_locationset_list();
/* add some data to the layers list */
// GtkTreeIter iter;
@@ -315,30 +321,6 @@
mainwindow_callback_on_gps_redraw_timeout(NULL);
}
-void mainwindow_load_locationset_list(void)
-{
- const GPtrArray* pLocationSetArray = locationset_get_set_array();
-
- /* add some data to the layers list */
- GtkTreeIter iter;
-
- GtkListStore* pListStore = (GtkListStore*)gtk_tree_view_get_model(g_MainWindow.m_pLocationSetsTreeView);
- g_assert(pListStore != NULL);
-
- /* Add each locationset to treeview */
- int i;
- for(i=0 ; i<pLocationSetArray->len ; i++) {
- locationset_t* pLocationSet = g_ptr_array_index(pLocationSetArray, i);
-
- gboolean bEnabled = TRUE;
-
- gtk_list_store_append(pListStore, &iter);
- gtk_list_store_set(pListStore, &iter,
- LAYERLIST_COLUMN_ENABLED, bEnabled,
- LAYERLIST_COLUMN_NAME, pLocationSet->m_pszName,
- -1);
- }
-}
void mainwindow_show(void)
{
@@ -356,6 +338,31 @@
gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pWindow), bSensitive);
}
+#define DRAW_PRETTY_TIMEOUT_MS (300)
+gboolean mainwindow_on_draw_pretty_timeout(gpointer _unused)
+{
+ g_MainWindow.m_nDrawPrettyTimeoutID = 0;
+ mainwindow_draw_map(DRAWFLAG_ALL);
+ return FALSE;
+}
+
+void mainwindow_cancel_draw_pretty_timeout()
+{
+ if(g_MainWindow.m_nDrawPrettyTimeoutID != 0) {
+ g_source_remove(g_MainWindow.m_nDrawPrettyTimeoutID);
+ }
+}
+
+void mainwindow_set_draw_pretty_timeout()
+{
+ // cancel existing one, if one exists
+ mainwindow_cancel_draw_pretty_timeout();
+
+ g_MainWindow.m_nDrawPrettyTimeoutID = g_timeout_add(DRAW_PRETTY_TIMEOUT_MS, mainwindow_on_draw_pretty_timeout, NULL);
+ g_assert(g_MainWindow.m_nDrawPrettyTimeoutID != 0);
+}
+
+
/*
** Toolbar
*/
@@ -428,32 +435,11 @@
return GTK_WIDGET_VISIBLE(g_MainWindow.m_pSidebox);
}
-
GtkWidget* mainwindow_get_window(void)
{
return GTK_WIDGET(g_MainWindow.m_pWindow);
}
-
-//
-// Progress Bar
-//
-//~ void mainwindow_statusbar_progressbar_set_text(const gchar* pszText)
-//~ {
- //~ gtk_progress_bar_set_text(g_MainWindow.m_pProgressBar, pszText);
-//~ }
-
-//~ void mainwindow_statusbar_progressbar_pulse()
-//~ {
- //~ gtk_progress_bar_pulse(g_MainWindow.m_pProgressBar);
-//~ }
-
-//~ void mainwindow_statusbar_progressbar_clear()
-//~ {
- //~ gtk_progress_bar_set_text(g_MainWindow.m_pProgressBar, "");
- //~ gtk_progress_bar_set_fraction(g_MainWindow.m_pProgressBar, 0.0);
-//~ }
-
void mainwindow_toggle_fullscreen(void)
{
GdkWindow* toplevelgdk = gdk_window_get_toplevel(GTK_WIDGET(g_MainWindow.m_pWindow)->window);
@@ -469,20 +455,20 @@
}
// User clicked Quit window
-void on_quitmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_quitmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
gui_exit();
}
// User closed main window
-gboolean on_application_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+gboolean mainwindow_on_application_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
gui_exit();
return FALSE; // satisfy strick compiler
}
// the range slider changed value
-void on_zoomscale_value_changed(GtkRange *range, gpointer user_data)
+void mainwindow_on_zoomscale_value_changed(GtkRange *range, gpointer user_data)
{
gdouble fValue = gtk_range_get_value(range);
gint16 nValue = (gint16)fValue;
@@ -491,7 +477,8 @@
map_set_zoomlevel(g_MainWindow.m_pMap, nValue);
mainwindow_statusbar_update_zoomscale();
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+ mainwindow_set_draw_pretty_timeout();
}
//
@@ -517,86 +504,70 @@
gdk_window_set_cursor(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, g_Tools[eTool].m_Cursor.m_pGdkCursor);
}
-void on_aboutmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_aboutmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
const gchar *ppAuthors[] = {
"Ian McIntosh <ian_mcintosh at linuxadvocate.org>",
+ "Nathan Fredrickson <nathan at silverorange.com>",
NULL
};
GtkWidget *pAboutWindow = gnome_about_new(
PROGRAM_NAME,
VERSION,
- PROGRAM_COPYRIGHT,
- PROGRAM_DESCRIPTION,
+ PROGRAM_COPYRIGHT,
+ PROGRAM_DESCRIPTION,
(const gchar **) ppAuthors,
- NULL,
+ NULL,
NULL,
- NULL);
+ NULL);
gtk_widget_show(pAboutWindow);
}
// Toggle toolbar visibility
-void on_toolbarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_toolbarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
mainwindow_set_toolbar_visible( !mainwindow_get_toolbar_visible() );
}
-#if ROADSTER_DEAD_CODE
-// Show preferences dialog
-static void on_preferencesmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
-{
-// gui_show_preferences_window();
-}
-#endif
-
// Toggle statusbar visibility
-void on_statusbarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_statusbarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
mainwindow_set_statusbar_visible( !mainwindow_get_statusbar_visible() );
}
-void on_sidebarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_sidebarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
mainwindow_set_sidebox_visible(!mainwindow_get_sidebox_visible());
}
-//
// Zoom buttons / menu items (shared callbacks)
-//
-void on_zoomin_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_zoomin_activate(GtkMenuItem *menuitem, gpointer user_data)
{
zoom_in_one();
}
-void on_zoomout_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_zoomout_activate(GtkMenuItem *menuitem, gpointer user_data)
{
zoom_out_one();
}
-void on_fullscreenmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_fullscreenmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
mainwindow_toggle_fullscreen();
}
void mainwindow_on_gotomenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
-// g_print("mainwindow_on_gotomenuitem_activate\n");
gotowindow_show();
}
-void on_reloadstylesmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+void mainwindow_on_reloadstylesmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
layers_reload();
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_ALL);
}
-
-// void on_gotobutton_clicked(GtkToolButton *toolbutton, gpointer user_data)
-// {
-// gotowindow_show();
-// }
-
static gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event)
{
gint nX;
@@ -605,19 +576,25 @@
gdk_window_get_pointer(w->window, &nX, &nY, NULL);
// Left double-click
- if(event->button == 1 && event->type == GDK_BUTTON_PRESS) {
- if(g_MainWindow.m_eSelectedTool == kToolZoom) {
- map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
- zoom_in_one();
- }
- else if(g_MainWindow.m_eSelectedTool == kToolPointer) {
- map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
+ if(event->button == 1) {
+ if(event->type == GDK_BUTTON_PRESS) {
+ GdkCursor* pCursor = gdk_cursor_new(GDK_HAND2);
+ if(GDK_GRAB_SUCCESS == gdk_pointer_grab(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, FALSE, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK, NULL, pCursor, GDK_CURRENT_TIME)) {
+ g_MainWindow.m_bMouseDragging = TRUE;
+ g_MainWindow.m_ptClickLocation.m_nX = nX;
+ g_MainWindow.m_ptClickLocation.m_nY = nY;
+ }
+ gdk_cursor_unref(pCursor);
}
- else {
- g_assert(FALSE);
+ else if(event->type == GDK_BUTTON_RELEASE) {
+ if(g_MainWindow.m_bMouseDragging == TRUE) {
+ g_MainWindow.m_bMouseDragging = FALSE;
+ gdk_pointer_ungrab(GDK_CURRENT_TIME);
+
+ mainwindow_cancel_draw_pretty_timeout();
+ mainwindow_draw_map(DRAWFLAG_ALL);
+ }
}
- mainwindow_draw_map();
- mainwindow_statusbar_update_position();
}
// Right-click?
// else if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
@@ -634,6 +611,40 @@
return TRUE;
}
+static gboolean mainwindow_on_mouse_motion(GtkWidget* w, GdkEventMotion *event)
+{
+ gint nX,nY;
+ gdk_window_get_pointer(w->window, &nX, &nY, NULL);
+
+ if(g_MainWindow.m_bMouseDragging) {
+ gint nDeltaX = g_MainWindow.m_ptClickLocation.m_nX - nX;
+ gint nDeltaY = g_MainWindow.m_ptClickLocation.m_nY - nY;
+
+ if(nDeltaX == 0 && nDeltaY == 0) return TRUE;
+
+ map_center_on_windowpoint(g_MainWindow.m_pMap,
+ (GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width) / 2 + nDeltaX,
+ (GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height) / 2 + nDeltaY);
+ mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+// mainwindow_set_draw_pretty_timeout();
+
+ g_MainWindow.m_ptClickLocation.m_nX = nX;
+ g_MainWindow.m_ptClickLocation.m_nY = nY;
+ }
+ return FALSE;
+}
+
+static gboolean mainwindow_on_mouse_scroll(GtkWidget* w, GdkEventScroll *event)
+{
+ // respond to scroll wheel events by zooming in and out
+ if(event->direction == GDK_SCROLL_UP) {
+ zoom_in_one();
+ }
+ else if(event->direction == GDK_SCROLL_DOWN) {
+ zoom_out_one();
+ }
+}
+
static void mainwindow_begin_import_geography_data(void)
{
GtkWidget* pDialog = gtk_file_chooser_dialog_new(
@@ -668,7 +679,7 @@
gtk_widget_destroy(pDialog);
}
-void on_import_maps_activate(GtkWidget *widget, gpointer user_data)
+void mainwindow_on_import_maps_activate(GtkWidget *widget, gpointer user_data)
{
mainwindow_begin_import_geography_data();
}
@@ -682,78 +693,58 @@
gui_set_tool(kToolZoom);
}
}
-//
+
// Handler for ALL tool buttons
-//
-void on_toolbutton_clicked(GtkToolButton *toolbutton, gpointer user_data)
+void mainwindow_on_toolbutton_clicked(GtkToolButton *toolbutton, gpointer user_data)
{
mainwindow_setup_selected_tool();
}
-void mainwindow_draw_map(void)
+void mainwindow_draw_map(gint nDrawFlags)
{
- map_draw(g_MainWindow.m_pMap);
- //map_draw_thread_begin(g_MainWindow.m_pMap, GTK_WIDGET(g_MainWindow.m_pDrawingArea));
+ map_draw(g_MainWindow.m_pMap, nDrawFlags);
+
+ // push it to screen
+ GdkPixmap* pMapPixmap = map_get_pixmap(g_MainWindow.m_pMap);
+ // Copy relevant portion of off-screen bitmap to window
+ gdk_draw_drawable(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
+ GTK_WIDGET(g_MainWindow.m_pDrawingArea)->style->fg_gc[GTK_WIDGET_STATE(g_MainWindow.m_pDrawingArea)],
+ pMapPixmap,
+ 0,0,
+ 0,0,
+ GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width, GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height);
+ map_release_pixmap(g_MainWindow.m_pMap);
}
-
+
static gint mainwindow_on_configure_event(GtkWidget *pDrawingArea, GdkEventConfigure *event)
{
- // Create a new backing pixmap of the appropriate size
-
-// if(g_MainWindow.m_pOffscreenPixmap != NULL) {
-// gdk_pixmap_unref(g_MainWindow.m_pOffscreenPixmap);
-// }
-// g_MainWindow.m_pOffscreenPixmap = gdk_pixmap_new(
-// GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
-// GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width,
-// GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height,
-// -1);
-
// tell the map how big to draw
dimensions_t dim;
dim.m_uWidth = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width;
dim.m_uHeight = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height;
map_set_dimensions(g_MainWindow.m_pMap, &dim);
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+ mainwindow_set_draw_pretty_timeout();
return TRUE;
}
static gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data)
{
-// g_print("mainwindow_on_expose_event(x=%d,y=%d,w=%d,h=%d)\n", event->area.x, event->area.y, event->area.width, event->area.height);
GdkPixmap* pMapPixmap = map_get_pixmap(g_MainWindow.m_pMap);
// Copy relevant portion of off-screen bitmap to window
-// TIMER_BEGIN(mytimer, "BEGIN EXPOSE");
gdk_draw_drawable(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
GTK_WIDGET(g_MainWindow.m_pDrawingArea)->style->fg_gc[GTK_WIDGET_STATE(g_MainWindow.m_pDrawingArea)],
pMapPixmap,
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
-// TIMER_END(mytimer, "END EXPOSE");
-
+
map_release_pixmap(g_MainWindow.m_pMap);
return FALSE;
}
-void mainwindow_on_addpointmenuitem_activate(GtkWidget *_unused, gpointer* __unused)
-{
- mappoint_t point;
- map_windowpoint_to_mappoint(g_MainWindow.m_pMap, &g_MainWindow.m_ptClickLocation, &point);
-
- gint nLocationSetID = 1;
- gint nNewLocationID;
-
- if(locationset_add_location(nLocationSetID, &point, &nNewLocationID)) {
- g_print("new location ID = %d\n", nNewLocationID);
- mainwindow_draw_map();
- }
- else {
- g_print("insert failed\n");
- }
-}
static gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer __unused)
{
@@ -776,7 +767,7 @@
// }
// redraw because GPS icon/trail may be different
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_ALL);
// update image and tooltip for GPS icon
util_set_image_to_stock(g_MainWindow.m_pStatusbarGPSIcon, GTK_STOCK_OK, GTK_ICON_SIZE_MENU);
@@ -831,9 +822,26 @@
map_set_centerpoint(g_MainWindow.m_pMap, pPoint);
}
+void mainwindow_on_addpointmenuitem_activate(GtkWidget *_unused, gpointer* __unused)
+{
+ mappoint_t point;
+ map_windowpoint_to_mappoint(g_MainWindow.m_pMap, &g_MainWindow.m_ptClickLocation, &point);
+
+ gint nLocationSetID = 1;
+ gint nNewLocationID;
+
+ if(locationset_add_location(nLocationSetID, &point, &nNewLocationID)) {
+ g_print("new location ID = %d\n", nNewLocationID);
+ mainwindow_draw_map(DRAWFLAG_ALL);
+ }
+ else {
+ g_print("insert failed\n");
+ }
+}
#ifdef ROADSTER_DEAD_CODE
/*
+
void on_importmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
{
g_print("on_importmenuitem_activate\n");
@@ -881,5 +889,36 @@
}
return FALSE;
}
+
+// Show preferences dialog
+static void on_preferencesmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+// gui_show_preferences_window();
+}
+
+void mainwindow_load_locationset_list(void)
+{
+ const GPtrArray* pLocationSetArray = locationset_get_set_array();
+
+ // add some data to the layers list
+ GtkTreeIter iter;
+
+ GtkListStore* pListStore = (GtkListStore*)gtk_tree_view_get_model(g_MainWindow.m_pLocationSetsTreeView);
+ g_assert(pListStore != NULL);
+
+ // Add each locationset to treeview
+ int i;
+ for(i=0 ; i<pLocationSetArray->len ; i++) {
+ locationset_t* pLocationSet = g_ptr_array_index(pLocationSetArray, i);
+
+ gboolean bEnabled = TRUE;
+
+ gtk_list_store_append(pListStore, &iter);
+ gtk_list_store_set(pListStore, &iter,
+ LAYERLIST_COLUMN_ENABLED, bEnabled,
+ LAYERLIST_COLUMN_NAME, pLocationSet->m_pszName,
+ -1);
+ }
+}
*/
#endif /* ROADSTER_DEAD_CODE */
Index: mainwindow.h
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mainwindow.h 3 Mar 2005 07:32:46 -0000 1.4
+++ mainwindow.h 4 Mar 2005 09:27:26 -0000 1.5
@@ -30,7 +30,7 @@
G_BEGIN_DECLS
void mainwindow_init(GladeXML* pGladeXML);
-void mainwindow_draw_map(void);
+void mainwindow_draw_map(gint nDrawFlags);
GtkWidget* mainwindow_get_window(void);
// Visibility
@@ -67,30 +67,7 @@
void mainwindow_statusbar_update_zoomscale(void);
void mainwindow_statusbar_update_position(void);
-/* Funky, auto-lookup glade signal handlers.
-
- XXX: Better would be to hook these up manually, remove these
- declarations, and make the functions static.
-*/
-void on_import_maps_activate(GtkWidget *widget, gpointer user_data);
-void on_quitmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-gboolean on_application_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data);
-void on_zoomscale_value_changed(GtkRange *range, gpointer user_data);
-void on_aboutmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_toolbarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_statusbarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_sidebarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_zoomin_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_zoomout_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_fullscreenmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_importmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void on_gotobutton_clicked(GtkToolButton *toolbutton, gpointer user_data);
-void on_toolbutton_clicked(GtkToolButton *toolbutton, gpointer user_data);
-
-void mainwindow_on_gotomenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
-void mainwindow_on_addpointmenuitem_activate(GtkWidget *_unused, gpointer* __unused);
-void mainwindow_on_datasetmenuitem_activate(GtkWidget *pWidget, gpointer* p);
-
+// Map
void mainwindow_set_centerpoint(mappoint_t* pPoint);
G_END_DECLS
Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- map.c 4 Mar 2005 04:06:35 -0000 1.16
+++ map.c 4 Mar 2005 09:27:26 -0000 1.17
@@ -23,7 +23,7 @@
#include <gdk/gdkx.h>
#include <cairo.h>
-#include <gnome.h>
+#include <gtk/gtk.h>
#include <math.h>
//#define THREADED_RENDERING
@@ -158,15 +158,13 @@
// }
-#define RENDERMODE_FAST 1
-#define RENDERMODE_PRETTY 2
+#define RENDERMODE_FAST 1
+#define RENDERMODE_PRETTY 2
-void map_draw(map_t* pMap)
+void map_draw(map_t* pMap, gint nDrawFlags)
{
g_assert(pMap != NULL);
- gint nRenderMode = RENDERMODE_FAST;
-
scenemanager_clear(pMap->m_pSceneManager);
// Get render metrics
@@ -182,12 +180,18 @@
// locationset_load_locations(&(pRenderMetrics->m_rWorldBoundingBox));
TIMER_END(loadtimer, "--- END ALL DB LOAD");
+ gint nRenderMode = RENDERMODE_FAST;
+
if(nRenderMode == RENDERMODE_FAST) {
- map_draw_gdk(pMap, pRenderMetrics, pMap->m_pPixmap, DRAWFLAG_BACKGROUND | DRAWFLAG_GEOMETRY);
-// map_draw_cairo(pMap, pRenderMetrics, pMap->m_pPixmap, DRAWFLAG_LABELS);
+ if(nDrawFlags & DRAWFLAG_GEOMETRY) {
+ map_draw_gdk(pMap, pRenderMetrics, pMap->m_pPixmap, DRAWFLAG_GEOMETRY);
+ }
+ if(nDrawFlags & DRAWFLAG_LABELS) {
+ map_draw_cairo(pMap, pRenderMetrics, pMap->m_pPixmap, DRAWFLAG_LABELS);
+ }
}
else {
- map_draw_cairo(pMap, pRenderMetrics, pMap->m_pPixmap, DRAWFLAG_BACKGROUND | DRAWFLAG_GEOMETRY | DRAWFLAG_LABELS);
+ map_draw_cairo(pMap, pRenderMetrics, pMap->m_pPixmap, nDrawFlags);
}
gtk_widget_queue_draw(pMap->m_pTargetWidget);
}
Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- map.h 4 Mar 2005 02:27:29 -0000 1.4
+++ map.h 4 Mar 2005 09:27:26 -0000 1.5
@@ -167,9 +167,9 @@
// Draw flags
#define DRAWFLAG_LABELS (1)
-#define DRAWFLAG_BACKGROUND (2)
-#define DRAWFLAG_GEOMETRY (4) // next is 8
-
+#define DRAWFLAG_GEOMETRY (2)
+// next is 4 :)
+#define DRAWFLAG_ALL (1|2)
#define NUM_SUBLAYER_TO_DRAW (22)
extern draworder_t layerdraworder[NUM_SUBLAYER_TO_DRAW]; //
@@ -205,7 +205,7 @@
void map_release_pixmap(map_t* pMap);
//void map_draw_thread_begin(map_t* pMap, GtkWidget* pTargetWidget);
-void map_draw(map_t* pMap);
+void map_draw(map_t* pMap, gint nDrawFlags);
double map_degrees_to_pixels(map_t* pMap, gdouble fDegrees, guint16 uZoomLevel);
#endif
Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- map_draw_cairo.c 4 Mar 2005 02:31:55 -0000 1.1
+++ map_draw_cairo.c 4 Mar 2005 09:27:26 -0000 1.2
@@ -30,7 +30,7 @@
#include <gdk/gdkx.h>
#include <cairo.h>
-#include <gnome.h>
+#include <gtk/gtk.h>
#include <math.h>
#include "gui.h"
@@ -72,7 +72,7 @@
cairo_set_fill_rule(pCairo, CAIRO_FILL_RULE_WINDING);
// 2.2. Draw Background
- if(nDrawFlags & DRAWFLAG_BACKGROUND) {
+ if(nDrawFlags & DRAWFLAG_GEOMETRY) {
map_draw_cairo_background(pMap, pCairo);
}
Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- map_draw_gdk.c 4 Mar 2005 02:31:55 -0000 1.1
+++ map_draw_gdk.c 4 Mar 2005 09:27:26 -0000 1.2
@@ -21,9 +21,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define MAX_GDK_LINE_SEGMENTS (2000)
+
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-#include <gnome.h>
+#include <gtk/gtk.h>
#include <math.h>
#include "gui.h"
@@ -52,7 +54,7 @@
// 2. Drawing
// 2.1. Draw Background
- if(nDrawFlags & DRAWFLAG_BACKGROUND) {
+ if(nDrawFlags & DRAWFLAG_GEOMETRY) {
map_draw_gdk_background(pMap, pPixmap);
}
@@ -115,7 +117,6 @@
for(iString=0 ; iString<pPointStringsArray->len ; iString++) {
pPointString = g_ptr_array_index(pPointStringsArray, iString);
-#define MAX_GDK_LINE_SEGMENTS (1000)
if(pPointString->m_pPointsArray->len >= 2) {
GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
@@ -151,9 +152,17 @@
// Raise the tolerance way up for thin lines
gint nCapStyle = pSubLayerStyle->m_nCapStyle;
- // Set line style
- gdk_gc_set_line_attributes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
- ((gint)fLineWidth), GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER);
+ // XXX: Don't use round at low zoom levels
+ if(fLineWidth < 8) {
+ // Set line style
+ gdk_gc_set_line_attributes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
+ ((gint)fLineWidth), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
+ }
+ else {
+ // Set line style
+ gdk_gc_set_line_attributes(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],
+ ((gint)fLineWidth), GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER);
+ }
GdkColor clr;
clr.red = pSubLayerStyle->m_clrColor.m_fRed * 65535;
@@ -161,21 +170,9 @@
clr.blue = pSubLayerStyle->m_clrColor.m_fBlue * 65535;
gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr);
-// cairo_set_line_join(pCairo, pSubLayerStyle->m_nJoinStyle);
-// cairo_set_line_cap(pCairo, nCapStyle); /* CAIRO_LINE_CAP_BUTT, CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_CAP */
-// if(g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount > 1) {
-// cairo_set_dash(pCairo, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_pfList, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount, 0.0);
-// }
-
-// // Set layer attributes
-// cairo_set_rgb_color(pCairo, pSubLayerStyle->m_clrColor.m_fRed, pSubLayerStyle->m_clrColor.m_fGreen, pSubLayerStyle->m_clrColor.m_fBlue);
-// cairo_set_alpha(pCairo, pSubLayerStyle->m_clrColor.m_fAlpha);
-// cairo_set_line_width(pCairo, fLineWidth);
-
for(iString=0 ; iString<pPointStringsArray->len ; iString++) {
pPointString = g_ptr_array_index(pPointStringsArray, iString);
-#define MAX_GDK_LINE_SEGMENTS (1000)
if(pPointString->m_pPointsArray->len >= 2) {
GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
Index: road.c
===================================================================
RCS file: /cvs/cairo/roadster/src/road.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- road.c 1 Mar 2005 19:48:21 -0000 1.1
+++ road.c 4 Mar 2005 09:27:26 -0000 1.2
@@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "road.h"
#include "util.h"
Index: scenemanager.h
===================================================================
RCS file: /cvs/cairo/roadster/src/scenemanager.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- scenemanager.h 1 Mar 2005 19:48:21 -0000 1.2
+++ scenemanager.h 4 Mar 2005 09:27:26 -0000 1.3
@@ -24,8 +24,6 @@
#ifndef _SCENEMANAGER_H_
#define _SCENEMANAGER_H_
-//#include <gnome.h>
-
typedef struct scenemanager {
GPtrArray* m_p;
GHashTable* m_pLabelHash;
Index: searchwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/searchwindow.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- searchwindow.c 4 Mar 2005 02:27:29 -0000 1.8
+++ searchwindow.c 4 Mar 2005 09:27:26 -0000 1.9
@@ -140,7 +140,7 @@
-1);
mainwindow_set_centerpoint(&pt);
- mainwindow_draw_map();
+ mainwindow_draw_map(DRAWFLAG_ALL);
mainwindow_statusbar_update_position();
}
}
Index: track.c
===================================================================
RCS file: /cvs/cairo/roadster/src/track.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- track.c 26 Feb 2005 04:48:39 -0000 1.1
+++ track.c 4 Mar 2005 09:27:26 -0000 1.2
@@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "map.h"
#include "pointstring.h"
#include "point.h"
Index: util.c
===================================================================
RCS file: /cvs/cairo/roadster/src/util.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.c 23 Feb 2005 17:22:07 -0000 1.3
+++ util.c 4 Mar 2005 09:27:26 -0000 1.4
@@ -21,9 +21,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <stdlib.h>
#include "util.h"
-#include "layers.h" // for color_t -- move it elsewhere!
void util_close_parent_window(GtkWidget* pWidget, gpointer data)
{
@@ -31,6 +29,8 @@
}
#if ROADSTER_DEAD_CODE
+#include <stdlib.h>
+#include "layers.h" // for color_t -- move it elsewhere!
static void util_random_color(color_t* pColor)
{
pColor->m_fRed = (random()%1000)/1000.0;
Index: util.h
===================================================================
RCS file: /cvs/cairo/roadster/src/util.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.h 4 Mar 2005 02:27:29 -0000 1.3
+++ util.h 4 Mar 2005 09:27:26 -0000 1.4
@@ -30,7 +30,7 @@
void util_random_color(void* pColor);
-// #define ENABLE_TIMING
+//#define ENABLE_TIMING
#ifdef ENABLE_TIMING
#define TIMER_BEGIN(name, str) GTimer* name = g_timer_new(); g_print("\n%s (%f)\n", str, g_timer_elapsed(name, NULL))
Index: welcomewindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/welcomewindow.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- welcomewindow.c 23 Feb 2005 17:22:07 -0000 1.3
+++ welcomewindow.c 4 Mar 2005 09:27:26 -0000 1.4
@@ -20,14 +20,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
+
#include <glade/glade.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include <gnome.h>
+#include <gtk/gtk.h>
#include "mainwindow.h"
#include "welcomewindow.h"
More information about the cairo-commit
mailing list