2008-06-09 06:25 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* tests/wvtext.prg
   * include/hbgtinfo.ch
   * include/hbgtcore.h
   * source/rtl/gtwvt/gtwvt.h
   * source/rtl/gtwvt/gtwvt.c
     ! Fixed a few warnings.
     ! Fixed bad selection behaviour when starting the 
       selection (to not let it "stick" to the upper left corned).
     - Removed predefined symbols as a way to control GT 
       behaviour.
     * HB_GTI_MARKCOPY -> HB_GTI_SELECTCOPY to use more generic 
       terminology.
     * HB_GTI_RESIZEABLE -> HB_GTI_RESIZABLE
This commit is contained in:
Viktor Szakats
2008-06-09 04:39:36 +00:00
parent 22169dced0
commit c6e89d45a8
6 changed files with 84 additions and 70 deletions

View File

@@ -8,6 +8,37 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-06-09 06:25 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* tests/wvtext.prg
* include/hbgtinfo.ch
* include/hbgtcore.h
* source/rtl/gtwvt/gtwvt.h
* source/rtl/gtwvt/gtwvt.c
! Fixed a few warnings.
! Fixed bad selection behaviour when starting the
selection (to not let it "stick" to the upper left corner).
- Removed predefined symbols as a way to control GT
behaviour. They may interfere with foreign libs. We have
hb_gtInfo() for these kinds of settings.
* HB_GTI_MARKCOPY -> HB_GTI_SELECTCOPY to use more generic
terminology.
* HB_GTI_RESIZEABLE -> HB_GTI_RESIZABLE
; TODO: Clean the callback interface to not be Windows specific,
and to hole one notifier block with higher level of
information.
; TOFIX: Sometime irreguralities appear in selection, probably due
to skipped updates or the like.
; TOFIX: The window gets messy while resizing to a bigger size.
Test: Grab the corner, resize to bigger size while not
releasing the mouse button.
; TOFIX: Window resized to a very small size will have "dead"
(non-updated) portions on the sides.
; TOFIX: Resize is without flicker now, but it's not interactive
anymore, so it's difficult to predict what the result
will be.
; TOFIX: It's possible to resize the windows so that parts of screen
disappear.
2008-06-08 20:12 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com
* harbour/source/rtl/gtwvt/gtwvt.c
* More fixes on resizing. Now appears to be behaving correctly. Please test.

View File

@@ -347,6 +347,8 @@ typedef struct _HB_GT_BASE
ULONG StrBufferSize;
ULONG StrBufferPos;
PHB_ITEM pNotififerBlock;
void * pGTData[HB_GT_MAX_]; /* local GT data */
/* Members holding information to Fire Events */

View File

@@ -118,8 +118,9 @@
#define HB_GTI_ISUNICODE 47 /* is Unicode input/output enabled? */
#define HB_GTI_MARKCOPY 48 /* toggles "Mark and Copy" option in SysMenu */
#define HB_GTI_RESIZEABLE 49 /* toggles resizeing feature of window */
#define HB_GTI_SELECTCOPY 48 /* toggles screen content selection and copy to clipboard (supported by: GTWVT) */
#define HB_GTI_RESIZABLE 49 /* toggles ability to resize window (supported by: GTWVT) */
#define HB_GTI_CLOSEALLOWED 50 /* toggles ability to close window (supported by: GTWVT) */
/* Additional constants to enhance GT */
#define HB_GTI_CALLBACK 51 /* holds information about callback fired when a key is pressed */

View File

