@@ -212,14 +212,6 @@ - (BOOL)closeButtonPressed;
212
212
- (void )dealloc ;
213
213
@end
214
214
215
- @interface ToolWindow : NSWindow
216
- {
217
- }
218
- - (ToolWindow*)initWithContentRect : (NSRect )rect master : (NSWindow *)window ;
219
- - (void )masterCloses : (NSNotification *)notification ;
220
- - (void )close ;
221
- @end
222
-
223
215
@interface View : NSView <NSWindowDelegate >
224
216
{ PyObject* canvas;
225
217
NSRect rubberband;
@@ -959,74 +951,17 @@ -(void)zoom:(id)sender
959
951
}
960
952
961
953
-(void )configure_subplots : (id )sender
962
- { PyObject* canvas;
963
- View* view;
964
- PyObject* size;
965
- NSRect rect;
966
- int width, height;
967
-
968
- rect.origin .x = 100 ;
969
- rect.origin .y = 350 ;
970
- PyGILState_STATE gstate = PyGILState_Ensure ();
971
- PyObject* master = PyObject_GetAttrString (toolbar, " canvas" );
972
- if (master==nil )
973
- {
974
- PyErr_Print ();
975
- PyGILState_Release (gstate);
976
- return ;
977
- }
978
- canvas = PyObject_CallMethod (toolbar, " prepare_configure_subplots" , " " );
979
- if (!canvas)
980
- {
981
- PyErr_Print ();
982
- Py_DECREF (master);
983
- PyGILState_Release (gstate);
984
- return ;
985
- }
986
-
987
- view = ((FigureCanvas*)canvas)->view ;
988
- if (!view) /* Something really weird going on */
989
- {
990
- PyErr_SetString (PyExc_RuntimeError, " NSView* is NULL" );
991
- PyErr_Print ();
992
- Py_DECREF (canvas);
993
- Py_DECREF (master);
994
- PyGILState_Release (gstate);
995
- return ;
996
- }
997
-
998
- size = PyObject_CallMethod (canvas, " get_width_height" , " " );
999
- Py_DECREF (canvas);
1000
- if (!size)
1001
- {
1002
- PyErr_Print ();
1003
- Py_DECREF (master);
1004
- PyGILState_Release (gstate);
1005
- return ;
1006
- }
1007
-
1008
- int ok = PyArg_ParseTuple (size, " ii" , &width, &height);
1009
- Py_DECREF (size);
1010
- if (!ok)
1011
- {
954
+ {
955
+ PyObject* result;
956
+ PyGILState_STATE gstate;
957
+ gstate = PyGILState_Ensure ();
958
+ result = PyObject_CallMethod (toolbar, " configure_subplots" , NULL );
959
+ if (result) {
960
+ Py_DECREF (result);
961
+ } else {
1012
962
PyErr_Print ();
1013
- Py_DECREF (master);
1014
- PyGILState_Release (gstate);
1015
- return ;
1016
963
}
1017
-
1018
- NSWindow * mw = [((FigureCanvas*)master)->view window ];
1019
- Py_DECREF (master);
1020
964
PyGILState_Release (gstate);
1021
-
1022
- rect.size .width = width;
1023
- rect.size .height = height;
1024
-
1025
- ToolWindow* window = [ [ToolWindow alloc ] initWithContentRect: rect
1026
- master: mw];
1027
- [window setContentView: view];
1028
- [view release ];
1029
- [window makeKeyAndOrderFront: nil ];
1030
965
}
1031
966
1032
967
-(void )save_figure : (id )sender
@@ -1455,36 +1390,6 @@ - (void)dealloc
1455
1390
}
1456
1391
@end
1457
1392
1458
- @implementation ToolWindow
1459
- - (ToolWindow*)initWithContentRect : (NSRect )rect master : (NSWindow *)window
1460
- {
1461
- [self initWithContentRect: rect
1462
- styleMask: NSWindowStyleMaskTitled
1463
- | NSWindowStyleMaskClosable
1464
- | NSWindowStyleMaskResizable
1465
- | NSWindowStyleMaskMiniaturizable
1466
- backing: NSBackingStoreBuffered
1467
- defer: YES ];
1468
- [self setTitle: @" Subplot Configuration Tool" ];
1469
- [[NSNotificationCenter defaultCenter ] addObserver: self
1470
- selector: @selector (masterCloses: )
1471
- name: NSWindowWillCloseNotification
1472
- object: window];
1473
- return self;
1474
- }
1475
-
1476
- - (void )masterCloses : (NSNotification *)notification
1477
- {
1478
- [self close ];
1479
- }
1480
-
1481
- - (void )close
1482
- {
1483
- [[NSNotificationCenter defaultCenter ] removeObserver: self ];
1484
- [super close ];
1485
- }
1486
- @end
1487
-
1488
1393
@implementation View
1489
1394
- (BOOL )isFlipped
1490
1395
{
0 commit comments