* defaults */
- (void)resizeTerminalWithContentRect: (NSRect)contentRect saveToDefaults: (BOOL)saveToDefaults;
+/* Change the minimum size for the window associated with the context. */
+- (void)setMinimumWindowSize;
+
/* Called from the view to indicate that it is starting or ending live resize */
- (void)viewWillStartLiveResize:(AngbandView *)view;
- (void)viewDidEndLiveResize:(AngbandView *)view;
/* Adjust terminal to fit window with new font; save the new columns
* and rows since they could be changed */
NSRect contentRect = [self->primaryWindow contentRectForFrameRect: [self->primaryWindow frame]];
+
+ [self setMinimumWindowSize];
+ NSSize size = self->primaryWindow.contentMinSize;
+ BOOL windowNeedsResizing = NO;
+ if (contentRect.size.width < size.width) {
+ contentRect.size.width = size.width;
+ windowNeedsResizing = YES;
+ }
+ if (contentRect.size.height < size.height) {
+ contentRect.size.height = size.height;
+ windowNeedsResizing = YES;
+ }
+ if (windowNeedsResizing) {
+ size.width = contentRect.size.width;
+ size.height = contentRect.size.height;
+ [self->primaryWindow setContentSize:size];
+ }
[self resizeTerminalWithContentRect: contentRect saveToDefaults: YES];
}
Term_activate( old );
}
+- (void)setMinimumWindowSize
+{
+ NSSize minsize;
+
+ if ([self terminalIndex] == 0) {
+ minsize.width = 80;
+ minsize.height = 24;
+ } else {
+ minsize.width = 1;
+ minsize.height = 1;
+ }
+ minsize.width =
+ minsize.width * self->tileSize.width + self->borderSize.width * 2.0;
+ minsize.height =
+ minsize.height * self->tileSize.height + self->borderSize.height * 2.0;
+ [[self makePrimaryWindow] setContentMinSize:minsize];
+}
+
- (void)saveWindowVisibleToDefaults: (BOOL)windowVisible
{
int termIndex = [self terminalIndex];
/* Get the window */
NSWindow *window = [context makePrimaryWindow];
- NSString *title;
-
/* Set its title and, for auxiliary terms, tentative size */
- if (termIdx == 0)
- {
- title = [NSString stringWithCString:angband_term_name[0]
+ NSString *title = [NSString stringWithCString:angband_term_name[termIdx]
#ifdef JP
- encoding:NSJapaneseEUCStringEncoding
-#else
- encoding:NSMacOSRomanStringEncoding
-#endif
- ];
- [window setTitle:title];
-
- /* Set minimum size (80x24) */
- NSSize minsize;
- minsize.width = 80 * context->tileSize.width + context->borderSize.width * 2.0;
- minsize.height = 24 * context->tileSize.height + context->borderSize.height * 2.0;
- [window setContentMinSize:minsize];
- }
- else
- {
- title = [NSString stringWithCString:angband_term_name[termIdx]
-#ifdef JP
- encoding:NSJapaneseEUCStringEncoding
+ encoding:NSJapaneseEUCStringEncoding
#else
- encoding:NSMacOSRomanStringEncoding
+ encoding:NSMacOSRomanStringEncoding
#endif
- ];
- [window setTitle:title];
- /* Set minimum size (1x1) */
- NSSize minsize;
- minsize.width = context->tileSize.width + context->borderSize.width * 2.0;
- minsize.height = context->tileSize.height + context->borderSize.height * 2.0;
- [window setContentMinSize:minsize];
- }
-
+ ];
+ [window setTitle:title];
+ [context setMinimumWindowSize];
/* If this is the first term, and we support full screen (Mac OS X Lion or
* later), then allow it to go full screen (sweet). Allow other terms to be