home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 12.9 KB | 640 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: SLInk.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef PRSHATTR_H
- #include "PRShAttr.h"
- #endif
-
- #ifndef FWODEXCE_H
- #include "FWODExce.h"
- #endif
-
- #ifndef SLSHATTR_H
- #include "SLShAttr.h"
- #endif
-
- #ifndef FWSTRMRW_H
- #include "FWStrmRW.h"
- #endif
-
- #ifndef FWAROPER_H
- #include "FWArOper.h"
- #endif
-
- //========================================================================================
- // Pattern
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Pattern
- #endif
-
- // Creation
-
- FW_HPattern SL_API FW_PrivPattern_CreateBlack(FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivBWPatternRep, ());
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HPattern SL_API FW_PrivPattern_CreateBW(const FW_BitPattern& bits, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivBWPatternRep, (bits));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HPattern SL_API FW_PrivPattern_CreateColor(const FW_PixelPattern& pixels, short nbColors, const FW_SColor* colorTable, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivColorPatternRep, (pixels, nbColors, colorTable));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HPattern SL_API FW_PrivPattern_CreateFromPlatformColorPattern(FW_PlatformColorPattern pattern, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivColorPatternRep, (pattern));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HPattern SL_API FW_PrivPattern_Copy(FW_HPattern pattern, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return pattern->Copy();
- }
- FW_ERR_CATCH
- return 0;
- }
-
- // Reference counting
-
- void SL_API FW_PrivPattern_Acquire(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->Acquire();
- }
-
- long SL_API FW_PrivPattern_GetRefCount(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- return pattern->GetRefCount();
- }
-
- void SL_API FW_PrivPattern_Release(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->Release();
- }
-
- // Comparison
-
- FW_Boolean SL_API FW_PrivPattern_IsEqual(FW_HPattern pattern1, FW_HPattern pattern2)
- {
- // No try block necessary - Do not throw
- return pattern1->IsEqual(pattern2);
- }
-
- // Operations
-
- FW_PlatformError SL_API FW_PrivPattern_Invert(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->Invert();
- return FW_xNoError;
- }
-
- FW_PlatformError SL_API FW_PrivPattern_FlipHorizontally(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->FlipHorizontally();
- return FW_xNoError;
- }
-
- FW_PlatformError SL_API FW_PrivPattern_FlipVertically(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->FlipVertically();
- return FW_xNoError;
- }
-
- FW_PlatformError SL_API FW_PrivPattern_ShiftUp(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->ShiftUp();
- return FW_xNoError;
- }
-
- FW_PlatformError SL_API FW_PrivPattern_ShiftDown(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->ShiftDown();
- return FW_xNoError;
- }
-
- FW_PlatformError SL_API FW_PrivPattern_ShiftLeft(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->ShiftLeft();
- return FW_xNoError;
- }
-
- FW_PlatformError SL_API FW_PrivPattern_ShiftRight(FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- pattern->ShiftRight();
- return FW_xNoError;
- }
-
- // Streaming
-
- FW_HPattern SL_API FW_PrivPattern_Read(FW_HReadableStream hStream, FW_PlatformError* error)
- {
- FW_CPrivPatternRep* pattern;
- FW_ERR_TRY
- {
- FW_CReadableStream stream(hStream);
- FW_READ_DYNAMIC_OBJECT(stream, &pattern, FW_CPrivPatternRep);
- }
- FW_ERR_CATCH
- return pattern;
- }
-
- void SL_API FW_PrivPattern_Write(FW_HPattern pattern, FW_HWritableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CWritableStream stream(hStream);
- FW_WRITE_DYNAMIC_OBJECT(stream, pattern, FW_CPrivPatternRep);
- }
- FW_ERR_CATCH
- }
-
- //========================================================================================
- // Ink
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Ink
- #endif
-
- // Creation
-
- FW_HInk SL_API FW_PrivInk_Create(FW_SColor fore, FW_SColor back, FW_TransferModes mode, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return new FW_CPrivInkRep(fore, back, mode);
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HInk SL_API FW_PrivInk_CreateStandard(FW_EStandardInks std, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return new FW_CPrivInkRep(std);
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HInk SL_API FW_PrivInk_Copy(FW_HInk ink, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return new FW_CPrivInkRep(*ink);
- }
- FW_ERR_CATCH
- return 0;
- }
-
- // Reference counting
-
- void SL_API FW_PrivInk_Acquire(FW_HInk ink)
- {
- // No try block necessary - Do not throw
- ink->Acquire();
- }
-
- long SL_API FW_PrivInk_GetRefCount(FW_HInk ink)
- {
- // No try block necessary - Do not throw
- return ink->GetRefCount();
- }
-
- void SL_API FW_PrivInk_Release(FW_HInk ink)
- {
- // No try block necessary - Do not throw
- ink->Release();
- }
-
- // Attributes
-
- FW_SColor SL_API FW_PrivInk_GetForeColor(FW_HInk ink)
- {
- // No try block necessary - Do not throw
- return ink->GetForeColor();
- }
-
- FW_SColor SL_API FW_PrivInk_GetBackColor(FW_HInk ink)
- {
- // No try block necessary - Do not throw
- return ink->GetBackColor();
- }
-
- FW_TransferModes SL_API FW_PrivInk_GetTransferMode(FW_HInk ink)
- {
- // No try block necessary - Do not throw
- return ink->GetTransferMode();
- }
-
- // Comparison
-
- FW_Boolean SL_API FW_PrivInk_IsEqual(FW_HInk ink, FW_HInk ink2)
- {
- // No try block necessary - Do not throw
- return ink->IsEqual(ink2);
- }
-
- // Operations
-
- void SL_API FW_PrivInk_SetForeColor(FW_HInk ink, FW_SColor color)
- {
- // No try block necessary - Do not throw
- ink->SetForeColor(color);
- }
-
- void SL_API FW_PrivInk_SetBackColor(FW_HInk ink, FW_SColor color)
- {
- // No try block necessary - Do not throw
- ink->SetBackColor(color);
- }
-
- void SL_API FW_PrivInk_SetTransferMode(FW_HInk ink, FW_TransferModes mode)
- {
- // No try block necessary - Do not throw
- ink->SetTransferMode(mode);
- }
-
- // Streaming
-
- FW_HInk SL_API FW_PrivInk_Read(FW_HReadableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CReadableStream stream(hStream);
- return new FW_CPrivInkRep(stream);
- }
- FW_ERR_CATCH
- return 0;
- }
-
- void SL_API FW_PrivInk_Write(FW_HInk ink, FW_HWritableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CWritableStream stream(hStream);
- ink->Write(stream);
- }
- FW_ERR_CATCH
- }
-
- //========================================================================================
- // Style
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Style
- #endif
-
- // Creation
-
- FW_HStyle SL_API FW_PrivStyle_CreateDash(FW_Fixed penSize, FW_EStyleDash dash, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivStyleRep, (penSize, dash));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HStyle SL_API FW_PrivStyle_CreatePattern(FW_Fixed penSize, FW_HPattern pattern, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivStyleRep, (penSize, pattern));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HStyle SL_API FW_PrivStyle_CreateStandard(FW_EStandardStyles std, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivStyleRep, (std));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HStyle SL_API FW_PrivStyle_Copy(FW_HStyle style, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivStyleRep, (*style));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- // Reference counting
-
- void SL_API FW_PrivStyle_Acquire(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- style->Acquire();
- }
-
- long SL_API FW_PrivStyle_GetRefCount(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- return style->GetRefCount();
- }
-
- void SL_API FW_PrivStyle_Release(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- style->Release();
- }
-
- // Attributes
-
- FW_Fixed SL_API FW_PrivStyle_GetPenSize(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- return style->GetPenSize();
- }
-
- FW_HPattern SL_API FW_PrivStyle_GetPattern(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- return style->GetPattern();
- }
-
- FW_HPattern SL_API FW_PrivStyle_GetUnSharedPattern(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- return style->GetUnSharedPattern();
- }
-
- FW_EStyleDash SL_API FW_PrivStyle_GetDashStyle(FW_HStyle style)
- {
- // No try block necessary - Do not throw
- return style->GetDashStyle();
- }
-
- // Comparison
-
- FW_Boolean SL_API FW_PrivStyle_IsEqual(FW_HStyle style, FW_HStyle style2)
- {
- // No try block necessary - Do not throw
- return style->IsEqual(style2);
- }
-
- // Operations
-
- void SL_API FW_PrivStyle_SetPenSize(FW_HStyle style, FW_Fixed penSize)
- {
- // No try block necessary - Do not throw
- style->SetPenSize(penSize);
- }
-
- FW_PlatformError SL_API FW_PrivStyle_SetPattern(FW_HStyle style, FW_HPattern pattern)
- {
- // No try block necessary - Do not throw
- style->SetPattern(pattern);
- return FW_xNoError;
- }
-
- void SL_API FW_PrivStyle_SetDashStyle(FW_HStyle style, FW_EStyleDash dash)
- {
- // No try block necessary - Do not throw
- style->SetDashStyle(dash);
- }
-
- // Streaming
-
- FW_HStyle SL_API FW_PrivStyle_Read(FW_HReadableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CReadableStream stream(hStream);
- return FW_NEW(FW_CPrivStyleRep, (stream));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- void SL_API FW_PrivStyle_Write(FW_HStyle style, FW_HWritableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CWritableStream stream(hStream);
- style->Write(stream);
- }
- FW_ERR_CATCH
- }
-
- //========================================================================================
- // Font
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Font
- #endif
-
- // Creation
-
- FW_HFont SL_API FW_PrivFont_Create(FW_HString fontName, FW_FontStyle fontStyle, FW_Fixed fontSize, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CString str(fontName);
- return FW_NEW(FW_CPrivFontRep, (str, fontStyle, fontSize));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HFont SL_API FW_PrivFont_CreateStandard(FW_EStandardFonts std, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivFontRep, (std));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- FW_HFont SL_API FW_PrivFont_Copy(FW_HFont font, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- return FW_NEW(FW_CPrivFontRep, (*font));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- // Reference counting
-
- void SL_API FW_PrivFont_Acquire(FW_HFont font)
- {
- // No try block necessary - Do not throw
- font->Acquire();
- }
-
- long SL_API FW_PrivFont_GetRefCount(FW_HFont font)
- {
- // No try block necessary - Do not throw
- return font->GetRefCount();
- }
-
- void SL_API FW_PrivFont_Release(FW_HFont font)
- {
- // No try block necessary - Do not throw
- font->Release();
- }
-
- // Attributes
-
- FW_Fixed SL_API FW_PrivFont_GetSize(FW_HFont font)
- {
- // No try block necessary - Do not throw
- return font->GetFontSize();
- }
-
- FW_FontStyle SL_API FW_PrivFont_GetStyle(FW_HFont font)
- {
- // No try block necessary - Do not throw
- return font->GetFontStyle();
- }
-
- void SL_API FW_PrivFont_GetName(FW_HFont font, FW_HString* fontName, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CString str(*fontName);
- font->GetFontName(str);
- }
- FW_ERR_CATCH
- }
-
- // Comparison
-
- FW_Boolean SL_API FW_PrivFont_IsEqual(FW_HFont font, FW_HFont font2)
- {
- // No try block necessary - Do not throw
- return font->IsEqual(font2);
- }
-
- // Operations
-
- void SL_API FW_PrivFont_SetSize(FW_HFont font, FW_Fixed size)
- {
- // No try block necessary - Do not throw
- font->SetFontSize(size);
- }
-
- void SL_API FW_PrivFont_SetStyle(FW_HFont font, FW_FontStyle style)
- {
- // No try block necessary - Do not throw
- font->SetFontStyle(style);
- }
-
-
- void SL_API FW_PrivFont_SetName(FW_HFont font, FW_HString fontName, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CString str(fontName);
- font->SetFontName(str);
- }
- FW_ERR_CATCH
- }
-
- // Streaming
-
- FW_HFont SL_API FW_PrivFont_Read(FW_HReadableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CReadableStream stream(hStream);
- return FW_NEW(FW_CPrivFontRep, (stream));
- }
- FW_ERR_CATCH
- return 0;
- }
-
- void SL_API FW_PrivFont_Write(FW_HFont font, FW_HWritableStream hStream, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CWritableStream stream(hStream);
- font->Write(stream);
- }
- FW_ERR_CATCH
- }
-
- // Macintosh-only
-
- #ifdef FW_BUILD_MAC
- short SL_API FW_PrivFont_MacGetFontID(FW_HFont font)
- {
- // No try block necessary - Do not throw
- return font->MacGetFontID();
- }
-
- Style SL_API FW_PrivFont_MacGetFontStyle(FW_HFont font)
- {
- // No try block necessary - Do not throw
- return font->MacGetFontStyle();
- }
-
- void SL_API FW_PrivFont_MacSetFontID(FW_HFont font, short macFontID, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- font->MacSetFontID(macFontID);
- }
- FW_ERR_CATCH
- }
-
- #endif
-