ciderpress/reformat/Teach.h
Andy McFadden 51b5f00f5c Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.

* Switch from MBCS to UNICODE APIs

Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out.  So it's
time to switch to wide strings.

This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode).  The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.

There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion.  These currently have fixed
place-holder "xyzzy" strings.

All UI strings are now wide.

Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow.  This doesn't play well with gcc, so
only the Windows-specific parts use those.

* Various updates to vcxproj files

The project-file conversion had some cruft that is now largely
gone.  The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.

* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots

The old "prebuilts" directory is now gone.  The libraries are now
built as part of building the apps.

I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).

* Replace symbols used for include guards

Symbols with a leading "__" are reserved.
2014-11-16 21:01:53 -08:00

212 lines
6.1 KiB
C++

/*
* CiderPress
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Teach Text handling.
*/
#ifndef REFORMAT_TEACH_H
#define REFORMAT_TEACH_H
#include "ReformatBase.h"
/*
* Reformat a generic IIgs text file.
*/
class ReformatGWP : public ReformatText {
public:
ReformatGWP(void) {}
virtual ~ReformatGWP(void) {}
virtual void Examine(ReformatHolder* pHolder);
virtual int Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput);
};
/*
* Reformat a Teach file
*/
class ReformatTeach : public ReformatText {
public:
ReformatTeach(void) {}
virtual ~ReformatTeach(void) {}
virtual void Examine(ReformatHolder* pHolder);
virtual int Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput);
private:
};
/*
* Class to hold the style block.
*
* The definition allows for an array of rulers, but in practice there
* is no way to actually use more than one. Because rulers are
* variable-length, we take the easy road here and assume there's just
* one. To be safe, the interface pretends there could be more than one.
*/
class RStyleBlock {
public:
RStyleBlock(void) : fpRulers(nil), fpStyles(nil), fpStyleItems(nil) {}
virtual ~RStyleBlock(void) {
delete[] fpRulers;
delete[] fpStyles;
delete[] fpStyleItems;
}
/* unpack the resource; returns false on failure */
bool Create(const unsigned char* buf, long len);
/*
* Class representing a IIgs TERuler object.
*/
class TERuler {
public:
TERuler(void) {}
virtual ~TERuler(void) {}
/* unpack the ruler; returns the #of bytes consumed */
int Create(const unsigned char* buf, long len);
typedef enum Justification {
kJustLeft = 0x0000,
kJustRight = 0xffff,
kJustCenter = 0x0001,
kJustFull = 0x0002
} Justification;
Justification GetJustification(void) const {
return (Justification) fJust;
}
private:
enum {
kMinLen = 0x12,
kTabArrayEnd = 0xffff,
};
typedef struct TabItem {
unsigned short tabKind; // must be $0000
unsigned short tabData; // tab location, in pixels from left
} TabItem;
unsigned short fLeftMargin; // pixel indent, except para start
unsigned short fLeftIndent; // pixel indent, for para start
unsigned short fRightMargin; // maximum line len, in pixels
unsigned short fJust; // enum Justification
unsigned short fExtraLS; // extra line spacing, in pixels
unsigned short fFlags; // reserved
unsigned long fUserData;
unsigned short fTabType; // 0=none, 1=interval, 2=irregular
// array of TabItem appears here for fTabType==2
unsigned short fTabTerminator; // present for fTabType==1 or 2
};
/*
* Class representing a IIgs TEStyle object.
*/
class TEStyle {
public:
TEStyle(void) {}
virtual ~TEStyle(void) {}
/* unpack the style; returns the #of bytes consumed */
void Create(const unsigned char* buf);
/* Apple IIgs font family number */
unsigned short GetFontFamily(void) const {
return (unsigned short) fFontID;
}
/* font size, in points */
int GetFontSize(void) const {
return (fFontID >> 24) & 0xff;
}
/* return QDII text style */
unsigned char GetTextStyle(void) const {
return (unsigned char) ((fFontID >> 16) & 0xff);
}
/* return QDII text color */
unsigned short GetTextColor(void) const { return fForeColor; }
/* individual text style getters */
//bool IsBold(void) const { return (GetTextStyle() & kBold) != 0; }
//bool IsItalic(void) const { return (GetTextStyle() & kItalic) != 0; }
//bool IsUnderline(void) const { return (GetTextStyle() & kUnderline) != 0; }
enum { kDataLen = 12 };
private:
unsigned long fFontID;
unsigned short fForeColor;
unsigned short fBackColor;
unsigned long fUserData;
};
/*
* Class representing a IIgs StyleItem object.
*/
class StyleItem {
public:
StyleItem(void) {}
virtual ~StyleItem(void) {}
/* unpack the item */
void Create(const unsigned char* buf);
unsigned long GetLength(void) const { return fLength; }
unsigned long GetOffset(void) const { return fOffset; }
int GetStyleIndex(void) const {
/* MSVC++6.0 won't let me use TEStyle::kDataLen here */
return fOffset / 12;
}
enum {
kDataLen = 8,
kUnusedItem = 0xffffffff, // in fLength field
};
private:
unsigned long fLength; // #of characters affected by this style
unsigned long fOffset; // offset in bytes into TEStyle list
};
enum {
kExpectedVersion = 0,
kMinLen = 4*3 +2,
};
/*
* More RStyleBlock declarations.
*/
TERuler* GetRuler(int idx) {
assert(idx >= 0 && idx < fNumRulers);
return &fpRulers[idx];
}
TEStyle* GetStyle(int idx) {
assert(idx >= 0 && idx < fNumStyles);
return &fpStyles[idx];
}
int GetNumStyleItems(void) const { return fNumStyleItems; }
StyleItem* GetStyleItem(int idx) {
assert(idx >= 0 && idx < fNumStyleItems);
return &fpStyleItems[idx];
}
private:
int fNumRulers;
int fNumStyles;
int fNumStyleItems;
TERuler* fpRulers;
TEStyle* fpStyles;
StyleItem* fpStyleItems;
};
#endif /*REFORMAT_TEACH_H*/