@@ -225,8 +225,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT )
pWVT->bBeingMarked = FALSE;
pWVT->bBeginMarked = FALSE;
pWVT->bResizeable = TRUE;
pWVT->bMarkCopy = TRUE;
pWVT->bSelectCopy = TRUE;
pWVT->bResizable = TRUE;
return pWVT;
}
@@ -997,7 +997,7 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
{
ULONG ulSize;
USHORT irow, icol, j, top, left, bottom, right;
BYTE * sBuffer;
char * sBuffer;
left = pWVT->markStartColRow.x;
top = pWVT->markStartColRow.y;
@@ -1017,7 +1017,7 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
bottom = x;
}
ulSize = ( ( bottom - top + 1 ) * ( right - left + 1 + 2 ) );
sBuffer = hb_xgrab( ulSize );
sBuffer = ( char * ) hb_xgrab( ulSize );
for( j = 0, irow = top; irow < bottom; irow++ )
{
@@ -1029,11 +1029,11 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
if( !HB_GTSELF_GETSCRCHAR( pWVT->pGT, irow, icol, &bColor, &bAttr, &usChar ) )
break;
sBuffer[ j++ ] = ( BYTE ) usChar;
sBuffer[ j++ ] = ( char ) usChar;
}
sBuffer[ j++ ] = ( BYTE ) '\r';
sBuffer[ j++ ] = ( BYTE ) '\n';
sBuffer[ j++ ] = '\r';
sBuffer[ j++ ] = '\n';
}
sBuffer[ j ] = '\0';
@@ -1071,8 +1071,9 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
{
if( pWVT->bBeingMarked )
{
POINT a0,a1;
RECT rect = {0,0,0,0};
POINT a0;
POINT a1;
RECT rect = { 0, 0, 0, 0 };
pWVT->markEndColRow = colrow;
@@ -1084,16 +1085,28 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
rect.right = a1.x;
rect.bottom = a1.y;
if( ( rect.left != s_rectOld.left ) ||
( rect.top != s_rectOld.top ) ||
( rect.right != s_rectOld.right ) ||
( rect.bottom != s_rectOld.bottom ) )
if( rect.left != s_rectOld.left ||
rect.top != s_rectOld.top ||
rect.right != s_rectOld.right ||
rect.bottom != s_rectOld.bottom )
{
HDC hdc = GetDC( pWVT->hWnd );
HDC hdc = GetDC( pWVT->hWnd );
RECT rectUpd;
if( ( abs( rect.left - rect.right ) * abs( rect.top - rect.bottom ) ) >
( abs( s_rectOld.left - s_rectOld.right ) * abs( s_rectOld.top - s_rectOld.bottom ) ) )
int nOldSize = ( abs( s_rectOld.left - s_rectOld.right ) * abs( s_rectOld.top - s_rectOld.bottom ) );
if( nOldSize == 0 )
{
/* New selection */
rect.left = a0.x;
rect.top = a0.y;
rect.right = a1.x;
rect.bottom = a1.y;
InvertRect( hdc, &rect );
}
else if( ( abs( rect.left - rect.right ) * abs( rect.top - rect.bottom ) ) > nOldSize )
{
/* Selection grown */
@@ -1658,6 +1671,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara
}
return 0;
*/
/* Pritpal Bedi - 06 Jun 2008 */
case WM_ACTIVATE:
hb_gt_wvt_FireEvent( pWVT, ( LOWORD( wParam ) == WA_INACTIVE ? HB_GTE_KILLFOCUS : HB_GTE_SETFOCUS ), wParam, lParam );
@@ -1761,7 +1775,6 @@ static HWND hb_gt_wvt_CreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance
{
HWND hWnd;
WNDCLASS wndclass;
ULONG style;
HB_SYMBOL_UNUSED( hPrevInstance );
HB_SYMBOL_UNUSED( szCmdLine );
@@ -1786,18 +1799,10 @@ static HWND hb_gt_wvt_CreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance
return 0;
}
if( hb_dynsymFind( "HB_NORESIZEABLEWINDOW" ) != NULL )
{
style = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_BORDER;
}
else
{
style = WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
}
hWnd = CreateWindow( s_szAppName, /* classname */
TEXT( "HARBOUR_WVT" ), /* window name */
style, /* style */
WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|
WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX, /* style */
0, /* x */
0, /* y */
CW_USEDEFAULT, /* width */
@@ -1814,17 +1819,6 @@ static HWND hb_gt_wvt_CreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance
return NULL;
}
/*
* If you wish to show window the way you want, put somewhere in your application
* ANNOUNCE HB_NOSTARTUPWINDOW
* If so compiled, then you need to issue Wvt_ShowWindow( SW_RESTORE )
* at the point you desire in your code.
*/
if( hb_dynsymFind( "HB_NOSTARTUPWINDOW" ) != NULL )
{
iCmdShow = SW_HIDE;
}
ShowWindow( hWnd, iCmdShow );
UpdateWindow( hWnd );
@@ -1880,11 +1874,6 @@ static void hb_gt_wvt_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStd
hb_xfree( pFileName );
}
if( hb_dynsymFind( "HB_NORESIZEABLEWINDOW" ) != NULL )
{
pWVT->bResizeable = FALSE;
}
/* Create "Mark" prompt in SysMenu to allow console type copy operation */
{
HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE );
@@ -2413,47 +2402,44 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
KillTimer( pWVT->hWnd, hb_itemGetNI( pInfo->pNewVal ) );
break;
case HB_GTI_RESIZEABLE:
case HB_GTI_RESIZABLE:
{
pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bResizeable );
pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bResizable );
if( pInfo->pNewVal )
{
BOOL bNewValue = hb_itemGetL( pInfo->pNewVal );
if( bNewValue != pWVT->bResizeable )
if( bNewValue != pWVT->bResizable )
{
LONG_PTR style;
if( bNewValue )
{
style = WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
}
else
{
style = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_BORDER;
}
SetWindowLongPtr( pWVT->hWnd, GWL_STYLE, style );
SetWindowPos( pWVT->hWnd, NULL, NULL, NULL, NULL, NULL,
SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
SWP_NOSIZE | SWP_NOZORDER | SWP_DEFERERASE );
ShowWindow( pWVT->hWnd, SW_HIDE );
ShowWindow( pWVT->hWnd, SW_NORMAL );
pWVT->bResizeable = bNewValue;
pWVT->bResizable = bNewValue;
}
}
break;
}
case HB_GTI_MARKCOPY:
case HB_GTI_SELECTCOPY:
{
pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bMarkCopy );
pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bSelectCopy );
if( pInfo->pNewVal )
{
BOOL bNewValue = hb_itemGetL( pInfo->pNewVal );
if( bNewValue != pWVT->bMarkCopy )
if( bNewValue != pWVT->bSelectCopy )
{
HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE );
EnableMenuItem( hSysMenu, SYS_EV_MARK, MF_BYCOMMAND | ( bNewValue ? MF_ENABLED : MF_GRAYED ) );
pWVT->bMarkCopy = bNewValue;
pWVT->bSelectCopy = bNewValue;
}
}
break;

