Class TCustomMPHexEditor
Unit
MPHexEditor
Declaration
type TCustomMPHexEditor = class()
Description
protected ancestor of the hex editor componentsFields
| Name | Description |
 |
FIsSelecting |
True: cells are currently to be selected |
 |
FUndoStorage |
memory stream which contains the undo/redo data |
Methods
Overview
Description
 |
procedure AdjustMetrics; |
adjust cell widths/heigths depending on font, offset format, bytes per row/column...
 |
procedure AppendBuffer(aBuffer: PChar; const aSize: integer; const UndoDesc: string = ''); |
append some data at the end of the data buffer
 |
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
 |
procedure Changed; virtual; |
call changed on every undo creation for OnChange event
 |
function CombineUndo(const aCount: integer; const sDesc: string = ''): boolean; |
combine two or more changes, so Undo
will discard the at once
 |
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
 |
procedure CopyToStream(strTo: TStream; const Operation: TMPHProgressKind; const FileName: string); |
copy the data to a stream
 |
procedure CreateEmptyFile(const TempName: string); |
empty the data buffer and set the filename (e.g. "Untitled")
 |
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
)
 |
procedure DeleteSelection(const UndoDesc: string = ''); |
delete the currently selected data
 |
function DropPosition: integer; |
returns the drop file position after a drag'n'drop operation
 |
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
 |
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
)
 |
function GetCursorPos: integer; |
get the current data position (depending on the cursor/caret)
 |
function GetDataSize: integer; |
get the size of the contained data
 |
function GetMemory(aIndex: integer): char; |
get the data at the specified position
 |
function GetOffsetString(const Position: cardinal): string; virtual; |
returns the given position as it would be drawn in the offset gutter, see also OffsetFormat
 |
function GetSelectionAsHex: string; |
returns the current selection in hex format ('00010203...') as string, uses SwapNibbles
 |
function GetSelectionAsText: string; |
returns a string containing the currently selected data
 |
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
 |
procedure HideDragCell; |
hide the drop position marker (see also ShowDragCell
)
 |
procedure InsertBuffer(aBuffer: PChar; const aSize, aPos: integer; const UndoDesc: string = ''); |
insert some data at the specified position into the data buffer
 |
function InsertNibble(const aPos: integer; const HighNibble: boolean; const UndoDesc: string = ''): boolean; |
insert 4 bits (0000) into the data buffer (see also DeleteNibble
)
 |
procedure LoadFromFile(const Filename: string); |
load the contents of a file into the data buffer
 |
procedure LoadFromStream(Strm: TStream); |
load the contents of a stream into the data buffer
 |
procedure OldCursor; |
reset the Cursor to the previous value (see also WaitCursor
)
 |
procedure PrepareOverwriteDiskFile; virtual; |
allows descendants to take special action if contents are to be saved to the file from where the data was load
 |
function Redo: boolean; |
discard the last undo action (only one single redo is possible)
 |
procedure ReplaceSelection(aBuffer: PChar; aSize: integer; const UndoDesc: string = ''); |
replace the currently selected data with some other data
 |
procedure ResetSelection(const aDraw: boolean); |
remove selection state from all data
 |
procedure ResetUndo; |
free the undo storage (discard all possible undo steps)
 |
function RowHeight: integer; |
returns the height of one row in pixels
 |
procedure SaveToFile(const Filename: string; const aUnModify: boolean = True); |
save the contents of the data buffer to a file
 |
procedure SaveToStream(Strm: TStream); |
save the contents of the data buffer into a stream
 |
function Seek(const aOffset, aOrigin: integer): integer; |
set the current position (like TStream.Seek)
 |
procedure SelectAll; |
select all data
 |
procedure SetMemory(aIndex: integer; const aChar: char); |
set the data at the specified position
 |
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
 |
procedure SetSelectionAsText(const s: string); |
replaces the currently selected data with the string's contents
 |
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
)
 |
function ShowDragCell(const X, Y: integer): integer; |
show a drop position marker on the cell at the given mouse cursor position (see also HideDragCell
)
 |
procedure Stream2Stream(strFrom, strTo: TStream; const Operation: TMPHProgressKind); |
copy a stream to a second one and fire the OnLoadSaveProgress handler
 |
function TranslateFromAnsiChar(const aByte: byte): char; |
translate a byte from Windows Codepage to the current Translation
(see also TranslateToAnsiChar
)
 |
function TranslateToAnsiChar(const aByte: byte): char; |
translate a byte from the current Translation
to the Windows Codepage (see also TranslateFromAnsiChar
)
 |
function Undo: boolean; |
undo the last modification, multiple undos are possible
 |
procedure UndoBeginUpdate; |
each call to UndoBeginUpdate increments an internal counter that prevents using undo storage and also disables undo functionality (see also UndoEndUpdate
)
 |
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
)
 |
procedure WaitCursor; |
store the current Cursor and set it to crHourGlass (see also OldCursor
)
Properties
Overview
Description
 |
property AllowInsertMode: boolean; |
if set to False, switching between overwrite and insert mode is not allowed (see also InsertMode
and NoSizeChange
)
 |
property AsHex: string; |
retrieve or set the data as hex formatted string (00 01 02 03...)
 |
property AsText: string; |
retrieve or set the data as string
retrieve or set bookmarks programmatically (see also TMPHBookmark
)
 |
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
)
 |
