home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vp11demo.zip
/
rtlsrc.rar
/
tv
/
COLORSEL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-10-08
|
6KB
|
236 lines
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1992 Borland International }
{ }
{*******************************************************}
{$PureInt+}
unit ColorSel;
{$X+,I-,S-,Cdecl-}
interface
uses Objects, Drivers, Views, Dialogs, Use32;
const
cmColorForegroundChanged = 71;
cmColorBackgroundChanged = 72;
cmColorSet = 73;
cmNewColorItem = 74;
cmNewColorIndex = 75;
cmSaveColorIndex = 76;
type
{ TColorItem }
PColorItem = ^TColorItem;
TColorItem = record
Name: PString;
Index: Byte;
Next: PColorItem;
end;
{ TColorGroup }
PColorGroup = ^TColorGroup;
TColorGroup = record
Name: PString;
Index: Byte;
Items: PColorItem;
Next: PColorGroup;
end;
{ TColorIndexes }
PColorIndex = ^TColorIndex;
TColorIndex = record
GroupIndex: byte;
ColorSize: byte;
ColorIndex: array[0..255] of byte;
end;
{ TColorSelector }
TColorSel = (csBackground, csForeground);
PColorSelector = ^TColorSelector;
TColorSelector = object(TView)
Color: Byte;
SelType: TColorSel;
constructor Init(var Bounds: TRect; ASelType: TColorSel);
constructor Load(var S: TStream);
procedure Draw; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure Store(var S: TStream);
end;
{ TMonoSelector }
PMonoSelector = ^TMonoSelector;
TMonoSelector = object(TCluster)
constructor Init(var Bounds: TRect);
procedure Draw; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function Mark(Item: Integer): Boolean; virtual;
procedure NewColor;
procedure Press(Item: Integer); virtual;
procedure MovedTo(Item: Integer); virtual;
end;
{ TColorDisplay }
PColorDisplay = ^TColorDisplay;
TColorDisplay = object(TView)
Color: ^Byte;
Text: PString;
constructor Init(var Bounds: TRect; AText: PString);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Draw; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure SetColor(var AColor: Byte); virtual;
procedure Store(var S: TStream);
end;
{ TColorGroupList }
PColorGroupList = ^TColorGroupList;
TColorGroupList = object(TListViewer)
Groups: PColorGroup;
constructor Init(var Bounds: TRect; AScrollBar: PScrollBar;
AGroups: PColorGroup);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure FocusItem(Item: Integer); virtual;
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure Store(var S: TStream);
procedure SetGroupIndex(GroupNum, ItemNum: Byte);
function GetGroup(GroupNum: Byte): PColorGroup;
function GetGroupIndex(GroupNum: Byte): Byte;
function GetNumGroups: byte;
end;
{ TColorItemList }
PColorItemList = ^TColorItemList;
TColorItemList = object(TListViewer)
Items: PColorItem;
constructor Init(var Bounds: TRect; AScrollBar: PScrollBar;
AItems: PColorItem);
procedure FocusItem(Item: Integer); virtual;
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
end;
{ TColorDialog }
PColorDialog = ^TColorDialog;
TColorDialog = object(TDialog)
GroupIndex: byte;
Display: PColorDisplay;
Groups: PColorGroupList;
ForLabel: PLabel;
ForSel: PColorSelector;
BakLabel: PLabel;
BakSel: PColorSelector;
MonoLabel: PLabel;
MonoSel: PMonoSelector;
Pal: TPalette;
constructor Init(APalette: TPalette; AGroups: PColorGroup);
constructor Load(var S: TStream);
function DataSize: Word; virtual;
procedure GetData(var Rec); virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure SetData(var Rec); virtual;
procedure Store(var S: TStream);
procedure GetIndexes(var Colors: PColorIndex);
procedure SetIndexes(var Colors: PColorIndex);
end;
{ Pointer to saved color list item indexes }
const
ColorIndexes: PColorIndex = nil;
{ Load and Store Palette routines }
procedure StoreIndexes(var S: TStream);
procedure LoadIndexes(var S: TStream);
{ Color list building routines }
function ColorItem(const Name: String; Index: Byte;
Next: PColorItem): PColorItem;
function ColorGroup(const Name: String; Items: PColorItem;
Next: PColorGroup): PColorGroup;
{ Standard color items functions }
function DesktopColorItems(const Next: PColorItem): PColorItem;
function MenuColorItems(const Next: PColorItem): PColorItem;
function DialogColorItems(Palette: Word; const Next: PColorItem): PColorItem;
function WindowColorItems(Palette: Word; const Next: PColorItem): PColorItem;
{ ColorSel registration procedure }
procedure RegisterColorSel;
{ Stream registration records }
const
RColorSelector: TStreamRec = (
ObjType: 21;
VmtLink: Ofs(TypeOf(TColorSelector)^);
Load: @TColorSelector.Load;
Store: @TColorSelector.Store
);
const
RMonoSelector: TStreamRec = (
ObjType: 22;
VmtLink: Ofs(TypeOf(TMonoSelector)^);
Load: @TMonoSelector.Load;
Store: @TMonoSelector.Store
);
const
RColorDisplay: TStreamRec = (
ObjType: 23;
VmtLink: Ofs(TypeOf(TColorDisplay)^);
Load: @TColorDisplay.Load;
Store: @TColorDisplay.Store
);
const
RColorGroupList: TStreamRec = (
ObjType: 24;
VmtLink: Ofs(TypeOf(TColorGroupList)^);
Load: @TColorGroupList.Load;
Store: @TColorGroupList.Store
);
const
RColorItemList: TStreamRec = (
ObjType: 25;
VmtLink: Ofs(TypeOf(TColorItemList)^);
Load: @TColorItemList.Load;
Store: @TColorItemList.Store
);
const
RColorDialog: TStreamRec = (
ObjType: 26;
VmtLink: Ofs(TypeOf(TColorDialog)^);
Load: @TColorDialog.Load;
Store: @TColorDialog.Store
);
implementation
end.