Listing: UCharacterDialog.p
{*******************************************************************u
****************
UCharacterDialog.p
********************************************************************u
***************}
UNIT UCharacterDialog;
INTERFACE
USES
{ • MacApp }
UMacApp,
{ • Building Blocks }
UGridView, UTEView, UDialog,
UMenuItemCommand;
CONST
kMaxFonds = 100; { Max number of FONDs the FontList holds }
kNormalSpacing = 0; { values for TSpaceCluster }
{ keystroke (UKeywordDialog) }
{ TextStyle mode constants -- see IM v5 p269 (TESetStyle()) }
doAlign = 64; { modify alignment }
doPlusFace = 128; { add face to existing face }
doMinusFace = 256; { subtract face from existing face }
doAllAndAlign = doAll + doAlign; { doAll, and align too }
{ DoChoice() message numbers }
mFontChanged = 101; { Character Dialog }
mFontSizeChanged = 102;
mFontFaceChanged = 103;
mTextJustChanged = 104;
mTextFontSizeChanged = 105;
mListFontSizeChanged = 106;
mSpacingChanged = 107;
{###################################################################
########
Unit Initialization
####################################################################
#######}
PROCEDURE InitUCharacterDialog;
{###################################################################
########
Utility Routines
####################################################################
#######}
FUNCTION SameRGBColor(color1, color2: RGBColor): BOOLEAN;
FUNCTION SameTextStyle(style1, style2: TextStyle): BOOLEAN;
{ AffectTextStyle(): Uses the given source TextStyle to modify the
given target TextStyle according to the given mode, in a manner
similar to that used in TTEView.SetOneStyle(). Note that "mode" may
include flags for setting the alignment, as defined above; if
present, they are ignored. }
PROCEDURE AffectTextStyle(theMode: INTEGER;
VAR source: TextStyle; { not changed }
VAR target: TextStyle);
{ AffectTextAlignment(): Uses the given source alignment to modify
the given target alignment according to the given mode, in a manner
similar to that used in TTEView.SetOneStyle(). Note that "mode" may
include flags for setting the alignment, as defined above. }
PROCEDURE AffectTextAlignment(theMode: INTEGER;
source: INTEGER; VAR target: INTEGER);
{ AffectTextStyleAndAlign(): Uses the given source TextStyle and
alignment to modify the given target TextStyle and alignment
according to the given mode, in a manner similar to that used in
TTEView.SetOneStyle(). Note that "mode" may include flags for
setting the alignment, as defined above. }
PROCEDURE AffectTextStyleAndAlign(theMode: INTEGER;
VAR sourceTS: TextStyle; { not changed }
sourceAlign: INTEGER; VAR targetTS: TextStyle;
VAR targetAlign: INTEGER);
TYPE
FontList = ARRAY [1..kMaxFonds] OF INTEGER; { FOND resource
IDs }
FontListPtr = ^FontList;
{###################################################################
############
TCharDialogView
This dialog accepts a TextStyle and an alignment, allows the user
to edit them, and allows access to the result.
####################################################################
###########}
TCharDialogView = OBJECT (TDialogView)
fSampleText: TSampleText;
fFontListView: TFontListView;
fSizeCluster: TSizeCluster;
fJustCluster: TJustifyCluster;
fFaceCluster: TFaceCluster;
{ PostRes(): Initialize the dialog's subview references. }
PROCEDURE TCharDialogView.PostRes;
OVERRIDE;
{ SetDialogInfo(): Initializes the dialog to reflect the given
TextStyle record and alignment value. }
PROCEDURE TCharDialogView.SetDialogInfo(
theStyle: TextStyle;
alignment: INTEGER; redraw: BOOLEAN);
{ GetDialogInfo(): Returns the dialog's current TextStyle record
and alignment value. }
PROCEDURE TCharDialogView.GetDialogInfo(
VAR theStyle: TextStyle;
VAR alignment: INTEGER);
PROCEDURE TCharDialogView.SetTextFont(
theFont: INTEGER; redraw: BOOLEAN);
PROCEDURE TCharDialogView.SetTextSize(
theSize: INTEGER; redraw: BOOLEAN);
PROCEDURE TCharDialogView.SetTextFace(
theFace: Style; redraw: BOOLEAN);
PROCEDURE TCharDialogView.SetTextColor(
theColor: RGBColor; redraw: BOOLEAN);
PROCEDURE TCharDialogView.SetTextJust(
alignment: INTEGER; redraw: BOOLEAN);
PROCEDURE TCharDialogView.DoChoice(
origView: TView; itsChoice: INTEGER);
OVERRIDE;
END; { TCharDialogView }
{###################################################################
############