navit  0.5.3-trunk
graphics_win32.c File Reference
#include <windows.h>
#include <windowsx.h>
#include <wingdi.h>
#include <glib.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "debug.h"
#include "point.h"
#include "graphics.h"
#include "color.h"
#include "callback.h"
#include "plugin.h"
#include "item.h"
#include "window.h"
#include "graphics_win32.h"
#include "xpm2bmp.h"
#include "profile.h"
#include "keys.h"
#include "png.h"

Data Structures

struct  graphics_priv
 
struct  window_priv
 
struct  graphics_image_priv
 
struct  graphics_gc_priv
 
struct  graphics_font_priv
 
struct  event_timeout
 

Macros

#define STRETCH_HALFTONE   4
 
#define GET_WHEEL_DELTA_WPARAM(wParam)   ((short)HIWORD(wParam))
 
#define EZ_ATTR_BOLD   1
 
#define EZ_ATTR_ITALIC   2
 
#define EZ_ATTR_UNDERLINE   4
 
#define EZ_ATTR_STRIKEOUT   8
 

Typedefs

typedef BOOL(WINAPI * FP_AlphaBlend) (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction)
 
typedef int(WINAPI * FP_SetStretchBltMode) (HDC dc, int mode)
 

Functions

HFONT EzCreateFont (HDC hdc, TCHAR *szFaceName, int iDeciPtHeight, int iDeciPtWidth, int iAttributes, BOOL fLogRes)
 
static void ErrorExit (LPTSTR lpszFunction)
 
static void create_memory_dc (struct graphics_priv *gr)
 
static void HandleButtonClick (struct graphics_priv *gra_priv, int updown, int button, long lParam)
 
static void HandleKeyChar (struct graphics_priv *gra_priv, WPARAM wParam)
 
static void HandleKeyDown (struct graphics_priv *gra_priv, WPARAM wParam)
 
static LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
static int fullscreen (struct window *win, int on)
 
void WINAPI SystemIdleTimerReset (void)
 
static struct event_timeoutevent_win32_add_timeout (int timeout, int multi, struct callback *cb)
 
static void disable_suspend (struct window *win)
 
static HANDLE CreateGraphicsWindows (struct graphics_priv *gr, HMENU hMenu)
 
static void graphics_destroy (struct graphics_priv *gr)
 
static void gc_destroy (struct graphics_gc_priv *gc)
 
static void gc_set_linewidth (struct graphics_gc_priv *gc, int w)
 
static void gc_set_dashes (struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n)
 
static void gc_set_foreground (struct graphics_gc_priv *gc, struct color *c)
 
static void gc_set_background (struct graphics_gc_priv *gc, struct color *c)
 
static struct graphics_gc_privgc_new (struct graphics_priv *gr, struct graphics_gc_methods *meth)
 
