2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Teach Text handling.
|
|
|
|
*/
|
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-10 23:32:55 +00:00
|
|
|
#ifndef REFORMAT_TEACH_H
|
|
|
|
#define REFORMAT_TEACH_H
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
#include "ReformatBase.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reformat a generic IIgs text file.
|
|
|
|
*/
|
|
|
|
class ReformatGWP : public ReformatText {
|
|
|
|
public:
|
2014-11-04 00:26:53 +00:00
|
|
|
ReformatGWP(void) {}
|
|
|
|
virtual ~ReformatGWP(void) {}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
virtual void Examine(ReformatHolder* pHolder);
|
|
|
|
virtual int Process(const ReformatHolder* pHolder,
|
|
|
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
|
|
|
ReformatOutput* pOutput);
|
2007-03-27 17:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reformat a Teach file
|
|
|
|
*/
|
|
|
|
class ReformatTeach : public ReformatText {
|
|
|
|
public:
|
2014-11-04 00:26:53 +00:00
|
|
|
ReformatTeach(void) {}
|
|
|
|
virtual ~ReformatTeach(void) {}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
virtual void Examine(ReformatHolder* pHolder);
|
|
|
|
virtual int Process(const ReformatHolder* pHolder,
|
|
|
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
|
|
|
ReformatOutput* pOutput);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
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:
|
2014-11-18 05:13:13 +00:00
|
|
|
RStyleBlock(void) : fpRulers(NULL), fpStyles(NULL), fpStyleItems(NULL) {}
|
2014-11-04 00:26:53 +00:00
|
|
|
virtual ~RStyleBlock(void) {
|
|
|
|
delete[] fpRulers;
|
|
|
|
delete[] fpStyles;
|
|
|
|
delete[] fpStyleItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unpack the resource; returns false on failure */
|
2014-11-21 02:10:18 +00:00
|
|
|
bool Create(const uint8_t* buf, long len);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class representing a IIgs TERuler object.
|
|
|
|
*/
|
|
|
|
class TERuler {
|
|
|
|
public:
|
|
|
|
TERuler(void) {}
|
|
|
|
virtual ~TERuler(void) {}
|
|
|
|
|
|
|
|
/* unpack the ruler; returns the #of bytes consumed */
|
2014-11-21 02:10:18 +00:00
|
|
|
int Create(const uint8_t* buf, long len);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
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 {
|
2014-11-21 02:10:18 +00:00
|
|
|
uint16_t tabKind; // must be $0000
|
|
|
|
uint16_t tabData; // tab location, in pixels from left
|
2014-11-04 00:26:53 +00:00
|
|
|
} TabItem;
|
|
|
|
|
2014-11-21 02:10:18 +00:00
|
|
|
uint16_t fLeftMargin; // pixel indent, except para start
|
|
|
|
uint16_t fLeftIndent; // pixel indent, for para start
|
|
|
|
uint16_t fRightMargin; // maximum line len, in pixels
|
|
|
|
uint16_t fJust; // enum Justification
|
|
|
|
uint16_t fExtraLS; // extra line spacing, in pixels
|
|
|
|
uint16_t fFlags; // reserved
|
|
|
|
uint32_t fUserData;
|
|
|
|
uint16_t fTabType; // 0=none, 1=interval, 2=irregular
|
2014-11-04 00:26:53 +00:00
|
|
|
// array of TabItem appears here for fTabType==2
|
2014-11-21 02:10:18 +00:00
|
|
|
uint16_t fTabTerminator; // present for fTabType==1 or 2
|
2014-11-04 00:26:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class representing a IIgs TEStyle object.
|
|
|
|
*/
|
|
|
|
class TEStyle {
|
|
|
|
public:
|
|
|
|
TEStyle(void) {}
|
|
|
|
virtual ~TEStyle(void) {}
|
|
|
|
|
|
|
|
/* unpack the style; returns the #of bytes consumed */
|
2014-11-21 02:10:18 +00:00
|
|
|
void Create(const uint8_t* buf);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* Apple IIgs font family number */
|
2014-11-21 02:10:18 +00:00
|
|
|
uint16_t GetFontFamily(void) const {
|
|
|
|
return (uint16_t) fFontID;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
/* font size, in points */
|
2014-11-21 02:10:18 +00:00
|
|
|
uint8_t GetFontSize(void) const {
|
2014-11-04 00:26:53 +00:00
|
|
|
return (fFontID >> 24) & 0xff;
|
|
|
|
}
|
|
|
|
/* return QDII text style */
|
2014-11-21 02:10:18 +00:00
|
|
|
uint8_t GetTextStyle(void) const {
|
|
|
|
return (fFontID >> 16) & 0xff;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
/* return QDII text color */
|
2014-11-21 02:10:18 +00:00
|
|
|
uint16_t GetTextColor(void) const { return fForeColor; }
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* 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:
|
2014-11-21 02:10:18 +00:00
|
|
|
/* font ID has family, size, and style */
|
|
|
|
uint32_t fFontID;
|
|
|
|
uint16_t fForeColor;
|
|
|
|
uint16_t fBackColor;
|
|
|
|
uint32_t fUserData;
|
2014-11-04 00:26:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class representing a IIgs StyleItem object.
|
|
|
|
*/
|
|
|
|
class StyleItem {
|
|
|
|
public:
|
|
|
|
StyleItem(void) {}
|
|
|
|
virtual ~StyleItem(void) {}
|
|
|
|
|
|
|
|
/* unpack the item */
|
2014-11-21 02:10:18 +00:00
|
|
|
void Create(const uint8_t* buf);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-21 02:10:18 +00:00
|
|
|
uint32_t GetLength(void) const { return fLength; }
|
|
|
|
uint32_t GetOffset(void) const { return fOffset; }
|
|
|
|
uint32_t GetStyleIndex(void) const {
|
|
|
|
return fOffset / TEStyle::kDataLen;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
2014-11-21 02:10:18 +00:00
|
|
|
kItemDataLen = 8,
|
2014-11-04 00:26:53 +00:00
|
|
|
kUnusedItem = 0xffffffff, // in fLength field
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2014-11-21 02:10:18 +00:00
|
|
|
uint32_t fLength; // #of characters affected by this style
|
|
|
|
uint32_t fOffset; // offset in bytes into TEStyle list
|
2014-11-04 00:26:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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];
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
private:
|
2014-11-04 00:26:53 +00:00
|
|
|
int fNumRulers;
|
|
|
|
int fNumStyles;
|
|
|
|
int fNumStyleItems;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
TERuler* fpRulers;
|
|
|
|
TEStyle* fpStyles;
|
|
|
|
StyleItem* fpStyleItems;
|
2007-03-27 17:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
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-10 23:32:55 +00:00
|
|
|
#endif /*REFORMAT_TEACH_H*/
|