1 /* 2 NSBox.h 3 4 Simple box view that can display a border and title 5 6 Copyright (C) 1996 Free Software Foundation, Inc. 7 8 Author: Scott Christley <scottc@net-community.com> 9 Date: 1996 10 11 This file is part of the GNUstep GUI Library. 12 13 This library is free software; you can redistribute it and/or 14 modify it under the terms of the GNU Lesser General Public 15 License as published by the Free Software Foundation; either 16 version 2 of the License, or (at your option) any later version. 17 18 This library is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 Lesser General Public License for more details. 22 23 You should have received a copy of the GNU Lesser General Public 24 License along with this library; see the file COPYING.LIB. 25 If not, see <http://www.gnu.org/licenses/> or write to the 26 Free Software Foundation, 51 Franklin Street, Fifth Floor, 27 Boston, MA 02110-1301, USA. 28 */ 29 30 #ifndef _GNUstep_H_NSBox 31 #define _GNUstep_H_NSBox 32 #import <GNUstepBase/GSVersionMacros.h> 33 34 #import <AppKit/NSView.h> 35 36 @class NSString; 37 @class NSColor; 38 @class NSFont; 39 40 /** Title positioning of an NSBox: 41 * <list> 42 * <item>NSNoTitle</item> 43 * <item>NSAboveTop</item> 44 * <item>NSAtTop</item> 45 * <item>NSBelowTop</item> 46 * <item>NSAboveBottom</item> 47 * <item>NSAtBottom</item> 48 * <item>NSBelowBottom</item> 49 * </list> 50 */ 51 typedef enum _NSTitlePosition { 52 NSNoTitle, 53 NSAboveTop, 54 NSAtTop, 55 NSBelowTop, 56 NSAboveBottom, 57 NSAtBottom, 58 NSBelowBottom 59 } NSTitlePosition; 60 61 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) 62 typedef enum _NSBoxType 63 { 64 NSBoxPrimary=0, 65 NSBoxSecondary, 66 NSBoxSeparator, 67 NSBoxOldStyle 68 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) 69 , NSBoxCustom 70 #endif 71 } NSBoxType; 72 #endif 73 74 @interface NSBox : NSView <NSCoding> 75 { 76 // Attributes 77 id _cell; 78 id _content_view; 79 NSSize _offsets; 80 NSRect _border_rect; 81 NSRect _title_rect; 82 NSBorderType _border_type; 83 NSTitlePosition _title_position; 84 NSBoxType _box_type; 85 // Only used when the type is NSBoxCustom 86 NSColor *_fill_color; 87 NSColor *_border_color; 88 CGFloat _border_width; 89 CGFloat _corner_radius; 90 BOOL _transparent; 91 } 92 93 // 94 // Getting and Modifying the Border and Title 95 // 96 - (NSRect)borderRect; 97 - (NSBorderType)borderType; 98 - (void)setBorderType:(NSBorderType)aType; 99 - (void)setTitle:(NSString *)aString; 100 - (void)setTitleFont:(NSFont *)fontObj; 101 - (void)setTitlePosition:(NSTitlePosition)aPosition; 102 - (NSString *)title; 103 - (id)titleCell; 104 - (NSFont *)titleFont; 105 - (NSTitlePosition)titlePosition; 106 - (NSRect)titleRect; 107 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) 108 - (void)setTitleWithMnemonic:(NSString *)aString; 109 - (NSBoxType)boxType; 110 - (void)setBoxType:(NSBoxType)aType; 111 #endif 112 113 // 114 // Setting and Placing the Content View 115 // 116 - (id)contentView; 117 - (NSSize)contentViewMargins; 118 - (void)setContentView:(NSView *)aView; 119 - (void)setContentViewMargins:(NSSize)offsetSize; 120 121 // 122 // Resizing the Box 123 // 124 - (void)setFrameFromContentFrame:(NSRect)contentFrame; 125 - (void)sizeToFit; 126 127 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE) 128 -(NSSize) minimumSize; 129 #endif 130 131 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) 132 - (NSColor*)fillColor; 133 - (void)setFillColor:(NSColor*)newFillColor; 134 - (NSColor*)borderColor; 135 - (void)setBorderColor:(NSColor*)newBorderColor; 136 - (CGFloat)borderWidth; 137 - (void)setBorderWidth:(CGFloat)borderWidth; 138 - (CGFloat)cornerRadius; 139 - (void)setCornerRadius:(CGFloat)cornerRadius; 140 - (BOOL)isTransparent; 141 - (void)setTransparent:(BOOL)transparent; 142 #endif 143 @end 144 145 #endif // _GNUstep_H_NSBox 146 147