• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

gr_CocoaCairoGraphics.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiWord
00003  * Copyright (C) 2004-2006 Tomas Frydrych <dr.tomas@yahoo.co.uk>
00004  * Copyright (C) 2009 Hubert Figuiere
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 
00023 #ifndef __GR_COCOACAIROGRAPHICS_H__
00024 #define __GR_COCOACAIROGRAPHICS_H__
00025 
00026 #import <Cocoa/Cocoa.h>
00027 
00028 #include "gr_CairoGraphics.h"
00029 
00030 class GR_PangoFont;
00031 @class XAP_CocoaNSView;
00032 
00033 class ABI_EXPORT GR_CocoaCairoAllocInfo : public GR_CairoAllocInfo
00034 {
00035 public:
00036     explicit GR_CocoaCairoAllocInfo(XAP_CocoaNSView * win, bool double_buffered = false)
00037         : GR_CairoAllocInfo(false, false, double_buffered),
00038         m_win(win)
00039         {}
00040 
00041     explicit GR_CocoaCairoAllocInfo(bool bPreview)
00042         : GR_CairoAllocInfo(bPreview, true, false),
00043           m_win(NULL){}
00044     virtual cairo_t *createCairo();
00045 
00046     XAP_CocoaNSView     * m_win;
00047 };
00048 
00049 class ABI_EXPORT GR_CocoaCairoGraphicsBase
00050     : public GR_CairoGraphics
00051 {
00052  public:
00053     ~GR_CocoaCairoGraphicsBase();
00054 
00055     virtual GR_Image*   createNewImage(const char* pszName,
00056                                        const UT_ConstByteBufPtr & pBB,
00057                                        const std::string & mimeType,
00058                                        UT_sint32 iDisplayWidth,
00059                                        UT_sint32 iDisplayHeight,
00060                                        GR_Image::GRType =GR_Image::GRT_Raster);
00061  protected:
00062     GR_CocoaCairoGraphicsBase();
00063     GR_CocoaCairoGraphicsBase(cairo_t *cr, UT_uint32 iDeviceResolution);
00064 
00065 };
00066 
00067 
00068 class ABI_EXPORT GR_CocoaCairoGraphics
00069     : public GR_CocoaCairoGraphicsBase
00070 {
00071 public:
00072     ~GR_CocoaCairoGraphics();
00073     static UT_uint32       s_getClassId() {return GRID_COCOA_PANGO;}
00074     virtual UT_uint32      getClassId() {return s_getClassId();}
00075 
00076     static const char *    graphicsDescriptor(){return "Cocoa Cairo Pango";}
00077     static GR_Graphics *   graphicsAllocator(GR_AllocInfo&);
00078     XAP_CocoaNSView *  getView () {return m_pWin;}
00079 
00080     virtual GR_Font * getGUIFont(void);
00081 
00082     virtual void        setCursor(GR_Graphics::Cursor c);
00083 
00084         static NSColor                          *_utRGBColorToNSColor (const UT_RGBColor& clr);
00085         static void                             _utNSColorToRGBColor (NSColor *c, UT_RGBColor &clr);
00086 
00087 //  void                createPixmapFromXPM(char ** pXPM,GdkPixmap *source,
00088 //                                          GdkBitmap * mask);
00089     virtual void        scroll(UT_sint32, UT_sint32);
00090     virtual void        scroll(UT_sint32 x_dest, UT_sint32 y_dest,
00091                            UT_sint32 x_src, UT_sint32 y_src,
00092                            UT_sint32 width, UT_sint32 height);
00093     virtual void        saveRectangle(UT_Rect & r, UT_uint32 iIndx);
00094     virtual void        restoreRectangle(UT_uint32 iIndx);
00095     virtual GR_Image *  genImageFromRectangle(const UT_Rect & r);
00096 
00097     virtual void _beginPaint ();
00098     virtual void _endPaint ();
00099 
00100     virtual bool        queryProperties(GR_Graphics::Properties gp) const;
00101     virtual bool        startPrint(void);
00102     virtual bool        endPrint(void);
00103     virtual bool        startPage(const char * szPageLabel,
00104                                   UT_uint32 pageNumber,
00105                                   bool bPortrait,
00106                                   UT_uint32 iWidth, UT_uint32 iHeight);
00107 
00108 // Cocoa specific
00109     static cairo_t *    _createCairo(NSView * view);
00110     void            init3dColors();
00111     void setIsPrinting(bool);
00112     void            setGrabCursor(GR_Graphics::Cursor c) { m_GrabCursor = c; }
00113 
00114     // at least one instance of GR_CocoaGraphics must have been created...
00115     static const UT_RGBColor &      HBlue()
00116         {
00117             return *m_colorBlue16x15;
00118         }
00119     static const UT_RGBColor &      VBlue()
00120         {
00121             return *m_colorBlue11x16;
00122         }
00123     static const UT_RGBColor &      HGrey()
00124         {
00125             return *m_colorGrey16x15;
00126         }
00127     static const UT_RGBColor &      VGrey()
00128         {
00129             return *m_colorGrey11x16;
00130         }
00131 
00132     static bool _isFlipped();
00133     typedef bool (*gr_cocoa_graphics_update) (NSRect * rect, GR_CocoaCairoGraphics *pGr, void * param);
00134     void                _setUpdateCallback (gr_cocoa_graphics_update callback, void * param);
00135     bool                _callUpdateCallback(NSRect *aRect);
00136     static  float       _getScreenResolution(void);
00137 protected:
00138     GR_CocoaCairoGraphics(XAP_CocoaNSView * win = nil, bool double_buffered = false);
00139 
00140     virtual UT_uint32   _getResolution(void) const;
00141 
00142 private:
00143     static UT_uint32                s_iInstanceCount;
00144     XAP_CocoaNSView *               m_pWin;
00145     gr_cocoa_graphics_update    m_updateCallback;
00146     void                *m_updateCBparam;
00147     std::vector<cairo_rectangle_t>  m_cacheRectArray;
00148     std::vector<cairo_surface_t*>       m_cacheArray;
00149     GR_Graphics::Cursor     m_GrabCursor;
00150     UT_uint32           m_screenResolution;
00151     bool                m_bIsPrinting;
00152     bool                m_bIsDrawing;
00153     bool                m_bDoShowPage;
00154     static void _initColorAndImage(void);
00155     static bool         m_colorAndImageInited;
00156     static UT_RGBColor *    m_colorBlue16x15;
00157     static UT_RGBColor *    m_colorBlue11x16;
00158     static UT_RGBColor *    m_colorGrey16x15;
00159     static UT_RGBColor *    m_colorGrey11x16;
00160 
00161     static NSCursor *   m_Cursor_E;
00162     static NSCursor *   m_Cursor_N;
00163     static NSCursor *   m_Cursor_NE;
00164     static NSCursor *   m_Cursor_NW;
00165     static NSCursor *   m_Cursor_S;
00166     static NSCursor *   m_Cursor_SE;
00167     static NSCursor *   m_Cursor_SW;
00168     static NSCursor *   m_Cursor_W;
00169 
00170     static NSCursor *   m_Cursor_Wait;
00171     static NSCursor *   m_Cursor_LeftArrow;
00172     static NSCursor *   m_Cursor_RightArrow;
00173     static NSCursor *   m_Cursor_Compass;
00174     static NSCursor *   m_Cursor_Exchange;
00175     static NSCursor *   m_Cursor_LeftRight;
00176     static NSCursor *   m_Cursor_UpDown;
00177     static NSCursor *   m_Cursor_Crosshair;
00178     static NSCursor *   m_Cursor_HandPointer;
00179     static NSCursor *   m_Cursor_DownArrow;
00180 };
00181 
00182 
00183 #endif
00184 

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1