home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.7 KB | 205 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWIcon.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef SLICON_H
- #include "SLIcon.h"
- #endif
-
- #ifndef FWICON_H
- #include "FWIcon.h"
- #endif
-
- #ifndef FWSTRMRW_H
- #include "FWStrmRW.h"
- #endif
-
- #ifndef SLGC_H
- #include "SLGC.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Icon
- #endif
-
- //========================================================================================
- // Template instantiation
- //========================================================================================
-
- #include "FWGrRef.tpp"
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TGrRefPtr, FW_HIcon)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TGrRefPtr<FW_HIcon>
-
- #else
-
- template class FW_TGrRefPtr<FW_HIcon>;
-
- #endif
-
- //========================================================================================
- // class FW_CIcon
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CIcon)
-
- //----------------------------------------------------------------------------------------
- // FW_PrivAcquireGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivAcquireGrRep(FW_HIcon rep)
- {
- if (rep != 0)
- FW_PrivIcon_Acquire(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivReleaseGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivReleaseGrRep(FW_HIcon rep)
- {
- if (rep != 0)
- FW_PrivIcon_Release(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::FW_CIcon
- //----------------------------------------------------------------------------------------
-
- FW_CIcon::FW_CIcon()
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::FW_CIcon
- //----------------------------------------------------------------------------------------
-
- FW_CIcon::FW_CIcon(FW_CReadableStream& stream)
- {
- FW_PlatformError error;
- FW_HIcon rep = FW_PrivIcon_Read(stream, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::FW_CIcon
- //----------------------------------------------------------------------------------------
-
- FW_CIcon::FW_CIcon(FW_PlatformIcon platformIcon)
- {
- FW_PlatformError error;
- FW_HIcon rep = FW_PrivIcon_CreateFromPlatformIcon(platformIcon, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::FW_CIcon
- //----------------------------------------------------------------------------------------
-
- FW_CIcon::FW_CIcon(FW_PResourceFile& resourceFile,
- FW_ResourceID resID,
- short size)
- {
- FW_PlatformError error;
- FW_HIcon rep = FW_PrivIcon_CreateFromResource(resourceFile, resID, size, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::FW_CIcon
- //----------------------------------------------------------------------------------------
-
- FW_CIcon::FW_CIcon(const FW_CIcon& other) :
- FW_TGrRefPtr<FW_HIcon>(other)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::~FW_CIcon
- //----------------------------------------------------------------------------------------
-
- FW_CIcon::~FW_CIcon()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CIcon& FW_CIcon::operator=(const FW_CIcon& other)
- {
- FW_TGrRefPtr<FW_HIcon>::operator=(other);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CIcon FW_CIcon::Copy() const
- {
- FW_PlatformError error;
- FW_HIcon rep = FW_PrivIcon_Copy(fRep, &error);
- FW_FailOnError(error);
-
- FW_CIcon icon;
- icon.SetRep(rep);
- return icon;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CIcon::GetIconSize
- //----------------------------------------------------------------------------------------
-
- void FW_CIcon::GetIconSize(FW_SGraphicContext& gc, FW_SPoint& size) const
- {
- FW_PrivIcon_GetIconSizeGC(gc.fEnvironment, fRep, gc, size);
- FW_FailOnEvError(gc.fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // operator <<
- //----------------------------------------------------------------------------------------
-
- FW_CWritableStream& operator << (FW_CWritableStream& stream, const FW_CIcon& icon)
- {
- FW_PlatformError error;
- FW_PrivIcon_Write(icon.fRep, stream, &error);
- FW_FailOnError(error);
- return stream;
- }
-
- //----------------------------------------------------------------------------------------
- // operator >>
- //----------------------------------------------------------------------------------------
-
- FW_CReadableStream& operator >> (FW_CReadableStream& stream, FW_CIcon& icon)
- {
- FW_PlatformError error;
- FW_HIcon rep = FW_PrivIcon_Read(stream, &error);
- FW_FailOnError(error);
- icon.SetRep(rep);
- return stream;
- }
-