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

Class TCustomMPHexEditor

Unit

MPHexEditor

Declaration

type TCustomMPHexEditor = class(TCustomGrid)

Description

protected ancestor of the hex editor components

Methods

Overview

Public procedure AddSelectionUndo(const AStart, ACount: integer);
Protected procedure AdjustMetrics;
Public procedure AppendBuffer(aBuffer: PChar; const aSize: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = True);
Protected procedure BookmarkChanged; virtual;
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 = '');
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 = '');
Public function DisplayEnd: integer;
Public function DisplayStart: integer;
Protected procedure DoSetCellWidth(const Index: integer; Value: integer);
Protected function DropPosition: integer;
Public function Find(aBuffer: PChar; aCount: integer; const aStart, aEnd: integer; const IgnoreCase: boolean): integer;
Public function FindWithWildcard(aBuffer: PChar; aCount: integer; const aStart, aEnd: integer; const IgnoreCase: boolean; const Wildcard: char): integer;
Public function GetAnyOffsetString(const Position: integer): string; virtual;
Public function GetCursorPos: integer;
Protected function GetDataSize: integer;
Public function GetOffsetString(const Position: cardinal): string; virtual;
Protected function GetSelectionAsHex: string;
Protected function GetSelectionAsText: string;
Public function GetTopLeftPosition(var oInCharField: boolean): integer;
Public function GotoBookmark(const Index: integer): boolean;
Public procedure HideDragCell;
Public procedure InsertBuffer(aBuffer: PChar; const aSize, aPos: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = True);
Public function InsertNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean;
Public function IsSelected(const APosition: integer): boolean;
Public procedure LoadFromFile(const Filename: string);
Public procedure LoadFromStream(Strm: TStream);
Protected procedure OldCursor;
Public function PrepareFindReplaceData(StrData: string; const IgnoreCase, IsText: boolean): string;
Protected procedure PrepareOverwriteDiskFile; virtual;
Public procedure ReadBuffer(var Buffer; const Index, Count: Integer);
Public function Redo: boolean;
Public function Replace(aBuffer: PChar; aPosition, aOldCount, aNewCount: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = False): integer;
Public procedure ReplaceSelection(aBuffer: PChar; aSize: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = True);
Public procedure ResetSelection(const aDraw: boolean);
Public procedure ResetUndo;
Public function RowHeight: integer;
Public procedure SaveRangeToStream(Strm: TStream; const APosition, ACount: 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 SeekToEOF;
Public procedure SelectAll;
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; const Count: integer = -1);
Public procedure SyncView(Source: TCustomMPHexEditor);
Public function TranslateFromAnsiChar(const aByte: byte): char;
Public function TranslateToAnsiChar(const aByte: byte): char;
Public function Undo: boolean;
Public function UndoBeginUpdate: integer; virtual;
Public function UndoEndUpdate: integer; virtual;
Public procedure UpdateGetOffsetText;
Protected procedure WaitCursor;
Public procedure WriteBuffer(const Buffer; const Index, Count: Integer); virtual;

Description

Public procedure AddSelectionUndo(const AStart, ACount: integer);

store a selection as undo record, so you can restore the selection start and end by using Undo. this can be useful e.g. to show position of replaced data

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 = ''; const MoveCursor: Boolean = True);

append some data at the end of the data buffer

Protected procedure BookmarkChanged; virtual;

fire OnBookmarkChanged

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

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

Public function DisplayEnd: integer;

return the offset of the last displayed data

Public function DisplayStart: integer;

return the offset of the first displayed data

Protected procedure DoSetCellWidth(const Index: integer; Value: integer);

 

Protected function DropPosition: integer;

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

Public function Find(aBuffer: PChar; aCount: integer; const aStart, aEnd: integer; const IgnoreCase: 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

NOTE: call PrepareFindReplaceData before the first Find call

Public function FindWithWildcard(aBuffer: PChar; aCount: integer; const aStart, aEnd: integer; const IgnoreCase: boolean; const Wildcard: char): integer;

searches for text or data in the data buffer using a wildcard character 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
- Wildcard: this character is a placeholder for any character

NOTE: call PrepareFindReplaceData before the first FindWithWildcard call

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

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 function GotoBookmark(const Index: integer): boolean;

call this procedure to navigate to a bookmarked position

Public procedure HideDragCell;

hide the drop position marker (see also ShowDragCell)

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

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 function IsSelected(const APosition: integer): boolean;

is the given position part of the selection?

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)

Public function PrepareFindReplaceData(StrData: string; const IgnoreCase, IsText: boolean): string;

 

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 procedure ReadBuffer(var Buffer; const Index, Count: Integer);

read data into a buffer

Public function Redo: boolean;

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

Public function Replace(aBuffer: PChar; aPosition, aOldCount, aNewCount: integer; const UndoDesc: string = ''; const MoveCursor: Boolean = False): integer;

