diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2012-05-22 16:59:45 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2012-05-22 16:59:45 +0100 |
commit | 295ae320e2385fd1340492a959e3633a339e3d0d (patch) | |
tree | 9b75f42c78b6bae62dd86afa57fafb11eb3a9f99 /tikzit/src/gtk/PreviewWindow.m | |
parent | 9a36706cc03ae3781ce8bdc02f10289a24408b58 (diff) |
almost there, just doesnt resize container now
Diffstat (limited to 'tikzit/src/gtk/PreviewWindow.m')
-rw-r--r-- | tikzit/src/gtk/PreviewWindow.m | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/tikzit/src/gtk/PreviewWindow.m b/tikzit/src/gtk/PreviewWindow.m index 6126bc1..bde39a4 100644 --- a/tikzit/src/gtk/PreviewWindow.m +++ b/tikzit/src/gtk/PreviewWindow.m @@ -91,36 +91,42 @@ static gboolean window_configure_event_cb (GtkWindow *window, [previewer setDocument:doc]; } +// - (void) updateSize { +// double width = 150; +// double height = 150; +// if ([previewer isValid]) { +// double pWidth = [previewer width]; +// double pHeight = [previewer height]; +// width = (width < pWidth + 4) ? pWidth + 4 : width; +// height = (height < pHeight + 4) ? pHeight + 4 : height; +// NSPoint offset; +// offset.x = (width-pWidth)/2.0; +// offset.y = (height-pHeight)/2.0; +// [[surface transformer] setOrigin:offset]; +// } +// [surface setSizeRequestWidth:width height:height]; +// } + - (void) updateSize { - double width = 150; - double height = 150; - if ([previewer isValid]) { - double pWidth = [previewer width]; - double pHeight = [previewer height]; - width = (width < pWidth + 4) ? pWidth + 4 : width; - height = (height < pHeight + 4) ? pHeight + 4 : height; - NSPoint offset; - offset.x = (width-pWidth)/2.0; - offset.y = (height-pHeight)/2.0; - [[surface transformer] setOrigin:offset]; - } - [surface setSizeRequestWidth:width height:height]; + gint w, h; + gtk_window_get_size(window, &w, &h); + double width = (double)w; + double height = (double)h; + [previewer setWidth:width]; + [previewer setHeight:height]; + [surface invalidate]; + //NSLog(@"got that resize event! --> (%d, %d)", w, h); } - (BOOL) update { if ([self updateOrShowError]) { [self updateSize]; - [surface invalidate]; return YES; } return NO; } -- (void) resize { - NSLog(@"got that resize event!"); -} - - (void) show { if ([self updateOrShowError]) { [self updateSize]; @@ -207,7 +213,7 @@ static gboolean window_configure_event_cb (GtkWindow *window, GdkEvent *event, PreviewWindow *preview) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [preview resize]; + [preview updateSize]; [pool drain]; return TRUE; // we dealt with this event } |