diff options
author | Tor Lillqvist <tml@iki.fi> | 2012-03-04 23:24:22 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2012-03-05 02:05:22 +0200 |
commit | 87618ea84b5b8e2cb0524311315abbcb1c7755be (patch) | |
tree | 4d33c72ddb4298876426210c2a7a15e5b2540fc3 /vcl | |
parent | Make the iOS device (ARM) stuff at least link, surely does not work yet (diff) | |
download | core-87618ea84b5b8e2cb0524311315abbcb1c7755be.tar.gz core-87618ea84b5b8e2cb0524311315abbcb1c7755be.zip |
Brutal dummy hacks based on "aqua" code just to get iOS stuff to link
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Library_vcl.mk | 5 | ||||
-rw-r--r-- | vcl/inc/ios/salcoretextfontutils.hxx | 62 | ||||
-rw-r--r-- | vcl/inc/ios/salframeview.h | 72 | ||||
-rw-r--r-- | vcl/ios/source/gdi/salcoretextfontutils.cxx | 270 | ||||
-rw-r--r-- | vcl/ios/source/gdi/salcoretextlayout.cxx | 297 | ||||
-rw-r--r-- | vcl/ios/source/gdi/salgdiutils.cxx | 307 | ||||
-rw-r--r-- | vcl/ios/source/gdi/salnativewidgets.cxx | 242 | ||||
-rw-r--r-- | vcl/ios/source/window/salframeview.mm | 268 |
8 files changed, 1451 insertions, 72 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 843dcebb5e0a..3e4aa8a604b7 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -517,6 +517,7 @@ $(eval $(call gb_Library_add_cxxflags,vcl,\ $(eval $(call gb_Library_add_objcxxobjects,vcl,\ vcl/ios/source/app/salnstimer \ vcl/ios/source/app/vcluiapp \ + vcl/ios/source/window/salframeview \ )) $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/ios/source/app/saldata \ @@ -526,8 +527,12 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/ios/source/dtrans/iOSTransferable \ vcl/ios/source/dtrans/ios_clipboard \ vcl/ios/source/dtrans/service_entry \ + vcl/ios/source/gdi/salcoretextfontutils \ + vcl/ios/source/gdi/salcoretextlayout \ vcl/ios/source/gdi/salbmp \ vcl/ios/source/gdi/salgdi \ + vcl/ios/source/gdi/salnativewidgets \ + vcl/ios/source/gdi/salgdiutils \ vcl/ios/source/gdi/salvd \ vcl/ios/source/window/salframe \ vcl/ios/source/window/salmenu \ diff --git a/vcl/inc/ios/salcoretextfontutils.hxx b/vcl/inc/ios/salcoretextfontutils.hxx new file mode 100644 index 000000000000..ed94b91ecfe5 --- /dev/null +++ b/vcl/inc/ios/salcoretextfontutils.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALCORETEXTFONTUTILS_HXX +#define _SV_SALCORETEXTFONTUTILS_HXX + +class ImplIosFontData; +class ImplDevFontList; + +#include <premac.h> +#include <CoreText/CoreText.h> +#include <postmac.h> + +#include <map> + +/* This class has the responsibility of assembling a list of CoreText + fonts available on the system and enabling access to that list. + */ +class SystemFontList +{ +public: + SystemFontList(); + ~SystemFontList(); + + void AnnounceFonts( ImplDevFontList& ) const; + ImplIosFontData* GetFontDataFromRef( CTFontRef ) const; + +private: + typedef boost::unordered_map<CTFontRef,ImplIosFontData*> IosFontContainer; + IosFontContainer maFontContainer; + + void InitGlyphFallbacks(); +}; + +#endif // _SV_SALCORETEXTFONTUTILS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/ios/salframeview.h b/vcl/inc/ios/salframeview.h index e631209c7b7f..692598902ad4 100644 --- a/vcl/inc/ios/salframeview.h +++ b/vcl/inc/ios/salframeview.h @@ -64,79 +64,7 @@ -(BOOL)acceptsFirstResponder; -(BOOL)isOpaque; -(void)drawRect: (CGRect)aRect; --(void)magnifyWithEvent: (UIEvent*)pEvent; --(void)rotateWithEvent: (UIEvent*)pEvent; --(void)swipeWithEvent: (UIEvent*)pEvent; --(void)keyDown: (UIEvent*)pEvent; -(void)flagsChanged: (UIEvent*)pEvent; --(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar; --(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod; --(BOOL)sendKeyToFrameDirect: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod; --(BOOL)sendSingleCharacter:(UIEvent*)pEvent; --(BOOL)handleKeyDownException:(UIEvent*)pEvent; --(void)clearLastEvent; -/* - text action methods -*/ --(void)insertText:(id)aString; --(void)insertTab: (id)aSender; --(void)insertBacktab: (id)aSender; --(void)moveLeft: (id)aSender; --(void)moveLeftAndModifySelection: (id)aSender; --(void)moveBackwardAndModifySelection: (id)aSender; --(void)moveRight: (id)aSender; --(void)moveRightAndModifySelection: (id)aSender; --(void)moveForwardAndModifySelection: (id)aSender; --(void)moveUp: (id)aSender; --(void)moveDown: (id)aSender; --(void)moveWordBackward: (id)aSender; --(void)moveWordBackwardAndModifySelection: (id)aSender; --(void)moveWordLeftAndModifySelection: (id)aSender; --(void)moveWordForward: (id)aSender; --(void)moveWordForwardAndModifySelection: (id)aSender; --(void)moveWordRightAndModifySelection: (id)aSender; --(void)moveToEndOfLine: (id)aSender; --(void)moveToRightEndOfLine: (id)aSender; --(void)moveToLeftEndOfLine: (id)aSender; --(void)moveToEndOfLineAndModifySelection: (id)aSender; --(void)moveToRightEndOfLineAndModifySelection: (id)aSender; --(void)moveToLeftEndOfLineAndModifySelection: (id)aSender; --(void)moveToBeginningOfLine: (id)aSender; --(void)moveToBeginningOfLineAndModifySelection: (id)aSender; --(void)moveToEndOfParagraph: (id)aSender; --(void)moveToEndOfParagraphAndModifySelection: (id)aSender; --(void)moveToBeginningOfParagraph: (id)aSender; --(void)moveToBeginningOfParagraphAndModifySelection: (id)aSender; --(void)moveParagraphForward: (id)aSender; --(void)moveParagraphForwardAndModifySelection: (id)aSender; --(void)moveParagraphBackward: (id)aSender; --(void)moveParagraphBackwardAndModifySelection: (id)aSender; --(void)moveToEndOfDocument: (id)aSender; --(void)scrollToEndOfDocument: (id)aSender; --(void)moveToEndOfDocumentAndModifySelection: (id)aSender; --(void)moveToBeginningOfDocument: (id)aSender; --(void)scrollToBeginningOfDocument: (id)aSender; --(void)moveToBeginningOfDocumentAndModifySelection: (id)aSender; --(void)insertNewline: (id)aSender; --(void)deleteBackward: (id)aSender; --(void)deleteForward: (id)aSender; --(void)cancelOperation: (id)aSender; --(void)deleteBackwardByDecomposingPreviousCharacter: (id)aSender; --(void)deleteWordBackward: (id)aSender; --(void)deleteWordForward: (id)aSender; --(void)deleteToBeginningOfLine: (id)aSender; --(void)deleteToEndOfLine: (id)aSender; --(void)deleteToBeginningOfParagraph: (id)aSender; --(void)deleteToEndOfParagraph: (id)aSender; --(void)insertLineBreak: (id)aSender; --(void)insertParagraphSeparator: (id)aSender; --(void)selectWord: (id)aSender; --(void)selectLine: (id)aSender; --(void)selectParagraph: (id)aSender; --(void)selectAll: (id)aSender; --(void)noop: (id)aSender; --(id)parentAttribute; --(UIView *)viewElementForParent; @end #endif diff --git a/vcl/ios/source/gdi/salcoretextfontutils.cxx b/vcl/ios/source/gdi/salcoretextfontutils.cxx new file mode 100644 index 000000000000..b67e9548de25 --- /dev/null +++ b/vcl/ios/source/gdi/salcoretextfontutils.cxx @@ -0,0 +1,270 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <boost/assert.hpp> +#include <vector> +#include <set> + +#include "vcl/svapp.hxx" + +#include "ios/salgdi.h" +#include "ios/saldata.hxx" +#include "ios/salcoretextfontutils.hxx" + +// we have to get the font attributes from the name table +// since neither head's macStyle nor OS/2's panose are easily available +// during font enumeration. macStyle bits would be not sufficient anyway +// and SFNT fonts on Mac usually do not contain an OS/2 table. +static void UpdateAttributesFromPSName( const String& rPSName, ImplDevFontAttributes& rDFA ) +{ + rtl::OString aPSName( rtl::OUStringToOString( rPSName, RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase() ); + + // TODO: use a multi-string ignore-case matcher once it becomes available + if( (aPSName.indexOf("regular") != -1) + || (aPSName.indexOf("normal") != -1) + || (aPSName.indexOf("roman") != -1) + || (aPSName.indexOf("medium") != -1) + || (aPSName.indexOf("plain") != -1) + || (aPSName.indexOf("standard") != -1) + || (aPSName.indexOf("std") != -1) ) + { + rDFA.meWidthType = WIDTH_NORMAL; + rDFA.meWeight = WEIGHT_NORMAL; + rDFA.meItalic = ITALIC_NONE; + } + + // heuristics for font weight + if (aPSName.indexOf("extrablack") != -1) + rDFA.meWeight = WEIGHT_BLACK; + else if (aPSName.indexOf("black") != -1) + rDFA.meWeight = WEIGHT_BLACK; + //else if (aPSName.indexOf("book") != -1) + // rDFA.meWeight = WEIGHT_SEMIBOLD; + else if( (aPSName.indexOf("semibold") != -1) + || (aPSName.indexOf("smbd") != -1)) + rDFA.meWeight = WEIGHT_SEMIBOLD; + else if (aPSName.indexOf("ultrabold") != -1) + rDFA.meWeight = WEIGHT_ULTRABOLD; + else if (aPSName.indexOf("extrabold") != -1) + rDFA.meWeight = WEIGHT_BLACK; + else if( (aPSName.indexOf("bold") != -1) + || (aPSName.indexOf("-bd") != -1)) + rDFA.meWeight = WEIGHT_BOLD; + else if (aPSName.indexOf("extralight") != -1) + rDFA.meWeight = WEIGHT_ULTRALIGHT; + else if (aPSName.indexOf("ultralight") != -1) + rDFA.meWeight = WEIGHT_ULTRALIGHT; + else if (aPSName.indexOf("light") != -1) + rDFA.meWeight = WEIGHT_LIGHT; + else if (aPSName.indexOf("thin") != -1) + rDFA.meWeight = WEIGHT_THIN; + else if (aPSName.indexOf("-w3") != -1) + rDFA.meWeight = WEIGHT_LIGHT; + else if (aPSName.indexOf("-w4") != -1) + rDFA.meWeight = WEIGHT_SEMILIGHT; + else if (aPSName.indexOf("-w5") != -1) + rDFA.meWeight = WEIGHT_NORMAL; + else if (aPSName.indexOf("-w6") != -1) + rDFA.meWeight = WEIGHT_SEMIBOLD; + else if (aPSName.indexOf("-w7") != -1) + rDFA.meWeight = WEIGHT_BOLD; + else if (aPSName.indexOf("-w8") != -1) + rDFA.meWeight = WEIGHT_ULTRABOLD; + else if (aPSName.indexOf("-w9") != -1) + rDFA.meWeight = WEIGHT_BLACK; + + // heuristics for font slant + if( (aPSName.indexOf("italic") != -1) + || (aPSName.indexOf(" ital") != -1) + || (aPSName.indexOf("cursive") != -1) + || (aPSName.indexOf("-it") != -1) + || (aPSName.indexOf("lightit") != -1) + || (aPSName.indexOf("mediumit") != -1) + || (aPSName.indexOf("boldit") != -1) + || (aPSName.indexOf("cnit") != -1) + || (aPSName.indexOf("bdcn") != -1) + || (aPSName.indexOf("bdit") != -1) + || (aPSName.indexOf("condit") != -1) + || (aPSName.indexOf("bookit") != -1) + || (aPSName.indexOf("blackit") != -1) ) + rDFA.meItalic = ITALIC_NORMAL; + if( (aPSName.indexOf("oblique") != -1) + || (aPSName.indexOf("inclined") != -1) + || (aPSName.indexOf("slanted") != -1) ) + rDFA.meItalic = ITALIC_OBLIQUE; + + // heuristics for font width + if( (aPSName.indexOf("condensed") != -1) + || (aPSName.indexOf("-cond") != -1) + || (aPSName.indexOf("boldcond") != -1) + || (aPSName.indexOf("boldcn") != -1) + || (aPSName.indexOf("cnit") != -1) ) + rDFA.meWidthType = WIDTH_CONDENSED; + else if (aPSName.indexOf("narrow") != -1) + rDFA.meWidthType = WIDTH_SEMI_CONDENSED; + else if (aPSName.indexOf("expanded") != -1) + rDFA.meWidthType = WIDTH_EXPANDED; + else if (aPSName.indexOf("wide") != -1) + rDFA.meWidthType = WIDTH_EXPANDED; + + // heuristics for font pitch + if( (aPSName.indexOf("mono") != -1) + || (aPSName.indexOf("courier") != -1) + || (aPSName.indexOf("monaco") != -1) + || (aPSName.indexOf("typewriter") != -1) ) + rDFA.mePitch = PITCH_FIXED; + + // heuristics for font family type + if( (aPSName.indexOf("script") != -1) + || (aPSName.indexOf("chancery") != -1) + || (aPSName.indexOf("zapfino") != -1)) + rDFA.meFamily = FAMILY_SCRIPT; + else if( (aPSName.indexOf("comic") != -1) + || (aPSName.indexOf("outline") != -1) + || (aPSName.indexOf("pinpoint") != -1) ) + rDFA.meFamily = FAMILY_DECORATIVE; + else if( (aPSName.indexOf("sans") != -1) + || (aPSName.indexOf("arial") != -1) ) + rDFA.meFamily = FAMILY_SWISS; + else if( (aPSName.indexOf("roman") != -1) + || (aPSName.indexOf("times") != -1) ) + rDFA.meFamily = FAMILY_ROMAN; + + // heuristics for codepoint semantic + if( (aPSName.indexOf("symbol") != -1) + || (aPSName.indexOf("dings") != -1) + || (aPSName.indexOf("dingbats") != -1) + || (aPSName.indexOf("ornaments") != -1) + || (aPSName.indexOf("embellishments") != -1) ) + rDFA.mbSymbolFlag = true; + + // #i100020# special heuristic for names with single-char styles + // NOTE: we are checking name that hasn't been lower-cased + if( rPSName.Len() > 3 ) + { + int i = rPSName.Len(); + sal_Unicode c = rPSName.GetChar( --i ); + if( c == 'C' ) { // "capitals" + rDFA.meFamily = FAMILY_DECORATIVE; + c = rPSName.GetChar( --i ); + } + if( c == 'O' ) { // CFF-based OpenType + c = rPSName.GetChar( --i ); + } + if( c == 'I' ) { // "italic" + rDFA.meItalic = ITALIC_NORMAL; + c = rPSName.GetChar( --i ); + } + if( c == 'B' ) // "bold" + rDFA.meWeight = WEIGHT_BOLD; + if( c == 'C' ) // "capitals" + rDFA.meFamily = FAMILY_DECORATIVE; + // TODO: check that all single-char styles have been resolved? + } +} + +static bool GetDevFontAttributes( CTFontRef nFontRef, ImplDevFontAttributes& rDFA ) +{ + // all CT fonts are device fonts that can be directly rotated + rDFA.mbOrientation = true; + rDFA.mbDevice = true; + rDFA.mnQuality = 0; + + // reset the attributes + rDFA.meFamily = FAMILY_DONTKNOW; + rDFA.mePitch = PITCH_VARIABLE; + rDFA.meWidthType = WIDTH_NORMAL; + rDFA.meWeight = WEIGHT_NORMAL; + rDFA.meItalic = ITALIC_NONE; + rDFA.mbSymbolFlag = false; + + // Implement... + + return false; +} + +// ======================================================================= + +SystemFontList::SystemFontList() +{ +} + +SystemFontList::~SystemFontList() +{ +} + +void SystemFontList::AnnounceFonts( ImplDevFontList& rFontList ) const +{ +} + +// not all fonts are suitable for glyph fallback => sort them +struct GfbCompare{ bool operator()(const ImplIosFontData*, const ImplIosFontData*); }; + +inline bool GfbCompare::operator()( const ImplIosFontData* pA, const ImplIosFontData* pB ) +{ + // use symbol fonts only as last resort + bool bPreferA = !pA->IsSymbolFont(); + bool bPreferB = !pB->IsSymbolFont(); + if( bPreferA != bPreferB ) + return bPreferA; + // prefer scalable fonts + bPreferA = pA->IsScalable(); + bPreferB = pB->IsScalable(); + if( bPreferA != bPreferB ) + return bPreferA; + // prefer non-slanted fonts + bPreferA = (pA->GetSlant() == ITALIC_NONE); + bPreferB = (pB->GetSlant() == ITALIC_NONE); + if( bPreferA != bPreferB ) + return bPreferA; + // prefer normal weight fonts + bPreferA = (pA->GetWeight() == WEIGHT_NORMAL); + bPreferB = (pB->GetWeight() == WEIGHT_NORMAL); + if( bPreferA != bPreferB ) + return bPreferA; + // prefer normal width fonts + bPreferA = (pA->GetWidthType() == WIDTH_NORMAL); + bPreferB = (pB->GetWidthType() == WIDTH_NORMAL); + if( bPreferA != bPreferB ) + return bPreferA; + return false; +} + +void SystemFontList::InitGlyphFallbacks() +{ +} + +ImplIosFontData* SystemFontList::GetFontDataFromRef( CTFontRef nFontRef ) const +{ + IosFontContainer::const_iterator it = maFontContainer.find( nFontRef ); + if( it == maFontContainer.end() ) + return NULL; + return (*it).second; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/gdi/salcoretextlayout.cxx b/vcl/ios/source/gdi/salcoretextlayout.cxx new file mode 100644 index 000000000000..461bb9c4645f --- /dev/null +++ b/vcl/ios/source/gdi/salcoretextlayout.cxx @@ -0,0 +1,297 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "tools/debug.hxx" + +#include "ios/saldata.hxx" +#include "ios/salgdi.h" +#include "ios/salcoretextfontutils.hxx" + +#include "sallayout.hxx" +#include "salgdi.hxx" + +#include <math.h> + +class CoreTextLayout : public SalLayout +{ +public: + CoreTextLayout( CTFontSymbolicTraits&, float fFontScale ); + virtual ~CoreTextLayout(); + + virtual bool LayoutText( ImplLayoutArgs& ); + virtual void AdjustLayout( ImplLayoutArgs& ); + virtual void DrawText( SalGraphics& ) const; + + virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&, + sal_Int32* pGlyphAdvances, int* pCharIndexes ) const; + + virtual long GetTextWidth() const; + virtual long FillDXArray( long* pDXArray ) const; + virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const; + virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const; + virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const; + virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const; + + const ImplFontData* GetFallbackFontData( sal_GlyphId ) const; + + virtual void InitFont() const; + virtual void MoveGlyph( int nStart, long nNewXPos ); + virtual void DropGlyph( int nStart ); + virtual void Simplify( bool bIsBase ); + +private: + // ??? + float mfFontScale; + +private: + bool InitGIA( ImplLayoutArgs* pArgs = NULL ) const; + bool GetIdealX() const; + bool GetDeltaY() const; + void InvalidateMeasurements(); + + // cached details about the resulting layout + // mutable members since these details are all lazy initialized + mutable int mnGlyphCount; // glyph count + mutable Fixed mnCachedWidth; // cached value of resulting typographical width + int mnTrailingSpaceWidth; // in Pixels + + mutable CGGlyph* mpGlyphIds; + mutable Fixed* mpCharWidths; // map relative charpos to charwidth + mutable int* mpChars2Glyphs; // map relative charpos to absolute glyphpos + mutable int* mpGlyphs2Chars; // map absolute glyphpos to absolute charpos + mutable bool* mpGlyphRTLFlags; // BiDi status for glyphs: true if RTL + mutable Fixed* mpGlyphAdvances; // contains glyph widths for the justified layout + mutable Fixed* mpGlyphOrigAdvs; // contains glyph widths for the unjustified layout + mutable Fixed* mpDeltaY; // vertical offset from the baseline + + struct SubPortion { int mnMinCharPos, mnEndCharPos; Fixed mnXOffset; }; + typedef std::vector<SubPortion> SubPortionVector; + mutable SubPortionVector maSubPortions; + + // storing details about fonts used in glyph-fallback for this layout + mutable class FallbackInfo* mpFallbackInfo; + + // x-offset relative to layout origin + // currently only used in RTL-layouts + mutable Fixed mnBaseAdv; +}; + +class FallbackInfo +{ +public: + FallbackInfo() : mnMaxLevel(0) {} + int AddFallback( CTFontRef ); + const ImplFontData* GetFallbackFontData( int nLevel ) const; + +private: + const ImplIosFontData* maFontData[ MAX_FALLBACK ]; + CTFontRef maCTFontRef[ MAX_FALLBACK ]; + int mnMaxLevel; +}; + +CoreTextLayout::CoreTextLayout( CTFontSymbolicTraits& rCoreTextStyle, float fFontScale ) +: + mfFontScale( fFontScale ), + mnGlyphCount( -1 ), + mnCachedWidth( 0 ), + mnTrailingSpaceWidth( 0 ), + mpGlyphIds( NULL ), + mpCharWidths( NULL ), + mpChars2Glyphs( NULL ), + mpGlyphs2Chars( NULL ), + mpGlyphRTLFlags( NULL ), + mpGlyphAdvances( NULL ), + mpGlyphOrigAdvs( NULL ), + mpDeltaY( NULL ), + mpFallbackInfo( NULL ), + mnBaseAdv( 0 ) +{} + +// ----------------------------------------------------------------------- + +CoreTextLayout::~CoreTextLayout() +{ + delete[] mpGlyphRTLFlags; + delete[] mpGlyphs2Chars; + delete[] mpChars2Glyphs; + if( mpCharWidths != mpGlyphAdvances ) + delete[] mpCharWidths; + delete[] mpGlyphIds; + delete[] mpGlyphOrigAdvs; + delete[] mpGlyphAdvances; + + delete mpFallbackInfo; +} + +bool CoreTextLayout::LayoutText( ImplLayoutArgs& rArgs ) +{ + // Implement... + return true; +} + +void CoreTextLayout::AdjustLayout( ImplLayoutArgs& rArgs ) +{ + // Implement... +} + +void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const +{ + // Implement... +} + +int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& nStart, + sal_Int32* pGlyphAdvances, int* pCharIndexes ) const +{ + if( nStart < 0 ) // first glyph requested? + nStart = 0; + + // Implement... + + return 0; +} + +long CoreTextLayout::GetTextWidth() const +{ + // Implement... + + return 0; +} + +long CoreTextLayout::FillDXArray( long* pDXArray ) const +{ + // short circuit requests which don't need full details + if( !pDXArray ) + return GetTextWidth(); + + // Implement... + + return 0; +} + +int CoreTextLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const +{ + return 0; +} + +void CoreTextLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) const +{ +} + +bool CoreTextLayout::GetBoundRect( SalGraphics&, Rectangle& rVCLRect ) const +{ + return true; +} + +bool CoreTextLayout::InitGIA( ImplLayoutArgs* pArgs ) const +{ + // no need to run InitGIA more than once on the same CoreTextLayout object + if( mnGlyphCount >= 0 ) + return true; + mnGlyphCount = 0; + + // Implement... + + return true; +} + +// ----------------------------------------------------------------------- + +bool CoreTextLayout::GetIdealX() const +{ + // compute the ideal advance widths only once + if( mpGlyphOrigAdvs != NULL ) + return true; + + // Implement... + + return true; +} + +// ----------------------------------------------------------------------- + +bool CoreTextLayout::GetDeltaY() const +{ + return true; +} + +// ----------------------------------------------------------------------- + +#define DELETEAZ( X ) { delete[] X; X = NULL; } + +void CoreTextLayout::InvalidateMeasurements() +{ + mnGlyphCount = -1; + DELETEAZ( mpGlyphIds ); + DELETEAZ( mpCharWidths ); + DELETEAZ( mpChars2Glyphs ); + DELETEAZ( mpGlyphs2Chars ); + DELETEAZ( mpGlyphRTLFlags ); + DELETEAZ( mpGlyphAdvances ); + DELETEAZ( mpGlyphOrigAdvs ); + DELETEAZ( mpDeltaY ); +} + +// glyph fallback is supported directly by Ios +// so methods used only by MultiSalLayout can be dummy implementated +bool CoreTextLayout::GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const { return false; } +void CoreTextLayout::InitFont() const {} +void CoreTextLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {} +void CoreTextLayout::DropGlyph( int /*nStart*/ ) {} +void CoreTextLayout::Simplify( bool /*bIsBase*/ ) {} + +// get the ImplFontData for a glyph fallback font +// for a glyphid that was returned by CoreTextLayout::GetNextGlyphs() +const ImplFontData* CoreTextLayout::GetFallbackFontData( sal_GlyphId nGlyphId ) const +{ + // check if any fallback fonts were needed + if( !mpFallbackInfo ) + return NULL; + // check if the current glyph needs a fallback font + int nFallbackLevel = (nGlyphId & GF_FONTMASK) >> GF_FONTSHIFT; + if( !nFallbackLevel ) + return NULL; + return mpFallbackInfo->GetFallbackFontData( nFallbackLevel ); +} + +int FallbackInfo::AddFallback( CTFontRef nFontId ) +{ + return 0; +} + +const ImplFontData* FallbackInfo::GetFallbackFontData( int nFallbackLevel ) const +{ + const ImplIosFontData* pFallbackFont = maFontData[ nFallbackLevel-1 ]; + return pFallbackFont; +} + +SalLayout* IosSalGraphics::GetTextLayout( ImplLayoutArgs&, int /*nFallbackLevel*/ ) +{ + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/gdi/salgdiutils.cxx b/vcl/ios/source/gdi/salgdiutils.cxx new file mode 100644 index 000000000000..e496493f9260 --- /dev/null +++ b/vcl/ios/source/gdi/salgdiutils.cxx @@ -0,0 +1,307 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include <boost/bind.hpp> + +#include "basebmp/scanlineformats.hxx" +#include "basebmp/color.hxx" + +#include "basegfx/range/b2drectangle.hxx" +#include "basegfx/range/b2irange.hxx" +#include "basegfx/vector/b2ivector.hxx" +#include "basegfx/polygon/b2dpolygon.hxx" +#include "basegfx/polygon/b2dpolygontools.hxx" + +#include "vcl/svapp.hxx" + +#include "ios/salgdi.h" +#include "ios/salframe.h" +#include "ios/saldata.hxx" + +// ---------------------------------------------------------------------- + +void IosSalGraphics::SetWindowGraphics( IosSalFrame* pFrame ) +{ + mpFrame = pFrame; + + mbWindow = true; + mbPrinter = false; + mbVirDev = false; +} + +void IosSalGraphics::SetPrinterGraphics( CGContextRef xContext, long nDPIX, long nDPIY, double fScale ) +{ + mbWindow = false; + mbPrinter = true; + mbVirDev = false; + + mrContext = xContext; + mfFakeDPIScale = fScale; + mnRealDPIX = nDPIX; + mnRealDPIY = nDPIY; + + // a previously set clip path is now invalid + if( mxClipPath ) + { + CGPathRelease( mxClipPath ); + mxClipPath = NULL; + } + + if( mrContext ) + { + CGContextSetFillColorSpace( mrContext, GetSalData()->mxRGBSpace ); + CGContextSetStrokeColorSpace( mrContext, GetSalData()->mxRGBSpace ); + CGContextSaveGState( mrContext ); + SetState(); + } +} + +void IosSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext, + int nBitmapDepth ) +{ + mbWindow = false; + mbPrinter = false; + mbVirDev = true; + + // set graphics properties + mxLayer = xLayer; + mrContext = xContext; + mnBitmapDepth = nBitmapDepth; + + // return early if the virdev is being destroyed + if( !xContext ) + return; + + // get new graphics properties + if( !mxLayer ) + { + mnWidth = CGBitmapContextGetWidth( mrContext ); + mnHeight = CGBitmapContextGetHeight( mrContext ); + } + else + { + const CGSize aSize = CGLayerGetSize( mxLayer ); + mnWidth = static_cast<int>(aSize.width); + mnHeight = static_cast<int>(aSize.height); + } + + // prepare graphics for drawing + const CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace; + CGContextSetFillColorSpace( mrContext, aCGColorSpace ); + CGContextSetStrokeColorSpace( mrContext, aCGColorSpace ); + + // re-enable XorEmulation for the new context + if( mpXorEmulation ) + { + mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer ); + if( mpXorEmulation->IsEnabled() ) + mrContext = mpXorEmulation->GetMaskContext(); + } + + // initialize stack of CGContext states + CGContextSaveGState( mrContext ); + SetState(); +} + +// ---------------------------------------------------------------------- + +void IosSalGraphics::InvalidateContext() +{ + UnsetState(); + mrContext = 0; +} + +// ---------------------------------------------------------------------- + +void IosSalGraphics::UnsetState() +{ + if( mrContext ) + { + CGContextRestoreGState( mrContext ); + mrContext = 0; + } + if( mxClipPath ) + { + CGPathRelease( mxClipPath ); + mxClipPath = NULL; + } +} + +void IosSalGraphics::SetState() +{ + CGContextRestoreGState( mrContext ); + CGContextSaveGState( mrContext ); + + // setup clipping + if( mxClipPath ) + { + CGContextBeginPath( mrContext ); // discard any existing path + CGContextAddPath( mrContext, mxClipPath ); // set the current path to the clipping path + CGContextClip( mrContext ); // use it for clipping + } + + // set RGB colorspace and line and fill colors + CGContextSetFillColor( mrContext, maFillColor.AsArray() ); + CGContextSetStrokeColor( mrContext, maLineColor.AsArray() ); + CGContextSetShouldAntialias( mrContext, false ); + if( mnXorMode == 2 ) + CGContextSetBlendMode( mrContext, kCGBlendModeDifference ); +} + +// ---------------------------------------------------------------------- + +bool IosSalGraphics::CheckContext() +{ + if( mbWindow && mpFrame != NULL ) + { + const unsigned int nWidth = mpFrame->maGeometry.nWidth; + const unsigned int nHeight = mpFrame->maGeometry.nHeight; + + CGContextRef rReleaseContext = 0; + CGLayerRef rReleaseLayer = NULL; + + // check if a new drawing context is needed (e.g. after a resize) + if( (unsigned(mnWidth) != nWidth) || (unsigned(mnHeight) != nHeight) ) + { + mnWidth = nWidth; + mnHeight = nHeight; + // prepare to release the corresponding resources + rReleaseContext = mrContext; + rReleaseLayer = mxLayer; + mrContext = NULL; + mxLayer = NULL; + } + + if( !mrContext ) + { +#if 0 // No idea + const CGSize aLayerSize = {nWidth,nHeight}; + UIGraphicsContext* puiGContext = [UIGraphicsContext graphicsContextWithWindow: mpFrame->getWindow()]; + CGContextRef xCGContext = reinterpret_cast<CGContextRef>([pUIGContext graphicsPort]); + mxLayer = CGLayerCreateWithContext( xCGContext, aLayerSize, NULL ); + if( mxLayer ) + mrContext = CGLayerGetContext( mxLayer ); +#endif + if( mrContext ) + { + // copy original layer to resized layer + if( rReleaseLayer ) + CGContextDrawLayerAtPoint( mrContext, CGPointZero, rReleaseLayer ); + + CGContextTranslateCTM( mrContext, 0, nHeight ); + CGContextScaleCTM( mrContext, 1.0, -1.0 ); + CGContextSetFillColorSpace( mrContext, GetSalData()->mxRGBSpace ); + CGContextSetStrokeColorSpace( mrContext, GetSalData()->mxRGBSpace ); + CGContextSaveGState( mrContext ); + SetState(); + + // re-enable XOR emulation for the new context + if( mpXorEmulation ) + mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer ); + } + } + + if( rReleaseLayer ) + CGLayerRelease( rReleaseLayer ); + else if( rReleaseContext ) + CGContextRelease( rReleaseContext ); + } + + DBG_ASSERT( mrContext || mbPrinter, "<<<WARNING>>> IosSalGraphics::CheckContext() FAILED!!!!\n" ); + return (mrContext != NULL); +} + + +void IosSalGraphics::RefreshRect(float lX, float lY, float lWidth, float lHeight) +{ + if( ! mbWindow ) // view only on Window graphics + return; + + if( mpFrame ) + { + // update a little more around the designated rectangle + // this helps with antialiased rendering + const Rectangle aVclRect(Point(static_cast<long int>(lX-1), + static_cast<long int>(lY-1) ), + Size( static_cast<long int>(lWidth+2), + static_cast<long int>(lHeight+2) ) ); + mpFrame->maInvalidRect.Union( aVclRect ); + } +} + +CGPoint* IosSalGraphics::makeCGptArray(sal_uLong nPoints, const SalPoint* pPtAry) +{ + CGPoint *CGpoints = new CGPoint[nPoints]; + if ( CGpoints ) + { + for(sal_uLong i=0;i<nPoints;i++) + { + CGpoints[i].x = (float)(pPtAry[i].mnX); + CGpoints[i].y = (float)(pPtAry[i].mnY); + } + } + return CGpoints; +} + +// ----------------------------------------------------------------------- + +void IosSalGraphics::UpdateWindow( CGRect& ) +{ +#if 0 // Sigh, this is just basically a copy of the "aqua" code and not + // applicable to iOS. + + if( !mpFrame ) + return; + UIGraphicsContext* pContext = [UIGraphicsContext currentContext]; + if( (mxLayer != NULL) && (pContext != NULL) ) + { + CGContextRef rCGContext = reinterpret_cast<CGContextRef>([pContext graphicsPort]); + + CGMutablePathRef rClip = mpFrame->getClipPath(); + if( rClip ) + { + CGContextSaveGState( rCGContext ); + CGContextBeginPath( rCGContext ); + CGContextAddPath( rCGContext, rClip ); + CGContextClip( rCGContext ); + } + + ApplyXorContext(); + CGContextDrawLayerAtPoint( rCGContext, CGPointZero, mxLayer ); + if( rClip ) // cleanup clipping + CGContextRestoreGState( rCGContext ); + } + else + DBG_ASSERT( mpFrame->mbInitShow, "UpdateWindow called on uneligible graphics" ); +#endif +} + +// ----------------------------------------------------------------------- + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/gdi/salnativewidgets.cxx b/vcl/ios/source/gdi/salnativewidgets.cxx new file mode 100644 index 000000000000..23d8b8d4589e --- /dev/null +++ b/vcl/ios/source/gdi/salnativewidgets.cxx @@ -0,0 +1,242 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vcl/salnativewidgets.hxx" +#include "vcl/decoview.hxx" +#include "vcl/svapp.hxx" +#include "vcl/timer.hxx" + +#include "ios/salconst.h" +#include "ios/salgdi.h" +#include "ios/saldata.hxx" +#include "ios/salframe.h" + +#include "premac.h" +#include <UIKit/UIKit.h> +#include "postmac.h" + + +/* + * IsNativeControlSupported() + * -------------------------- + * Returns sal_True if the platform supports native + * drawing of the control defined by nPart. + * + */ +sal_Bool IosSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) +{ + bool bOk = sal_False; + + // Native controls are now defaults + // If you want to disable experimental native controls code, + // just set the environment variable SAL_NO_NWF to something + // and vcl controls will be used as default again. + + switch( nType ) + { + case CTRL_PUSHBUTTON: + case CTRL_RADIOBUTTON: + case CTRL_CHECKBOX: + case CTRL_LISTNODE: + if( nPart == PART_ENTIRE_CONTROL ) + return true; + break; + + case CTRL_SCROLLBAR: + if( nPart == PART_DRAW_BACKGROUND_HORZ || + nPart == PART_DRAW_BACKGROUND_VERT || + nPart == PART_ENTIRE_CONTROL || + nPart == HAS_THREE_BUTTONS ) + return true; + break; + + case CTRL_SLIDER: + if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) + return true; + break; + + case CTRL_EDITBOX: + if( nPart == PART_ENTIRE_CONTROL || + nPart == HAS_BACKGROUND_TEXTURE ) + return true; + break; + + case CTRL_MULTILINE_EDITBOX: + if( nPart == PART_ENTIRE_CONTROL || + nPart == HAS_BACKGROUND_TEXTURE ) + return true; + break; + + case CTRL_SPINBOX: + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_ALL_BUTTONS || + nPart == HAS_BACKGROUND_TEXTURE ) + return true; + break; + + case CTRL_SPINBUTTONS: + return false; + break; + + case CTRL_COMBOBOX: + if( nPart == PART_ENTIRE_CONTROL || + nPart == HAS_BACKGROUND_TEXTURE ) + return true; + break; + + case CTRL_LISTBOX: + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_WINDOW || + nPart == HAS_BACKGROUND_TEXTURE || + nPart == PART_SUB_EDIT + ) + return true; + break; + + case CTRL_TAB_ITEM: + case CTRL_TAB_PANE: + case CTRL_TAB_BODY: // see vcl/source/window/tabpage.cxx + case CTRL_FIXEDBORDER: + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_TABS_DRAW_RTL || + nPart == HAS_BACKGROUND_TEXTURE ) + return true; + break; + + // when PART_BUTTON is used, toolbar icons are not highlighted when mouse rolls over. + // More Ios compliant + case CTRL_TOOLBAR: + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_DRAW_BACKGROUND_HORZ || + nPart == PART_DRAW_BACKGROUND_VERT) + return true; + break; + + case CTRL_WINDOW_BACKGROUND: + if ( nPart == PART_BACKGROUND_WINDOW || + nPart == PART_BACKGROUND_DIALOG ) + return true; + break; + + case CTRL_MENUBAR: + if( nPart == PART_ENTIRE_CONTROL ) + return true; + break; + + case CTRL_TOOLTIP: // ** TO DO + break; + + case CTRL_MENU_POPUP: + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_MENU_ITEM || + nPart == PART_MENU_ITEM_CHECK_MARK || + nPart == PART_MENU_ITEM_RADIO_MARK) + return true; + break; + case CTRL_PROGRESS: + case CTRL_INTROPROGRESS: + if( nPart == PART_ENTIRE_CONTROL ) + return true; + break; + case CTRL_FRAME: + if( nPart == PART_BORDER ) + return true; + break; + case CTRL_LISTNET: + if( nPart == PART_ENTIRE_CONTROL ) + return true; + break; + } + + return bOk; +} + +/* + * HitTestNativeControl() + * + * If the return value is sal_True, bIsInside contains information whether + * aPos was or was not inside the native widget specified by the + * nType/nPart combination. + */ +sal_Bool IosSalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, + const Point& rPos, sal_Bool& rIsInside ) +{ + return sal_False; +} + +UInt32 IosSalGraphics::getState( ControlState nState ) +{ + return 0; +} + +UInt32 IosSalGraphics::getTrackState( ControlState nState ) +{ + return 0; +} + +/* + * DrawNativeControl() + * + * Draws the requested control described by nPart/nState. + * + * rControlRegion: The bounding region of the complete control in VCL frame coordinates. + * aValue: An optional value (tristate/numerical/string) + * aCaption: A caption or title string (like button text etc) + */ +sal_Bool IosSalGraphics::drawNativeControl(ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const rtl::OUString& ) +{ + return sal_False; +} + +/* + * GetNativeControlRegion() + * + * If the return value is sal_True, rNativeBoundingRegion + * contains the true bounding region covered by the control + * including any adornment, while rNativeContentRegion contains the area + * within the control that can be safely drawn into without drawing over + * the borders of the control. + * + * rControlRegion: The bounding region of the control in VCL frame coordinates. + * aValue: An optional value (tristate/numerical/string) + * aCaption: A caption or title string (like button text etc) + */ +sal_Bool IosSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState /*nState*/, + const ImplControlValue& aValue, const rtl::OUString&, + Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ) + +{ + return sal_False; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/window/salframeview.mm b/vcl/ios/source/window/salframeview.mm new file mode 100644 index 000000000000..68c34a9fbd8e --- /dev/null +++ b/vcl/ios/source/window/salframeview.mm @@ -0,0 +1,268 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/*n*********************************************************************** + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include <sal/alloca.h> +#include <sal/macros.h> + +#include "vcl/window.hxx" +#include "vcl/svapp.hxx" + +#include "ios/salinst.h" +#include "ios/salgdi.h" +#include "ios/salframe.h" +#include "ios/salframeview.h" + +#define WHEEL_EVENT_FACTOR 1.5 + +@implementation SalFrameWindow +-(id)initWithSalFrame: (IosSalFrame*)pFrame +{ + mpFrame = pFrame; + CGRect aRect = { { pFrame->maGeometry.nX, pFrame->maGeometry.nY }, + { pFrame->maGeometry.nWidth, pFrame->maGeometry.nHeight } }; +#if 0 + NSWindow* pNSWindow = [super initWithContentRect: aRect styleMask: mpFrame->getStyleMask() backing: NSBackingStoreBuffered defer: NO ]; + [pNSWindow useOptimizedDrawing: YES]; // OSX recommendation when there are no overlapping subviews within the receiver + return pNSWindow; +#endif + return nil; +} + +-(IosSalFrame*)getSalFrame +{ + return mpFrame; +} + +-(void)displayIfNeeded +{ + if( GetSalData() && GetSalData()->mpFirstInstance ) + { + osl::SolarMutex* pMutex = GetSalData()->mpFirstInstance->GetYieldMutex(); + if( pMutex ) + { + pMutex->acquire(); + [super displayIfNeeded]; + pMutex->release(); + } + } +} + +-(BOOL)canBecomeKeyWindow +{ + if( (mpFrame->mnStyle & + ( SAL_FRAME_STYLE_FLOAT | + SAL_FRAME_STYLE_TOOLTIP | + SAL_FRAME_STYLE_INTRO + )) == 0 ) + return YES; + if( (mpFrame->mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) != 0 ) + return YES; + if( (mpFrame->mnStyle & SAL_FRAME_STYLE_FLOAT_FOCUSABLE) ) + return YES; + return [super canBecomeKeyWindow]; +} + +-(void)windowDidBecomeKey: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + static const sal_uLong nGuessDocument = SAL_FRAME_STYLE_MOVEABLE| + SAL_FRAME_STYLE_SIZEABLE| + SAL_FRAME_STYLE_CLOSEABLE; + + mpFrame->CallCallback( SALEVENT_GETFOCUS, 0 ); + mpFrame->SendPaintEvent(); // repaint controls as active + } +} + +-(void)windowDidResignKey: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + mpFrame->CallCallback(SALEVENT_LOSEFOCUS, 0); + mpFrame->SendPaintEvent(); // repaint controls as inactive + } +} + +-(void)windowDidChangeScreen: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + mpFrame->screenParametersChanged(); +} + +-(void)windowDidMove: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + mpFrame->UpdateFrameGeometry(); + mpFrame->CallCallback( SALEVENT_MOVE, 0 ); + } +} + +-(void)windowDidResize: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + mpFrame->UpdateFrameGeometry(); + mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); + mpFrame->SendPaintEvent(); + } +} + +-(void)windowDidMiniaturize: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + mpFrame->mbShown = false; + mpFrame->UpdateFrameGeometry(); + mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); + } +} + +-(void)windowDidDeminiaturize: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + mpFrame->mbShown = true; + mpFrame->UpdateFrameGeometry(); + mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); + } +} + +-(BOOL)windowShouldClose: (NSNotification*)pNotification +{ + (void)pNotification; + YIELD_GUARD; + + BOOL bRet = YES; + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + // #i84461# end possible input + mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 ); + if( IosSalFrame::isAlive( mpFrame ) ) + { + mpFrame->CallCallback( SALEVENT_CLOSE, 0 ); + bRet = NO; // application will close the window or not, AppKit shouldn't + } + } + + return bRet; +} + +@end + +@implementation SalFrameView + +-(id)initWithSalFrame: (IosSalFrame*)pFrame +{ + // ??? + + mfLastMagnifyTime = 0.0; + return self; +} + +-(IosSalFrame*)getSalFrame +{ + return mpFrame; +} + +-(BOOL)acceptsFirstResponder +{ + return YES; +} + +-(BOOL)isOpaque +{ + return mpFrame ? (mpFrame->getClipPath() != 0 ? NO : YES) : YES; +} + +// helper class similar to a osl::SolarGuard for the SalYieldMutex +// the difference is that it only does tryToAcquire instead of aquire +// so dreaded deadlocks like #i93512# are prevented +class TryGuard +{ +public: + TryGuard() { mbGuarded = ImplSalYieldMutexTryToAcquire(); } + ~TryGuard() { if( mbGuarded ) ImplSalYieldMutexRelease(); } + bool IsGuarded() { return mbGuarded; } +private: + bool mbGuarded; +}; + +-(void)drawRect: (CGRect)aRect +{ + // HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex + TryGuard aTryGuard; + if( !aTryGuard.IsGuarded() ) + { + // NOTE: the mpFrame access below is not guarded yet! + // TODO: mpFrame et al need to be guarded by an independent mutex + IosSalGraphics* pGraphics = (mpFrame && IosSalFrame::isAlive(mpFrame)) ? mpFrame->mpGraphics : NULL; + if( pGraphics ) + { + pGraphics->RefreshRect( aRect ); + } + return; + } + + if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) + { + if( mpFrame->mpGraphics ) + { + mpFrame->mpGraphics->UpdateWindow( aRect ); + if( mpFrame->getClipPath() ) + [mpFrame->getWindow() invalidateShadow]; + } + } +} + +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |