Added uiAreaHandler.RedrawOnResize() to handle redrawing on resizes.
This commit is contained in:
parent
aa446a3e51
commit
95e0ca8f49
|
@ -113,6 +113,8 @@ static void areaWidget_size_allocate(GtkWidget *w, GtkAllocation *allocation)
|
|||
ap->clientWidth = allocation->width;
|
||||
ap->clientHeight = allocation->height;
|
||||
updateScroll(areaWidget(w));
|
||||
if ((*(ap->ah->RedrawOnResize))(ap->ah, ap->a))
|
||||
gtk_widget_queue_resize(w);
|
||||
}
|
||||
|
||||
static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
||||
|
|
|
@ -99,6 +99,11 @@ static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|||
return gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(nvspinb));
|
||||
}
|
||||
|
||||
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void recalcScroll(GtkSpinButton *sb, gpointer data)
|
||||
{
|
||||
areaUpdateScroll(area);
|
||||
|
@ -124,6 +129,7 @@ int main(void)
|
|||
h.ah.Draw = handlerDraw;
|
||||
h.ah.HScrollMax = handlerHScrollMax;
|
||||
h.ah.VScrollMax = handlerVScrollMax;
|
||||
h.ah.RedrawOnResize = handlerRedrawOnResize;
|
||||
|
||||
gtk_init(NULL, NULL);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ struct uiAreaHandler {
|
|||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
||||
uintmax_t (*VScrollMax)(uiAreaHandler *, uiArea *);
|
||||
int (*RedrawOnResize)(uiAreaHandler *, uiArea *);
|
||||
};
|
||||
|
||||
struct uiAreaDrawParams {
|
||||
|
|
|
@ -287,6 +287,9 @@ struct uiArea {
|
|||
// and update the scrolling position
|
||||
[self hscrollTo:self->hscrollpos];
|
||||
[self vscrollTo:self->vscrollpos];
|
||||
|
||||
if ((*(self->libui_a->ah->RedrawOnResize))(self->libui_a->ah, self->libui_a))
|
||||
[self->drawingView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (IBAction)hscrollEvent:(id)sender
|
||||
|
|
|
@ -105,6 +105,11 @@ static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|||
return _wtoi(c);
|
||||
*/}
|
||||
|
||||
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// areaUpdateScroll(area);
|
||||
|
||||
@interface appDelegate : NSObject<NSApplicationDelegate, NSTextFieldDelegate>
|
||||
|
@ -162,6 +167,7 @@ int main(void)
|
|||
h.ah.Draw = handlerDraw;
|
||||
h.ah.HScrollMax = handlerHScrollMax;
|
||||
h.ah.VScrollMax = handlerVScrollMax;
|
||||
h.ah.RedrawOnResize = handlerRedrawOnResize;
|
||||
|
||||
app = [NSApplication sharedApplication];
|
||||
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
|
|
|
@ -10,6 +10,7 @@ struct uiAreaHandler {
|
|||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
||||
uintmax_t (*VScrollMax)(uiAreaHandler *, uiArea *);
|
||||
int (*RedrawOnResize)(uiAreaHandler *, uiArea *);
|
||||
};
|
||||
|
||||
struct uiAreaDrawParams {
|
||||
|
|
|
@ -105,6 +105,11 @@ static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|||
return _wtoi(c);
|
||||
*/}
|
||||
|
||||
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// areaUpdateScroll(area);
|
||||
|
||||
@interface appDelegate : NSObject<NSApplicationDelegate, NSTextFieldDelegate>
|
||||
|
@ -162,6 +167,7 @@ int main(void)
|
|||
h.ah.Draw = handlerDraw;
|
||||
h.ah.HScrollMax = handlerHScrollMax;
|
||||
h.ah.VScrollMax = handlerVScrollMax;
|
||||
h.ah.RedrawOnResize = handlerRedrawOnResize;
|
||||
|
||||
app = [NSApplication sharedApplication];
|
||||
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
|
|
|
@ -10,6 +10,7 @@ struct uiAreaHandler {
|
|||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
||||
uintmax_t (*VScrollMax)(uiAreaHandler *, uiArea *);
|
||||
int (*RedrawOnResize)(uiAreaHandler *, uiArea *);
|
||||
};
|
||||
|
||||
struct uiAreaDrawParams {
|
||||
|
|
|
@ -257,6 +257,7 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
HDC dc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT client;
|
||||
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
||||
|
||||
a = (uiArea *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||
if (a == NULL) {
|
||||
|
@ -281,6 +282,13 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
logLastError("error getting client rect in WM_PRINTCLIENT in areaWndProc()");
|
||||
doPaint(a, (HDC) wParam, &client, &client);
|
||||
return 0;
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
if ((wp->flags & SWP_NOSIZE) != 0)
|
||||
break;
|
||||
if ((*(a->ah->RedrawOnResize))(a->ah, a))
|
||||
if (InvalidateRect(a->hwnd, NULL, TRUE) == 0)
|
||||
logLastError("error redrawing area on resize in areaWndProc()");
|
||||
return 0;
|
||||
case WM_HSCROLL:
|
||||
hscroll(a, wParam, lParam);
|
||||
return 0;
|
||||
|
@ -312,7 +320,7 @@ ATOM registerAreaClass(void)
|
|||
//TODO wc.hIcon = hDefaultIcon;
|
||||
//TODO wc.hCursor = hDefaultCursor;
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
// don't specify CS_HREDRAW or CS_VREDRAW; that's decided by the uiAreaHandler in RedrawOnResize()
|
||||
return RegisterClassW(&wc);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,11 @@ static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|||
return _wtoi(c);
|
||||
}
|
||||
|
||||
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void repos(HWND hwnd)
|
||||
{
|
||||
RECT r;
|
||||
|
@ -155,6 +160,7 @@ int main(void)
|
|||
h.ah.Draw = handlerDraw;
|
||||
h.ah.HScrollMax = handlerHScrollMax;
|
||||
h.ah.VScrollMax = handlerVScrollMax;
|
||||
h.ah.RedrawOnResize = handlerRedrawOnResize;
|
||||
|
||||
registerAreaClass();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ struct uiAreaHandler {
|
|||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
||||
uintmax_t (*VScrollMax)(uiAreaHandler *, uiArea *);
|
||||
int (*RedrawOnResize)(uiAreaHandler *, uiArea *);
|
||||
};
|
||||
|
||||
struct uiAreaDrawParams {
|
||||
|
|
Loading…
Reference in New Issue