static void draw_lines (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
 
static void draw_polygon (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
 
static void draw_polygon_with_holes (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int hole_count, int *ccount, struct point **holes)
 
static void draw_rectangle (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
 
static void draw_circle (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
 
static void draw_drag (struct graphics_priv *gr, struct point *p)
 
static void draw_mode (struct graphics_priv *gr, enum draw_mode_num mode)
 
static void * get_data (struct graphics_priv *this_, const char *type)
 
static void background_gc (struct graphics_priv *gr, struct graphics_gc_priv *gc)
 
static void draw_text (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
 
static void font_destroy (struct graphics_font_priv *font)
 
static struct graphics_font_privfont_new (struct graphics_priv *gr, struct graphics_font_methods *meth, char *name, int size, int flags)
 
static int pngdecode (struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
 
static void pngscale (struct graphics_image_priv *img, struct graphics_priv *gr, int width, int height)
 
static void pngrender (struct graphics_image_priv *img, struct graphics_priv *gr, int x0, int y0)
 
static int xpmdecode (char *name, struct graphics_image_priv *img)
 
static struct graphics_image_privimage_new (struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation)
 
static void draw_image (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
 
static struct graphics_privgraphics_win32_new_helper (struct graphics_methods *meth)
 
static void overlay_resize (struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
 
static struct graphics_privoverlay_new (struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
 
static void overlay_disable (struct graphics_priv *gr, int disable)
 
static void get_text_bbox (struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
 
static void bind_late (struct graphics_priv *gra_priv)
 
static struct graphics_privgraphics_win32_new (struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
static void event_win32_main_loop_run (void)
 
static void event_win32_main_loop_quit (void)
 
static struct event_watchevent_win32_add_watch (int h, enum event_watch_cond cond, struct callback *cb)
 
static void event_win32_remove_watch (struct event_watch *ev)
 
static void run_timer (UINT_PTR idEvent)
 
static VOID CALLBACK win32_timer_cb (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
 
static void event_win32_remove_timeout (struct event_timeout *to)
 
static struct event_idleevent_win32_add_idle (int priority, struct callback *cb)
 
static void event_win32_remove_idle (struct event_idle *ev)
 
static void event_win32_call_callback (struct callback_list *cb)
 
static struct event_privevent_win32_new (struct event_methods *meth)
 
void plugin_init (void)
 

Variables

static HWND g_hwnd = NULL
 
static const TCHAR g_szClassName [] = {'N','A','V','G','R','A','\0'}
 
static struct graphics_gc_methods gc_methods
 
static struct graphics_font_methods font_methods
 
static struct graphics_methods graphics_methods
 
static GListtimers
 
static struct event_methods event_win32_methods
 

Macro Definition Documentation

◆ EZ_ATTR_BOLD

#define EZ_ATTR_BOLD   1

◆ EZ_ATTR_ITALIC

#define EZ_ATTR_ITALIC   2

◆ EZ_ATTR_STRIKEOUT

#define EZ_ATTR_STRIKEOUT   8

◆ EZ_ATTR_UNDERLINE

#define EZ_ATTR_UNDERLINE   4

◆ GET_WHEEL_DELTA_WPARAM

#define GET_WHEEL_DELTA_WPARAM (   wParam)    ((short)HIWORD(wParam))

◆ STRETCH_HALFTONE

#define STRETCH_HALFTONE   4

Typedef Documentation

◆ FP_AlphaBlend

typedef BOOL(WINAPI * FP_AlphaBlend) (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction)

◆ FP_SetStretchBltMode

typedef int(WINAPI * FP_SetStretchBltMode) (HDC dc, int mode)

Function Documentation

◆ background_gc()

static void background_gc ( struct graphics_priv gr,
struct graphics_gc_priv gc 
)
static

◆ bind_late()

◆ create_memory_dc()

◆ CreateGraphicsWindows()

◆ disable_suspend()

static void disable_suspend ( struct window win)
static

◆ draw_circle()

static void draw_circle ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  r 
)
static

◆ draw_drag()

static void draw_drag ( struct graphics_priv gr,
struct point p 
)
static

◆ draw_image()

static void draw_image ( struct graphics_priv gr,
struct graphics_gc_priv fg,
struct point p,
struct graphics_image_priv img 
)
static

◆ draw_lines()

static void draw_lines ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count 
)
static

◆ draw_mode()

◆ draw_polygon()

static void draw_polygon ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count 
)
static

◆ draw_polygon_with_holes()

static void draw_polygon_with_holes ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count,
int  hole_count,
int *  ccount,
struct point **  holes 
)
static

◆ draw_rectangle()

static void draw_rectangle ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  w,
int  h 
)
static

◆ draw_text()

static void draw_text ( struct graphics_priv gr,
struct graphics_gc_priv fg,
struct graphics_gc_priv bg,
struct graphics_font_priv font,
char *  text,
struct point p,
int  dx,
int  dy 
)
static

◆ ErrorExit()

static void ErrorExit ( LPTSTR  lpszFunction)
static

References _tprintf, dbg, and lvl_error.

◆ event_win32_add_idle()

static struct event_idle* event_win32_add_idle ( int  priority,
struct callback cb 
)
static

◆ event_win32_add_timeout()

static struct event_timeout * event_win32_add_timeout ( int  timeout,
int  multi,
struct callback cb 
)
static

◆ event_win32_add_watch()

static struct event_watch* event_win32_add_watch ( int  h,
enum event_watch_cond  cond,
struct callback cb 
)
static

References dbg, and lvl_debug.

◆ event_win32_call_callback()

static void event_win32_call_callback ( struct callback_list cb)
static

References event_idle::cb, and g_hwnd.

◆ event_win32_main_loop_quit()

static void event_win32_main_loop_quit ( void  )
static

References dbg, g_hwnd, L, and lvl_debug.

◆ event_win32_main_loop_run()

static void event_win32_main_loop_run ( void  )
static

References dbg, and lvl_debug.

◆ event_win32_new()

static struct event_priv* event_win32_new ( struct event_methods meth)
static

References event_win32_methods.

Referenced by plugin_init().

◆ event_win32_remove_idle()

static void event_win32_remove_idle ( struct event_idle ev)
static

◆ event_win32_remove_timeout()

static void event_win32_remove_timeout ( struct event_timeout to)
static

◆ event_win32_remove_watch()

static void event_win32_remove_watch ( struct event_watch ev)
static

References dbg, and lvl_debug.

◆ EzCreateFont()

HFONT EzCreateFont ( HDC  hdc,
TCHAR *  szFaceName,
int  iDeciPtHeight,
int  iDeciPtWidth,
int  iAttributes,
BOOL  fLogRes 
)

◆ font_destroy()

static void font_destroy ( struct graphics_font_priv font)
static

◆ font_new()

static struct graphics_font_priv* font_new ( struct graphics_priv gr,
struct graphics_font_methods meth,
char *  name,
int  size,
int  flags 
)
static

◆ fullscreen()

static int fullscreen ( struct window win,
int  on 
)
static

References g_hwnd, and L.

Referenced by get_data().

◆ gc_destroy()

static void gc_destroy ( struct graphics_gc_priv gc)
static

◆ gc_new()

◆ gc_set_background()

static void gc_set_background ( struct graphics_gc_priv gc,
struct color c 
)
static

◆ gc_set_dashes()

static void gc_set_dashes ( struct graphics_gc_priv gc,
int  width,
int  offset,
unsigned char  dash_list[],
int  n 
)
static

◆ gc_set_foreground()

◆ gc_set_linewidth()

static void gc_set_linewidth ( struct graphics_gc_priv gc,
int  w 
)
static

◆ get_data()

◆ get_text_bbox()

static void get_text_bbox ( struct graphics_priv gr,
struct graphics_font_priv font,
char *  text,
int  dx,
int  dy,
struct point ret,
int  estimate 
)
static

◆ graphics_destroy()

static void graphics_destroy ( struct graphics_priv gr)
static

◆ graphics_win32_new()

◆ graphics_win32_new_helper()

static struct graphics_priv * graphics_win32_new_helper ( struct graphics_methods meth)
static

◆ HandleButtonClick()

static void HandleButtonClick ( struct graphics_priv gra_priv,
int  updown,
int  button,
long  lParam 
)
static

References callback_list_call_attr_3, and graphics_priv::cbl.

Referenced by WndProc().

◆ HandleKeyChar()

static void HandleKeyChar ( struct graphics_priv gra_priv,
WPARAM  wParam 
)
static

◆ HandleKeyDown()

static void HandleKeyDown ( struct graphics_priv gra_priv,
WPARAM  wParam 
)
static

◆ image_new()

static struct graphics_image_priv* image_new ( struct graphics_priv gr,
struct graphics_image_methods meth,
char *  name,
int *  w,
int *  h,
struct point hot,
int  rotation 
)
static

◆ overlay_disable()

static void overlay_disable ( struct graphics_priv gr,
int  disable 
)
static

◆ overlay_new()

◆ overlay_resize()

static void overlay_resize ( struct graphics_priv gr,
struct point p,
int  w,
int  h,
int  wraparound 
)
static

◆ plugin_init()

void plugin_init ( void  )

◆ pngdecode()

◆ pngrender()

◆ pngscale()

◆ run_timer()

static void run_timer ( UINT_PTR  idEvent)
static

◆ SystemIdleTimerReset()

void WINAPI SystemIdleTimerReset ( void  )

Referenced by disable_suspend(), and WndProc().

◆ win32_timer_cb()

static VOID CALLBACK win32_timer_cb ( HWND  hwnd,
UINT  uMsg,
UINT_PTR  idEvent,
DWORD  dwTime 
)
static

References run_timer().

Referenced by event_win32_add_timeout().

◆ WndProc()

◆ xpmdecode()

Variable Documentation

◆ event_win32_methods

struct event_methods event_win32_methods
static
Initial value:
= {
}
static struct event_watch * event_win32_add_watch(int h, enum event_watch_cond cond, struct callback *cb)
Definition: graphics_win32.c:1802
static struct event_timeout * event_win32_add_timeout(int timeout, int multi, struct callback *cb)
Definition: graphics_win32.c:1847
static void event_win32_remove_watch(struct event_watch *ev)
Definition: graphics_win32.c:1807
static void event_win32_remove_timeout(struct event_timeout *to)
Definition: graphics_win32.c:1860
static void event_win32_call_callback(struct callback_list *cb)
Definition: graphics_win32.c:1890
static void event_win32_main_loop_quit(void)
Definition: graphics_win32.c:1783
static struct event_idle * event_win32_add_idle(int priority, struct callback *cb)
Definition: graphics_win32.c:1882
static void event_win32_main_loop_run(void)
Definition: graphics_win32.c:1772
static void event_win32_remove_idle(struct event_idle *ev)
Definition: graphics_win32.c:1886

Referenced by event_win32_new().

◆ font_methods

struct graphics_font_methods font_methods
static
Initial value:
= {
}
static void font_destroy(struct graphics_font_priv *font)
Definition: graphics_win32.c:1237

Referenced by font_new().

◆ g_hwnd

◆ g_szClassName

const TCHAR g_szClassName[] = {'N','A','V','G','R','A','\0'}
static

Referenced by CreateGraphicsWindows().

◆ gc_methods

struct graphics_gc_methods gc_methods
static
Initial value:
= {
}
static void gc_destroy(struct graphics_gc_priv *gc)
Definition: graphics_win32.c:725
static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_win32.c:746
static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_win32.c:760
static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n)
Definition: graphics_win32.c:737
static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
Definition: graphics_win32.c:731

Referenced by gc_new().

◆ graphics_methods

◆ timers