View File

@@ -160,8 +160,8 @@ typedef struct
POINT markStartColRow;
POINT markEndColRow;
BOOL bResizeable;
BOOL bMarkCopy;
BOOL bResizable;
BOOL bSelectCopy;
} HB_GTWVT, * PHB_GTWVT;

View File

@@ -52,12 +52,12 @@ FUNCTION Main()
Alert( '<Enter> Pressed' )
CASE nKey == K_F2
lMark := Hb_GtInfo( HB_GTI_MARKCOPY )
Hb_GtInfo( HB_GTI_MARKCOPY, !lMark )
lMark := Hb_GtInfo( HB_GTI_SELECTCOPY )
Hb_GtInfo( HB_GTI_SELECTCOPY, !lMark )
CASE nKey == K_F3
lResize := Hb_GtInfo( HB_GTI_RESIZEABLE )
Hb_GtInfo( HB_GTI_RESIZEABLE, !lResize )
lResize := Hb_GtInfo( HB_GTI_RESIZABLE )
Hb_GtInfo( HB_GTI_RESIZABLE, !lResize )
ENDCASE
ENDDO
@@ -88,17 +88,11 @@ STATIC FUNCTION MyCallBacks( nEvent, iGT, xCargo, wParam, lParam, xSentByMe )
STATIC FUNCTION DispScreen()
CLS
DispOutAt( 0,0,padc( '[x]Harbour GT - New Features', maxcol()+1 ), 'N/GR*' )
DispOutAt( 0,0,padc( 'Harbour GT - New Features', maxcol()+1 ), 'N/GR*' )
DispOutAt( maxrow(),0,padc( '<F2 MarkCopy> <F3 Resize> <Click Other Window> <Click X Button>', maxcol()+1 ), 'N/G*' )
RETURN NIL
//----------------------------------------------------------------------//
// Comment out this function if you do not want "Mark and Copy" prompt
// available in SysMenu at the left of Title Bar of the application window.
//
//FUNCTION Hb_NoCopyConsole() ; RETURN NIL
//----------------------------------------------------------------------//
FUNCTION HB_GTSYS()