Got rid of the clientWidth and clientHeight variables.
This commit is contained in:
parent
473c6c92f0
commit
8ea3b07aa8
45
unix/area.c
45
unix/area.c
|
@ -24,18 +24,19 @@ struct areaWidgetClass {
|
||||||
|
|
||||||
struct uiArea {
|
struct uiArea {
|
||||||
uiUnixControl c;
|
uiUnixControl c;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget; // either swidget or areaWidget depending on whether it is scrolling
|
||||||
|
|
||||||
|
GtkWidget *swidget;
|
||||||
GtkContainer *scontainer;
|
GtkContainer *scontainer;
|
||||||
GtkScrolledWindow *sw;
|
GtkScrolledWindow *sw;
|
||||||
|
|
||||||
GtkWidget *areaWidget;
|
GtkWidget *areaWidget;
|
||||||
GtkDrawingArea *drawingArea;
|
GtkDrawingArea *drawingArea;
|
||||||
areaWidget *area;
|
areaWidget *area;
|
||||||
|
|
||||||
uiAreaHandler *ah;
|
uiAreaHandler *ah;
|
||||||
|
|
||||||
// TODO get rid of the need for these
|
gboolean scrolling;
|
||||||
int clientWidth;
|
|
||||||
int clientHeight;
|
|
||||||
|
|
||||||
clickCounter cc;
|
clickCounter cc;
|
||||||
};
|
};
|
||||||
|
@ -93,6 +94,23 @@ static void areaWidget_size_allocate(GtkWidget *w, GtkAllocation *allocation)
|
||||||
gtk_widget_queue_resize(w);
|
gtk_widget_queue_resize(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void loadAreaSize(uiArea *a, double *width, double *height)
|
||||||
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
*width = 0;
|
||||||
|
*height = 0;
|
||||||
|
// don't provide size information for scrolling areas
|
||||||
|
if (!a->scrolling) {
|
||||||
|
gtk_widget_get_allocation(a->areaWidget, &allocation);
|
||||||
|
// these are already in drawing space coordinates
|
||||||
|
// for drawing, the size of drawing space has the same value as the widget allocation
|
||||||
|
// thanks to tristan in irc.gimp.net/#gtk+
|
||||||
|
*width = allocation.width;
|
||||||
|
*height = allocation.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
||||||
{
|
{
|
||||||
areaWidget *aw = areaWidget(w);
|
areaWidget *aw = areaWidget(w);
|
||||||
|
@ -102,16 +120,7 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
||||||
|
|
||||||
dp.Context = newContext(cr);
|
dp.Context = newContext(cr);
|
||||||
|
|
||||||
if (a->scrolling) {
|
loadAreaSize(a, &(dp.AreaWidth), &(dp.AreaHeight));
|
||||||
dp.AreaWidth = 0;
|
|
||||||
dp.AreaHeight = 0;
|
|
||||||
} else {
|
|
||||||
// these are already in drawing space coordinates
|
|
||||||
// the size of drawing space has the same value as the widget allocation
|
|
||||||
// thanks to tristan in irc.gimp.net/#gtk+
|
|
||||||
dp.AreaWidth = a->clientWidth;
|
|
||||||
dp.AreaHeight = a->clientHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
cairo_clip_extents(cr, &clipX0, &clipY0, &clipX1, &clipY1);
|
cairo_clip_extents(cr, &clipX0, &clipY0, &clipX1, &clipY1);
|
||||||
dp.ClipX = clipX0;
|
dp.ClipX = clipX0;
|
||||||
|
@ -191,13 +200,7 @@ static void finishMouseEvent(uiArea *a, uiAreaMouseEvent *me, guint mb, gdouble
|
||||||
me->X = x;
|
me->X = x;
|
||||||
me->Y = y;
|
me->Y = y;
|
||||||
|
|
||||||
if (a->scrolling) {
|
loadAreaSize(a, &(me->AreaWidth), &(me->AreaHeight));
|
||||||
me->AreaWidth = 0;
|
|
||||||
me->AreaHeight = 0;
|
|
||||||
} else {
|
|
||||||
me->AreaWidth = a->clientWidth;
|
|
||||||
me->AreaHeight = a->clientHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*(a->ah->MouseEvent))(a->ah, a, me);
|
(*(a->ah->MouseEvent))(a->ah, a, me);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue