From f9ff908030e822c1332c6eb100a4656507fb454b Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 25 Aug 2011 23:14:04 +0000 Subject: [PATCH] 2011-08-25 16:02 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbcuied/cu_object.prg * contrib/hbcuied/cu_utlty.prg + Implemented: K_ALT_P preview. Preview takes following considerations: 0. Background color is always set to "W/B". You can change this behavior with a BOX covering entire screen. 1. Rows and columns of the screen are calculated based on maximum ending row and column of objects defined. if those values are greater than 25/80 then one more row and column is added to them, otherwise, rows/columns are 25/80 as in standard screen. 2. If COLOR is defined as a literal value enclosed in quotes, then this value is used otherwise "W/B" is used. 3. If PICTURE is defined as literal string enclosed in quotes, then it is used, otherwise left. For numeric fields, picture is always generated as "9999??[.9?]" based on field length and decimals. --- harbour/ChangeLog | 24 +++++ harbour/contrib/hbcuied/cu_object.prg | 134 +++++++++++++++++++++++++- harbour/contrib/hbcuied/cu_utlty.prg | 99 ++++++++++++------- 3 files changed, 217 insertions(+), 40 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ffa30ca3c4..2286d1d5dd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,30 @@ The license applies to all entries newer than 2009-04-28. */ +2011-08-25 16:02 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbcuied/cu_object.prg + * contrib/hbcuied/cu_utlty.prg + + Implemented: K_ALT_P preview. + Preview takes following considerations: + + 0. Background color is always set to "W/B". + You can change this behavior with a BOX covering + entire screen. + + 1. Rows and columns of the screen are calculated based + on maximum ending row and column of objects defined. + if those values are greater than 25/80 then one more + row and column is added to them, otherwise, + rows/columns are 25/80 as in standard screen. + + 2. If COLOR is defined as a literal value enclosed in + quotes, then this value is used otherwise "W/B" is used. + + 3. If PICTURE is defined as literal string enclosed + in quotes, then it is used, otherwise left. For numeric + fields, picture is always generated as "9999??[.9?]" based + on field length and decimals. + 2011-08-24 17:21 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbcuied/cu_object.prg * contrib/hbcuied/cu_utlty.prg diff --git a/harbour/contrib/hbcuied/cu_object.prg b/harbour/contrib/hbcuied/cu_object.prg index 22abc718a7..7db33dc328 100644 --- a/harbour/contrib/hbcuied/cu_object.prg +++ b/harbour/contrib/hbcuied/cu_object.prg @@ -199,6 +199,7 @@ CLASS hbCUIEditor METHOD scrOrdGets() METHOD scrUpdateUndo() METHOD scrUndo() + METHOD scrPreview() ENDCLASS @@ -858,6 +859,8 @@ METHOD hbCUIEditor:operate() ::scrSave() ENDIF EXIT + CASE ::nLastKey == K_ALT_P + ::scrPreview() CASE ::nLastKey == K_ALT_L ::scrLoad( .t. ) CASE ::nLastKey == K_ALT_S @@ -2384,24 +2387,23 @@ METHOD hbCUIEditor:scrAddTxt( nMode ) ENDIF IF len( s1 ) == 0 .AND. len( s2 ) == 0 VouchAShrink( txt_, nTxt ) - IF empty( txt_ ) - aadd( txt_, ::scrObjBlank() ) - ENDIF ENDIF ENDIF ENDIF IF !empty( txt_ ) DO WHILE .t. - IF( n := ascan( txt_, {|e_| e_[ OBJ_TO_COL ] < e_[ OBJ_COL ] } ) ) > 0 + IF ( n := ascan( txt_, {|e_| e_[ OBJ_TO_COL ] < e_[ OBJ_COL ] } ) ) > 0 VouchAShrink( txt_, n ) ELSE EXIT ENDIF ENDDO + #if 0 IF empty( txt_ ) aadd( txt_, ::scrObjBlank() ) ENDIF + #endif // CLUB DIFFERENT TEXT OBJECTS IF THESE ARE ADJACENT asort( txt_ , , , {|e_,f_| e_[ OBJ_COL ] < f_[ OBJ_COL ] } ) @@ -2803,3 +2805,127 @@ METHOD hbCUIEditor:scrGetProperty( nObj ) /*----------------------------------------------------------------------*/ +METHOD hbCUIEditor:scrPreview() + LOCAL nRows, nCols, a_, cColor, aScr, cPic + LOCAL nMaxRows := 0 + LOCAL nMaxCols := 0 + LOCAL getlist := {} + LOCAL g_ := {} + + aeval( ::obj_, {|e_| nMaxRows := max( e_[ OBJ_TO_ROW ], nMaxRows ), nMaxCols := max( e_[ OBJ_TO_COL ], nMaxCols ) } ) + + IF nMaxRows > 25 + nMaxRows++ + ELSE + nMaxRows := 25 + ENDIF + IF nMaxCols > 80 + nMaxCols++ + ELSE + nMaxCols := 80 + ENDIF + + nRows := maxrow() + nCols := maxcol() + aScr := VouchWndSave( 0,0,maxrow(),maxcol() ) + vstk_push() + + ::scrOrdObj() + aeval( ::obj_, {|e_| iif( e_[ OBJ_TYPE ] == OBJ_O_FIELD, aadd( g_, VouchVrbBlank( e_ ) ), aadd( g_, NIL ) ) } ) + + SetColor( "W/B" ) + SetCursor( 0 ) + SetMode( nMaxRows, nMaxCols ) + CLS + + FOR EACH a_ IN ::obj_ + cColor := VouchGetColor( a_[ OBJ_TYPE ], a_[ OBJ_COLOR ] ) + + SWITCH a_[ OBJ_TYPE ] + CASE OBJ_O_BOX + DispBox( a_[ OBJ_ROW ]-1, a_[ OBJ_COL ]-1, a_[ OBJ_TO_ROW ]-1, a_[ OBJ_TO_COL ]-1, a_[ OBJ_BOX_SHAPE ] + iif( a_[ OBJ_PATTERN ] == "CLEAR", "", " " ), cColor ) + EXIT + CASE OBJ_O_TEXT + @ a_[ OBJ_ROW ]-1, a_[ OBJ_COL ]-1 SAY a_[ OBJ_TEXT ] COLOR cColor + EXIT + CASE OBJ_O_FIELD + cPic := VouchGetPic( a_[ OBJ_F_TYPE ], a_[ OBJ_F_PIC ], a_[ OBJ_F_LEN ], a_[ OBJ_F_DEC ] ) + IF ! empty( cPic ) + @ a_[ OBJ_ROW ]-1, a_[ OBJ_COL ]-1 GET g_[ a_:__enumIndex() ] COLOR cColor PICTURE cPic + ELSE + @ a_[ OBJ_ROW ]-1, a_[ OBJ_COL ]-1 GET g_[ a_:__enumIndex() ] COLOR cColor + ENDIF + EXIT + ENDSWITCH + NEXT + + IF len( getlist ) > 0 + READ + ELSE + DO WHILE inkey() != K_ESC; ENDDO + ENDIF + + SetMode( nRows + 1, nCols + 1 ) + VouchWndRest( aScr ) + vstk_pop() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION VouchGetPic( cType, cPic, nLen, nDec ) + LOCAL cP := "" + + IF cType == "N" + cP := iif( nDec > 0, replicate( "9", nLen - nDec - 1 ) + "." + replicate( "9", nDec ), replicate( "9", nLen ) ) + ELSE + IF left( cPic,1 ) == '"' .and. right( cPic,1 ) == '"' + cP := substr( cPic, 2, len( cPic ) - 2 ) + ELSEIF left( cPic,1 ) == "'" .and. right( cPic,1 ) == "'" + cP := substr( cPic, 2, len( cPic ) - 2 ) + ENDIF + ENDIF + + RETURN cP + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION VouchVrbBlank( o_ ) + + SWITCH o_[ OBJ_F_TYPE ] + CASE "C" + RETURN space( o_[ OBJ_F_LEN ] ) + CASE "M" + RETURN space( 10 ) + CASE "N" + RETURN 0 + CASE "D" + RETURN ctod( "" ) + CASE "L" + RETURN .f. + ENDSWITCH + + RETURN "" + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION VouchGetColor( cType, cColor ) + + IF left( cColor,1 ) == '"' .and. right( cColor,1 ) == '"' + RETURN cColor + ELSEIF left( cColor,1 ) == "'" .and. right( cColor,1 ) == "'" + RETURN cColor + ELSE + IF cType == OBJ_O_BOX + RETURN "W/B" + ELSEIF cType == OBJ_O_TEXT + RETURN "W/B" + ELSEIF cType == OBJ_O_FIELD + RETURN "N/W,GR+/BG" + ENDIF + ENDIF + + RETURN "W/B" + +/*----------------------------------------------------------------------*/ + \ No newline at end of file diff --git a/harbour/contrib/hbcuied/cu_utlty.prg b/harbour/contrib/hbcuied/cu_utlty.prg index 967eaf771f..801672022c 100644 --- a/harbour/contrib/hbcuied/cu_utlty.prg +++ b/harbour/contrib/hbcuied/cu_utlty.prg @@ -586,7 +586,7 @@ FUNCTION VouchMenuM( id,nInit,msg ) //----------------------------------------------------------------------// -STATIC FUNCTION vstk_push() +FUNCTION vstk_push() s_vid_stk := chr( set( _SET_CURSOR ) ) + ; chr( row() ) + chr( col() ) + ; pad( setcolor(), LEN_COL_STR ) + ; @@ -595,7 +595,7 @@ STATIC FUNCTION vstk_push() //----------------------------------------------------------------------// -STATIC FUNCTION vstk_pop() +FUNCTION vstk_pop() IF len( s_vid_stk ) > 0 setcursor( asc( substr( s_vid_stk, 1, 1 ) ) ) @ asc( substr( s_vid_stk, 2, 1 ) ), asc( substr( s_vid_stk, 3, 1 ) ) SAY "" @@ -1182,22 +1182,22 @@ STATIC FUNCTION DispHelp( cToken ) @ 4, 2 SAY "F4 " COLOR "GR+/B" /// 5 3 C 59 0 @ 4, 10 SAY "Properties of current object in a selectable/editable list." - /// 6 3 C 7 0 - @ 5, 2 SAY "F5 " COLOR "GR+/B" - /// 7 3 C 64 0 + /// 6 3 C 64 0 @ 5, 10 SAY "Edit current object: Text-no action, Box-resize action, Field-F4" + /// 7 3 C 7 0 + @ 5, 2 SAY "F5 " COLOR "GR+/B" /// 8 3 C 7 0 @ 6, 2 SAY "F6 " COLOR "GR+/B" /// 9 3 C 40 0 @ 6, 10 SAY "Selects current object (Box/Field/Text)." - /// 10 3 C 39 0 - @ 7, 10 SAY "Copies current object (Box/Field/Text)." - /// 11 3 C 7 0 + /// 10 3 C 7 0 @ 7, 2 SAY "F7 " COLOR "GR+/B" - /// 12 3 C 7 0 - @ 8, 2 SAY "F8 " COLOR "GR+/B" - /// 13 3 C 48 0 + /// 11 3 C 39 0 + @ 7, 10 SAY "Copies current object (Box/Field/Text)." + /// 12 3 C 48 0 @ 8, 10 SAY "Pastes copied object at current cursor position." + /// 13 3 C 7 0 + @ 8, 2 SAY "F8 " COLOR "GR+/B" /// 14 3 C 7 0 @ 9, 2 SAY "F9 " COLOR "GR+/B" /// 15 3 C 32 0 @@ -1218,43 +1218,47 @@ STATIC FUNCTION DispHelp( cToken ) @ 14, 10 SAY "Cursor is positioned at the next to last column of last object." /// 23 3 C 7 0 @ 14, 2 SAY "End " COLOR "GR+/B" - /// 24 3 C 7 0 - @ 15, 2 SAY "Alt_Z " COLOR "GR+/B" - /// 25 3 C 5 0 - @ 15, 10 SAY "Undo." - /// 26 3 C 54 0 + /// 24 3 C 54 0 @ 16, 10 SAY "Inserts blank row, all objects are moved down one row." - /// 27 3 C 7 0 + /// 25 3 C 7 0 @ 16, 2 SAY "Alt_N " COLOR "GR+/B" - /// 28 3 C 66 0 + /// 26 3 C 66 0 @ 17, 10 SAY "Deletes objects on current row, next objects are moved up one row." - /// 29 3 C 7 0 + /// 27 3 C 7 0 @ 17, 2 SAY "Alt_O " COLOR "GR+/B" - /// 30 3 C 53 0 - @ 18, 10 SAY "Re-order GETS. This is different than creation order." - /// 31 3 C 7 0 + /// 28 3 C 7 0 @ 18, 2 SAY "Alt_G " COLOR "GR+/B" - /// 32 3 C 23 0 - @ 20, 10 SAY "Begins block selection." - /// 33 3 C 7 0 + /// 29 3 C 53 0 + @ 18, 10 SAY "Re-order GETS. This is different than creation order." + /// 30 3 C 7 0 @ 20, 2 SAY "Ctrl_F6" COLOR "GR+/B" - /// 34 3 C 36 0 + /// 31 3 C 23 0 + @ 20, 10 SAY "Begins block selection." + /// 32 3 C 36 0 @ 21, 10 SAY "Copy selected block at new location." - /// 35 3 C 7 0 + /// 33 3 C 7 0 @ 21, 2 SAY "Ctrl_F7" COLOR "GR+/B" - /// 36 3 C 45 0 + /// 34 3 C 7 0 + @ 22, 63 SAY "Alt_Z " COLOR "GR+/B" + /// 35 3 C 45 0 @ 22, 10 SAY "Cut and paste selected block at new location." + /// 36 3 C 4 0 + @ 22, 71 SAY "Undo" /// 37 3 C 7 0 @ 22, 2 SAY "Ctrl_F8" COLOR "GR+/B" - /// 38 3 C 20 0 - @ 24, 58 SAY "Load another screen." + /// 38 3 C 7 0 + @ 24, 63 SAY "Alt_P " COLOR "GR+/B" /// 39 3 C 7 0 - @ 24, 50 SAY "Alt_L " COLOR "GR+/B" - /// 40 3 C 21 0 - @ 24, 10 SAY "Save designed screen." - /// 41 3 C 7 0 + @ 24, 71 SAY "Preview" + /// 40 3 C 7 0 + @ 24, 33 SAY "Alt_L " COLOR "GR+/B" + /// 41 3 C 20 0 + @ 24, 41 SAY "Load another screen." + /// 42 3 C 7 0 @ 24, 2 SAY "Alt_S " COLOR "GR+/B" - /// 42 3 C 76 0 + /// 43 3 C 21 0 + @ 24, 10 SAY "Save designed screen." + /// 44 3 C 76 0 @ 26, 2 SAY " ESC-Designer 1-Keys 2-General 3-ListedInputs 4-BlockSelection 5-About " COLOR "N/W*" /* HB_SCREEN_ENDS */ @@ -1363,4 +1367,27 @@ STATIC FUNCTION DispHelp( cToken ) RETURN NIL /*----------------------------------------------------------------------*/ - \ No newline at end of file + +FUNCTION hbcui_test() + LOCAL getlist := {} + + /* HB_SCREEN_BEGINS */ + + /// 1 1 . 9 0 + @ 1, 2 , 12, 36 BOX "ÚÄ¿³ÙÄÀ³" + /// 2 3 C 5 0 + @ 3, 4 SAY "Name " + /// 3 3 C 15 0 + @ 5, 4 SAY "Salary " + /// 4 3 C 14 0 + @ 7, 4 SAY "Date of Birth " + /// 5 4 C 25 0 + @ 3, 10 GET cName PICTURE "@K! " + /// 6 4 N 12 2 + @ 5, 23 GET nSalary + /// 7 4 D 8 0 + @ 7, 27 GET dBirth + + /* HB_SCREEN_ENDS */ + + RETURN NIL