Units
Classes, Interfaces and Objects
Types
Variables
Constants
Functions and Procedures
Identifiers

Class TCustomMPHexEditor

Unit

MPHexEditor

Declaration

type TCustomMPHexEditor = class()

Description

protected ancestor of the hex editor components

Fields

 NameDescription
Protected FIsSelecting True: cells are currently to be selected
Protected FUndoStorage memory stream which contains the undo/redo data

Methods

Overview

Protected procedure AdjustMetrics;
Public procedure AppendBuffer(aBuffer: PChar; const aSize: integer; const UndoDesc: string = '');
Public function BufferFromFile(const aPos: integer; var aCount: integer): PChar;
Protected procedure Changed; virtual;
Public function CombineUndo(const aCount: integer; const sDesc: string = ''): boolean;
Public procedure ConvertRange(const aFrom, aTo: integer; const aTransFrom, aTransTo: TMPHTranslationKind; const UndoDesc: string = '');
Protected procedure CopyToStream(strTo: TStream; const Operation: TMPHProgressKind; const FileName: string);
Public procedure CreateEmptyFile(const TempName: string);
Public function DeleteNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean;
Public procedure DeleteSelection(const UndoDesc: string = '');
Protected function DropPosition: integer;
Public function Find(aBuffer: PChar; const aCount, aStart, aEnd: integer; const IgnoreCase, SearchText: boolean): integer;
Public function GetAnyOffsetString(const Position: integer): string; virtual;
Public function GetCursorPos: integer;
Protected function GetDataSize: integer;
Protected function GetMemory(aIndex: integer): char;
Public function GetOffsetString(const Position: cardinal): string; virtual;
Protected function GetSelectionAsHex: string;
Protected function GetSelectionAsText: string;
Public function GetTopLeftPosition(var oInCharField: boolean): integer;
Public procedure HideDragCell;
Public procedure InsertBuffer(aBuffer: PChar; const aSize, aPos: integer; const UndoDesc: string = '');
Public function InsertNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean;
Public procedure LoadFromFile(const Filename: string);
Public procedure LoadFromStream(Strm: TStream);
Protected procedure OldCursor;
Protected procedure PrepareOverwriteDiskFile; virtual;
Public function Redo: boolean;
Public procedure ReplaceSelection(aBuffer: PChar; aSize: integer; const UndoDesc: string = '');
Public procedure ResetSelection(const aDraw: boolean);
Public procedure ResetUndo;
Public function RowHeight: integer;
Public procedure SaveToFile(const Filename: string; const aUnModify: boolean = True);
Public procedure SaveToStream(Strm: TStream);
Public function Seek(const aOffset, aOrigin: integer): integer;
Public procedure SelectAll;
Protected procedure SetMemory(aIndex: integer; const aChar: char);
Protected procedure SetSelectionAsHex(const s: string);
Protected procedure SetSelectionAsText(const s: string);
Public procedure SetTopLeftPosition(const aPosition: integer; const aInCharField: boolean);
Public function ShowDragCell(const X, Y: integer): integer;
Protected procedure Stream2Stream(strFrom, strTo: TStream; const Operation: TMPHProgressKind);
Public function TranslateFromAnsiChar(const aByte: byte): char;
Public function TranslateToAnsiChar(const aByte: byte): char;
Public function Undo: boolean;
Public procedure UndoBeginUpdate;
Public function UndoEndUpdate: integer;
Protected procedure WaitCursor;

Description

Protected procedure AdjustMetrics;

adjust cell widths/heigths depending on font, offset format, bytes per row/column...

Public procedure AppendBuffer(aBuffer: PChar; const aSize: integer; const UndoDesc: string = '');

append some data at the end of the data buffer

Public function BufferFromFile(const aPos: integer; var aCount: integer): PChar;

returns a buffer containing parts of the data buffer's contents. the buffer is allocated in this routine and must be freed by the caller

Protected procedure Changed; virtual;

call changed on every undo creation for OnChange event

Public function CombineUndo(const aCount: integer; const sDesc: string = ''): boolean;

combine two or more changes, so Undo will discard the at once

Public procedure ConvertRange(const aFrom, aTo: integer; const aTransFrom, aTransTo: TMPHTranslationKind; const UndoDesc: string = '');

convert a part of the data buffer's content from one character table to a different one

Protected procedure CopyToStream(strTo: TStream; const Operation: TMPHProgressKind; const FileName: string);

copy the data to a stream

Public procedure CreateEmptyFile(const TempName: string);

empty the data buffer and set the filename (e.g. "Untitled")

Public function DeleteNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean;

delete 4 bits (=half byte = nibble) from the data buffer (see also InsertNibble)

Public procedure DeleteSelection(const UndoDesc: string = '');

delete the currently selected data

Protected function DropPosition: integer;

returns the drop file position after a drag'n'drop operation

Public function Find(aBuffer: PChar; const aCount, aStart, aEnd: integer; const IgnoreCase, SearchText: boolean): integer;

searches for text or data in the data buffer, returns the find position (-1, if data have not been found):

- aBuffer: data to search for
- aCount: size of data in aBuffer
- aStart: start search at this position
- aEnd: searches up to this position
- IgnoreCase: if True, lowercase and uppercase characters are treated as if they were equal
- SearchText: if True, the current Translation is taken into account when searching textual data

Public function GetAnyOffsetString(const Position: integer): string; virtual;

returns the given position as it would be drawn in the offset gutter, exception: if OffsetFormat is set to an empty string, returns the hexadecimal representation of the Position value (see also GetOffsetString)

Public function GetCursorPos: integer;

get the current data position (depending on the cursor/caret)

Protected function GetDataSize: integer;

get the size of the contained data

Protected function GetMemory(aIndex: integer): char;

get the data at the specified position

Public function GetOffsetString(const Position: cardinal): string; virtual;

returns the given position as it would be drawn in the offset gutter, see also OffsetFormat

Protected function GetSelectionAsHex: string;

returns the current selection in hex format ('00010203...') as string, uses SwapNibbles

Protected function GetSelectionAsText: string;

returns a string containing the currently selected data

Public function GetTopLeftPosition(var oInCharField: boolean): integer;

returns the data position of the top left cell and also whether the caret is in the character pane, see also SetTopLeftPosition

Public procedure HideDragCell;

hide the drop position marker (see also ShowDragCell)

Public procedure InsertBuffer(aBuffer: PChar; const aSize, aPos: integer; const UndoDesc: string = '');

insert some data at the specified position into the data buffer

Public function InsertNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean;

insert 4 bits (0000) into the data buffer (see also DeleteNibble)

Public procedure LoadFromFile(const Filename: string);

load the contents of a file into the data buffer

Public procedure LoadFromStream(Strm: TStream);

load the contents of a stream into the data buffer

Protected procedure OldCursor;

reset the Cursor to the previous value (see also WaitCursor)

Protected procedure PrepareOverwriteDiskFile; virtual;

allows descendants to take special action if contents are to be saved to the file from where the data was load

Public function Redo: boolean;

discard the last undo action (only one single redo is possible)

Public procedure ReplaceSelection(aBuffer: PChar; aSize: integer; const UndoDesc: string = '');

replace the currently selected data with some other data

Public procedure ResetSelection(const aDraw: boolean);

remove selection state from all data

Public procedure ResetUndo;

free the undo storage (discard all possible undo steps)

Public function RowHeight: integer;

returns the height of one row in pixels

Public procedure SaveToFile(const Filename: string; const aUnModify: boolean = True);

save the contents of the data buffer to a file

Public procedure SaveToStream(Strm: TStream);

save the contents of the data buffer into a stream

Public function Seek(const aOffset, aOrigin: integer): integer;

set the current position (like TStream.Seek)

Public procedure SelectAll;

select all data

Protected procedure SetMemory(aIndex: integer; const aChar: char);

set the data at the specified position

Protected procedure SetSelectionAsHex(const s: string);

replace the current selection by a string containing data in hex format ('00 01 02 03' or similar), uses SwapNibbles

Protected procedure SetSelectionAsText(const s: string);

replaces the currently selected data with the string's contents

Public procedure SetTopLeftPosition(const aPosition: integer; const aInCharField: boolean);

set top left cell to the given data position and also whether the caret is in the character pane (see also GetTopLeftPosition)

Public function ShowDragCell(const X, Y: integer): integer;

show a drop position marker on the cell at the given mouse cursor position (see also HideDragCell)

Protected procedure Stream2Stream(strFrom, strTo: TStream; const Operation: TMPHProgressKind);

copy a stream to a second one and fire the OnLoadSaveProgress handler

Public function TranslateFromAnsiChar(const aByte: byte): char;

translate a byte from Windows Codepage to the current Translation (see also TranslateToAnsiChar)

Public function TranslateToAnsiChar(const aByte: byte): char;

translate a byte from the current Translation to the Windows Codepage (see also TranslateFromAnsiChar)

Public function Undo: boolean;

undo the last modification, multiple undos are possible

Public procedure UndoBeginUpdate;

each call to UndoBeginUpdate increments an internal counter that prevents using undo storage and also disables undo functionality (see also UndoEndUpdate)

Public function UndoEndUpdate: integer;

each call to UndoEndUpdate decrements an internal counter that prevents using undo storage and also disables undo functionality. the return value is the value of this counter. if the counter is reset to zero, undo creation is permitted again (see also UndoBeginUpdate)

Protected procedure WaitCursor;

store the current Cursor and set it to crHourGlass (see also OldCursor)

Properties

Overview

Protected property AllowInsertMode: boolean;
Public property AsHex: string;
Public property AsText: string;
Public property Bookmark[Index: byte]: TMPHBookmark;
Protected property BookmarkBitmap: TBitmap;
Public property ByteChanged[index: integer]: boolean;
Protected property BytesPerColumn: integer;
Protected property BytesPerRow: integer;
Public property CanRedo: boolean;
Public property CanUndo: boolean;
Public property Canvas;
Protected property CaretKind: TMPHCaretKind;
Public property Col;
Public property ColCountRO: integer;
Protected property Colors: TMPHColors;
Public property CurrentValue: integer;
Public property Data[Index: integer]: char;
Public property DataPointer: Pointer;
Public property DataSize: integer;
Protected property DrawGridLines: boolean;
Protected property DrawGutter3D: boolean;
Public property Filename: string;
Protected property FocusFrame: boolean;
Protected property GraySelectionIfNotFocused: boolean;
Protected property GutterWidth: integer;
Public property HasFile: boolean;
Protected property HexLowerCase: boolean;
Protected property HideSelection: boolean;
Public property InCharField: boolean;
Protected property InsertMode: boolean;
Public property LeftCol;
Protected property MaskChar: char;
Protected property MaxUndo: integer;
Public property Modified: boolean;
Public property MouseOverSelection: boolean;
Protected property NoSizeChange: boolean;
Protected property OffsetFormat: string;
Protected property OnChange: TNotifyEvent;
Protected property OnInvalidKey: TNotifyEvent;
Protected property OnLoadSaveProgress: TMPHProgressEvent;
Protected property OnTopLeftChanged: TNotifyEvent;
Public property ReadOnlyFile: boolean;
Protected property ReadOnlyView: boolean;
Public property Row;
Public property RowCountRO: integer;
Public property SelCount: integer;
Public property SelectionAsHex: string;
Public property SelectionAsText: string;
Public property SelEnd: integer;
Public property SelStart: integer;
Protected property ShowRuler: boolean;
Protected property SwapNibbles: boolean;
Public property TopRow;
Protected property Translation: TMPHTranslationKind;
Public property UndoDescription: string;
Protected property Version: string;
Public property VisibleColCount;
Public property VisibleRowCount;
Protected property WantTabs: boolean;

Description

Protected property AllowInsertMode: boolean;

if set to False, switching between overwrite and insert mode is not allowed (see also InsertMode and NoSizeChange)

Public property AsHex: string;

retrieve or set the data as hex formatted string (00 01 02 03...)

Public property AsText: string;

retrieve or set the data as string

Public property Bookmark[Index: byte]: TMPHBookmark;

retrieve or set bookmarks programmatically (see also TMPHBookmark)

Protected property BookmarkBitmap: TBitmap;

bitmap containing 20 10x10 pixels pictures for bokkmarks (they are displayed in the offset gutter), the first ten pictures represent the bookmarks 0(10)..9, if they are set in the hexpane, the last 10 pics are shown if bookmarks are set in the character pane (see also TMPHBookmark)

Public property ByteChanged[index: integer]: boolean;

has the byte at the given position been modified ? (only in overwrite mode)

Protected property BytesPerColumn: integer;

number of bytes to show in each column

Protected property BytesPerRow: integer;

number of bytes to show in each row

Public property CanRedo: boolean;

is Redo possible?

Public property CanUndo: boolean;

is Undo possible?

Public property Canvas;

the control's canvas

Protected property CaretKind: TMPHCaretKind;

look of the editor's caret (see TMPHCaretKind)

Public property Col;

current column (grid column)

Public property ColCountRO: integer;

retrieves the number of columns (grid columns)

Protected property Colors: TMPHColors;

colors to display (see TMPHColors)

Public property CurrentValue: integer;

get the data value at the current caret position, returns -1 if an error occured

Public property Data[Index: integer]: char;

array to the data buffer's content

Public property DataPointer: Pointer;

pointer to the whole data buffer's contents

Public property DataSize: integer;

retrieves the amount of data in the data buffer

Protected property DrawGridLines: boolean;

if set to True, a grid is drawn

Protected property DrawGutter3D: boolean;

if set to True, a 3d line is drawn at the right of the offset gutter

Public property Filename: string;

name of the file that has been loaded into the data buffer

Protected property FocusFrame: boolean;

if FocusFrame is set to True, the current caret position will be displayed in the second field (hex - characters) as a dotted focus frame, if set to False, it will be shown as an ordinary rectangle

Protected property GraySelectionIfNotFocused: boolean;

if set to True and HideSelection is False, then the current selection will be grayed when the hex editor looses focus (the values from the Colors property will be converted to grayscale colors)

Protected property GutterWidth: integer;

width of the offset display gutter, if set to -1, automatically adjust the gutter's width

Public property HasFile: boolean;

has data been load from/saved to a file (or is the filename valid)

Protected property HexLowerCase: boolean;

if set to True, hex data and hex offsets are displayed in lower case

Protected property HideSelection: boolean;

hide the current selection when the hex editor looses focus (see also GraySelectionIfNotFocused)

Public property InCharField: boolean;

is the caret in the character or the hex pane ?

Protected property InsertMode: boolean;

insert mode (typed characters are inserted at the current position) or overwrite mode (typed characters replace values at the current position), see also AllowInsertMode, NoSizeChange and ReadOnlyView

Public property LeftCol;

first visible column

Protected property MaskChar: char;

replace whitespaces (#0..#31) with the following character in the character pane

Protected property MaxUndo: integer;

maximum memory that is used for undo storage (in bytes, approximately)

Public property Modified: boolean;

if True, changes have been made to the data buffer content

Public property MouseOverSelection: boolean;

returns True if the mouse cursor is positionned over selected data

Protected property NoSizeChange: boolean;

if set to True, the data size is readonly, e.g. no data may be appended, deleted or inserted, just overwriting is allowed. this also affects InsertMode.

Protected property OffsetFormat: string;

offset display ("line numbers") format, in the form
[r|c|<HEXNUM>%][-|<HEXNUM>!]<HEXNUM>:[Prefix]|[Suffix]
(<HEXNUM> means a number in hexadecimal format (without prefix/suffix))

- first field (up to the percent sign):


- second field (up to the exclamation mark):

- third field (up to the colon):

- fourth field (up to the pipe ('|') char):

- fifth (and last) field:

Protected property OnChange: TNotifyEvent;

this event is called on every data change (load/empty/undo/redo)

Protected property OnInvalidKey: TNotifyEvent;

this event is fired if an invalid character has been typed (like non-hex characters in the hex pane)

Protected property OnLoadSaveProgress: TMPHProgressEvent;

this event is called in LoadFromFile and SaveToFile routines, so a progress indicator may be updated (see also TMPHProgressEvent)

Protected property OnTopLeftChanged: TNotifyEvent;

this event is fired if the first visible row or column have been changed (e.g. on scrolling)

Public property ReadOnlyFile: boolean;

if True, the currently loaded file cannot be overwritten

Protected property ReadOnlyView: boolean;

if set to True, the data can not be edited, just cursor movement is allowed ("Hex Viewer" mode)

Public property Row;

current row (grid row)

Public property RowCountRO: integer;

retrieves the number of rows (grid rows)

Public property SelCount: integer;

retrieve the size of the selected data

Public property SelectionAsHex: string;

see GetSelectionAsHex and SetSelectionAsHex

Public property SelectionAsText: string;

see GetSelectionAsText and SetSelectionAsText

Public property SelEnd: integer;

retrieve or set the selection end

Public property SelStart: integer;

retrieve or set the selection start

Protected property ShowRuler: boolean;

if set to True, a ruler is shown above the first row

Protected property SwapNibbles: boolean;

if SwapNibbles is set to True, the hex pane will show all bytes in the order lower 4 bits-higher 4 bits (i.e. the value 192 dec = C0 hex will be drawn as 0C). if set to False, hex values will be displayed in usual order. this setting also affects hex data input and hex-string conversions

Public property TopRow;

first visible row (grid row)

Protected property Translation: TMPHTranslationKind;

translation kind of the data (used to show characters on and to handle key presses in the char pane), (see also TMPHTranslationKind)

Public property UndoDescription: string;

description of the next Undo action

Protected property Version: string;

current version of the hex editor component (returns the build data), readonly

Public property VisibleColCount;

retrieves the number of visible columns

Public property VisibleRowCount;

retrieves the number of visible rows

Protected property WantTabs: boolean;

if set to True, the Tab key is used to switch the caret between hex and character pane. if set to False, the Tab key can be used to switch between controls. then the combination CTRL+T is used to switch the panes


Generated by DIPasDoc 0.8.0 on Fri 25 Oct 2002 15:50:00