summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/gtkdraw-cairo.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
commitd1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch)
tree326578f0505cbed07cfe60de530022822dc237ac /app/wlib/gtklib/gtkdraw-cairo.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/wlib/gtklib/gtkdraw-cairo.c')
-rw-r--r--app/wlib/gtklib/gtkdraw-cairo.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/app/wlib/gtklib/gtkdraw-cairo.c b/app/wlib/gtklib/gtkdraw-cairo.c
index a19eb2b..4f3b1d2 100644
--- a/app/wlib/gtklib/gtkdraw-cairo.c
+++ b/app/wlib/gtklib/gtkdraw-cairo.c
@@ -174,8 +174,9 @@ static cairo_t* gtkDrawCreateCairoContext(
}
case wDrawLineDash:
{
- double dashes[] = { 5, 5 };
- cairo_set_dash(cairo, dashes, 2, 0);
+ double dashes[] = { 5, 3 };
+ static int len_dashes = sizeof(dashes) / sizeof(dashes[0]);
+ cairo_set_dash(cairo, dashes, len_dashes, 0);
break;
}
}
@@ -183,13 +184,14 @@ static cairo_t* gtkDrawCreateCairoContext(
if(opts & wDrawOptTemp)
{
cairo_set_source_rgba(cairo, 0, 0, 0, 0);
+ cairo_set_operator(cairo, CAIRO_OPERATOR_OVER);
}
else
{
GdkColor* const gcolor = wlibGetColor(color, TRUE);
cairo_set_source_rgb(cairo, gcolor->red / 65535.0, gcolor->green / 65535.0, gcolor->blue / 65535.0);
- cairo_set_operator(cairo, CAIRO_OPERATOR_OVER);
+ cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
}
return cairo;
@@ -197,6 +199,7 @@ static cairo_t* gtkDrawCreateCairoContext(
static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
cairo_destroy(cairo);
+ return NULL;
}
void wDrawDelayUpdate(
@@ -442,7 +445,7 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
update_rect.x = (gint) x - ascent - descent - 1;
update_rect.y = (gint) y - (gint) ascent - 1;
update_rect.width = (gint) (w * cos( angle ) + 2 + ascent + descent);
- update_rect.height = (gint) (w * sin( angle ) + ascent + descent + 2 );
+ update_rect.height = (gint) (h * sin( angle ) + ascent + descent + 2 );
gtk_widget_draw(bd->widget, &update_rect);
}
@@ -469,8 +472,8 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
(int *) &ascent, (int *) &descent));
*w = (wPos_t) textWidth;
- *h = (wPos_t) ascent;
- *d = (wPos_t) descent;
+ *h = (wPos_t) textHeight;
+ *d = (wPos_t) textHeight-ascent;
if (debugWindow >= 3)
fprintf(stderr, "text metrics: w=%d, h=%d, d=%d\n", *w, *h, *d);
@@ -693,7 +696,7 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
wDrawColor color,
wDrawOpts opts )
{
- GdkGC * gc;
+ //GdkGC * gc;
GdkRectangle update_rect;
int i, j, wb;
wPos_t xx, yy;
@@ -703,7 +706,8 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
x = INMAPX( bd, x-bm->x );
y = INMAPY( bd, y-bm->y )-bm->h;
wb = (bm->w+7)/8;
- gc = selectGC( bd, 0, wDrawLineSolid, color, opts );
+ //gc = selectGC( bd, 0, wDrawLineSolid, color, opts );
+ cairo_t* cairo = gtkDrawCreateCairoContext(bd, 0, wDrawLineSolid, color, opts);
for ( i=0; i<bm->w; i++ )
for ( j=0; j<bm->h; j++ )
@@ -732,7 +736,9 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
continue;
}
/*printf( "gdk_draw_point( %ld, gc, %d, %d )\n", (long)gdk_window, xx, yy );*/
- gdk_draw_point( gdk_window, gc, xx, yy );
+ //gdk_draw_point( gdk_window, gc, xx, yy );
+ cairo_rectangle(cairo, xx-0.5, yy-0.5, 1, 1);
+ cairo_fill(cairo);
if ( b && b->type == B_DRAW ) {
update_rect.x = xx-1;
update_rect.y = yy-1;
@@ -741,6 +747,7 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
gtk_widget_draw( b->widget, &update_rect );
}
}
+ gtkDrawDestroyCairoContext(cairo);
#ifdef LATER
gdk_draw_pixmap(bd->pixmap, gc,
bm->pixmap,
@@ -836,9 +843,9 @@ static cairo_t* gtkDrawDestroyCairoContext(cairo_t *cairo) {
bd->pixmap = gdk_pixmap_new( bd->widget->window, w, h, -1 );
wDrawClear( bd );
- /*bd->redraw( bd, bd->context, w, h );*/
+ bd->redraw( bd, bd->context, w, h );
}
- /*wRedraw( bd );*/
+ /*wRedraw( bd )*/;
}
@@ -996,7 +1003,8 @@ static gint draw_button_event(
printf( "%s[%dx%d]\n", actionNames[action], bd->lastX, bd->lastY );
bd->action( bd, bd->context, action, bd->lastX, bd->lastY );
}
- gtk_widget_grab_focus( bd->widget );
+ if (!(bd->option & BD_NOFOCUS))
+ gtk_widget_grab_focus( bd->widget );
return TRUE;
}
@@ -1032,7 +1040,8 @@ static gint draw_motion_event(
if (drawVerbose >= 2)
printf( "%lx: %s[%dx%d] %s\n", (long)bd, actionNames[action], bd->lastX, bd->lastY, event->is_hint?"<Hint>":"<>" );
bd->action( bd, bd->context, action, bd->lastX, bd->lastY );
- gtk_widget_grab_focus( bd->widget );
+ if (!(bd->option & BD_NOFOCUS))
+ gtk_widget_grab_focus( bd->widget );
return TRUE;
}
@@ -1042,11 +1051,17 @@ static gint draw_char_event(
GdkEventKey *event,
wDraw_p bd )
{
+ GdkModifierType modifiers;
guint key = event->keyval;
wAccelKey_e extKey = wAccelKey_None;
switch (key) {
case GDK_KEY_Escape: key = 0x1B; break;
- case GDK_KEY_Return: key = 0x0D; break;
+ case GDK_KEY_Return:
+ modifiers = gtk_accelerator_get_default_mod_mask();
+ if (((event->state & modifiers)==GDK_CONTROL_MASK) || ((event->state & modifiers)==GDK_MOD1_MASK))
+ extKey = wAccelKey_LineFeed; //If Return plus Control or Alt send in LineFeed
+ key = 0x0D;
+ break;
case GDK_KEY_Linefeed: key = 0x0A; break;
case GDK_KEY_Tab: key = 0x09; break;
case GDK_KEY_BackSpace: key = 0x08; break;
@@ -1141,7 +1156,9 @@ int xw, xh, cw, ch;
(GtkSignalFunc) draw_char_event, bd);
gtk_signal_connect (GTK_OBJECT (bd->widget), "leave_notify_event",
(GtkSignalFunc) draw_leave_event, bd);
- GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bd->widget), GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(bd->widget,!(option & BD_NOFOCUS));
+ //if (!(option & BD_NOFOCUS))
+ // GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bd->widget), GTK_CAN_FOCUS);
gtk_widget_set_events (bd->widget, GDK_EXPOSURE_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK