00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 00002 00003 /* AbiSource Program Utilities 00004 * Copyright (C) 2002 Francis James Franklin <fjf@alinameridon.com> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 * 02110-1301 USA. 00020 */ 00021 00022 #ifndef XAP_COCOAWINDOW_H 00023 #define XAP_COCOAWINDOW_H 00024 00025 #import <Cocoa/Cocoa.h> 00026 00027 /* pre-emptive dismissal; ut_types.h is needed by just about everything, 00028 * so even if it's commented out in-file that's still a lot of work for 00029 * the preprocessor to do... 00030 */ 00031 #ifndef UT_TYPES_H 00032 #include "ut_types.h" 00033 #endif 00034 00035 class XAP_CocoaWindow; 00036 00037 @interface XAP_CocoaWindowDelegate 00038 : NSWindowController<NSWindowDelegate> 00039 { 00040 XAP_CocoaWindow * m_window; 00041 } 00042 - (id)initWithWindow:(NSWindow *)window withXAPWindow:(XAP_CocoaWindow *)xap; 00043 - (void)windowDidResize:(NSNotification *)aNotification; 00044 @end 00045 00046 class XAP_CocoaWindow 00047 { 00048 public: 00049 enum WindowStyle 00050 { 00051 ws_Normal = 0, 00052 ws_Raw, // i.e., no decorations; use by toolbar window 00053 ws_Frame, 00054 ws_Panel 00055 }; 00056 enum WindowError 00057 { 00058 we_NoController, 00059 we_NoWindow 00060 }; 00061 00062 protected: 00063 XAP_CocoaWindow (WindowStyle ws, const NSRect & frameRect); 00064 XAP_CocoaWindow (); // special case for document/frame 00065 XAP_CocoaWindow (float height); // special case for toolbar 00066 private: 00067 void _init (WindowStyle ws); 00068 public: 00069 virtual ~XAP_CocoaWindow (); 00070 00071 /* callback notification of main-window resize 00072 */ 00073 virtual void _windowResized (); 00074 00075 protected: 00076 void _show (); // this should be called only from the child's constructor, I think 00077 00078 void _moveto (const NSPoint & position); 00079 00080 void _resize (const NSSize & size); 00081 void _resize (float height); // special case for toolbar 00082 00083 protected: 00084 unsigned int m_styleMask; 00085 00086 NSBackingStoreType m_backingType; 00087 XAP_CocoaWindowDelegate * m_controller; 00088 NSWindow * m_window; 00089 bool m_isToolbar; 00090 NSRect m_frame; 00091 }; 00092 00093 #endif /* ! XAP_COCOAWINDOW_H */