@@ -934,20 +934,19 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
934
934
[self ->handler installCallbacks: actions forButtons: buttons];
935
935
936
936
NSFont * font = [NSFont systemFontOfSize: 0.0 ];
937
- rect.size .width = 300 ;
938
- rect.size .height = 0 ;
939
- rect.origin .x += height;
940
- NSTextView * messagebox = [[NSTextView alloc ] initWithFrame: rect];
937
+ // rect.origin.x is now at the far right edge of the buttons
938
+ // we want the messagebox to take up the rest of the toolbar area
939
+ rect.size .width = bounds.size .width - rect.origin .x ;
940
+ rect.origin .x = bounds.size .width - rect.size .width ;
941
+ NSTextView * messagebox = [[[NSTextView alloc ] initWithFrame: rect] autorelease ];
941
942
messagebox.textContainer .maximumNumberOfLines = 2 ;
942
943
messagebox.textContainer .lineBreakMode = NSLineBreakByTruncatingTail;
944
+ messagebox.alignment = NSTextAlignmentRight;
943
945
[messagebox setFont: font];
944
946
[messagebox setDrawsBackground: NO ];
945
947
[messagebox setSelectable: NO ];
946
948
/* if selectable, the messagebox can become first responder,
947
949
* which is not supposed to happen */
948
- rect = [messagebox frame ];
949
- rect.origin .y = 0.5 * (height - rect.size .height );
950
- [messagebox setFrameOrigin: rect.origin];
951
950
[[window contentView ] addSubview: messagebox];
952
951
[messagebox release ];
953
952
[[window contentView ] display ];
@@ -974,25 +973,29 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
974
973
{
975
974
const char * message;
976
975
977
- if (!PyArg_ParseTuple (args, " y " , &message)) { return NULL ; }
976
+ if (!PyArg_ParseTuple (args, " s " , &message)) { return NULL ; }
978
977
979
978
NSTextView * messagebox = self->messagebox ;
980
979
981
980
if (messagebox) {
982
981
NSString * text = [NSString stringWithUTF8String: message];
983
982
[messagebox setString: text];
984
983
985
- // Adjust width with the window size
984
+ // Adjust width and height with the window size and content
986
985
NSRect rectWindow = [messagebox.superview frame ];
987
986
NSRect rect = [messagebox frame ];
987
+ // Entire region to the right of the buttons
988
988
rect.size .width = rectWindow.size .width - rect.origin .x ;
989
989
[messagebox setFrame: rect];
990
-
991
- // Adjust height with the content size
990
+ // We want to control the vertical position of
991
+ // the rect by the content size to center it vertically
992
+ // TODO: This seems to disable the cursor updates with newlines that
993
+ // are included in the image hover text. It is only when trying
994
+ // to set the frame height based on the contentRect's size.
992
995
[messagebox.layoutManager ensureLayoutForTextContainer: messagebox.textContainer];
993
- NSRect contentSize = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
994
- rect = [messagebox frame ] ;
995
- rect.origin . y = 0.5 * (self-> height - contentSize. size .height ) ;
996
+ NSRect contentRect = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
997
+ rect. origin . y = 0.5 * (self-> height - contentRect. size . height ) ;
998
+ rect.size . height = contentRect. size .height ;
996
999
[messagebox setFrame: rect];
997
1000
}
998
1001
0 commit comments