replace some amount of data

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

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 SaveRangeToStream(Strm: TStream; const APosition, ACount: integer);

save a range of bytes to a stream

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 SeekToEOF;

seek behind the last position if InsertMode = True, goto last position otherwise

Public procedure SelectAll;

select all data

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; const Count: integer = -1);

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

Public procedure SyncView(Source: TCustomMPHexEditor);

synchronize another TCustomMPHexEditor view (top, left, selection)

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 function UndoBeginUpdate: integer; virtual;

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; virtual;

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)

Public procedure UpdateGetOffsetText;

call this function if the external offset formatting changed (see OnGetOffsetText)

Protected procedure WaitCursor;

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

Public procedure WriteBuffer(const Buffer; const Index, Count: Integer); virtual;

write a buffer to the file data

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 BytesPerBlock: Integer;
Protected property BytesPerColumn: integer;
Protected property BytesPerRow: integer;
Protected property BytesPerUnit: 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]: Byte;
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 IsCharFieldCol[const ACol: integer]: 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;
Public property OnBookmarkChanged: TNotifyEvent;
Protected property OnChange: TNotifyEvent;
Protected property OnDrawCell: TMPHDrawCellEvent;
Protected property OnGetOffsetText: TMPHGetOffsetTextEvent;
Protected property OnInvalidKey: TNotifyEvent;
Protected property OnLoadSaveProgress: TMPHProgressEvent;
Protected property OnSelectionChanged: TNotifyEvent;
Protected property OnTopLeftChanged: TNotifyEvent;
Public property PositionAtCursor[const ACol, ARow: integer]: integer;
Public property ReadOnlyFile: boolean;
Protected property ReadOnlyView: boolean;
Public property Row;
Public property RowCountRO: integer;
Protected property RulerBytesPerUnit: integer;
Public property SelCount: integer;
Public property SelectionAsHex: string;
Public property SelectionAsText: string;
Public property SelEnd: integer;
Public property SelStart: integer;
Protected property SeparateBlocksInCharField: boolean;
Protected property ShowPositionIfNotFocused: Boolean;
Protected property ShowRuler: boolean;
Protected property SwapNibbles: boolean;
Public property TopRow;
Protected property Translation: TMPHTranslationKind;
Public property UndoDescription: string;
Protected property UnicodeBigEndian: Boolean;
Protected property UnicodeChars: Boolean;
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 BytesPerBlock: Integer;

how many bytes form one block in a row? blocks are separated by a one character wide blank. -1 means no block separation (see also SeparateBlocksInCharField)

Protected property BytesPerColumn: integer;

number of bytes to show in each column

Protected property BytesPerRow: integer;

number of bytes to show in each row

Protected property BytesPerUnit: integer;

setting this property changes the way how mouse/keyboard selection works:
e.g. if set to two, two bytes will be treated as a unit, that means you cannot select a single byte, only two, four, six... bytes can be selected. also drag/drop and clipboard pasting is affected (data size is always a multiple of BytesPerUnit). See also RulerBytesPerUnit

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]: Byte;

array to the data buffer's content

Public property DataSize: integer;

retrieves or stores 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 IsCharFieldCol[const ACol: integer]: Boolean;

is the given col in the hex or the character pane?

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:

Public property OnBookmarkChanged: TNotifyEvent;

this event is fired when a bookmark is added/modifed/removed

Protected property OnChange: TNotifyEvent;

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

Protected property OnDrawCell: TMPHDrawCellEvent;

use this event to implement owner drawing. see also TMPHDrawCellEvent

Protected property OnGetOffsetText: TMPHGetOffsetTextEvent;

if this handler is assigned, the OffsetFormat is not used to create "line numbers", but the application tells the editor how to format the offset text

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 OnSelectionChanged: TNotifyEvent;

this event is fired when the selection/caret position has changed

Protected property OnTopLeftChanged: TNotifyEvent;

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

Public property PositionAtCursor[const ACol, ARow: integer]: integer;

calculate a data position from a col/row pair

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)

Protected property RulerBytesPerUnit: integer;

setting this property affects the offset/ruler drawing:
e.g. if set to two, two bytes will be treated as a unit, that means the offset and ruler values will step by one each two bytes. if this property is set to -1, it will use the value of the BytesPerUnit property

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 SeparateBlocksInCharField: boolean;

if BytesPerBlock is used, this property tells the editor whether it should separate blocks of bytes in the character pane too or not

Protected property ShowPositionIfNotFocused: Boolean;

mark the current position even if the editor is not focused

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 UnicodeBigEndian: Boolean;

if set to True, big endian unicode mode is used if UnicodeChars is enabled

Protected property UnicodeChars: Boolean;

if set to True, the character pane displays unicode characters and the BytesPerUnit property is set to 2. Translation is set to tkAsIs. BytesPerRow and BytesPerColumn must be a multiple of two to be able to use the unicode mode. see also UnicodeBigEndian

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.6 on Mi 10. Sep 2003 19:43:56