property ByteChanged[index: integer]: boolean; |
has the byte at the given position been modified ? (only in overwrite mode)
 |
property BytesPerColumn: integer; |
number of bytes to show in each column
 |
property BytesPerRow: integer; |
number of bytes to show in each row
 |
property CanRedo: boolean; |
is Redo
possible?
 |
property CanUndo: boolean; |
is Undo
possible?
 |
property Canvas; |
the control's canvas
 |
property CaretKind: TMPHCaretKind; |
look of the editor's caret (see TMPHCaretKind
)
 |
property Col; |
current column (grid column)
 |
property ColCountRO: integer; |
retrieves the number of columns (grid columns)
 |
property Colors: TMPHColors; |
colors to display (see TMPHColors
)
 |
property CurrentValue: integer; |
get the data value at the current caret position, returns -1 if an error occured
 |
property Data[Index: integer]: char; |
array to the data buffer's content
 |
property DataPointer: Pointer; |
pointer to the whole data buffer's contents
 |
property DataSize: integer; |
retrieves the amount of data in the data buffer
 |
property DrawGridLines: boolean; |
if set to True, a grid is drawn
 |
property DrawGutter3D: boolean; |
if set to True, a 3d line is drawn at the right of the offset gutter
 |
property Filename: string; |
name of the file that has been loaded into the data buffer
 |
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
 |
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)
 |
property GutterWidth: integer; |
width of the offset display gutter, if set to -1, automatically adjust the gutter's width
 |
property HasFile: boolean; |
has data been load from/saved to a file (or is the filename valid)
 |
property HexLowerCase: boolean; |
if set to True, hex data and hex offsets are displayed in lower case
 |
property HideSelection: boolean; |
hide the current selection when the hex editor looses focus (see also GraySelectionIfNotFocused
)
 |
property InCharField: boolean; |
is the caret in the character or the hex pane ?
 |
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
 |
property LeftCol; |
first visible column
 |
property MaskChar: char; |
replace whitespaces (#0..#31) with the following character in the character pane
 |
property MaxUndo: integer; |
maximum memory that is used for undo storage (in bytes, approximately)
 |
property Modified: boolean; |
if True, changes have been made to the data buffer content
 |
property MouseOverSelection: boolean; |
returns True if the mouse cursor is positionned over selected data
 |
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
.
 |
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):
- sets the "bytes per unit field" of the offset display format
- if it's set to 1, each row offset displays the data position in bytes
- if it's set to 2, each row offset displays the data position in words
- if it's set to 4, each row offset displays the data position in dwords
- if it's set to "r", each row offset displays the current row number (1st row=0, see also
BytesPerRow
) - if it's set to "c", each row offset displays the current column number (1st column=0, see also
BytesPerColumn
) - if this field is omitted, bytes per unit is set to 1
- second field (up to the exclamation mark):
- sets the minimum width of the number part, if the number is shorter, it will be padded by '0' chars at the left
- if this field reads -!, the the minimum width is automatically set to the longest number that can appear in the editor (the data's size)
- if this field is omitted, the minimum width is set to 1
- third field (up to the colon):
- sets the radix (base) of the offset format in hex notation
- set this to '10' (without quotes) for hexadecimal offset display, set it to '08' for octal and to '0a' for decimal offset display
- this field cannot be omitted, but the whole format string my be blank to avoid the display of offset identifiers
- fourth field (up to the pipe ('|') char):
- the prefix that is put in front of the "number" string (e.g. '0x' or '$' to show that numbers are in hex format)
- this field may be omitted (but not the pipe char!)
- fifth (and last) field:
- the suffix to put after the "number string" (e.g. 'h' to show hex numbers)
- this field may be omitted
 |
property OnChange: TNotifyEvent; |
this event is called on every data change (load/empty/undo/redo)
 |
property OnInvalidKey: TNotifyEvent; |
this event is fired if an invalid character has been typed (like non-hex characters in the hex pane)
 |
property OnLoadSaveProgress: TMPHProgressEvent; |
this event is called in LoadFromFile
and SaveToFile
routines, so a progress indicator may be updated (see also TMPHProgressEvent
)
 |
property OnTopLeftChanged: TNotifyEvent; |
this event is fired if the first visible row or column have been changed (e.g. on scrolling)
 |
property ReadOnlyFile: boolean; |
if True, the currently loaded file cannot be overwritten
 |
property ReadOnlyView: boolean; |
if set to True, the data can not be edited, just cursor movement is allowed ("Hex Viewer" mode)
 |
property Row; |
current row (grid row)
 |
property RowCountRO: integer; |
retrieves the number of rows (grid rows)
 |
property SelCount: integer; |
retrieve the size of the selected data
 |
property SelectionAsHex: string; |
see GetSelectionAsHex
and SetSelectionAsHex
 |
property SelectionAsText: string; |
see GetSelectionAsText
and SetSelectionAsText
 |
property SelEnd: integer; |
retrieve or set the selection end
 |
property SelStart: integer; |
retrieve or set the selection start
 |
property ShowRuler: boolean; |
if set to True, a ruler is shown above the first row
 |
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
 |
property TopRow; |
first visible row (grid row)
 |
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
)
 |
property UndoDescription: string; |
description of the next Undo
action
 |
property Version: string; |
current version of the hex editor component (returns the build data), readonly
 |
property VisibleColCount; |
retrieves the number of visible columns
 |
property VisibleRowCount; |
retrieves the number of visible rows
 |
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