Show
Ignore:
Timestamp:
07/08/06 18:42:16 (2 years ago)
Author:
jvw
Message:

HEX/ASCII (sector) editor control added

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/txlib/include/txwin.h

    r11 r14  
    8484   TXW_BUTTON        = 7,                       // button - push/radio/checkbox 
    8585   TXW_LISTBOX       = 8,                       // simple selection-list 
     86   TXW_HEXEDIT       = 9,                       // Hex (sector) editor 
    8687} TXWCLASS;                                     // end of enum "txwclass" 
    8788 
     
    315316} TXSTLINE;                                     // end of struct "txstatic" 
    316317 
    317 typedef struct txbutton 
     318typedef struct txbutton                         // any button class 
    318319{ 
    319320   BOOL               *checked;                 // button state 
     
    321322} TXBUTTON;                                     // end of struct "txbutton" 
    322323 
    323 typedef struct txlistbox 
     324typedef struct txlistbox                        // listbox, popup/submenu 
    324325{ 
    325326   short               cpos;                    // current position   (cursor) 
     
    334335   TXSELIST           *list;                    // actual selection list data 
    335336} TXLISTBOX;                                    // end of struct "txlistbox" 
     337 
     338 
     339typedef enum txhexedcmd 
     340{ 
     341   TXHE_CB_UPD_DESC,                            // update buffer desc (hex/dec) 
     342   TXHE_CB_INIT_POS,                            // load initial buffers 
     343   TXHE_CB_NEXT_BUF,                            // make 'next' buffer current 
     344   TXHE_CB_PREV_BUF,                            // make 'prev' buffer current 
     345   TXHE_CB_TO_START,                            // to start of object 
     346   TXHE_CB_TO_FINAL,                            // to end of object 
     347   TXHE_CB_GOTOITEM,                            // go to specified item (sn) 
     348   TXHE_CB_FINDDATA,                            // find data, goto found item 
     349   TXHE_CB_FNDAGAIN,                            // find data again, same data 
     350   TXHE_CB_WRITEBUF,                            // write (changed) buffer 
     351} TXHEXEDCMD;                                   // end of enum "txhexedcmd" 
     352 
     353 
     354typedef ULONG (* TXHEXEDIT_CALLBACK)            // Hex editor action callback 
     355( 
     356   ULONG               cmd,                     // IN    action command 
     357   struct txhexedit   *data                     // INOUT hexedit data 
     358); 
     359 
     360 
     361typedef struct txhebuf                          // hex editor data buffer 
     362{ 
     363   BYTE               *data;                    // start of data buffer 
     364   LLONG               start;                   // abs start position (ref) 
     365   ULONG               size;                    // size of buffer    (item) 
     366   TXLN                desc;                    // buffer description  (76) 
     367} TXHEBUF;                                      // end of struct "txhebuf" 
     368 
     369 
     370typedef struct txhexedit                        // hex editor control 
     371{ 
     372   //- note: a negative offset in the buffer means the current item (buffer) 
     373   //-       is NOT at the top of the display, but further down, and part of 
     374   //-       the PREV buffer is also visible. (0 = buffer start at top-left) 
     375 
     376   LONG                posCurBuf;               // offset in buffer, 1st byte 
     377   LONG                posCursor;               // offset in screen, cursor 
     378   USHORT              hexLsb;                  // hex LSB nibble   (0 or 1) 
     379   USHORT              rows;                    // nr of rows shown    (16) 
     380   USHORT              cols;                    // nr of bytes per row (16) 
     381   BOOL                autocols;                // get 8/16/32/cols from width 
     382   BOOL                ascii;                   // cursor in ascii area 
     383   BOOL                decimal;                 // use decimal positions 
     384   TXHEBUF            *prev;                    // buffer BEFORE current one 
     385   TXHEBUF            *curr;                    // current buffer (item) 
     386   TXHEBUF            *next;                    // buffer AFTER  current one 
     387   BYTE               *diff;                    // difference buf (original) 
     388   ULONG               diffSize;                // size of difference buf 
     389   ULONG               currCrc;                 // 32-bit buf CRC (original) 
     390   void               *userdata;                // application user data 
     391   TXHEXEDIT_CALLBACK  actionCallback;          // application action handler 
     392} TXHEXEDIT;                                    // end of struct "txhexedit" 
    336393 
    337394 
     
    363420      TXBUTTON         bu;                      // push- radio or checkbox 
    364421      TXLISTBOX        lb;                      // listbox with selection list 
     422      TXHEXEDIT        he;                      // hex editor control 
    365423   }; 
    366424} TXWINDOW;                                     // end of struct "txwindow" 
     
    409467#define TXStdStatic(    text) "",   TXW_STATIC,     0, NULL, TXWgStatic(text) 
    410468#define TXStdStline(    text) "",   TXW_STLINE,     0, NULL, TXWgStline(text) 
    411 #define TXStdButton(var,text) "",   TXW_BUTTON,     0, NULL, TXWgButton(&(var),text) 
     469#define TXStdButton(var,text) "",   TXW_BUTTON,     0, NULL, TXWgButton(var,text) 
    412470#define TXStdLstBox(v,p,text) text, TXW_LISTBOX,    0, NULL, TXWgListbox((p),0,0,0,0,0,0,0,0,(v)) 
    413471 
     
    492550#define TXVS_CLOSE_BUTTON     0x01000000        // include close button in border 
    493551 
     552// TXHE_ hex editor control styles 
     553#define TXHE_CLOSE_BUTTON     0x01000000        // include close button in border 
     554#define TXHE_WRITE_PROMPT     0x10000000        // prompt before write-back 
     555#define TXHE_TAB_HTOGGLE      0x20000000        // TAB toggles hex/ascii 
     556 
    494557//- often used Dialog frame/child window combinations 
    495 #define TXWS_CANVAS   TXWS_DISABLED    | TXWS_VISIBLE     | TXWS_SAVEBITS | TXWS_SYNCPAINT 
     558#define TXWS_CANVAS   TXWS_DISABLED    | TXWS_VISIBLE      | TXWS_SAVEBITS    \ 
     559                                       | TXWS_SYNCPAINT 
    496560#define TXWS_DIALOG   TXWS_STDWINDOW   | TXWS_FOURBORDERS 
    497 #define TXWS_DFRAME   TXWS_DIALOG      | TXWS_DISABLED    | TXWS_MOVEABLE 
     561#define TXWS_DFRAME   TXWS_DIALOG      | TXWS_DISABLED     | TXWS_MOVEABLE 
    498562#define TXWS_FRAMED   TXWS_CHILDWINDOW | TXWS_FOURBORDERS 
    499 #define TXWS_PBUTTON  TXWS_FRAMED      | TXBS_PUSHBUTTON  | TXWS_FOCUS_PAINT 
    500 #define TXWS_AUTORAD  TXWS_CHILDWINDOW | TXBS_AUTORADIO   | TXWS_FOCUS_PAINT 
    501 #define TXWS_RADIOB   TXWS_CHILDWINDOW | TXBS_RADIOBUTTON | TXWS_FOCUS_PAINT 
    502 #define TXWS_AUTOCHK  TXWS_CHILDWINDOW | TXBS_AUTOCHECK   | TXWS_FOCUS_PAINT 
    503 #define TXWS_CHECKB   TXWS_CHILDWINDOW | TXBS_CHECKBOX    | TXWS_FOCUS_PAINT 
    504 #define TXWS_EFOCUS   TXWS_LEFTJUSTIFY | TXWS_BRACKETSIDE | TXWS_FOCUS_PAINT 
     563#define TXWS_PBUTTON  TXWS_FRAMED      | TXBS_PUSHBUTTON   | TXWS_FOCUS_PAINT 
     564#define TXWS_AUTORAD  TXWS_CHILDWINDOW | TXBS_AUTORADIO    | TXWS_FOCUS_PAINT 
     565#define TXWS_RADIOB   TXWS_CHILDWINDOW | TXBS_RADIOBUTTON  | TXWS_FOCUS_PAINT 
     566#define TXWS_AUTOCHK  TXWS_CHILDWINDOW | TXBS_AUTOCHECK    | TXWS_FOCUS_PAINT 
     567#define TXWS_CHECKB   TXWS_CHILDWINDOW | TXBS_CHECKBOX     | TXWS_FOCUS_PAINT 
     568#define TXWS_EFOCUS   TXWS_LEFTJUSTIFY | TXWS_BRACKETSIDE  | TXWS_FOCUS_PAINT 
    505569#define TXWS_EF_BASE  TXWS_EFOCUS      | TXES_DLGE_FIELD 
    506 #define TXWS_ENTRYF   TXWS_CHILD_BASE  | TXWS_EF_BASE     | TXWS_SIDEBORDERS 
     570#define TXWS_ENTRYF   TXWS_CHILD_BASE  | TXWS_EF_BASE      | TXWS_SIDEBORDERS 
    507571#define TXWS_ENTRYT   TXWS_ENTRYF      | TXWS_TITLEBORDER 
    508 #define TXWS_ENTRYB   TXWS_CHILDWINDOW | TXWS_EF_BASE     | TXWS_SIDEBORDERS \ 
     572#define TXWS_ENTRYB   TXWS_CHILDWINDOW | TXWS_EF_BASE      | TXWS_SIDEBORDERS \ 
    509573                                       | TXWS_BRACKETSIDE 
    510 #define TXWS_ENTRYBT  TXWS_ENTRYB      | TXWS_TITLEBORDER | TXWS_TF_TEXTONLY 
    511 #define TXWS_OUTPUT   TXWS_CHILD_BASE  | TXWS_DISABLED    | TXWS_LEFTJUSTIFY 
     574#define TXWS_ENTRYBT  TXWS_ENTRYB      | TXWS_TITLEBORDER  | TXWS_TF_TEXTONLY 
     575#define TXWS_OUTPUT   TXWS_CHILD_BASE  | TXWS_DISABLED     | TXWS_LEFTJUSTIFY 
    512576#define TXWS_OUTPUTT  TXWS_OUTPUT      | TXWS_TITLEBORDER 
    513577#define TXWS_DROPMENU TXWS_CHILD_BASE  | TXLS_DROP_MENU 
    514578#define TXWS_A_MENU   TXWS_DROPMENU    | TXWS_TITLEBORDER 
    515 #define TXWS_D_DOWN   TXWS_CHILD_BASE  | TXWS_TITLEBORDER | TXLS_DROP_VALUE 
    516 #define TXWS_D_SPIN   TXWS_D_DOWN      | TXWS_BRACKETSIDE | TXWS_SIDEBORDERS \ 
    517                                        | TXLS_SPIN_WRAP   | TXWS_FOCUS_PAINT 
    518 #define TXWS_DSPINB   TXWS_CHILDWINDOW | TXLS_DROP_VALUE  | TXWS_BRACKETSIDE \ 
    519                     | TXWS_SIDEBORDERS | TXLS_SPIN_WRAP   | TXWS_FOCUS_PAINT 
    520 #define TXWS_DSPINBT  TXWS_DSPINB      | TXWS_TITLEBORDER | TXWS_TF_TEXTONLY 
    521  
     579#define TXWS_D_DOWN   TXWS_CHILD_BASE  | TXWS_TITLEBORDER  | TXLS_DROP_VALUE 
     580#define TXWS_D_SPIN   TXWS_D_DOWN      | TXWS_BRACKETSIDE  | TXWS_SIDEBORDERS \ 
     581                                       | TXLS_SPIN_WRAP    | TXWS_FOCUS_PAINT 
     582#define TXWS_DSPINB   TXWS_CHILDWINDOW | TXLS_DROP_VALUE   | TXWS_BRACKETSIDE \ 
     583                    | TXWS_SIDEBORDERS | TXLS_SPIN_WRAP    | TXWS_FOCUS_PAINT 
     584#define TXWS_DSPINBT  TXWS_DSPINB      | TXWS_TITLEBORDER  | TXWS_TF_TEXTONLY 
     585 
     586#define TXWS_HEXECTL  TXWS_CHILDWINDOW | TXHE_TAB_HTOGGLE 
     587#define TXWS_HEXEDIT  TXWS_HEXECTL     | TXHE_CLOSE_BUTTON | TXWS_FOURBORDERS 
    522588 
    523589// TXWM_COMMAND msg source codes 
     
    669735#define TXLN_ENTER                   5 
    670736 
     737// Hex edit tandard dialog flags 
     738#define TXHE_MOVEABLE                0x2000 
    671739 
    672740// Scroll-buffer related color conversions 
     
    9631031   cMLEntTextStand,                             // Multi-line entry field text 
    9641032   cMLEntTextFocus, 
     1033   cHexEdCurByteChg,                            // Hex Editor control 
     1034   cHexEdCursorByte, 
     1035   cHexEdHexByteStd, 
     1036   cHexEdHexByteChg, 
     1037   cHexEdAscByteStd, 
     1038   cHexEdAscBracket, 
     1039   cHexEdRelPosPrev, 
     1040   cHexEdRelPosCurr, 
     1041   cHexEdRelPosNext, 
     1042   cHexEdAbsBytePos, 
     1043   cHexEdAbsByteCur, 
     1044   cHexEdRelCursorP, 
     1045   cHexEdButtonText, 
     1046   cHexEdButBracket, 
     1047   cHexEdByteNumber, 
     1048   cHexEdItemSnText, 
     1049   cHexEdItemHlight, 
     1050   cHexEdModifyText, 
    9651051   cNrOfSchemeColors 
    9661052} TXW_WINCOLORS;                                // end of enum "txw_wincolors" 
     
    10231109#define  TX_Red_on_White       (TXwCnW + TXwCNR) 
    10241110#define  TX_Magenta_on_White   (TXwCnW + TXwCNM) 
     1111#define  TX_Brown_on_White     (TXwCnW + TXwCNY) 
    10251112#define  TX_Yellow_on_White    (TXwCnW + TXwCBY) 
    10261113#define  TX_Grey_on_White      (TXwCnW + TXwCBZ) 
     
    10431130#define  TX_Black_on_Magenta   (TXwCnM + TXwCNZ) 
    10441131#define  TX_White_on_Magenta   (TXwCnM + TXwCNW) 
     1132#define  TX_Lcyan_on_Magenta   (TXwCnM + TXwCBC) 
    10451133#define  TX_Lwhite_on_Magenta  (TXwCnM + TXwCBW) 
    10461134#define  TX_Magenta_on_Magenta (TXwCnM + TXwCNM) 
     
    20372125); 
    20382126 
    2039 /*======== Help related functions, TXWHELP.C ================================*/ 
     2127/*======== Help related functions, TXWHELP.C ================================                    */ 
    20402128 
    20412129#define TXHELPITEM(nr,title) \ 
     
    20642152); 
    20652153 
     2154/*======== Hex Editor standard dialog, TXWHEXED.C ===========================*/ 
     2155 
     2156// Initialize the Hex-editor dialog/control data structures 
     2157// To be called by CUSTOM hex-editor control users (not standard dialog) 
     2158BOOL txwInitHexeditDialogs 
     2159( 
     2160   void 
     2161); 
     2162 
     2163// Display standard Hex editor dialog 
     2164ULONG txwHexEditor 
     2165( 
     2166   TXWHANDLE           parent,                  // IN    parent window 
     2167   TXWHANDLE           owner,                   // IN    owner  window 
     2168   TXHEXEDIT          *hedat,                   // IN    hex edit data 
     2169   char               *title,                   // IN    title for the dialog 
     2170   ULONG               helpid,                  // IN    help on message 
     2171   ULONG               flags                    // IN    specification flags 
     2172); 
     2173 
    20662174/*======== Window drawing functions, TXWDRAW.C ==============================*/ 
    20672175 
     
    20942202); 
    20952203 
     2204#define txwStringAt(r,c,s,a) txwDrawCharStrCol(hwnd,r,c,s,a) 
    20962205// Draw a character-string at position in specified color, using clip-rect 
    20972206void txwDrawCharStrCol