1 /* AbiWord
2  * Copyright (C) 1998 AbiSource, Inc.
3  * Copyright (C) 2001-2003, 2005 Hubert Figuiere
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301 USA.
19  */
20 
21 #import <Cocoa/Cocoa.h>
22 
23 #import "xap_CocoaFrame.h"
24 #import "xap_CocoaFrameImpl.h"
25 
26 
27 class AP_CocooApp;
28 
29 @class XAP_CocoaTextView, XAP_NSScroller;
30 
31 @interface AP_DocViewDelegate : NSObject <XAP_MouseEventDelegate>
32 {
33 }
34 @end
35 
36 @interface AP_CocoaFrameController : XAP_CocoaFrameController
37 {
38     IBOutlet XAP_CocoaNSView *hRuler;
39     IBOutlet XAP_CocoaNSView *vRuler;
40 }
41 + (XAP_CocoaFrameController*)createFrom:(XAP_CocoaFrameImpl *)frame;
42 - (id)initWith:(XAP_CocoaFrameImpl *)frame;
43 - (IBAction)rulerClick:(id)sender;
44 - (XAP_CocoaNSView *)getVRuler;
45 - (XAP_CocoaNSView *)getHRuler;
46 - (IBAction)scrollAction:(id)sender;
47 @end
48 
49 /*****************************************************************/
50 class AP_CocoaFrameImpl : public XAP_CocoaFrameImpl
51 {
52  public:
53 	AP_CocoaFrameImpl(AP_CocoaFrame *pCocoaFrame);
54 	virtual XAP_FrameImpl * createInstance(XAP_Frame *pFrame);
55 
56 	virtual NSString *			_getNibName (); /* must be public to be called from Obj-C */
57 
_getHScrollValue()58 	UT_sint32 _getHScrollValue()	{ return m_HCurrentScroll; };
_getHScrollMin()59 	UT_sint32 _getHScrollMin()	{ return m_HMinScroll; };
_getHScrollMax()60 	UT_sint32 _getHScrollMax()	{ return m_HMaxScroll; };
_getHVisible()61 	UT_sint32 _getHVisible()	{ return m_HVisible; };
62 	void _setHScrollValue(UT_sint32);
63 	void _setHScrollMin(UT_sint32);
64 	void _setHScrollMax(UT_sint32);
65 	void _setHVisible(UT_sint32);
_getVScrollValue()66 	UT_sint32 _getVScrollValue()	{ return m_VCurrentScroll; };
_getVScrollMin()67 	UT_sint32 _getVScrollMin()	{ return m_VMinScroll; };
_getVScrollMax()68 	UT_sint32 _getVScrollMax()	{ return m_VMaxScroll; };
_getVVisible()69 	UT_sint32 _getVVisible()	{ return m_VVisible; };
70 	void _setVScrollValue(UT_sint32);
71 	void _setVScrollMin(UT_sint32);
72 	void _setVScrollMax(UT_sint32);
73 	void _setVVisible(UT_sint32);
74 	void _scrollAction(id sender);
75 
76 	void _showTopRulerNSView(void);
77 	void _hideTopRulerNSView(void);
78 	void _showLeftRulerNSView(void);
79 	void _hideLeftRulerNSView(void);
_getDocAreaGRView(void)80 	XAP_CocoaTextView *_getDocAreaGRView(void)
81 		{ return m_docAreaGRView; }
82  protected:
83 
84 	void _showOrHideStatusbar(void);
85 
86 	void _showOrHideToolbars(void);
87 	virtual void _refillToolbarsInFrameData();
88 	void _bindToolbars(AV_View * pView);
89 
90 	virtual void _createDocumentWindow();
91 	virtual void _createStatusBarWindow(XAP_CocoaNSStatusBar *);
92 
93 	friend class AP_CocoaFrame;
94 	virtual void _setWindowIcon();
95 	/* Cocoa specific stuff */
96 	virtual XAP_CocoaFrameController *_createController();
97 	virtual	void	_createDocView(GR_Graphics* &pG);
98 
_hideMenuScroll(bool)99 	virtual void _hideMenuScroll(bool /*bHideMenuScroll*/) { UT_ASSERT_HARMLESS(UT_NOT_IMPLEMENTED); }
100 
101 	void giveFocus();
102 private:
103 	XAP_NSScroller*					m_hScrollbar;
104 	XAP_NSScroller*					m_vScrollbar;
105 	XAP_CocoaTextView*				m_docAreaGRView;
106 	static bool					_graphicsUpdateCB(NSRect * aRect, GR_CocoaCairoGraphics *pG, void* param);
107 private:
108 	UT_sint32					m_HMinScroll;
109 	UT_sint32					m_HMaxScroll;
110 	UT_sint32					m_HCurrentScroll;
111 	UT_sint32					m_HVisible;
112 	UT_sint32					m_VMinScroll;
113 	UT_sint32					m_VMaxScroll;
114 	UT_sint32					m_VCurrentScroll;
115 	UT_sint32					m_VVisible;
116 	/* called when updating */
117 	void _setHScrollbarValues();
118 	void _setVScrollbarValues();
119 };
120