diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e7cf7e7603..becbe6023b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,125 @@ The license applies to all entries newer than 2009-04-28. */ +2011-12-06 23:28 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/gtwvg/gtwvg.hbp + + Added: wvggenrc.prg + + * contrib/gtwvg/gtwvg.h + + Added: structure member - PHB_ITEM pNotifierGUI + + * contrib/gtwvg/gtwvg.c + * contrib/gtwvg/wvgwin.c + * contrib/gtwvg/wvgwing.c + + * contrib/gtwvg/hbgtwvg.ch + + Added: event notification - HB_GTE_ANY + + * contrib/gtwvg/wvg3stat.prg + * contrib/gtwvg/wvgax.prg + * contrib/gtwvg/wvgcheck.prg + * contrib/gtwvg/wvgclass.prg + * contrib/gtwvg/wvgcombo.prg + * contrib/gtwvg/wvgcrt.prg + * contrib/gtwvg/wvgcuig.c + * contrib/gtwvg/wvgdarea.prg + * contrib/gtwvg/wvgdatar.prg + * contrib/gtwvg/wvgdlg.prg + + contrib/gtwvg/wvggenrc.prg + + Implemented: Xbase++ compliant SetAppWindow() function. + The function simulates a WvgCRT() window from current + thread specific GT console if the function is called + without parameters and current thread has not posted + any application window. This facilitates hosting + WVG*Gui controls on pure GT invoked console. + + * contrib/gtwvg/wvghtmlv.prg + * contrib/gtwvg/wvglistb.prg + * contrib/gtwvg/wvgmenub.prg + * contrib/gtwvg/wvgmle.prg + * contrib/gtwvg/wvgpaint.prg + + Added: WVT_GetRGBColorByString( cClipperColorString, nForeBack ) + Retrieves RGB color given the clipper color string from + active GT palette: + WVT_GetRGBColorByString( "W+/GR", 0 ) => nRGBForeColor + WVT_GetRGBColorByString( "W+/GR", 1 ) => nRGBBackColor + + * contrib/gtwvg/wvgphdlr.prg + * contrib/gtwvg/wvgpushb.prg + * contrib/gtwvg/wvgradio.prg + * contrib/gtwvg/wvgscrlb.prg + * contrib/gtwvg/wvgsle.prg + * contrib/gtwvg/wvgstatb.prg + * contrib/gtwvg/wvgstatc.prg + * contrib/gtwvg/wvgsysw.prg + * contrib/gtwvg/wvgtoolb.prg + * contrib/gtwvg/wvgtreev.prg + * contrib/gtwvg/wvgwnd.prg + + Restructured: GTWVG at GUI space. + Xbase++ compatible controls can be hosted on CUI console. + The only requirement is that the parent of such GUI + controls is an object created with WvgCRT(). If there + is no object of type WvgCRT() is in sight, in case of a + pure GT invoked console, a WvgCRT() object is created and + current console window handle is assigned to it. This is + achieved through SetAppWindow() function which is called + if a control's parent is supplied as NIL, in accordance + with Xbase++ documentation. + + + The events assigned and executed by such controls are not + posted to inkey() processing, instead, are executed directly. + Just before executing an assigned event, focus is imposed + on GT console and returned to GUI control after processing + the execution. This ensures that GT is always in focus while + GUI control executes an assignment. + + + Introduced: In accordance with console coordinate system, the + positioning and size parameters supplied at the time of + construction of GUI objects now support + aPos == { nRow, nColumn } and aSize == { nRows, nColumns } + protocol. This has been achieved by supplying all four values + in negative. Thus WVG engine checks for negativity of position + and size values and determines that coordinate system be + interpreted as row/column instead of x/y(s). For example, + WvgPushButton( , , { -10, -2 }, { -3, -10 } ) + call will render the push button at 10,2,13,12 console area + in terms of rows and columns. These coordinates will be + maintained with resizing of console, etc. + + To extend this coordinate system a step further, the pos + and size arrays can be populated with code blocks evaluating + to a negative numeric value. This implimentation facilitates + to ancor any GUI control to a specific postion always. Thus, + WvgPushButton( , , { {|| -( maxrow()-3 ) }, -2 }, { -10, -3 } ) + will always position push button on last row-3 of the console + no matter how many rows the console is resized to. + + + Introduced: oWVG:SetColorFG/BG() now accept clipper color string + and renders the corresponding RGB color of active GT palette. + This facilitates the embedding of GUI controls on Clipper + complaint screen colors. Thus, + oStatic:setColorBG( "GR*" ) + will render the background of text label as yellow. + + IMPORTANT: The above concepts are on the top of existing ones + so no current functionality is lost. + + * contrib/gtwvg/tests/demowvg.prg + * contrib/gtwvg/tests/wvgtbrowser.prg + * contrib/gtwvg/tests/wvgutilities.prg + * contrib/gtwvg/tests/wvgxbp.prg + + Restructured: the code parts to demonstrate newly introduced + GTWVG concepts. Specialy look at main window's menu system, + push buttons at the bottom. Also look at +
. + This example is reworked entirely and is a testimony to + GTWVG power. + + NOTE: more changes and code shifting and simplifying is + on the drawing board. Hopefully code will get an + an overhaul in coming days. + 2011-12-06 11:42 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbrdddbf.h * modified DB_DBFLOCK_HB64 locking scheme diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index 6da49fc3b0..311041ed95 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -257,7 +257,12 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) if( pWVT->hInstance ) UnregisterClass( s_szClassName, pWVT->hInstance ); } - HB_WVT_UNLOCK + + if( pWVT->pNotifierGUI ) + { + hb_itemRelease( pWVT->pNotifierGUI ); + pWVT->pNotifierGUI = NULL; + } if( pWVT->pszSelectCopy ) hb_xfree( pWVT->pszSelectCopy ); @@ -266,7 +271,7 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) if( pWVT->hFontBox && pWVT->hFontBox != pWVT->hFont ) DeleteObject( pWVT->hFontBox ); #endif - #if 0 + #if 1 if( pWVT->hFont ) DeleteObject( pWVT->hFont ); #endif @@ -304,39 +309,41 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) while( pWVT->gObjs ) { - gObj = pWVT->gObjs->gObjNext; + gObj = pWVT->gObjs->gObjNext; - if( pWVT->gObjs->lpText != NULL ) + if( pWVT->gObjs->lpText != NULL ) #if defined( UNICODE ) - HB_TCHAR_FREE( pWVT->gObjs->lpText ); + HB_TCHAR_FREE( pWVT->gObjs->lpText ); #else - hb_xfree( pWVT->gObjs->lpText ); + hb_xfree( pWVT->gObjs->lpText ); #endif - if( pWVT->gObjs->hFont ) - if( pWVT->gObjs->bDestroyFont ) - DeleteObject( pWVT->gObjs->hFont ); - if( pWVT->gObjs->hPen ) - if( pWVT->gObjs->bDestroyPen ) - DeleteObject( pWVT->gObjs->hPen ); - if( pWVT->gObjs->hBrush ) - if( pWVT->gObjs->bDestroyBrush ) - DeleteObject( pWVT->gObjs->hBrush ); - if( pWVT->gObjs->bBlock ) - hb_itemRelease( pWVT->gObjs->bBlock ); + if( pWVT->gObjs->hFont ) + if( pWVT->gObjs->bDestroyFont ) + DeleteObject( pWVT->gObjs->hFont ); + if( pWVT->gObjs->hPen ) + if( pWVT->gObjs->bDestroyPen ) + DeleteObject( pWVT->gObjs->hPen ); + if( pWVT->gObjs->hBrush ) + if( pWVT->gObjs->bDestroyBrush ) + DeleteObject( pWVT->gObjs->hBrush ); + if( pWVT->gObjs->bBlock ) + hb_itemRelease( pWVT->gObjs->bBlock ); #if ! defined( HB_OS_WIN_CE ) - if( pWVT->gObjs->iPicture ) - if( pWVT->gObjs->bDestroyPicture ) - HB_VTBL( pWVT->gObjs->iPicture )->Release( HB_THIS( pWVT->gObjs->iPicture ) ); + if( pWVT->gObjs->iPicture ) + if( pWVT->gObjs->bDestroyPicture ) + HB_VTBL( pWVT->gObjs->iPicture )->Release( HB_THIS( pWVT->gObjs->iPicture ) ); #endif - hb_xfree( pWVT->gObjs ); - pWVT->gObjs = gObj; - } + hb_xfree( pWVT->gObjs ); + pWVT->gObjs = gObj; + } } if( pWVT->hWnd ) DestroyWindow( pWVT->hWnd ); hb_xfree( pWVT ); + + HB_WVT_UNLOCK } static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) @@ -458,6 +465,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->gObjs = NULL; pWVT->hWndParent = NULL; + pWVT->pNotifierGUI = NULL; + return pWVT; } @@ -465,16 +474,22 @@ static int hb_gt_wvt_FireEvent( PHB_GTWVT pWVT, int nEvent, PHB_ITEM pParams ) { int nResult = 0; /* Unhandled */ - if( pWVT->pGT->pNotifierBlock ) + if( pWVT->pGT->pNotifierBlock || pWVT->pNotifierGUI ) { if( hb_vmRequestReenter() ) { PHB_ITEM pEvent = hb_itemPutNI( NULL, nEvent ); - nResult = hb_itemGetNI( hb_vmEvalBlockV( pWVT->pGT->pNotifierBlock, 2, pEvent, pParams ) ); + if( pWVT->pGT->pNotifierBlock ) + nResult = hb_itemGetNI( hb_vmEvalBlockV( pWVT->pGT->pNotifierBlock, 2, pEvent, pParams ) ); + + if( pWVT->pNotifierGUI ) + { +//OutputDebugString( L"if( pWVT->pNotifierGUI )" ); + nResult = hb_itemGetNI( hb_vmEvalBlockV( pWVT->pNotifierGUI, 2, pEvent, pParams ) ); + } hb_itemRelease( pEvent ); - hb_vmRequestRestore(); } } @@ -668,7 +683,6 @@ static void hb_gt_wvt_AddCharToInputQueue( PHB_GTWVT pWVT, int iKey ) PHB_ITEM pEvParams = hb_itemNew( NULL ); hb_itemPutNI( pEvParams, iKey ); hb_gt_wvt_FireEvent( pWVT, HB_GTE_KEYBOARD, pEvParams ); - /* hb_itemRelease( pEvParams ); */ /* Under situations it GPF's */ } } @@ -2117,18 +2131,19 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara } return 0; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - case WM_CHAR: case WM_SYSCHAR: + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + case WM_CHAR: return hb_gt_wvt_KeyEvent( pWVT, message, wParam, lParam ); + case WM_LBUTTONUP: + SetFocus( hWnd ); case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONUP: - case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONDBLCLK: @@ -2318,7 +2333,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara PHB_ITEM pEvParams = hb_itemNew( NULL ); hb_arrayNew( pEvParams, 2 ); - +HB_TRACE( HB_TR_ALWAYS, ( "lParam %d", ( int ) lParam ) ); hb_arraySetNI( pEvParams , 1, ( int ) wParam ); hb_arraySetNInt( pEvParams, 2, ( HB_PTRDIFF ) lParam ); @@ -3037,8 +3052,17 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pWVT->CodePage ); if( hFont ) { + pInfo->pResult = hb_itemPutL( pInfo->pResult, HB_TRUE ); + + hb_strncpy( pWVT->fontFace, hb_arrayGetCPtr( pInfo->pNewVal, 1 ), sizeof( pWVT->fontFace ) - 1 ); + pWVT->fontHeight = hb_arrayGetNI( pInfo->pNewVal, 2 ); + pWVT->fontWidth = hb_arrayGetNI( pInfo->pNewVal, 3 ); + pWVT->fontWeight = hb_arrayGetNI( pInfo->pNewVal, 4 ); + pWVT->fontQuality = hb_arrayGetNI( pInfo->pNewVal, 5 ); + if( hb_gt_wvt_ValidWindowSize( pWVT->hWnd, pWVT->ROWS, pWVT->COLS, hFont, hb_arrayGetNI( pInfo->pNewVal, 3 ) ) ) { +#if 0 pInfo->pResult = hb_itemPutL( pInfo->pResult, HB_TRUE ); hb_strncpy( pWVT->fontFace, hb_arrayGetCPtr( pInfo->pNewVal, 1 ), sizeof( pWVT->fontFace ) - 1 ); @@ -3046,6 +3070,7 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pWVT->fontWidth = hb_arrayGetNI( pInfo->pNewVal, 3 ); pWVT->fontWeight = hb_arrayGetNI( pInfo->pNewVal, 4 ); pWVT->fontQuality = hb_arrayGetNI( pInfo->pNewVal, 5 ); +#endif if( pWVT->hWnd ) { hb_gt_wvt_ResetWindowSize( pWVT ); @@ -3941,7 +3966,23 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_REFRESH: { if( pWVT->hWnd ) + { InvalidateRect( pWVT->hWnd, NULL, FALSE ); + } + break; + } + case HB_GTI_NOTIFIERBLOCKGUI: + { + if( pWVT->pNotifierGUI ) + { + hb_itemRelease( pWVT->pNotifierGUI ); + pWVT->pNotifierGUI = NULL; + } + if( hb_itemType( pInfo->pNewVal ) & HB_IT_BLOCK ) + { + pWVT->pNotifierGUI = hb_itemNew( pInfo->pNewVal ); + } + break; } default: return HB_GTSUPER_INFO( pGT, iType, pInfo ); @@ -4478,6 +4519,7 @@ static void hb_wvt_gtCreateObjects( PHB_GTWVT pWVT ) static void hb_wvt_gtExitGui( PHB_GTWVT pWVT ) { int i; + #if ! defined( HB_OS_WIN_CE ) HMENU hMenu = GetMenu( pWVT->hWnd ); if( hMenu ) @@ -4567,6 +4609,8 @@ static void hb_wvt_gtSaveGuiState( PHB_GTWVT pWVT ) SetTextCharacterExtra( pWVT->hGuiDC,0 ); SelectObject( pWVT->hGuiDC, pWVT->hFont ); + if( pWVT->hGuiBmp ) + DeleteObject( pWVT->hGuiBmp ); } static void hb_wvt_gtHandleMenuSelection( PHB_GTWVT pWVT, int menuIndex ) diff --git a/harbour/contrib/gtwvg/gtwvg.h b/harbour/contrib/gtwvg/gtwvg.h index fda61a4537..1273955868 100644 --- a/harbour/contrib/gtwvg/gtwvg.h +++ b/harbour/contrib/gtwvg/gtwvg.h @@ -115,7 +115,7 @@ HB_EXTERN_BEGIN # define WVT_DEFAULT_ROWS 25 # define WVT_DEFAULT_COLS 80 # define WVT_DEFAULT_FONT_HEIGHT 16 -# define WVT_DEFAULT_FONT_WIDTH 8 +# define WVT_DEFAULT_FONT_WIDTH 10 #endif #define WVT_DEFAULT_FONT_NAME "Courier New" @@ -470,6 +470,8 @@ typedef struct HWND hWndParent; /* Parent Window Handle, if any */ + PHB_ITEM pNotifierGUI; /* Notifier to Wvg*Parts if embedded into a GT Window */ + } HB_GTWVT, * PHB_GTWVT; /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/gtwvg.hbp b/harbour/contrib/gtwvg/gtwvg.hbp index cc31bf60a6..9eb815245d 100644 --- a/harbour/contrib/gtwvg/gtwvg.hbp +++ b/harbour/contrib/gtwvg/gtwvg.hbp @@ -9,6 +9,8 @@ -w3 -es2 +-DUNICODE + -stop{!win|hbdyn} ../hbwin/hbwin.hbc @@ -55,3 +57,5 @@ wvgtabpg.prg wvgtoolb.prg wvgtreev.prg wvgwnd.prg +wvggenrc.prg + diff --git a/harbour/contrib/gtwvg/hbgtwvg.ch b/harbour/contrib/gtwvg/hbgtwvg.ch index 276b8f038d..beac8cbea3 100644 --- a/harbour/contrib/gtwvg/hbgtwvg.ch +++ b/harbour/contrib/gtwvg/hbgtwvg.ch @@ -74,6 +74,7 @@ #define HB_GTE_GUIPARTS 14 #define HB_GTE_HSCROLL 15 #define HB_GTE_VSCROLL 16 +#define HB_GTE_ANY 17 #define HB_GTI_SETFONT 71 #define HB_GTI_PRESPARAMS 72 @@ -84,6 +85,7 @@ #define HB_GTI_ACTIVATESELECTCOPY 77 #define HB_GTI_SETPOSANDSIZE 78 #define HB_GTI_REFRESH 79 +#define HB_GTI_NOTIFIERBLOCKGUI 80 /* Presentation Parameters | HB_GTI_PRESPARAMS */ #define HB_GTI_PP_EXSTYLE 1 diff --git a/harbour/contrib/gtwvg/tests/demowvg.prg b/harbour/contrib/gtwvg/tests/demowvg.prg index 54a9affd0b..21dbb9f82e 100644 --- a/harbour/contrib/gtwvg/tests/demowvg.prg +++ b/harbour/contrib/gtwvg/tests/demowvg.prg @@ -60,10 +60,10 @@ MEMVAR cCdxExp, First, Last, City //-------------------------------------------------------------------// -thread static t_wvtScreen := {} + THREAD STATIC t_wvtScreen := {} #ifdef __XCC__ -static s_paint_:= { { "", {} } } + STATIC s_paint_:= { { "", {} } } #endif /*----------------------------------------------------------------------*/ @@ -75,18 +75,18 @@ EXIT PROCEDURE CleanHandles() WVG_DeleteObject( obj ) obj := NIL NEXT - FOR EACH obj IN SetIcons() WVG_DeleteObject( obj ) obj := NIL NEXT + RETURN //-------------------------------------------------------------------// PROCEDURE Main() LOCAL aLastPaint, clr, scr, pGT - LOCAL hPopup, oMenu + LOCAL hPopup LOCAL dDate := ctod( "" ) LOCAL cName := Pad( "Pritpal Bedi", 35 ) LOCAL cAdd1 := Pad( "60, New Professor Colony", 35 ) @@ -100,11 +100,11 @@ PROCEDURE Main() LOCAL nLft := 4 LOCAL nBtm := 20 LOCAL nRgt := 75 - LOCAL nMaxRows := MaxRow() - LOCAL nBtnRow := nMaxRows - 1 LOCAL cLabel := "Harbour simulated GUI." LOCAL aObjects := WvtSetObjects( {} ) + LOCAL oError := ErrorBlock( {|o| MyError( o ) } ) + SET DATE BRITISH SET( _SET_EVENTMASK, INKEY_ALL + HB_INKEY_GTEVENT ) @@ -118,17 +118,19 @@ PROCEDURE Main() CLS Wvt_ShowWindow( SW_RESTORE ) + /* Xbase++ compatible menu protocol */ + BuildMainMenu() + SetMode( maxrow()+1, maxcol()+1 ) /* Needed to accomodate attached menu */ + SetKey( K_F12 , {|| hb_gtInfo( HB_GTI_ACTIVATESELECTCOPY ) } ) SetKey( K_CTRL_V , {|| __KeyBoard( hb_gtInfo( HB_GTI_CLIPBOARDDATA ) ) } ) SetKey( K_RBUTTONDOWN, {|| __KeyBoard( hb_gtInfo( HB_GTI_CLIPBOARDDATA ) ) } ) hPopup := Wvt_SetPopupMenu() - oMenu := CreateMainMenu() pGT := SetGT( 1, hb_gtSelect() ) - // Force mouse pointer right below the Harbour label - // + /* Force mouse pointer right below the Harbour label */ Wvt_SetMousePos( 2,40 ) aAdd( aBlocks, {|| Wvt_SetIcon( GetResource( "vr_1.ico" ) ) } ) @@ -141,86 +143,21 @@ PROCEDURE Main() aAdd( aBlocks, {|| Wvt_DrawImage( 8,62,12,69, IMAGE_VOUCH ) } ) aAdd( aBlocks, {|| Wvt_DrawBoxRecessed( 7, 48, 13, 55 ) } ) aAdd( aBlocks, {|| Wvt_DrawLine( maxrow()-2,0,maxrow()-2,maxcol(),WVT_LINE_HORZ,WVT_LINE_RECESSED,WVT_LINE_BOTTOM ) } ) - - aAdd( aBlocks, {|| Wvt_DrawLine( maxrow()-1, 4,maxrow(), 4,WVT_LINE_VERT,WVT_LINE_RECESSED,WVT_LINE_CENTER ) } ) aAdd( aBlocks, {|| Wvt_DrawLine( maxrow()-1,41,maxrow(),41,WVT_LINE_VERT,WVT_LINE_RECESSED,WVT_LINE_CENTER ) } ) - aAdd( aBlocks, {|| aEval( GetList, {|oGet| Wvt_DrawBoxGet( oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } ) } ) - #define btnFDisp WVT_BTN_FORMAT_FLAT - #define btnFMOver WVT_BTN_FORMAT_RAISED - #define btnFBDown WVT_BTN_FORMAT_RECESSED - #define btnFBUp WVT_BTN_FORMAT_FLAT - - WvtSetObjects( { OBJ_TYPE_BUTTON, 1, nBtnRow, 6, nBtnRow+1, 9, ; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFDisp ) },; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFMOver ) },; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFBDown ) },; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFBUp ) ,; - eval( SetKey( K_F2 ) ) } ; - } ) - - WvtSetObjects( { OBJ_TYPE_BUTTON, 2, nBtnRow,11, nBtnRow+1,14, ; - {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFDisp ) },; - {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFMOver ) },; - {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFBDown ) },; - {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFBUp ) ,; - eval( SetKey( K_F5 ) ) } ; - } ) - - WvtSetObjects( { OBJ_TYPE_BUTTON, 3, nBtnRow,16, nBtnRow+1,19, ; - {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFDisp ) },; - {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFMOver ) },; - {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFBDown ) },; - {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFBUp ) ,; - eval( SetKey( K_F3 ) ) } ; - } ) - - WvtSetObjects( { OBJ_TYPE_BUTTON, 4, nBtnRow,21, nBtnRow+1,24, ; - {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFDisp , rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; - {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFMOver, rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; - {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFBDown, rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; - {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFBUp , rgb( 100,22,241 ), rgb( 0,100,0 ) ) ,; - eval( SetKey( K_F4 ) ) } ; - } ) - - WvtSetObjects( { OBJ_TYPE_BUTTON, 5, nBtnRow,26, nBtnRow+1,29, ; - {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFDisp ) },; - {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFMOver ) },; - {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFBDown ) },; - {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFBUp ) ,; - eval( SetKey( K_F6 ) ) },; - } ) - - WvtSetObjects( { OBJ_TYPE_BUTTON, 6, nBtnRow,31, nBtnRow+1,34, ; - {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFDisp ) },; - {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFMOver ) },; - {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFBDown ) },; - {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFBUp ) ,; - eval( SetKey( K_F7 ) ) },; - } ) - - WvtSetObjects( { OBJ_TYPE_BUTTON, 7, nBtnRow,36,nBtnRow+1,39, ; - {|| Wvt_DrawButton( nBtnRow,36,nBtnRow+1,39,"Lines",IMAGE_VR, btnFDisp , rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; - {|| Wvt_DrawButton( nBtnRow,36,nBtnRow+1,39,"Lines",IMAGE_VR, btnFMOver, rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; - {|| Wvt_DrawButton( nBtnRow,36,nBtnRow+1,39,"Lines",IMAGE_VR, btnFBDown, rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; - {|| Wvt_DrawButton( nBtnRow,36,nBtnRow+1,39,"Lines",IMAGE_VR, btnFBUp , rgb( 100,22,241 ), rgb( 0,100,0 ) ) ,; - eval( SetKey( K_F8 ) ) } ; - } ) - aAdd( aBlocks, {|| Wvt_Mouse( -1000001 ) } ) aLastPaint := WvtSetBlocks( aBlocks ) + /* XBase++ compatible pure GUI controls onto CUI console */ + BuildButtons() + scr := SaveScreen( 0,0,maxrow(),maxcol() ) clr := SetColor( "N/W" ) CLS SetColor( "N/W,N/GR*,,,N/W*" ) - Wvt_SetMenu( oMenu:hMenu ) - - SetKey( Wvt_SetMenuKeyEvent(), { || ActivateMenu( oMenu ) } ) - @ 6, nColGet SAY "< Date >" @ 9, nColGet SAY "<" + PadC( "Name", 33 ) + ">" @ 12, nColGet SAY "<" + PadC( "Address", 33 ) + ">" @@ -228,15 +165,18 @@ PROCEDURE Main() dDate := ctod( "04/01/04" ) - @ 7, nColGet GET dDate WHEN DispStatusMsg( "Date must be Valid" ); - VALID ClearStatusMsg() - @ 10, nColGet GET cName WHEN DispStatusMsg( "Must be one of the list!" ); - VALID ( VouChoice() < 7 .and. ClearStatusMsg() ) + @ 7, nColGet GET dDate WHEN DispStatusMsg( "Date must be valid" ) VALID ClearStatusMsg() + @ 10, nColGet GET cName WHEN DispStatusMsg( "Must be one of the list!" ) VALID ( VouChoice() < 7 .and. ClearStatusMsg() ) @ 13, nColGet GET cAdd1 @ 15, nColGet GET cAdd2 @ 17, nColGet GET cAdd3 @ 17, 61 GET nSlry PICTURE "@Z 9999999.99" +#if 0 /* Suitable when whole window is subject to this protocol */ + aEval( GetList, {|oGet| Wvg_BoxGet( oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } ) + SetAppWindow():refresh() +#endif + READ // Restore Environment @@ -251,14 +191,17 @@ PROCEDURE Main() Popups( 1, .t. ) SetGT( 1, pGT ) + ErrorBlock( oError ) + RETURN + //-------------------------------------------------------------------// Function HB_GTSYS() REQUEST HB_GT_WVG_DEFAULT REQUEST HB_GT_WVT REQUEST HB_GT_WGU - Return NIL + RETURN NIL //------------------------------------------------------------------// @@ -269,9 +212,8 @@ PROCEDURE WvtConsoleGets( nMode ) IF hb_mtvm() Hb_ThreadStart( {|oCrt| hb_gtReload( 'WVT' ) , ; oCrt := hb_gtSelect(), ; - IF( nMode == 0, WvtNextGetsConsole(), GoogleMap() ) , ; - oCrt := NIL ; - } ) + iif( nMode == 0, WvtNextGetsConsole(), GoogleMap() ) , ; + oCrt := NIL } ) ENDIF RETURN @@ -310,13 +252,14 @@ PROCEDURE WvtNextGetsConsole() READ RETURN + //-------------------------------------------------------------------// + PROCEDURE WvtNextGets() IF hb_mtvm() Hb_ThreadStart( {|| Hb_gtReload( 'WVG' ), Wvt_setFont( 'Terminal',20 ), ; hb_clear(), Wvt_ShowWindow( SW_RESTORE ), WvtNextGets_X() } ) - ELSE WvtNextGets_X() ENDIF @@ -344,7 +287,7 @@ PROCEDURE WvtNextGets_X() LOCAL scr := SaveScreen( 0,0,maxrow(),maxcol() ) LOCAL wvtScr := Wvt_SaveScreen( 0,0,maxrow(),maxcol() ) - Static nPalletMultiplier := 0 + STATIC nPalletMultiplier := 0 // Change the values of pallatte arbitrarily though yu can fine tune // these values with realistic values. @@ -422,8 +365,8 @@ FUNCTION WvtPartialScreen() wvtScr1 := Wvt_SaveScreen( 7,20,15,60 ) - do while inkey( 0 ) != K_ESC - enddo + DO WHILE inkey( 0 ) != K_ESC + ENDDO DispBox( 7, 20, 15, 60, " ", "W/B*" ) @ 10,25 SAY "Wvt_SaveScreen()" COLOR "N/B*" @@ -431,13 +374,13 @@ FUNCTION WvtPartialScreen() @ 13,25 SAY "Press Esc " COLOR "N/B*" Wvt_DrawBoxRecessed( 8,22,14,58 ) - do while inkey( 0 ) != K_ESC - enddo + DO WHILE inkey( 0 ) != K_ESC + ENDDO Wvt_RestScreen( 7,20,15,60, wvtScr1 ) - do while inkey( 0 ) != K_ESC - enddo + DO WHILE inkey( 0 ) != K_ESC + ENDDO RestScreen( 7,20,15,60,scr ) Wvt_RestScreen( 0, 0, MaxRow(), MaxCol(), wvtScr ) @@ -492,8 +435,8 @@ function WvtLines() @ 15,8 Say "D" @ 16,9 Say "E" - do while ( inkey(0) != K_ESC ) - enddo + DO WHILE ( inkey(0) != K_ESC ) + ENDDO // Restore Environments // @@ -509,11 +452,11 @@ function WvtLines() //-------------------------------------------------------------------// -FUNCTION CreateMainMenu() +FUNCTION BuildMainMenu() LOCAL oMenu - LOCAL g_oMenuBar := wvtMenu():new():create() + LOCAL g_oMenuBar := SetAppWindow():menuBar() - oMenu := WvtMenu():new():create() + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() oMenu:Caption:= "Wvt*Classes" oMenu:AddItem( "Dialog One . New Window . Threaded" , {|| DialogWvgClassesOne( 1 ) } ) oMenu:AddItem( "Dialog One . Main Window . Primary Thread", {|| DialogWvgClassesOne( 2 ) } ) @@ -521,10 +464,10 @@ FUNCTION CreateMainMenu() oMenu:AddItem( "Dialog Two" , {|| DialogWvgClassesTwo() } ) oMenu:AddItem( "-" ) oMenu:AddItem( "Exit" , {|| __keyboard( K_ESC ) } ) - g_oMenuBar:addItem( "",oMenu ) + g_oMenuBar:addItem( { oMenu, "Wvt*Classes" } ) - oMenu := wvtMenu():new():create() - oMenu:Caption := "Traditional" + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() + oMenu:caption := "Traditional" oMenu:AddItem( "Gets . GTWVG . Threaded" , {|| WvtNextGets() } ) oMenu:AddItem( "-") oMenu:AddItem( "Gets . GTWVT . Threaded" , {|| WvtConsoleGets( 0 ) } ) @@ -540,34 +483,34 @@ FUNCTION CreateMainMenu() oMenu:AddItem( "Wvg Console with GCUI" , {|| ExecGCUI() } ) oMenu:AddItem( "-") oMenu:AddItem( "Modal Window" , {|| DoModalWindow() } ) - g_oMenuBar:addItem( "",oMenu ) + g_oMenuBar:addItem( { oMenu, "Traditional" } ) - oMenu := wvtMenu():new():create() + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() oMenu:Caption:= "Common Dialogs" oMenu:AddItem( "Fonts" , {|| Wvt_ChooseFont() } ) oMenu:AddItem( "-") oMenu:AddItem( "Colors" , {|| Wvt_ChooseColor() } ) - g_oMenuBar:addItem( "",oMenu) + g_oMenuBar:addItem( { oMenu, "Common Dialogs" } ) - oMenu := wvtMenu():new():create() + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() oMenu:Caption:= "Functionality" oMenu:AddItem( "Expand" , {|| WvtWindowExpand( 1 ) } ) oMenu:AddItem( "Shrink" , {|| WvtWindowExpand( -1 ) } ) oMenu:AddItem( "-") oMenu:AddItem( "Minimize" , {|| Wvt_Minimize() } ) oMenu:AddItem( "Maximize" , {|| hb_gtInfo( HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED ) } ) - g_oMenuBar:addItem( "",oMenu) + g_oMenuBar:addItem( { oMenu, "Functionality" } ) - oMenu := wvtMenu():new():create() + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() oMenu:Caption:= "Modeless Dialogs" oMenu:AddItem( "Dynamic Dialog . Modeless" , {|| DynWinDialog( 1 ) } ) oMenu:AddItem( "Dynamic Dialog . Modal " , {|| DynWinDialog( 2 ) } ) oMenu:AddItem( "-") oMenu:AddItem( "Slide Show . Modeless" , {|| DlgSlideShow() } ) - g_oMenuBar:addItem( "",oMenu) + g_oMenuBar:addItem( { oMenu, "Modeless Dialogs" } ) - oMenu := wvtMenu():new():create() - oMenu:Caption:= "~XbpDialog()s" + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() + oMenu:Caption := "~XbpDialog()s" oMenu:AddItem( "Pure Xbase++" , {|| Hb_ThreadStart( {|| demoXbp() } ) } ) oMenu:AddItem( "-") oMenu:AddItem( "ActiveX - Internet Explorer" , {|| Hb_ThreadStart( {|| ExecuteActiveX( 1 ) } ) } ) @@ -581,40 +524,21 @@ FUNCTION CreateMainMenu() oMenu:AddItem( "ActiveX - Analog Clock" , {|| Hb_ThreadStart( {|| ExecuteActiveX( 2 ) } ) } ) oMenu:AddItem( "-") oMenu:AddItem( "ActiveX - Image Viewer" , {|| Hb_ThreadStart( {|| ExecuteActiveX( 5 ) } ) } ) - g_oMenuBar:addItem( "",oMenu) + g_oMenuBar:addItem( { oMenu, "~XbpDialog()s" } ) #ifdef __QT__ - oMenu := wvtMenu():new():create() + oMenu := WvgMenu():new( g_oMenuBar, , .t. ):create() oMenu:Caption:= "~QT" oMenu:AddItem( "All Widgets" , {|| Hb_ThreadStart( {|| ExeQTWidgets() } ) } ) #endif - RETURN g_oMenuBar - -//-------------------------------------------------------------------// - -STATIC FUNCTION ActivateMenu( oMenu ) - LOCAL nMenu := Wvt_GetLastMenuEvent() - LOCAL aMenuItem - - IF !EMPTY( nMenu ) - - IF HB_ISOBJECT( oMenu ) - IF !EMPTY( aMenuItem := oMenu:FindMenuItemById( nMenu ) ) - IF HB_ISBLOCK( aMenuItem[ WVT_MENU_ACTION ] ) - EVAL( aMenuItem[ WVT_MENU_ACTION ] ) - ENDIF - ENDIF - ENDIF - ENDIF - RETURN NIL //-------------------------------------------------------------------// STATIC FUNCTION GoogleMap() - Local mfrom1, mto1, mfrom2, mto2, mfrom3, mto3, mweb - Local nCursor := setcursor() + LOCAL mfrom1, mto1, mfrom2, mto2, mfrom3, mto3, mweb + LOCAL nCursor := setcursor() LOCAL getlist := {} SetMode( 22,65 ) @@ -626,8 +550,7 @@ STATIC FUNCTION GoogleMap() mfrom2 := mto2 := space(40) mfrom3 := mto3 := space(50) - while .T. - + WHILE .T. @ 05, 01 say "FROM :" @ 07, 01 say "State ...:" get mfrom1 picture "@!" @ 08, 01 say "City ....:" get mfrom2 picture "@!" @@ -639,9 +562,9 @@ STATIC FUNCTION GoogleMap() setcursor(1); read; setcursor(nCursor) - if lastkey() == K_ESC - exit - endif + IF lastkey() == K_ESC + EXIT + ENDIF mweb := "http://maps.google.com/maps?q=from " +; alltrim( mfrom3 ) +" "+ alltrim( mfrom2 ) +" "+ alltrim( mfrom1 ) + " to " +; @@ -653,3 +576,53 @@ STATIC FUNCTION GoogleMap() RETURN NIL //----------------------------------------------------------------------// + +FUNCTION BuildButtons() + LOCAL oXbp + + oXbp := WvgPushButton():new() + oXbp:caption := "Hi" + oXbp:create( , , { {|| -( maxrow()-1 ) }, -1 }, { -2, -4 } ) + oXbp:activate := {|| Wvg_MessageBox( , "Harbour!" ) } + oXbp:toolTipText := "Harbour CUI/GUI Console" + + oXbp := WvgPushButton():new() + oXbp:caption := IMAGE_VOUCH + oXbp:create( , , { {|| -( maxrow()-1 ) }, -6 }, { -2, -4 } ) + oXbp:activate := {|| Wvt_Keyboard( K_F2 ) } + oXbp:toolTipText := "Open Another GET Screen" + + oXbp := WvgPushButton():new() + oXbp:caption := IMAGE_BROWSE + oXbp:create( , , { {|| -( maxrow()-1 ) }, -11 }, { -2, -4 } ) + oXbp:activate := {|| Wvt_Keyboard( K_F5 ) } + oXbp:toolTipText := "TBrowse + GUI Controls" + + oXbp := WvgPushButton():new() + oXbp:caption := IMAGE_NOTES + oXbp:create( , , { {|| -( maxrow()-1 ) }, -16 }, { -2, -4 } ) + oXbp:activate := {|| Wvt_Keyboard( K_F3 ) } + + oXbp := WvgPushButton():new() + oXbp:caption := IMAGE_TOOLS + oXbp:create( , , { {|| -( maxrow()-1 ) }, -21 }, { -2, -4 } ) + oXbp:activate := {|| Wvt_Keyboard( K_F6 ) } + + oXbp := WvgPushButton():new() + oXbp:caption := IMAGE_HELP + oXbp:create( , , { {|| -( maxrow()-1 ) }, -26 }, { -2, -4 } ) + oXbp:activate := {|| Wvt_Keyboard( K_F7 ) } + + oXbp := WvgPushButton():new() + oXbp:caption := IMAGE_VR + oXbp:border := .f. + oXbp:create( , , { {|| -( maxrow()-1 ) }, -31 }, { -2, -4 } ) + oXbp:activate := {|| Hb_ThreadStart( {|| demoXbp() } ) } // {|| Wvt_Keyboard( K_F8 ) } + oXbp:toolTipText := "Flat Button . Lines: press ESC when finished." + + RETURN NIL + +/*----------------------------------------------------------------------*/ + + + diff --git a/harbour/contrib/gtwvg/tests/wvgtbrowser.prg b/harbour/contrib/gtwvg/tests/wvgtbrowser.prg index f0e26380ef..82087e0f66 100644 --- a/harbour/contrib/gtwvg/tests/wvgtbrowser.prg +++ b/harbour/contrib/gtwvg/tests/wvgtbrowser.prg @@ -42,7 +42,7 @@ FUNCTION WvtMyBrowse() IF hb_mtvm() - Hb_ThreadStart( {|oCrt| oCrt := WvgCrt():New( , , { -1,-2 }, { 34,69 }, , .T. ), ; + Hb_ThreadStart( {|oCrt| oCrt := WvgCrt():new( , , { -1,-2 }, { 34,69 }, , .T. ), ; oCrt:resizeMode := HB_GTI_RESIZEMODE_ROWS,; oCrt:icon := GetResource( "dia_excl.ico" ),; oCrt:create(),; @@ -55,13 +55,13 @@ FUNCTION WvtMyBrowse() ExecBrowser() ENDIF - Return NIL + RETURN NIL //----------------------------------------------------------------------// FUNCTION ExecBrowser( oCrt ) LOCAL nKey, bBlock, oBrowse , aLastPaint, i, pGT, oVBar, oHBar - LOCAL cFileIndex, cFileDbf, cRDD, nIndex, oTBar, cScr, info_ + LOCAL cFileIndex, cFileDbf, cRDD, nIndex, oTBar, cScr, info_ //, oLB LOCAL lEnd := .f. LOCAL aBlocks := {} LOCAL nTop := 4 @@ -79,11 +79,12 @@ FUNCTION ExecBrowser( oCrt ) THREAD STATIC nFactor := 200 IF oCrt == NIL - cScr := SaveScreen( 0,0,maxrow(),maxcol() ) + cScr := SaveScreen( 0,0,maxrow(),maxcol() ) ENDIF BrwBuildMenu( oCrt ) - oTBar := BuildWvgToolBar( oCrt ) + oTBar := BrwBuildToolBar( oCrt ) + SetMode( maxrow()+1, maxCol()+1 ) /* Neccessary because adding menu has reduced the overall size of window */ pGT := SetGT( 2, hb_gtSelect() ) @@ -92,15 +93,15 @@ FUNCTION ExecBrowser( oCrt ) cFileIndex := "test.z01" USE ( cFileDbf ) NEW SHARED VIA ( cRDD ) - if NetErr() - return nil - endif - if fLock() + IF NetErr() + RETURN NIL + ENDIF + IF fLock() INDEX ON Test->FIRST TAG "001" TO ( cFileIndex ) INDEX ON Test->LAST TAG "002" TO ( cFileIndex ) INDEX ON Test->CITY TAG "003" TO ( cFileIndex ) dbUnlock() - endif + ENDIF SET INDEX TO SET INDEX TO ( cFileIndex ) SET ORDER TO 1 @@ -110,7 +111,7 @@ FUNCTION ExecBrowser( oCrt ) Popups( 2 ) - oBrowse := TBrowseWVG():New( nTop + 3, nLeft + 2, nBottom - 1, nRight - 2 ) + oBrowse := TBrowseWVG():New( nTop + 3, nLeft + 12, nBottom - 1, nRight - 2 ) oBrowse:ColSep := " " oBrowse:HeadSep := "__" @@ -122,94 +123,94 @@ FUNCTION ExecBrowser( oCrt ) bBlock := VouBlockField( i ) oBrowse:AddColumn( TBColumnNew( info_[ i,1 ], bBlock ) ) next - oBrowse:configure() if nStyle > 5 nStyle := 0 endif - Wvt_SetPen( nStyle, 0, rgb( 210,1210,210 ) ) - nStyle++ - - //hb_gtInfo( HB_GTI_ICONFILE, "dia_excl.ico" ) hb_gtInfo( HB_GTI_WINTITLE, "WVT Gui TBrowse()" ) - aAdd( aBlocks, {|| Wvt_DrawBoxRaised( oBrowse:nTop-3, oBrowse:nLeft-2, oBrowse:nBottom+1, oBrowse:nRight+2 ) } ) + aAdd( aBlocks, {|| Wvt_DrawBoxRaised( oBrowse:nTop-2, oBrowse:nLeft-2, oBrowse:nBottom+1, oBrowse:nRight+2 ) } ) aAdd( aBlocks, {|| Wvt_DrawBoxRecessed( oBrowse:nTop, oBrowse:nLeft, oBrowse:nBottom, oBrowse:nRight ) } ) aAdd( aBlocks, {|| Wvt_DrawGridHorz( oBrowse:nTop+3, oBrowse:nLeft, oBrowse:nRight, oBrowse:nBottom - oBrowse:nTop - 2 ) } ) aAdd( aBlocks, {|| Wvt_DrawGridVert( oBrowse:nTop, oBrowse:nBottom, oBrowse:aColumnsSep, len( oBrowse:aColumnsSep ) ) } ) Vou_BrwAddScrollBars( oCrt, oBrowse, @oVBar, @oHBar ) - + aLastPaint := WvtSetBlocks( aBlocks ) + BrwBuildCheckBox( oCrt, oBrowse ) + BrwBuildSLE( oCrt, oBrowse ) + BrwBuildListBox( oCrt, oBrowse ) + BrwBuildMLE( oCrt, oBrowse ) + BrwBuildButtons( oCrt, oBrowse ) + BrwBuildTree( oCrt, oBrowse ) + DispBox( 0, 0, maxrow(), maxcol(), " ", "N/W" ) - DispOutAt( oBrowse:nTop-2, oBrowse:nleft, padc( cFileDbf, oBrowse:nRight-oBrowse:nLeft+1 ), "W+/W" ) - DispOutAt( maxrow(), 0, padc( ' ',maxcol()+1), 'B/W' ) + DispOutAt( oBrowse:nTop-2, oBrowse:nleft-2, padc( cFileDbf, oBrowse:nRight-oBrowse:nLeft+5 ), "W+/B*" ) oTBar:buttonClick := {|oBtn| Vou_ExecTBarAction( oBtn ) } WHILE ! lEnd dispbegin() DO WHILE ( ( nKey := inkey( , INKEY_ALL + HB_INKEY_GTEVENT ) ) == 0 .or. nKey == K_MOVING ) .and. ! oBrowse:stabilize() - ENDDO + ENDDO dispend() - + IF nKey == 0 oVBar:setData( OrdKeyNo() ) oHBar:setData( oBrowse:colPos ) DO WHILE ( ( nKey := inkey( , INKEY_ALL + HB_INKEY_GTEVENT ) ) == 0 .or. nKey == K_MOVING ) - ENDDO - ENDIF + ENDDO + ENDIF - do CASE - case nKey == K_F12 + DO CASE + CASE nKey == K_F12 nFactor-- hb_gtInfo( HB_GTI_SPEC, HB_GTS_FACTOR, nFactor ) - case nKey == K_F11 + CASE nKey == K_F11 nFactor++ hb_gtInfo( HB_GTI_SPEC, HB_GTS_FACTOR, nFactor ) - case nKey == K_F6 + CASE nKey == K_F6 hb_gtInfo( HB_GTI_RESIZABLE, .f. ) - case nKey == K_F7 + CASE nKey == K_F7 hb_gtInfo( HB_GTI_RESIZABLE, .t. ) - case nKey == K_F2 + CASE nKey == K_F2 nIndex := IndexOrd() nIndex++ - if nIndex > 3 + IF nIndex > 3 nIndex := 1 - endif - Set Order To ( nIndex ) + ENDIF + SET ORDER TO ( nIndex ) oBrowse:RefreshAll() oBrowse:ForceStable() - - case nKey == K_F3 + + CASE nKey == K_F3 DoModalWindow() - case nKey == K_F4 + CASE nKey == K_F4 hb_gtInfo( HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED ) - case BrwHandleKey( oBrowse, nKey, @lEnd ) + CASE BrwHandleKey( oBrowse, nKey, @lEnd ) - case nKey == HB_K_RESIZE + CASE nKey == HB_K_RESIZE oBrowse:nBottom := maxrow() - 3 oBrowse:nRight := maxcol() - 5 - Vou_BrwResetScrollBars( oBrowse, oVBar, oHBar ) - + BrwReposButtons( oCrt ) /* Because we are repositioning at the center of console width */ + DispBox( 0, 0, maxrow(), maxcol(), " ", "N/W" ) - DispOutAt( oBrowse:nTop-2, oBrowse:nleft, padc( cFileDbf, oBrowse:nRight - oBrowse:nLeft + 1 ), "W+/W" ) - DispOutAt( maxrow(), 0, padc( ' ',maxcol()+1), 'B/W' ) + DispOutAt( oBrowse:nTop-2, oBrowse:nleft-2, padc( cFileDbf, oBrowse:nRight - oBrowse:nLeft + 5 ), "W+/B*" ) oBrowse:configure() - endcase - end + ENDCASE + END Wvt_SetPen( 0 ) WvtSetBlocks( aLastPaint ) @@ -230,12 +231,200 @@ FUNCTION ExecBrowser( oCrt ) //-------------------------------------------------------------------// +STATIC FUNCTION BrwShowColumn( oBrw, cHeading ) + LOCAL i, j, nCur + + nCur := oBrw:colPos + FOR i := 1 TO oBrw:colCount + IF oBrw:getColumn( i ):heading == cHeading + EXIT + ENDIF + NEXT + IF i < nCur + FOR j := nCur-1 TO i STEP -1 + oBrw:left() + oBrw:refreshCurrent() + oBrw:forceStable() + NEXT + ELSEIF i > nCur + FOR j := nCur+1 TO i + oBrw:right() + oBrw:refreshCurrent() + oBrw:forceStable() + NEXT + ENDIF + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwBuildTree( oCrt /*, oBrw*/ ) + LOCAL oTree, oItem1, oItem2 + + oTree := WvgTreeView():new( oCrt ) + oTree:hasLines := .T. + oTree:hasButtons := .T. + oTree:alwaysShowSelection := .T. + oTree:create( , , { -25, -1 }, { -8, -10 } ) + oTree:setColorFG( "W+" ) + oTree:setColorBG( "R*" ) + oTree:itemSelected := {|oItem| WVG_MessageBox( , iif( oItem <> NIL, oItem:caption, "Some Problem" ) ) } + + oItem1 := oTree:rootItem:addItem( "First level A" ) + + oTree:rootItem:addItem( "First level B" ) + + oItem2 := oItem1:addItem( "Second level 1" ) + oItem1:addItem( "Second level 2" ) + + oItem2:addItem( "Third level x" ) + oItem2:addItem( "Third level y" ) + oItem2:addItem( "Third level z" ) + + oTree:showExpanded( .t., 2 ) + oTree:setData( oItem2 ) + + oTree:tooltipText := "Treeview embedded onto CUI window" + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwBuildMLE( oCrt /*, oBrw*/ ) + LOCAL oXbp + + oXbp := WvgMLE():new( oCrt ) + oXbp:create( , , { -16,-1 }, { -8, -10 }, , .t. ) + oXbp:setColorFG( "B" ) + oXbp:setData( "Harbour's implementation of GUI controls onto CUI console." ) + oXbp:tooltipText := "Multi-line Edit Control" + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwBuildSLE( oCrt, oBrw ) + LOCAL oXbp + + oXbp := WvgStatic():new( oCrt ) + oXbp:type := WVGSTATIC_TYPE_TEXT + oXbp:options := WVGSTATIC_TEXT_LEFT + oXbp:caption := "Field Name:" + oXbp:create( , , { -3, -13 }, { -1, -7 } ) + oXbp:setColorFG( "W+" ) + oXbp:setColorBG( "BG" ) + + oXbp := WvgSLE():new( oCrt ) + oXbp:create( , , { -3, -21 }, { -1, -20 } ) + oXbp:setColorFG( "N" ) + oXbp:setColorBG( "BG+" ) + oXbp:returnPressed := {|m1,m2,o| m1:=m1, m2:=m2, BrwShowColumn( oBrw, upper( trim( o:getData() ) ) ) } + oXbp:tooltipText := "Typein a FieldName to focus it!" + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwBuildListBox( oCrt, oBrw ) + LOCAL oXbp, i + + oXbp := WvgListBox():new( oCrt ) + oXbp:create( , , { -5,-1 }, { -10, -10 }, , .t. ) + oXbp:setColorFG( "W+" ) + oXbp:setColorBG( "B*" ) + oXbp:itemMarked := {|m1,m2,o| m1 := m1, m2 := m2, BrwShowColumn( oBrw, o:getCurItem() ) } + FOR i := 1 TO oBrw:colCount + oXbp:addItem( oBrw:getColumn( i ):heading ) + NEXT + oXbp:setData( 3 ) + oXbp:tooltipText := "Click on a FieldName to make it active!" + + RETURN oXbp + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwBuildCheckBox( oCrt, oBrw ) + LOCAL oXbp + + oXbp := WvgCheckBox():new( oCrt ) + oXbp:caption := "Navigate" + oXbp:selected := {|x,y,o| x := x, y := y, iif( o:getData(), oBrw:goTop():forceStable(), oBrw:goBottom():forceStable() ) } + oXbp:selection := .t. + oXbp:create( , , { -3,-1 }, { -1,-7 } ) + oXbp:setColorFG( "R+" ) + oXbp:setColorBG( "W" ) + oXbp:tooltipText := "Checked: GoBottom, Unchecked: GoTop" + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwReposButtons( oCrt ) + LOCAL oXbp, nOff, nTtl, nG, i + LOCAL aW := { 10, 10, 10, 10, 10 } + + nG := 2 + nTtl := 0 + aeval( aW, {|e| nTtl += e } ) + nTtl += ( len( aW ) - 1 ) * nG + + nOff := ( ( maxcol()+1 ) - nTtl ) / 2 + i := 0 + FOR EACH oXbp IN oCrt:childList() + IF __ObjGetClsName( oXbp ) == "WVGPUSHBUTTON" + i++ + oXbp:setPosAndSize( { -maxrow(), -nOff }, { -1, -aW[ i ] } ) + nOff += aW[ i ] + nG + ENDIF + NEXT + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BrwBuildButtons( oCrt, oBrw ) + LOCAL oPB, nOff, nTtl, nG, i + LOCAL aPmt := { "Modal Window", "Maximize", "Go Top", "Go Bottom", "Right Most" } + LOCAL aAct := { {|| Wvt_Keyboard( K_F3 ) }, ; + {|| Wvt_Keyboard( K_F4 ) }, ; + {|| oBrw:goTop(), oBrw:forceStable() }, ; + {|| oBrw:goBottom(), oBrw:forceStable() }, ; + {|| oBrw:panEnd(), oBrw:forceStable() } } + LOCAL aW := { 10, 10, 10, 10, 10 } + + nG := 2 + nTtl := 0 + aeval( aW, {|e| nTtl += e } ) + nTtl += ( len( aW ) - 1 ) * nG + + nOff := ( ( maxcol()+1 ) - nTtl ) / 2 + + FOR i := 1 TO len( aPmt ) + oPB := WvgPushButton():new( oCrt ) + IF i == len( aPmt ) + oPB:caption := hb_dirBase() + "\" + "v_lock.bmp" + oPB:create( , , { {|| -maxrow() }, -nOff }, { -1,-aW[ i ] } ) + ELSE + oPB:caption := aPmt[ i ] + oPB:create( , , { {|| -maxrow() }, -nOff }, { -1,-aW[ i ] } ) + ENDIF + oPB:activate := aAct[ i ] + oPB:setColorFG( RGB( 0,255,0 ) ) + oPB:tooltipText := aPmt[ i ] + + nOff += aW[ i ] + nG + NEXT + + RETURN NIL + +/*----------------------------------------------------------------------*/ + STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) LOCAL lVMove := .f. LOCAL lHMove := .f. LOCAL lRet := .t. - DO CASE + DO CASE CASE nKey == K_ESC lEnd := .t. @@ -246,7 +435,7 @@ STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) lVMove := .t. oBrowse:Down() - case nKey == K_UP + CASE nKey == K_UP lVMove := .t. oBrowse:Up() @@ -305,57 +494,55 @@ STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) CASE nKey == K_MWFORWARD lVMove := .t. oBrowse:up() - + CASE Vou_NavigateToCell( oBrowse, nKey ) - - OTHERWISE + + OTHERWISE lRet := .f. - ENDCASE + ENDCASE IF lHMove .or. lVMove oBrowse:forceStable() - ENDIF - + ENDIF + RETURN lRet /*----------------------------------------------------------------------*/ STATIC FUNCTION DbSkipBlock( n ) - LOCAL nSkipped := 0 - if n == 0 + IF n == 0 DBSkip( 0 ) - elseif n > 0 - do while nSkipped != n .and. TBNext() + ELSEIF n > 0 + DO WHILE nSkipped != n .AND. TBNext() nSkipped++ enddo else - do while nSkipped != n .and. TBPrev() + DO WHILE nSkipped != n .AND. TBPrev() nSkipped-- - enddo - endif + ENDDO + ENDIF RETURN nSkipped //-------------------------------------------------------------------// STATIC FUNCTION TBNext() - LOCAL nSaveRecNum := recno() LOCAL lMoved := .T. - if Eof() + IF Eof() lMoved := .F. - else + ELSE DBSkip( 1 ) - if Eof() + IF Eof() lMoved := .F. DBGoTo( nSaveRecNum ) - endif - endif + ENDIF + ENDIF RETURN lMoved @@ -367,10 +554,10 @@ STATIC FUNCTION TBPrev() DBSkip( -1 ) - if Bof() + IF Bof() DBGoTo( nSaveRecNum ) lMoved := .F. - endif + ENDIF RETURN lMoved @@ -380,28 +567,28 @@ STATIC FUNCTION VouBlockField( i ) RETURN {|| fieldget( i ) } /*----------------------------------------------------------------------*/ - + STATIC FUNCTION Vou_ExecTBarAction( oBtn ) SWITCH oBtn:caption CASE "New" Wvt_Keyboard( K_DOWN ); EXIT - CASE "Select" + CASE "Select" Wvt_Keyboard( K_UP ); EXIT - CASE "Calendar" + CASE "Calendar" Wvt_Keyboard( K_RIGHT ); EXIT - CASE "Tools" + CASE "Tools" Wvt_Keyboard( K_LEFT ); EXIT - CASE "Index" + CASE "Index" Wvt_Keyboard( K_PGDN ); EXIT - CASE "Show" + CASE "Show" Wvt_Keyboard( K_PGUP ); EXIT CASE "Hide" Wvt_Keyboard( K_CTRL_HOME ); EXIT - ENDSWITCH - + ENDSWITCH + RETURN NIL - + /*----------------------------------------------------------------------*/ FUNCTION Vou_NavigateToCell( oBrowse ) @@ -416,70 +603,48 @@ FUNCTION Vou_NavigateToCell( oBrowse ) oBrowse:Up() oBrowse:ForceStable() ENDDO - + WHILE ( nCount > 0 ) nCount -- oBrowse:Down() oBrowse:ForceStable() ENDDO - + nCount := oBrowse:mColPos - oBrowse:ColPos WHILE ( nCount < 0 ) nCount++ oBrowse:Left() ENDDO - + WHILE ( nCount > 0 ) nCount-- oBrowse:Right() ENDDO DispEnd() RETURN .t. - ENDIF + ENDIF RETURN .f. - + /*----------------------------------------------------------------------*/ - -#include 'wvgparts.ch' FUNCTION Vou_BrwAddScrollBars( oCrt, oBrowse, oVBar, oHBar ) - LOCAL aXY, aXY1 - aXY := Wvt_GetXYFromRowCol( oBrowse:nBottom+1, oBrowse:nLeft ) - aXY1 := Wvt_GetXYFromRowCol( oBrowse:nBottom+2, oBrowse:nRight+1 ) - // - oHBar := WvgScrollBar():new( oCrt, , { aXY[ 1 ], aXY[ 2 ]+2 }, { aXY1[ 1 ]-aXY[ 1 ], aXY1[ 2 ]-aXY[ 2 ]-2 }, , .t. ) + oHBar := WvgScrollBar():new( oCrt, , { {|| -( maxrow()-2 ) }, {|| -( oBrowse:nLeft ) } }, ; + { -1, {|| -( maxcol() - 5 - oBrowse:nLeft + 1 ) } } ) oHBar:range := { 1, oBrowse:colCount } oHBar:type := WVGSCROLL_HORIZONTAL oHBar:create() oHBar:scroll := {|mp1| oBrowse:colPos := mp1[ 1 ], oBrowse:refreshAll(), oBrowse:forceStable() } - aXY := Wvt_GetXYFromRowCol( oBrowse:nTop , oBrowse:nRight+1 ) - aXY1 := Wvt_GetXYFromRowCol( oBrowse:nBottom+1, oBrowse:nRight+3 ) - // - oVBar := WvgScrollBar():new( oCrt, , { aXY[ 1 ]+2,aXY[ 2 ] }, { aXY1[ 1 ]-aXY[ 1 ]-2, aXY1[ 2 ]-aXY[ 2 ] }, , .t. ) + oVBar := WvgScrollBar():new( oCrt, , { {|| -( oBrowse:nTop ) }, {|| -( maxcol()-4 ) } }, ; + { {|| -( maxrow()-3-oBrowse:nTop+1 ) }, {|| -( 2 ) } } ) oVBar:range := { 1, LastRec() } oVBar:type := WVGSCROLL_VERTICAL oVBar:create() oVBar:scroll := {|mp1| Vou_BrwSetVScroll( mp1, oBrowse ) } - RETURN nil - -/*----------------------------------------------------------------------*/ - -FUNCTION Vou_BrwResetScrollBars( oBrowse, oVBar, oHBar ) - LOCAL aXY, aXY1 - - aXY := Wvt_GetXYFromRowCol( oBrowse:nBottom+1, oBrowse:nLeft ) - aXY1 := Wvt_GetXYFromRowCol( oBrowse:nBottom+2, oBrowse:nRight+1 ) - oHBar:setPosAndSize( {aXY[1],aXY[2]+2}, { aXY1[1]-aXY[1], aXY1[2]-aXY[2]-2 }, .t. ) - - aXY := Wvt_GetXYFromRowCol( oBrowse:nTop , oBrowse:nRight+1 ) - aXY1 := Wvt_GetXYFromRowCol( oBrowse:nBottom+1, oBrowse:nRight+3 ) - oVBar:setPosAndSize( {aXY[1]+2,aXY[2]}, { aXY1[1]-aXY[1]-2, aXY1[2]-aXY[2] }, .t. ) - - RETURN nil + RETURN NIL /*----------------------------------------------------------------------*/ @@ -527,104 +692,104 @@ STATIC FUNCTION BrwOnEvent( oWvtBrw, cPaintID, oBrowse, nKey ) HB_SYMBOL_UNUSED( cPaintID ) - do case - case nKey == K_DOWN + DO CASE + CASE nKey == K_DOWN oBrowse:Down() - case nKey == K_UP + CASE nKey == K_UP oBrowse:Up() - case nKey == K_LEFT + CASE nKey == K_LEFT oBrowse:Left() - case nKey == K_RIGHT + CASE nKey == K_RIGHT oBrowse:Right() - case nKey == K_PGDN + CASE nKey == K_PGDN oBrowse:pageDown() lRefAll := .t. - case nKey == K_PGUP + CASE nKey == K_PGUP oBrowse:pageUp() lRefAll := .t. - case nKey == K_CTRL_PGUP + CASE nKey == K_CTRL_PGUP oBrowse:goTop() lRefAll := .t. - case nKey == K_CTRL_PGDN + CASE nKey == K_CTRL_PGDN oBrowse:goBottom() lRefAll := .t. - case nKey == K_HOME + CASE nKey == K_HOME oBrowse:home() - case nKey == K_END + CASE nKey == K_END oBrowse:end() - case nKey == K_CTRL_LEFT + CASE nKey == K_CTRL_LEFT oBrowse:panLeft() - case nKey == K_CTRL_RIGHT + CASE nKey == K_CTRL_RIGHT oBrowse:panRight() - case nKey == K_CTRL_HOME + CASE nKey == K_CTRL_HOME oBrowse:panHome() - case nKey == K_CTRL_END + CASE nKey == K_CTRL_END oBrowse:panEnd() - case nKey == K_MWBACKWARD + CASE nKey == K_MWBACKWARD oBrowse:down() - case nKey == K_MWFORWARD + CASE nKey == K_MWFORWARD oBrowse:up() - case nKey == K_SBTHUMBTRACKVERT + CASE nKey == K_SBTHUMBTRACKVERT OrdKeyGoTo( oWvtBrw:oVBar:GetPos() ) lRefAll := .t. - case nKey == K_SBTHUMBTRACKHORZ + CASE nKey == K_SBTHUMBTRACKHORZ oBrowse:ColPos := oWvtBrw:oHBar:GetPos() - case nKey == K_SBLINEUP + CASE nKey == K_SBLINEUP oBrowse:up() - case nKey == K_SBLINEDOWN + CASE nKey == K_SBLINEDOWN oBrowse:down() - case nKey == K_SBPAGEUP + CASE nKey == K_SBPAGEUP oBrowse:pageUp() - case nKey == K_SBPAGEDOWN + CASE nKey == K_SBPAGEDOWN oBrowse:pageDown() - case nKey == K_SBLINELEFT + CASE nKey == K_SBLINELEFT oBrowse:left() - case nKey == K_SBLINERIGHT + CASE nKey == K_SBLINERIGHT oBrowse:right() - case nKey == K_SBPAGELEFT + CASE nKey == K_SBPAGELEFT oBrowse:left() - case nKey == K_SBPAGERIGHT + CASE nKey == K_SBPAGERIGHT oBrowse:right() - otherwise + OTHERWISE lRet := .f. - endcase + ENDCASE - if lRet - if lRefAll + IF lRet + IF lRefAll oBrowse:refreshAll() - endif + ENDIF oBrowse:forceStable() oWvtBrw:oVBar:setPos( OrdKeyCount(),OrdKeyNo() ) oWvtBrw:oHBar:setPos( oBrowse:ColCount, oBrowse:ColPos ) - endif + ENDIF RETURN lRet @@ -644,7 +809,6 @@ FUNCTION ConfigBrowser( aFields, cUseAlias, aTLBR, cDesc, oParent, cColorSpec, n Select( cUseAlias ) info_:= DbStruct() - //oBrowse := TBrowseNew( aTLBR[ 1 ], aTLBR[ 2 ], aTLBR[ 3 ], aTLBR[ 4 ] ) oBrowse := TBrowseWVG():New( aTLBR[ 1 ], aTLBR[ 2 ], aTLBR[ 3 ], aTLBR[ 4 ] ) oBrowse:ColSep := " " @@ -654,10 +818,10 @@ FUNCTION ConfigBrowser( aFields, cUseAlias, aTLBR, cDesc, oParent, cColorSpec, n oBrowse:GoBottomBlock := { || dbGoBottom() } oBrowse:SkipBlock := { | nSkip | dbSkipBlock( nSkip,oBrowse ) } - for i := 1 to len( aFields ) + FOR i := 1 TO len( aFields ) bBlock := VouBlockField( aFields[ i ] ) oBrowse:AddColumn( TBColumnNew( info_[ aFields[ i ],1 ], bBlock ) ) - next + NEXT oBrowse:configure() @@ -682,9 +846,9 @@ FUNCTION ConfigBrowser( aFields, cUseAlias, aTLBR, cDesc, oParent, cColorSpec, n //-------------------------------------------------------------------// STATIC FUNCTION BrwBuildMenu( oCrt ) - Local oMenu, oSMenu + LOCAL oMenu, oSMenu - oMenu := WvgMenuBar():new( oCrt, , .t. ):create() + oMenu := oCrt:menubar() oSMenu := WvgMenu():new( oMenu ):create() oSMenu:addItem( { '~First' , {|| alert( 'First' ) } } ) @@ -706,9 +870,40 @@ STATIC FUNCTION BrwBuildMenu( oCrt ) oSMenu:addItem( { "Procedure ~2", } ) oSMenu:itemSelected := {|mp1| MyMenuProcedure( 100+mp1 ) } oSMenu:checkItem( 2 ) - oMenu:addItem( { oSMenu, NIL } ) - Return oMenu + RETURN oMenu //----------------------------------------------------------------------// + +STATIC FUNCTION BrwBuildToolBar( oCrt ) + LOCAL oTBar + + oTBar := WvgToolBar():new( oCrt, , { -0.1,-0.1 }, { -3, {|| -( maxcol()+1 ) } } ) + + oTBar:style := WVGTOOLBAR_STYLE_FLAT + oTBar:borderStyle := WVGFRAME_RECT + + oTBar:buttonWidth := 40 //28 + oTBar:buttonHeight := 26 + + oTBar:imageWidth := 26 + oTBar:imageHeight := 24 + + oTBar:showToolTips := .t. + + // After setting properties, create toolbar. + oTBar:create() + + oTBar:addItem( "New" , hb_DirBase() + 'v_new.bmp' ) + oTBar:addItem( "Select" , hb_DirBase() + 'v_selct1.bmp' ) + oTBar:addItem( "Calendar" , hb_DirBase() + 'v_calend.bmp' ) + oTBar:addItem( "Tools" , hb_DirBase() + 'v_lock.bmp' ) + oTBar:addItem( "Index" , hb_DirBase() + 'v_index.bmp' ) + oTBar:addItem( "Show" , hb_DirBase() + 'v_clclt.bmp' ) + oTBar:addItem( "Hide" , hb_DirBase() + 'v_notes1.bmp' ) + + RETURN oTBar + +//----------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/tests/wvgutilities.prg b/harbour/contrib/gtwvg/tests/wvgutilities.prg index 9fcd1069c2..fe94a35969 100644 --- a/harbour/contrib/gtwvg/tests/wvgutilities.prg +++ b/harbour/contrib/gtwvg/tests/wvgutilities.prg @@ -48,14 +48,14 @@ /*----------------------------------------------------------------------*/ -thread static t_keys_:= { , , , , , , , , , , , , , , , , , , , } -thread static t_pic_ := { , , , , , , , , , , , , , , , , , , , } +THREAD STATIC t_keys_:= { , , , , , , , , , , , , , , , , , , , } +THREAD STATIC t_pic_ := { , , , , , , , , , , , , , , , , , , , } /*----------------------------------------------------------------------*/ FUNCTION WvtSetKeys( lSet ) - if lSet + IF lSet t_keys_[ 2 ] := SetKey( K_F2, {|| WvtNextGets() } ) t_keys_[ 3 ] := SetKey( K_F3, {|| WvtWindowExpand( 1 ) } ) t_keys_[ 4 ] := SetKey( K_F4, {|| WvtWindowExpand( -1 ) } ) @@ -65,7 +65,7 @@ FUNCTION WvtSetKeys( lSet ) t_keys_[ 8 ] := SetKey( K_F8, {|| WvtLines() } ) t_keys_[ 9 ] := SetKey( K_F9, {|| Wvt_ChooseFont() } ) t_keys_[ 10] := SetKey( K_F10,{|| Wvt_ChooseColor() } ) - else + ELSE SetKey( K_F2, t_keys_[ 2 ] ) SetKey( K_F3, t_keys_[ 3 ] ) SetKey( K_F4, t_keys_[ 4 ] ) @@ -75,7 +75,7 @@ FUNCTION WvtSetKeys( lSet ) SetKey( K_F8, t_keys_[ 8 ] ) SetKey( K_F9, t_keys_[ 9 ] ) SetKey( K_F10, t_keys_[ 10] ) - endif + ENDIF RETURN Nil //-------------------------------------------------------------------// @@ -114,7 +114,6 @@ FUNCTION Wvt_SetFocus() //-------------------------------------------------------------------// #if 0 FUNCTION Wvt_KillFocus() - LOCAL nRow := row() LOCAL nCol := col() @@ -122,7 +121,7 @@ FUNCTION Wvt_KillFocus() DevPos( nRow, nCol ) - RETURN nil + RETURN NIL #endif //-------------------------------------------------------------------// @@ -139,16 +138,16 @@ FUNCTION Wvt_Mouse( nKey, nRow, nCol ) STATIC nLastObj := 0 STATIC nLastKey := 0 - if ( nLen := len( aObjects ) ) == 0 - return nil - endif + IF ( nLen := len( aObjects ) ) == 0 + RETURN NIL + ENDIF - if !SetMouseCheck() - return nil - endif + IF ! SetMouseCheck() + RETURN NIL + ENDIF - if nKey == -1000001 - for nObj := 1 to nLen + IF nKey == -1000001 + FOR nObj := 1 TO nLen DO CASE CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_DISP eval( aObjects[ nObj, WVT_OBJ_ONDISP ] ) @@ -161,50 +160,50 @@ FUNCTION Wvt_Mouse( nKey, nRow, nCol ) CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_HIDE ENDCASE - next - return nil - endif + NEXT + RETURN NIL + ENDIF - nObj := ascan( aObjects, {|e_| e_[ WVT_OBJ_ROW ] <= nRow .and. ; - e_[ WVT_OBJ_ROWTO ] >= nRow .and. ; - e_[ WVT_OBJ_COL ] <= nCol .and. ; + nObj := ascan( aObjects, {|e_| e_[ WVT_OBJ_ROW ] <= nRow .AND. ; + e_[ WVT_OBJ_ROWTO ] >= nRow .AND. ; + e_[ WVT_OBJ_COL ] <= nCol .AND. ; e_[ WVT_OBJ_COLTO ] >= nCol } ) - if nObj == 0 - if nLastObj > 0 + IF nObj == 0 + IF nLastObj > 0 aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_DISP eval( aObjects[ nLastObj, WVT_OBJ_ONDISP ] ) nLastObj := 0 - endif - return nil - endif + ENDIF + RETURN NIL + ENDIF - if nLastObj == nObj .and. nLastKey == nKey - return nil - endif + IF nLastObj == nObj .and. nLastKey == nKey + RETURN NIL + ENDIF nLastObj := nObj nLastKey := nKey DO CASE CASE nKey == K_MOUSEMOVE - if aObjects[ nLastObj, WVT_OBJ_STATE ] != OBJ_STATE_MOUSEOVER - aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_MOUSEOVER - if aObjects[ nObj, WVT_OBJ_ONMOUSEOVER ] != nil + IF aObjects[ nLastObj, WVT_OBJ_STATE ] != OBJ_STATE_MOUSEOVER + aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_MOUSEOVER + IF aObjects[ nObj, WVT_OBJ_ONMOUSEOVER ] != nil eval( aObjects[ nObj, WVT_OBJ_ONMOUSEOVER ] ) - endif - endif + ENDIF + ENDIF CASE nKey == K_LBUTTONDOWN - aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_BUTTONDOWN - if aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] != nil - eval( aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] ) - endif + aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_BUTTONDOWN + IF aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] != nil + eval( aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] ) + ENDIF CASE nKey == K_LBUTTONUP - aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_DISP - if aObjects[ nObj, WVT_OBJ_ONBUTTONUP ] != nil - eval( aObjects[ nObj, WVT_OBJ_ONBUTTONUP ] ) - endif + aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_DISP + IF aObjects[ nObj, WVT_OBJ_ONBUTTONUP ] != nil + eval( aObjects[ nObj, WVT_OBJ_ONBUTTONUP ] ) + ENDIF ENDCASE @@ -215,7 +214,6 @@ FUNCTION Wvt_Mouse( nKey, nRow, nCol ) //-------------------------------------------------------------------// FUNCTION WvtSetBlocks( a_ ) - LOCAL o THREAD STATIC t := {} @@ -232,27 +230,27 @@ FUNCTION WvtSetBlocks( a_ ) //-------------------------------------------------------------------// FUNCTION WvtSetObjects( aObject ) - LOCAL oObjects + THREAD STATIC aObjects := {} oObjects := aclone( aObjects ) - if aObject != nil - if empty( aObject ) + IF aObject != NIL + IF empty( aObject ) aObjects := {} - else - if valtype( aObject[ 1 ] ) == "A" + ELSE + IF valtype( aObject[ 1 ] ) == "A" aeval( aObject, {|e_| aadd( aObjects, e_ ) } ) - else + ELSE aSize( aObject, WVT_OBJ_VRBLS ) DEFAULT aObject[ WVT_OBJ_STATE ] TO OBJ_STATE_DISP aadd( aObjects, aObject ) - endif - endif - endif + ENDIF + ENDIF + ENDIF RETURN oObjects @@ -261,12 +259,10 @@ FUNCTION WvtSetObjects( aObject ) FUNCTION SetMouseCheck( lYes ) LOCAL lOYes STATIC lSYes := .t. - lOYes := lSYes - if lYes != nil + IF lYes != NIL lSYes := lYes - endif - + ENDIF RETURN lOYes //-------------------------------------------------------------------// @@ -312,13 +308,13 @@ FUNCTION Hb_Clear() //----------------------------------------------------------------------// FUNCTION MyMenuProcedure( nID ) - do case - case nID == 101 + DO CASE + CASE nID == 101 alert( 'Procedure 101' ) - case nID == 102 + CASE nID == 102 alert( 'Procedure 102' ) - endcase - Return .t. + ENDCASE + RETURN .t. //----------------------------------------------------------------------// @@ -368,7 +364,7 @@ FUNCTION SetGT( nIndex, pGT ) FUNCTION SetFonts( hFont ) LOCAL oldFont - thread STATIC t_ahFonts := {} + THREAD STATIC t_ahFonts := {} oldFont := t_ahFonts IF !empty( hFont ) aadd( t_ahFonts, hFont ) @@ -379,7 +375,7 @@ FUNCTION SetFonts( hFont ) FUNCTION SetIcons( hIcon ) LOCAL oldIcon - thread STATIC t_ahIcons := {} + THREAD STATIC t_ahIcons := {} oldIcon := t_ahIcons IF !empty( hIcon ) aadd( t_ahIcons, hIcon ) @@ -394,22 +390,22 @@ FUNCTION Popups( nID, lDestroy ) THREAD STATIC hPop_:= { , , , , , , , , } - if nID == nil + IF nID == NIL Wvt_SetPopupMenu() - return nil - endif + RETURN NIL + ENDIF - if lDestroy != nil + IF lDestroy != NIL Wvt_DestroyMenu( hPop_[ nID ] ) - return nil - endif + RETURN NIL + ENDIF hPop := hPop_[ nID ] - do case - case nID == 1 // Data Entry Module + DO CASE + CASE nID == 1 // Data Entry Module - if hPop == nil + IF hPop == nil hPop := Wvt_CreatePopupMenu() Wvt_AppendMenu( hPop, nPrompt, K_F2, "Second Get Screen" ) Wvt_AppendMenu( hPop, nPrompt, K_F3, "Expand Window" ) @@ -425,11 +421,11 @@ FUNCTION Popups( nID, lDestroy ) Wvt_AppendMenu( hPop, nPrompt, K_F5, "Browse" ) - endif + ENDIF - case nID == 2 // Browser + CASE nID == 2 // Browser - if hPop == nil + IF hPop == NIL hPop := Wvt_CreatePopupMenu() Wvt_AppendMenu( hPop, nPrompt, K_DOWN , "Down" ) Wvt_AppendMenu( hPop, nPrompt, K_UP , "Up" ) @@ -448,9 +444,9 @@ FUNCTION Popups( nID, lDestroy ) Wvt_AppendMenu( hPop, MF_ENABLED+MF_POPUP, hPop1, "Column Movement" ) - endif + ENDIF - endcase + ENDCASE hPop_[ nID ] := hPop @@ -480,13 +476,13 @@ FUNCTION ClearStatusMsg() FUNCTION WvtPictures( nSlot,cFilePic ) - if nSlot != nil .and. nSlot <= 20 .and. file( cFilePic ) - if t_pic_[ nSlot ] != cFilePic - if Wvt_LoadPicture( cFilePic, nSlot ) + IF nSlot != NIL .AND. nSlot <= 20 .AND. file( cFilePic ) + IF t_pic_[ nSlot ] != cFilePic + IF Wvt_LoadPicture( cFilePic, nSlot ) t_pic_[ nSlot ] := cFilePic - endif - endif - endif + ENDIF + ENDIF + ENDIF RETURN NIL @@ -494,9 +490,9 @@ FUNCTION WvtPictures( nSlot,cFilePic ) FUNCTION WvtExePicture( nTop, nLeft, nBottom, nRight, nSlot, aOffset ) - if t_pic_[ nSlot ] != nil + IF t_pic_[ nSlot ] != NIL Wvt_DrawPicture( nTop, nLeft, nBottom, nRight, nSlot, aOffSet ) - endif + ENDIF RETURN NIL @@ -510,12 +506,27 @@ FUNCTION GetResource( cName ) FUNCTION uiDebug( ... ) LOCAL aP := hb_aParams() LOCAL s := "" - + aeval( aP, {|e| s += hb_valTOstr( e ) + " " } ) - + WAPI_OutputDebugString( s ) - + RETURN NIL - + /*----------------------------------------------------------------------*/ - \ No newline at end of file + +FUNCTION MyError( oError ) + + ? oError:description + ? oError:operation + + ? procname( 1 ), procline( 1 ) + ? procname( 2 ), procline( 2 ) + ? procname( 3 ), procline( 3 ) + ? procname( 4 ), procline( 4 ) + DO WHILE inkey() != 27; ENDDO + + RETURN NIL + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/gtwvg/tests/wvgxbp.prg b/harbour/contrib/gtwvg/tests/wvgxbp.prg index 9a4db4fa74..5c5776b6ea 100644 --- a/harbour/contrib/gtwvg/tests/wvgxbp.prg +++ b/harbour/contrib/gtwvg/tests/wvgxbp.prg @@ -1,8 +1,8 @@ /* * $Id$ */ - -/* + +/* * Pritpal Bedi */ @@ -13,12 +13,12 @@ #include "wvtwin.ch" #include "hbgtinfo.ch" #include "hbgtwvg.ch" -#include "wvgparts.ch" +#include "wvgparts.ch" /*----------------------------------------------------------------------*/ #define MUSIC_WAITON {800, 1600} - + /*----------------------------------------------------------------------*/ // // A Pure Xbase++ Implementation @@ -143,11 +143,11 @@ FUNCTION demoxbp() //--------------------------- Active-X ---------------------------\\ hb_gtInfo( HB_GTI_WINTITLE, 'http://www.harbour.vouch.info' ) - #if 0 + #if 0 oCom := WvgActiveXControl():New( oDA, , { 0, 0 }, { 100, 100 }, , .t. ) oCom:CLSID := 'Shell.Explorer.2' oCom:mapEvent( 269, {|| QOut( ' E X P L O R E R - 2 6 9' ) } ) - #else + #else oCom := WvgHTMLViewer():New( oDA, , { 0, 0 }, { 100, 100 }, , .t. ) oCom:beforeNavigate := {|cURL, x, oHTML| x := x, oHTML := oHTML, oPanel:caption := cURL } oCom:statusTextChange := {|cText| oPanel:caption := cText } @@ -333,7 +333,7 @@ STATIC FUNCTION ActiveXBuildMenuXbp( oCrt, oStatic, oStatic2 ) oMenuBar:addItem( { oSubMenu, NIL } ) - RETURN NIL + RETURN NIL //----------------------------------------------------------------------// STATIC FUNCTION ActiveXBuildToolBarXbp( oCrt ) diff --git a/harbour/contrib/gtwvg/wvg3stat.prg b/harbour/contrib/gtwvg/wvg3stat.prg index af68893007..15a0093ea7 100644 --- a/harbour/contrib/gtwvg/wvg3stat.prg +++ b/harbour/contrib/gtwvg/wvg3stat.prg @@ -106,7 +106,7 @@ CLASS Wvg3State INHERIT WvgWindow, DataRef METHOD Wvg3State:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + BS_AUTO3STATE ::className := "BUTTON" diff --git a/harbour/contrib/gtwvg/wvgax.prg b/harbour/contrib/gtwvg/wvgax.prg index 805e5b8564..a3d8110f64 100644 --- a/harbour/contrib/gtwvg/wvgax.prg +++ b/harbour/contrib/gtwvg/wvgax.prg @@ -117,6 +117,7 @@ CLASS WvgActiveXControl FROM WvgWindow METHOD mouseUp() METHOD mouseMove() METHOD activate() + ERROR HANDLER OnError ENDCLASS @@ -125,7 +126,7 @@ CLASS WvgActiveXControl FROM WvgWindow METHOD WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS ::objType := objTypeActiveX @@ -185,6 +186,7 @@ PROCEDURE execEvent( nEvent, ... ) CLASS WvgActiveXControl #if 0 LOCAL cEvents := HB_ValToStr( nEvent ) + ", " LOCAL aEvents := { ... } + aEval( aEvents, { | xEvent | cEvents += HB_ValToStr( xEvent ) + ", " } ) WAPI_OutputDebugString( cEvents ) #endif @@ -209,7 +211,8 @@ METHOD WvgActiveXControl:handleEvent( nEvent, aInfo ) eval( ::sl_resize, NIL, NIL, self ) ENDIF EXIT - END + + ENDSWITCH RETURN nHandled diff --git a/harbour/contrib/gtwvg/wvgcheck.prg b/harbour/contrib/gtwvg/wvgcheck.prg index 65448ff44e..4b9e626e20 100644 --- a/harbour/contrib/gtwvg/wvgcheck.prg +++ b/harbour/contrib/gtwvg/wvgcheck.prg @@ -110,7 +110,7 @@ CLASS WvgCheckBox INHERIT WvgWindow, DataRef METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgCheckBox - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + BS_PUSHBUTTON + BS_AUTOCHECKBOX /*+ BS_NOTIFY */ ::className := "BUTTON" @@ -122,24 +122,25 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgCheck METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgCheckBox - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oParent:AddChild( SELF ) ::createControl() - ::SetWindowProcCallback() + IF ::isParentCrt() + ::SetWindowProcCallback() + ENDIF IF ::visible ::show() ENDIF + ::setPosAndSize() ::setCaption( ::caption ) - IF ::selection ::sendMessage( BM_SETCHECK, BST_CHECKED, 0 ) ENDIF - ::editBuffer := ( WVG_Button_GetCheck( ::hWnd ) == BST_CHECKED ) RETURN Self @@ -147,36 +148,54 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgCh /*----------------------------------------------------------------------*/ METHOD handleEvent( nMessage, aNM ) CLASS WvgCheckBox + LOCAL hDC hb_traceLog( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) DO CASE + CASE nMessage == HB_GTE_RESIZED + ::sendMessage( WM_SIZE, 0, 0 ) + IF ::isParentCrt() + ::rePosition() + ENDIF + CASE nMessage == HB_GTE_COMMAND IF aNM[ NMH_code ] == BN_CLICKED ::editBuffer := ( WVG_Button_GetCheck( ::hWnd ) == BST_CHECKED ) - IF hb_isBlock( ::sl_lbClick ) eval( ::sl_lbClick, ::editBuffer, NIL, self ) RETURN 0 - ENDIF ENDIF - CASE nMessage == HB_GTE_CTLCOLOR + CASE nMessage == HB_GTE_CTLCOLOR + hDC := aNM[ 1 ] IF hb_isNumeric( ::clr_FG ) - WVG_SetTextColor( aNM[ 1 ], ::clr_FG ) + WVG_SetTextColor( hDC, ::clr_FG ) ENDIF IF hb_isNumeric( ::hBrushBG ) - WVG_SetBkMode( aNM[ 1 ], 1 ) + WVG_SetBkMode( hDC, 1 ) RETURN ::hBrushBG ELSE - RETURN WVG_GetCurrentBrush( aNM[ 1 ] ) + RETURN WVG_GetCurrentBrush( hDC ) + ENDIF + + CASE nMessage == HB_GTE_ANY + IF ::isParentCrt() + IF aNM[ 1 ] == WM_LBUTTONUP + IF hb_isBlock( ::sl_lbClick ) + ::oParent:setFocus() + ::sendMessage( BM_SETCHECK, iif( WVG_Button_GetCheck( ::hWnd ) == BST_CHECKED, BST_UNCHECKED, BST_CHECKED ), 0 ) + ::editBuffer := ( WVG_Button_GetCheck( ::hWnd ) == BST_CHECKED ) + eval( ::sl_lbClick, NIL, NIL, Self ) + ENDIF + ENDIF ENDIF ENDCASE - RETURN 1 + RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgclass.prg b/harbour/contrib/gtwvg/wvgclass.prg index 0dd8dd7371..6805c5cd64 100644 --- a/harbour/contrib/gtwvg/wvgclass.prg +++ b/harbour/contrib/gtwvg/wvgclass.prg @@ -361,11 +361,9 @@ METHOD wvtDialog:Destroy() METHOD wvtDialog:Event() LOCAL nKey - IF ( nKey := inkey( 0.1, INKEY_ALL ) ) == 0 + IF ( nKey := inkey( 0.1, INKEY_ALL + HB_INKEY_GTEVENT ) ) == 0 IF Wvt_IsLButtonPressed() - nKey := K_LBUTTONPRESSED - ENDIF ENDIF @@ -376,14 +374,14 @@ METHOD wvtDialog:Event() METHOD wvtDialog:Execute() IF ::nObjects == 0 - do while .t. - IF inkey( 0.1 ) == K_ESC + DO WHILE .t. + IF inkey( 0.1, INKEY_ALL + HB_INKEY_GTEVENT ) == K_ESC EXIT ENDIF - enddo + ENDDO ELSE - do while ( ::Inkey() <> K_ESC ) - enddo + DO WHILE ( ::Inkey() <> K_ESC ) + ENDDO ENDIF RETURN ::nKey @@ -401,14 +399,14 @@ METHOD wvtDialog:Inkey() IF ::nKey <> 0 IF ::nKey == K_ESC .or. ::nKey == K_CTRL_ENTER - return K_ESC + RETURN K_ESC ENDIF DO CASE CASE ::nKey == K_TAB IF ::lTabStops - do while .t. + DO WHILE .t. ::nCurObj++ IF ::nCurObj > ::nObjects ::nCurObj := 1 @@ -416,14 +414,14 @@ METHOD wvtDialog:Inkey() IF ::aObjects[ ::nCurObj ]:lTabStop EXIT ENDIF - enddo + ENDDO ENDIF ::lEventHandled := .t. CASE ::nKey == K_SH_TAB IF ::lTabStops - do while .t. + DO WHILE .t. ::nCurObj-- IF ::nCurObj < 1 ::nCurObj := ::nObjects @@ -431,7 +429,7 @@ METHOD wvtDialog:Inkey() IF ::aObjects[ ::nCurObj ]:lTabStop EXIT ENDIF - enddo + ENDDO ENDIF ::lEventHandled := .t. @@ -531,7 +529,9 @@ METHOD wvtDialog:Inkey() IF ::nUseObj > 0 IF !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftDown() ) ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftDown ) - + IF ::aObjects[ ::nUseObj ]:className == "WVTBROWSE" + ::lEventHandled := .f. + ENDIF ENDIF ENDIF ENDIF @@ -613,10 +613,10 @@ METHOD wvtDialog:MouseOver() LOCAL nObj nObj := ascan( ::aObjects, ; - {|o| o:nType <> DLG_OBJ_STATIC .and. ; - o:nType <> DLG_OBJ_TOOLBAR .and. ; - mRow >= o:nTop .and. mRow <= o:nBottom .and. ; - mCol >= o:nLeft .and. mCol <= o:nRight } ) + {|o| o:nType <> DLG_OBJ_STATIC .AND. ; + o:nType <> DLG_OBJ_TOOLBAR .AND. ; + mRow >= o:nTop .AND. mRow <= o:nBottom .AND. ; + mCol >= o:nLeft .AND. mCol <= o:nRight } ) ::nObjOver := nObj ::oObjOver := iif( nObj > 0, ::aObjects[ nObj ], nil ) @@ -801,7 +801,7 @@ CLASS WvtObject DATA bOnFocus INIT {|| NIL } DATA bOnRefresh INIT {|| NIL } DATA bOnLeftUp INIT {|| NIL } - DATA bOnLeftDown INIT {|| NIL } + DATA bOnLeftDown INIT {|| .f. } DATA bOnMMLeftDown INIT {|| NIL } DATA bOnLeftPressed INIT {|| NIL } DATA bTooltip INIT {|| NIL } @@ -1049,12 +1049,17 @@ METHOD WvtBrowse:New( oParent, nID, nTop, nLeft, nBottom, nRight ) METHOD WvtBrowse:Create() Select( ::cAlias ) - +#if 0 ::nTop := ::oBrw:nTop-2 ::nLeft := ::oBrw:nLeft-2 ::nBottom := iif( ::lHSBar, ::oBrw:nBottom, ::oBrw:nBottom+1 ) ::nRight := iif( ::lVSBar, ::oBrw:nRight , ::oBrw:nRight+2 ) - +#else + ::nTop := ::oBrw:nTop + ::nLeft := ::oBrw:nLeft + ::nBottom := ::oBrw:nBottom + ::nRight := ::oBrw:nRight +#endif ::PaintBlock( 1 ) ::PaintBlock( 2 ) ::PaintBlock( 3 ) @@ -2531,7 +2536,7 @@ METHOD wvtScrollbar:Create() ENDIF ::bOnLeftUp := {|| ::HandleEvent( K_LBUTTONUP ) } - ::bOnLeftDown := {|| ::HandleEvent( K_LBUTTONDOWN ) } + ::bOnLeftDown := {|| ::HandleEvent( K_LBUTTONDOWN ), .f. } ::bOnMMLeftDown := {|| ::HandleEvent( K_MMLEFTDOWN ) } ::bOnLeftPressed := {|| ::HandleEvent( K_LBUTTONPRESSED ) } @@ -2601,7 +2606,7 @@ METHOD wvtScrollbar:Configure( nTop, nLeft, nBottom, nRight ) ::ThumbPos() ENDIF - + ::Refresh() RETURN Self diff --git a/harbour/contrib/gtwvg/wvgcombo.prg b/harbour/contrib/gtwvg/wvgcombo.prg index 336b81aeec..63246a0459 100644 --- a/harbour/contrib/gtwvg/wvgcombo.prg +++ b/harbour/contrib/gtwvg/wvgcombo.prg @@ -89,7 +89,7 @@ CLASS WvgComboBox INHERIT WvgListBox /* WvgSLE */ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgComboBox - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -103,7 +103,7 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgCombo METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgComboBox - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oParent:AddChild( SELF ) diff --git a/harbour/contrib/gtwvg/wvgcrt.prg b/harbour/contrib/gtwvg/wvgcrt.prg index 29db0b18bf..49dc6654a0 100644 --- a/harbour/contrib/gtwvg/wvgcrt.prg +++ b/harbour/contrib/gtwvg/wvgcrt.prg @@ -86,8 +86,8 @@ CLASS WvgCrt INHERIT WvgWindow, WvgPartHandler DATA clipChildren INIT .F. DATA closable INIT .T. DATA fontHeight INIT 16 + DATA fontWidth INIT 10 DATA fontName INIT "Courier New" - DATA fontWidth INIT 8 DATA gridMove INIT .F. DATA icon INIT 0 DATA minMax INIT .T. @@ -172,17 +172,18 @@ CLASS WvgCrt INHERIT WvgWindow, WvgPartHandler DATA lHasInputFocus INIT .F. DATA nFrameState INIT 0 /* normal */ + DATA isGT INIT .F. + METHOD setTitle( cTitle ) INLINE ::title := cTitle, hb_gtInfo( HB_GTI_WINTITLE, cTitle ) METHOD getTitle() INLINE hb_gtInfo( HB_GTI_WINTITLE ) METHOD showWindow() INLINE ::show() METHOD refresh() INLINE ::invalidateRect() /* LIFE CYCLE */ - METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD destroy() - METHOD setFocus() /* METHODS */ METHOD currentPos() @@ -259,22 +260,25 @@ CLASS WvgCrt INHERIT WvgWindow, WvgPartHandler * Instance Initiation /*----------------------------------------------------------------------*/ -METHOD WvgCrt:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) +METHOD WvgCrt:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - if hb_isArray( aPos ) + IF hb_isArray( aPos ) ::aPos := aPos - endif - if hb_isArray( aSize ) + ENDIF + IF hb_isArray( aSize ) ::aSize := aSize - endif - if hb_isArray( aPresParams ) + ENDIF + IF hb_isArray( aPresParams ) ::aPresParams := aPresParams - endif - if hb_isLogical( lVisible ) + ENDIF + IF hb_isLogical( lVisible ) ::visible := lVisible - endif + ENDIF + + /* Drawing Area of oCrt will point to itself */ + ::drawingArea := Self RETURN Self @@ -304,13 +308,13 @@ METHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::WvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - if ::lModal + IF ::lModal ::pGT := hb_gtCreate( "WVG" ) ::pGTp := hb_gtSelect( ::pGT ) - else + ELSE hb_gtReload( "WVG" ) ::pGT := hb_gtSelect() - endif + ENDIF IF ::lModal ::style := WS_POPUP + WS_CAPTION + WS_SYSMENU @@ -337,6 +341,7 @@ METHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /* CreateWindow() be forced to execute */ ? " " ::hWnd := hb_gtInfo( HB_GTI_SPEC, HB_GTS_WINDOWHANDLE ) + ::setFocus() Hb_GtInfo( HB_GTI_CLOSABLE , ::closable ) hb_gtInfo( HB_GTI_WINTITLE , ::title ) @@ -352,15 +357,7 @@ METHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::lHasInputFocus := .t. ENDIF - /* Drawing Area of oCrt will point to itself */ - ::drawingArea := self - - HB_GtInfo( HB_GTI_NOTIFIERBLOCK, {|nEvent, ...| ::notifier( nEvent, ... ) } ) - - /* Not working yet. need to investigate how I have implemented it. */ - if !empty( ::toolTipText ) - Wvt_SetTooltip( ::toolTipText ) - endif + HB_GtInfo( HB_GTI_NOTIFIERBLOCKGUI, {|nEvent, ...| ::notifier( nEvent, ... ) } ) RETURN Self @@ -396,15 +393,16 @@ METHOD WvgCrt:destroy() aeval( ::aChildren, {|o| o:destroy() } ) ENDIF - if ::lModal - hb_gtInfo( HB_GTI_ENABLE , ::pGTp ) - hb_gtSelect( ::pGTp ) - hb_gtInfo( HB_GTI_SETFOCUS, ::pGTp ) + IF ! ::isGT + IF ::lModal + hb_gtInfo( HB_GTI_ENABLE , ::pGTp ) + hb_gtSelect( ::pGTp ) + hb_gtInfo( HB_GTI_SETFOCUS, ::pGTp ) + ENDIF + ::pGT := NIL + ::pGTp := NIL ENDIF - ::pGT := NIL - ::pGTp := NIL - RETURN Self /*----------------------------------------------------------------------*/ @@ -1158,12 +1156,3 @@ METHOD WvgCrt:dragDrop( xParam, xParam1 ) RETURN Self /*----------------------------------------------------------------------*/ - * HARBOUR SPECIFIC -/*----------------------------------------------------------------------*/ -METHOD WvgCrt:SetFocus() - - ::sendMessage( WM_ACTIVATE, 1, 0 ) - /* ::sendMessage( WM_SETFOCUS, 0, 0 ) */ - - RETURN Self -/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgcuig.c b/harbour/contrib/gtwvg/wvgcuig.c index 02f2011079..8f2100174d 100644 --- a/harbour/contrib/gtwvg/wvgcuig.c +++ b/harbour/contrib/gtwvg/wvgcuig.c @@ -619,7 +619,7 @@ HB_FUNC( WVG_LABEL ) gObj->aOffset.iRight = hb_parvni( 3, 4 ); #if defined( UNICODE ) - gObj->lpText = hb_mbtowc( hb_parcx( 4 ) ); + gObj->lpText = HB_TCHAR_CONVTO( hb_parc( 4 ) ); //hb_mbtowc( hb_parcx( 4 ) ); #else gObj->lpText = hb_strdup( hb_parcx( 4 ) ); #endif diff --git a/harbour/contrib/gtwvg/wvgdarea.prg b/harbour/contrib/gtwvg/wvgdarea.prg index 23a695b6c5..de0942a2b4 100644 --- a/harbour/contrib/gtwvg/wvgdarea.prg +++ b/harbour/contrib/gtwvg/wvgdarea.prg @@ -96,9 +96,9 @@ CLASS WvgDrawingArea INHERIT WvgWindow ENDCLASS /*----------------------------------------------------------------------*/ -METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDrawingArea +METHOD WvgDrawingArea:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD ::exStyle := 0 @@ -110,27 +110,26 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDrawi /*----------------------------------------------------------------------*/ -METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDrawingArea +METHOD WvgDrawingArea:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) HB_SYMBOL_UNUSED( lVisible ) ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, .t. ) - ::oParent:addChild( SELF ) + ::oParent:addChild( Self ) Wvg_RegisterClass_ByName( ::className ) ::createControl() ::SetWindowProcCallback() - ::show() RETURN Self /*----------------------------------------------------------------------*/ -METHOD handleEvent( nMessage, aNM ) CLASS WvgDrawingArea +METHOD WvgDrawingArea:handleEvent( nMessage, aNM ) LOCAL hDC hb_traceLog( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) @@ -142,7 +141,7 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgDrawingArea eval( ::sl_resize, NIL, NIL, self ) ENDIF aeval( ::aChildren, {|o| o:handleEvent( HB_GTE_RESIZED, { 0, 0, 0, 0, 0 } ) } ) - RETURN 0 + RETURN EVENT_HANDELLED CASE nMessage == HB_GTE_CTLCOLOR hDC := aNM[ 1 ] @@ -153,13 +152,13 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgDrawingArea IF hb_isNumeric( ::hBrushBG ) WVG_SetBkMode( hDC, 1 ) - Wvg_FillRect( hDC, { 0,0,::currentSize()[1],::currentSize()[1]}, ::hBrushBG ) - RETURN 0 + WVG_FillRect( hDC, { 0,0,::currentSize()[1],::currentSize()[2]}, ::hBrushBG ) + RETURN EVENT_HANDELLED ENDIF ENDCASE - RETURN 1 + RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgdatar.prg b/harbour/contrib/gtwvg/wvgdatar.prg index 80abd5b25a..c223796c78 100644 --- a/harbour/contrib/gtwvg/wvgdatar.prg +++ b/harbour/contrib/gtwvg/wvgdatar.prg @@ -109,13 +109,13 @@ CLASS DataRef /*----------------------------------------------------------------------*/ -METHOD new() CLASS DataRef +METHOD DataRef:new() RETURN self /*----------------------------------------------------------------------*/ -METHOD getData() CLASS DataRef +METHOD DataRef:getData() DO CASE CASE ::className == "EDIT" @@ -130,7 +130,7 @@ METHOD getData() CLASS DataRef /*----------------------------------------------------------------------*/ -METHOD setData( xValue, mp2 ) CLASS DataRef +METHOD DataRef:setData( xValue, mp2 ) HB_SYMBOL_UNUSED( mp2 ) @@ -174,13 +174,13 @@ METHOD setData( xValue, mp2 ) CLASS DataRef /*----------------------------------------------------------------------*/ -METHOD undo() CLASS DataRef +METHOD DataRef:undo() RETURN .f. /*----------------------------------------------------------------------*/ -METHOD validate( xParam ) CLASS DataRef +METHOD DataRef:validate( xParam ) IF PCount() == 0 .and. hb_isBlock( ::sl_validate ) RETURN eval( ::sl_validate, self ) diff --git a/harbour/contrib/gtwvg/wvgdlg.prg b/harbour/contrib/gtwvg/wvgdlg.prg index 428d7fde3f..138d5d6150 100644 --- a/harbour/contrib/gtwvg/wvgdlg.prg +++ b/harbour/contrib/gtwvg/wvgdlg.prg @@ -83,7 +83,7 @@ CLASS WvgDialog FROM WvgWindow DATA drawingArea DATA tasklist INIT .t. - METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD destroy() @@ -103,16 +103,16 @@ CLASS WvgDialog FROM WvgWindow /*----------------------------------------------------------------------*/ -METHOD WvgDialog:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) +METHOD WvgDialog:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::className := "WVGDIALOG" ::resizeMode := 0 ::mouseMode := 0 ::objType := objTypeDialog - ::style := WS_THICKFRAME+WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX; + ::style := WS_THICKFRAME+WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX RETURN Self @@ -162,10 +162,10 @@ METHOD WvgDialog:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) if ::visible ::lHasInputFocus := .t. - endif + ENDIF - oW := WvgDrawingArea():new( self ):create( , , {0,0}, self:currentSize(), , .f. ) - IF !empty( oW:hWnd ) + oW := WvgDrawingArea():new( Self ):create( , , {0,0}, Self:currentSize(), , .f. ) + IF ! empty( oW:hWnd ) ::drawingArea := oW ELSE ::drawingArea := Self diff --git a/harbour/contrib/gtwvg/wvggenrc.prg b/harbour/contrib/gtwvg/wvggenrc.prg new file mode 100644 index 0000000000..d4a1ddb3f2 --- /dev/null +++ b/harbour/contrib/gtwvg/wvggenrc.prg @@ -0,0 +1,117 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Wvg*Classes + * + * Copyright 2011 Pritpal Bedi + * http://harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + * + * EkOnkar + * ( The LORD is ONE ) + * + * Xbase++ Parts Compatible functions + * + * Pritpal Bedi + * 03Dec2011 + * +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "hbclass.ch" +#include "common.ch" +#include "inkey.ch" +#include "hbgtinfo.ch" + +#include "hbgtwvg.ch" +#include "wvtwin.ch" +#include "wvgparts.ch" + +/*----------------------------------------------------------------------*/ + + THREAD STATIC s_oCrt := NIL + +/*----------------------------------------------------------------------*/ + +EXIT PROCEDURE KillGTChildren() + LOCAL aChilds, oXbp + + IF hb_isObject( s_oCrt ) .AND. __objGetClsName( s_oCrt ) == "WVGCRT" .AND. s_oCrt:isGT + IF ! empty( aChilds := s_oCrt:childList() ) + FOR EACH oXbp IN aChilds + oXbp:destroy() + oXbp := NIL + NEXT + ENDIF + ENDIF + + RETURN + +/*----------------------------------------------------------------------*/ + +FUNCTION SetAppWindow( oCrt ) + LOCAL ooCrt := s_oCrt + + IF empty( oCrt ) + IF empty( s_oCrt ) + s_oCrt := WvgCrt():new() + s_oCrt:hWnd := Wvt_GetWindowHandle() + s_oCrt:pWnd := Win_N2P( s_oCrt:hWnd ) + HB_GtInfo( HB_GTI_NOTIFIERBLOCKGUI, {|nEvent, ...| s_oCrt:notifier( nEvent, ... ) } ) + s_oCrt:isGT := .T. + RETURN s_oCrt + ENDIF + ELSE + s_oCrt := oCrt + ENDIF + + RETURN ooCrt + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvghtmlv.prg b/harbour/contrib/gtwvg/wvghtmlv.prg index e13e500114..32c563541a 100644 --- a/harbour/contrib/gtwvg/wvghtmlv.prg +++ b/harbour/contrib/gtwvg/wvghtmlv.prg @@ -145,7 +145,7 @@ CLASS WvgHTMLViewer INHERIT WvgActiveXControl METHOD WvgHTMLViewer:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -155,7 +155,7 @@ METHOD WvgHTMLViewer:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD WvgHTMLViewer:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::mapEvent( evBeforeNavigate, {| cURL, Flags, TFName, PData, Headers | ; ::xBeforeNavigate( cURL, Flags, TFName, PData, Headers ) } ) diff --git a/harbour/contrib/gtwvg/wvglistb.prg b/harbour/contrib/gtwvg/wvglistb.prg index 3103af1aae..d3ec6eb4fb 100644 --- a/harbour/contrib/gtwvg/wvglistb.prg +++ b/harbour/contrib/gtwvg/wvglistb.prg @@ -148,9 +148,9 @@ CLASS WvgListBox INHERIT WvgWindow, DataRef METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgListBox - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::style := WS_CHILD + WS_OVERLAPPED + WS_TABSTOP + LBS_NOTIFY + ::style := WS_CHILD + WS_OVERLAPPED + WS_TABSTOP ::exStyle := WS_EX_CLIENTEDGE + WS_EX_LEFT + WS_EX_LTRREADING + WS_EX_RIGHTSCROLLBAR ::className := "LISTBOX" ::objType := objTypeListBox @@ -182,6 +182,7 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgLi IF ::visible ::show() ENDIF + ::setPosAndSize() RETURN Self @@ -189,30 +190,28 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgLi METHOD handleEvent( nMessage, aNM ) CLASS WvgListBox - hb_traceLog( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) - DO CASE + CASE nMessage == HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ENDIF + ::sendMessage( WM_SIZE, 0, 0 ) + CASE nMessage == HB_GTE_COMMAND IF aNM[ 1 ] == LBN_SELCHANGE ::nCurSelected := WVG_LBGetCurSel( ::hWnd )+ 1 - IF hb_isBlock( ::sl_itemMarked ) eval( ::sl_itemMarked, NIL, NIL, self ) ENDIF ELSEIF aNM[ 1 ] == LBN_DBLCLK ::editBuffer := ::nCurSelected - IF hb_isBlock( ::sl_itemSelected ) eval( ::sl_itemSelected, NIL, NIL, self ) ENDIF ENDIF - CASE nMessage == HB_GTE_RESIZED - ::sendMessage( WM_SIZE, 0, 0 ) - RETURN 0 - CASE nMessage == HB_GTE_CTLCOLOR IF hb_isNumeric( ::clr_FG ) WVG_SetTextColor( aNM[ 1 ], ::clr_FG ) @@ -224,26 +223,61 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgListBox RETURN WVG_GetCurrentBrush( aNM[ 1 ] ) ENDIF + CASE nMessage == HB_GTE_ANY + IF aNM[ 1 ] == WM_LBUTTONUP + ::nCurSelected := WVG_LBGetCurSel( ::hWnd ) + 1 + IF hb_isBlock( ::sl_itemMarked ) + IF ::isParentCrt() + ::oParent:setFocus() + ENDIF + eval( ::sl_itemMarked, NIL, NIL, self ) + IF ::isParentCrt() + ::setFocus() + ENDIF + ENDIF + + ELSEIF aNM[ 1 ] == WM_LBUTTONDBLCLK + ::editBuffer := ::nCurSelected + IF hb_isBlock( ::sl_itemSelected ) + IF ::isParentCrt() + ::oParent:setFocus() + ENDIF + eval( ::sl_itemSelected, NIL, NIL, self ) + IF ::isParentCrt() + ::setFocus() + ENDIF + RETURN EVENT_HANDELLED + ENDIF + + ELSEIF aNM[ 1 ] == WM_KEYUP + IF ::nCurSelected != WVG_LBGetCurSel( ::hWnd ) + 1 + ::nCurSelected := WVG_LBGetCurSel( ::hWnd ) + 1 + IF hb_isBlock( ::sl_itemMarked ) + IF ::isParentCrt() + ::oParent:setFocus() + ENDIF + eval( ::sl_itemMarked, NIL, NIL, self ) + IF ::isParentCrt() + ::setFocus() + ENDIF + ENDIF + ENDIF + + ENDIF ENDCASE - RETURN 0 + RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgListBox - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - RETURN Self /*----------------------------------------------------------------------*/ METHOD destroy() CLASS WvgListBox - - hb_traceLog( " %s:destroy()", __objGetClsName() ) - ::WvgWindow:destroy() - RETURN NIL /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgmenub.prg b/harbour/contrib/gtwvg/wvgmenub.prg index 52aabaa056..f4ee3998fb 100644 --- a/harbour/contrib/gtwvg/wvgmenub.prg +++ b/harbour/contrib/gtwvg/wvgmenub.prg @@ -165,7 +165,7 @@ METHOD WvgMenuBar:create( oParent, aPresParams, lVisible ) ::hMenu := WVG_CreateMenu() - if ::hMenu <> 0 + IF ::hMenu <> 0 /* check for if the parent already has a menu we need to destroy that first TO DO @@ -176,15 +176,15 @@ METHOD WvgMenuBar:create( oParent, aPresParams, lVisible ) #endif /* how to make menu invisible ? */ - if ( ::visible ) + IF ( ::visible ) #if 0 WVG_ShowWindow( ::oParent:getHWND(), SW_MINIMIZE ) WVG_ShowWindow( ::oParent:getHWND(), SW_NORMAL ) #endif - endif + ENDIF ::oParent:oMenu := Self - endif + ENDIF RETURN Self diff --git a/harbour/contrib/gtwvg/wvgmle.prg b/harbour/contrib/gtwvg/wvgmle.prg index e83f976976..4ff6a12ef2 100644 --- a/harbour/contrib/gtwvg/wvgmle.prg +++ b/harbour/contrib/gtwvg/wvgmle.prg @@ -92,7 +92,6 @@ CLASS WvgMLE INHERIT WvgWindow, DataRef DATA ignoreTab INIT .F. DATA bufferLength INIT 32000 - DATA changed INIT .F. METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -100,9 +99,9 @@ CLASS WvgMLE INHERIT WvgWindow, DataRef METHOD destroy() METHOD handleEvent( nMessage, aNM ) - METHOD clear() VIRTUAL - METHOD copyMarked() VIRTUAL - METHOD cutMarked() VIRTUAL + METHOD clear() + METHOD copyMarked() + METHOD cutMarked() METHOD deleteMarked() VIRTUAL METHOD delete() VIRTUAL METHOD pasteMarked() VIRTUAL @@ -111,7 +110,7 @@ CLASS WvgMLE INHERIT WvgWindow, DataRef METHOD setFirstChar() VIRTUAL METHOD setMarked() VIRTUAL METHOD insert() VIRTUAL - METHOD charFromLine() VIRTUAL + METHOD charFromLine( nLine ) VIRTUAL METHOD lineFromChar() VIRTUAL METHOD pos() VIRTUAL @@ -130,13 +129,15 @@ CLASS WvgMLE INHERIT WvgWindow, DataRef ACCESS vScroll INLINE ::sl_vScroll ASSIGN vScroll( bBlock ) INLINE ::sl_vScroll := bBlock + METHOD changed( lChanged ) SETGET + ENDCLASS /*----------------------------------------------------------------------*/ -METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgMLE +METHOD WvgMLE:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + ES_MULTILINE + ES_WANTRETURN ::exStyle := WS_EX_CLIENTEDGE @@ -147,7 +148,7 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgMLE /*----------------------------------------------------------------------*/ -METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgMLE +METHOD WvgMLE:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -182,25 +183,20 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgML IF ::visible ::show() ENDIF + ::setPosAndSize() RETURN Self /*----------------------------------------------------------------------*/ -METHOD handleEvent( nMessage, aNM ) CLASS WvgMLE +METHOD WvgMLE:handleEvent( nMessage, aNM ) hb_traceLog( " %s:handleEvent( %i )", __objGetClsName( self ), nMessage ) DO CASE + CASE nMessage == HB_GTE_COMMAND DO CASE - CASE aNM[ NMH_code ] == EN_CHANGE - ::changed := .t. - - CASE aNM[ NMH_code ] == EN_UPDATE - - CASE aNM[ NMH_code ] == EN_MAXTEXT - CASE aNM[ NMH_code ] == EN_KILLFOCUS IF hb_isBlock( ::sl_killInputFocus ) eval( ::sl_killInputFocus, NIL, NIL, Self ) @@ -221,6 +217,10 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgMLE eval( ::sl_vScroll, NIL, NIL, Self ) ENDIF + CASE aNM[ NMH_code ] == EN_CHANGE + CASE aNM[ NMH_code ] == EN_UPDATE + CASE aNM[ NMH_code ] == EN_MAXTEXT + ENDCASE CASE nMessage == HB_GTE_CTLCOLOR @@ -234,13 +234,46 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgMLE RETURN WVG_GetCurrentBrush( aNM[ 1 ] ) ENDIF + CASE nMessage == HB_GTE_ANY + IF ::isParentCrt() + + DO CASE + CASE aNM[ NMH_code ] == WM_KEYDOWN + IF aNM[ 2 ] == VK_TAB + ::oParent:setFocus() + RETURN EVENT_HANDELLED + ENDIF + + CASE aNM[ NMH_code ] == WM_KILLFOCUS + IF hb_isBlock( ::sl_killInputFocus ) + eval( ::sl_killInputFocus, NIL, NIL, Self ) + ENDIF + + CASE aNM[ NMH_code ] == WM_SETFOCUS + IF hb_isBlock( ::sl_setInputFocus ) + eval( ::sl_setInputFocus, NIL, NIL, Self ) + ENDIF + + CASE aNM[ NMH_code ] == WM_HSCROLL + IF hb_isBlock( ::sl_hScroll ) + eval( ::sl_hScroll, NIL, NIL, Self ) + ENDIF + + CASE aNM[ NMH_code ] == WM_VSCROLL + IF hb_isBlock( ::sl_vScroll ) + eval( ::sl_vScroll, NIL, NIL, Self ) + ENDIF + + ENDCASE + ENDIF + ENDCASE - RETURN 0 + RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ -METHOD destroy() CLASS WvgMLE +METHOD WvgMLE:destroy() hb_traceLog( " %s:destroy()", __objGetClsName( self ) ) @@ -249,3 +282,56 @@ METHOD destroy() CLASS WvgMLE RETURN NIL /*----------------------------------------------------------------------*/ + +METHOD WvgMLE:changed( lChanged ) + LOCAL lChg := ::sendMessage( EM_GETMODIFY, 0, 0 ) + + IF hb_isLogical( lChanged ) + ::sendMessage( EM_SETMODIFY, iif( lChanged, 0, 1 ), 0 ) + ENDIF + + RETURN lChg + +/*----------------------------------------------------------------------*/ + +METHOD WvgMLE:clear() + LOCAL cText := ::getData() + + ::setData( "" ) + + RETURN len( cText ) + +/*----------------------------------------------------------------------*/ + +METHOD WvgMLE:copyMarked() + LOCAL n, nB, nE + + n := ::sendMessage( EM_GETSEL ) + nB := WVG_LOWORD( n ) + nE := WVG_HIWORD( n ) + + IF ( n := nE - nB ) > 0 + Wvt_SetClipboard( substr( ::getData(), nB, n ) ) + ENDIF + + RETURN n + +/*----------------------------------------------------------------------*/ + +METHOD WvgMLE:cutMarked() + LOCAL n, nB, nE, cText + + n := ::sendMessage( EM_GETSEL ) + nB := WVG_LOWORD( n ) + nE := WVG_HIWORD( n ) + + IF ( n := nE - nB ) > 0 + cText := ::getData() + ::setData( substr( cText, 1, nB-1 ) + substr( cText, nE ) ) + ENDIF + + RETURN n + +/*----------------------------------------------------------------------*/ + + diff --git a/harbour/contrib/gtwvg/wvgpaint.prg b/harbour/contrib/gtwvg/wvgpaint.prg index e0eadb3a26..4188b9e84f 100644 --- a/harbour/contrib/gtwvg/wvgpaint.prg +++ b/harbour/contrib/gtwvg/wvgpaint.prg @@ -258,18 +258,18 @@ function InsertPaint( cID, aPaint, lSet ) /* nMode : 0 == Rows/cols - DEFAULT 1 == DlagUnits as from any standard dialog definition */ FUNCTION Wvt_SetDlgCoMode( nMode ) LOCAL nOldMode - + STATIC sMode := 0 - + nOldMode := sMode - IF hb_isNumeric( nMode ) .and. nMode <= 1 .and. nMode >= 0 + IF hb_isNumeric( nMode ) .and. nMode <= 1 .and. nMode >= 0 sMode := nMode - ENDIF - + ENDIF + RETURN nOldMode - + /*----------------------------------------------------------------------*/ - + FUNCTION Wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle, ; cFaceName, nPointSize, nWeight, lItalic, nHelpId, nExStyle ) @@ -279,7 +279,7 @@ FUNCTION Wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY LOCAL aFont LOCAL nMode := Wvt_SetDlgCoMode() - + aFont := Wvt_GetFontInfo() IF nMode == 0 @@ -293,16 +293,16 @@ FUNCTION Wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle nBaseUnits := WVG_GetDialogBaseUnits() nBaseUnitsX := WVG_LOWORD( nBaseUnits ) nBaseUnitsY := WVG_HIWORD( nBaseUnits ) - + nW := aFont[ 7 ] * nCols + aOffSet[ 4 ] nH := aFont[ 6 ] * nRows + aOffSet[ 3 ] - + /* Position it exactly where user has requested */ - + aXY := Wvt_ClientToScreen( nTop,nLeft ) nX := aXY[ 1 ] + aOffSet[ 2 ] nY := aXY[ 2 ] + aOffSet[ 1 ] - + /* MSDN says DlgBaseUnits and Screen Coordinates has multiplier of 4,8 for x & Y. * But in my practice, the values below are 99% accurate. * I have tested it on many fonts but on 1280/800 resolution. @@ -310,17 +310,17 @@ FUNCTION Wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle */ nXM := 5.25 nYM := 10.25 - + nX := ( nX * nXM / nBaseUnitsX ) nY := ( nY * nYM / nBaseUnitsY ) nW := ( nW * nXM / nBaseUnitsX ) nH := ( nH * nYM / nBaseUnitsY ) - ELSE + ELSE nX := nLeft nY := nTop nW := nCols nH := nRows - ENDIF + ENDIF If !ISNUMBER( nStyle ) nStyle := + WS_CAPTION + WS_SYSMENU ; @@ -359,44 +359,44 @@ Function Wvt_AddDlgItem( aDlg, nTop, nLeft, nRows, nCols, aOffSet,; LOCAL nBottom, nRight LOCAL nMode := Wvt_SetDlgCoMode() - IF nMode == 0 + IF nMode == 0 nBottom := nTop + nRows - 1 nRight := nLeft + nCols - 1 - + DEFAULT aOffSet TO {} - + aSize( aOffSet,4 ) - + DEFAULT aOffSet[ 1 ] TO 0 DEFAULT aOffSet[ 2 ] TO 0 DEFAULT aOffSet[ 3 ] TO 0 DEFAULT aOffSet[ 4 ] TO 0 - + nBaseUnits := WVG_GetDialogBaseUnits() nBaseUnitsX := WVG_LOWORD( nBaseUnits ) nBaseUnitsY := WVG_HIWORD( nBaseUnits ) - + aXY := Wvt_GetXYFromRowCol( nTop, nLeft ) nX := aXY[ 1 ] + aOffSet[ 2 ] nY := aXY[ 2 ] + aOffSet[ 1 ] - + aXY := Wvt_GetXYFromRowCol( nBottom+1, nRight+1 ) nW := aXY[ 1 ] + aOffSet[ 4 ] - nX nH := aXY[ 2 ] + aOffSet[ 3 ] - nY - + nXM := 5.25 nYM := 10.25 - + nX := ( nX * nXM / nBaseUnitsX ) nY := ( nY * nYM / nBaseUnitsY ) nW := ( nW * nXM / nBaseUnitsX ) nH := ( nH * nYM / nBaseUnitsY ) - ELSE + ELSE nX := nLeft nY := nTop nW := nCols nH := nRows - ENDIF + ENDIF aDlg[ 1,4 ]++ /* item count */ @@ -479,7 +479,7 @@ Function Wvt_DialogBox( acnDlg, cbDlgProc, hWndParent ) nResult := Wvt_CreateDialogModal( xTemplate, .f., cbDlgProc, nDlgMode, hWndParent ) Wvg_SetFocus( hWndParent ) - + Return nResult /*----------------------------------------------------------------------*/ @@ -500,32 +500,32 @@ Returns: If OFN_ALLOWMULTISELECT ? Array of files selected : FileName. */ FUNCTION WVT_GetOpenFileName( hWnd, cPath, cTitle, acFilter, nFlags, cInitDir, cDefExt, nFilterIndex, cDefName ) LOCAL cRet, aTmp, xRet, i - + HB_SYMBOL_UNUSED( hWnd ) - + DEFAULT cPath TO "" DEFAULT nFlags TO OFN_EXPLORER + OFN_NOCHANGEDIR - + /* WIN_GETOPENFILENAME( [[@]], [], [], [],; * [], [[@]], [], [] ) * -> | + e"\0" + [ + e"\0" + ] | "" */ cRet := WIN_GetOpenFileName( @nFlags, cTitle, cInitDir, cDefExt, acFilter, @nFilterIndex, /*nBufferSize*/, cDefName ) - - IF WVG_And( nFlags, OFN_ALLOWMULTISELECT ) > 0 + + IF WVG_And( nFlags, OFN_ALLOWMULTISELECT ) > 0 xRet := {} IF ! empty( aTmp := hb_aTokens( cRet, chr( 0 ) ) ) cPath := aTmp[ 1 ] FOR i := 2 TO len( aTmp ) aadd( xRet, cPath + "\" + aTmp[ i ] ) - NEXT - ENDIF - ELSE - xRet := cRet - ENDIF - - RETURN xRet - + NEXT + ENDIF + ELSE + xRet := cRet + ENDIF + + RETURN xRet + /*----------------------------------------------------------------------*/ /* Wvt_GetSaveFileName( hWnd, cDefFile, cTitle, acFilter, nFlags, cInitDir, cDefExt, @nFilterIndex ) @@ -546,28 +546,28 @@ FUNCTION WVT_GetSaveFileName( hWnd, cDefName, cTitle, acFilter, nFlags, cInitDir LOCAL cRet, aTmp, xRet, i, cPath HB_SYMBOL_UNUSED( hWnd ) - + DEFAULT nFlags TO OFN_EXPLORER + OFN_NOCHANGEDIR - + /* WIN_GETSAVEFILENAME( [[@]], [], [], [],; * [], [[@]], [], [] ) * -> | + e"\0" + [ + e"\0" + ] | "" */ cRet := WIN_GetSaveFileName( @nFlags, cTitle, cInitDir, cDefExt, acFilter, @nFilterIndex, /*nBufferSize*/, cDefName ) - - IF WVG_And( nFlags, OFN_ALLOWMULTISELECT ) > 0 + + IF WVG_And( nFlags, OFN_ALLOWMULTISELECT ) > 0 xRet := {} IF ! empty( aTmp := hb_aTokens( cRet, chr( 0 ) ) ) cPath := aTmp[ 1 ] FOR i := 2 TO len( aTmp ) aadd( xRet, cPath + "\" + aTmp[ i ] ) - NEXT - ENDIF - ELSE - xRet := cRet - ENDIF - - RETURN xRet + NEXT + ENDIF + ELSE + xRet := cRet + ENDIF + + RETURN xRet /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ @@ -647,6 +647,58 @@ FUNCTION Wvt_GetRGBColor( nIndex ) RETURN Hb_GtInfo( HB_GTI_PALETTE, nIndex ) +/*----------------------------------------------------------------------*/ +#define BLACK RGB( 0x0 ,0x0 ,0x0 ) +#define BLUE RGB( 0x0 ,0x0 ,0x85 ) +#define GREEN RGB( 0x0 ,0x85,0x0 ) +#define CYAN RGB( 0x0 ,0x85,0x85 ) +#define RED RGB( 0x85,0x0 ,0x0 ) +#define MAGENTA RGB( 0x85,0x0 ,0x85 ) +#define BROWN RGB( 0x85,0x85,0x0 ) +#define LIGHT_GRAY RGB( 0xC6,0xC6,0xC6 ) +#define GRAY RGB( 0x60,0x60,0x60 ) +#define BRIGHT_BLUE RGB( 0x00,0x00,0xFF ) +#define BRIGHT_GREEN RGB( 0x60,0xFF,0x60 ) +#define BRIGHT_CYAN RGB( 0x60,0xFF,0xFF ) +#define BRIGHT_RED RGB( 0xF8,0x00,0x26 ) +#define BRIGHT_MAGENTA RGB( 0xFF,0x60,0xFF ) +#define YELLOW RGB( 0xFF,0xFF,0x00 ) +#define WHITE RGB( 0xFF,0xFF,0xFF ) + +FUNCTION Wvt_GetRGBColorByString( cColor, nForeBack ) + LOCAL s, n, lEnh + LOCAL nIndex := 0 + LOCAL a_:= { "N", "B", "G", "BG", "R", "RB", "GR", "W" } + + nForeBack := iif( hb_isNumeric( nForeBack ), nForeBack, 0 ) + + IF hb_isChar( cColor ) + IF ( n := at( cColor, "/" ) ) > 0 + IF nForeBack == 0 + s := substr( cColor, 1, n-1 ) + ELSE + s := substr( cColor, n+1 ) + ENDIF + ELSE + s := cColor + ENDIF + s := upper( s ) + lEnh := ( "*" $ s ) .OR. ( "+" $ s ) + IF lEnh + s := strtran( s, "*" ) + s := strtran( s, "+" ) + ENDIF + nIndex := ascan( a_, {|e| e == s } ) + IF nIndex > 0 + IF lEnh + nIndex += 8 + ENDIF + nIndex-- + ENDIF + ENDIF + + RETURN Hb_GtInfo( HB_GTI_PALETTE, nIndex ) + /*----------------------------------------------------------------------*/ FUNCTION Wvt_SetAltF4Close( lSetClose ) diff --git a/harbour/contrib/gtwvg/wvgphdlr.prg b/harbour/contrib/gtwvg/wvgphdlr.prg index ca9ffa908a..4108ad353a 100644 --- a/harbour/contrib/gtwvg/wvgphdlr.prg +++ b/harbour/contrib/gtwvg/wvgphdlr.prg @@ -80,7 +80,7 @@ CLASS WvgPartHandler DATA cargo - METHOD init( oParent, oOwner ) + METHOD new( oParent, oOwner ) METHOD create( oParent, oOwner ) METHOD configure( oParent, oOwner ) METHOD destroy() @@ -107,7 +107,7 @@ CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD init( oParent, oOwner ) CLASS WvgPartHandler +METHOD WvgPartHandler:new( oParent, oOwner ) ::oParent := oParent ::oOwner := oOwner @@ -116,7 +116,7 @@ METHOD init( oParent, oOwner ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD create( oParent, oOwner ) CLASS WvgPartHandler +METHOD WvgPartHandler:create( oParent, oOwner ) DEFAULT oParent TO ::oParent DEFAULT oOwner TO ::oOwner @@ -128,7 +128,7 @@ METHOD create( oParent, oOwner ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD configure( oParent, oOwner ) CLASS WvgPartHandler +METHOD WvgPartHandler:configure( oParent, oOwner ) DEFAULT oParent TO ::oParent DEFAULT oOwner TO ::oOwner @@ -140,7 +140,7 @@ METHOD configure( oParent, oOwner ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD destroy() CLASS WvgPartHandler +METHOD WvgPartHandler:destroy() ::hChildren := NIL ::nNameId := NIL @@ -151,7 +151,7 @@ METHOD destroy() CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD handleEvent( hEvent, mp1, mp2 ) CLASS WvgPartHandler +METHOD WvgPartHandler:handleEvent( hEvent, mp1, mp2 ) HB_SYMBOL_UNUSED( hEvent ) HB_SYMBOL_UNUSED( mp1 ) @@ -161,13 +161,13 @@ METHOD handleEvent( hEvent, mp1, mp2 ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD status() CLASS WvgPartHandler +METHOD WvgPartHandler:status() RETURN ::nStatus /*----------------------------------------------------------------------*/ -METHOD addChild( oWvg ) CLASS WvgPartHandler +METHOD WvgPartHandler:addChild( oWvg ) oWvg:nNameID := oWvg:nID aadd( ::aChildren, oWvg ) @@ -176,7 +176,7 @@ METHOD addChild( oWvg ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD childFromName( nNameId ) CLASS WvgPartHandler +METHOD WvgPartHandler:childFromName( nNameId ) LOCAL i, oWvg FOR i := 1 TO len( ::aChildren ) @@ -189,13 +189,13 @@ METHOD childFromName( nNameId ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD childList() CLASS WvgPartHandler +METHOD WvgPartHandler:childList() RETURN ::aChildren /*----------------------------------------------------------------------*/ -METHOD delChild( oWvg ) CLASS WvgPartHandler +METHOD WvgPartHandler:delChild( oWvg ) LOCAL n n := ascan( ::aChildren, {|o| o == oWvg } ) @@ -209,7 +209,7 @@ METHOD delChild( oWvg ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD setName( nNameId ) CLASS WvgPartHandler +METHOD WvgPartHandler:setName( nNameId ) LOCAL nOldNameId := ::nNameId IF Valtype( nNameId ) == "N" @@ -220,7 +220,7 @@ METHOD setName( nNameId ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD setOwner( oWvg ) CLASS WvgPartHandler +METHOD WvgPartHandler:setOwner( oWvg ) LOCAL oOldXbp := ::oOwner IF valtype( oWvg ) == "O" @@ -231,7 +231,7 @@ METHOD setOwner( oWvg ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD setParent( oWvg ) CLASS WvgPartHandler +METHOD WvgPartHandler:setParent( oWvg ) LOCAL oOldXbp := ::oParent IF valtype( oWvg ) == "O" @@ -242,7 +242,7 @@ METHOD setParent( oWvg ) CLASS WvgPartHandler /*----------------------------------------------------------------------*/ -METHOD notifier( nEvent, xParams ) CLASS WvgPartHandler +METHOD WvgPartHandler:notifier( nEvent, xParams ) Local aPos, aMenuItem, nIndex, nCtrlID, oObj LOCAL nReturn := 0 diff --git a/harbour/contrib/gtwvg/wvgpushb.prg b/harbour/contrib/gtwvg/wvgpushb.prg index 90e3fa1cdd..0edd17235f 100644 --- a/harbour/contrib/gtwvg/wvgpushb.prg +++ b/harbour/contrib/gtwvg/wvgpushb.prg @@ -86,7 +86,7 @@ CLASS WvgPushButton INHERIT WvgWindow DATA autosize INIT .F. DATA border INIT .T. - DATA caption INIT "" + DATA caption INIT NIL DATA pointerFocus INIT .T. DATA preSelect INIT .F. DATA drawMode INIT WVG_DRAW_NORMAL @@ -110,11 +110,11 @@ CLASS WvgPushButton INHERIT WvgWindow /*----------------------------------------------------------------------*/ -METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgPushButton +METHOD WvgPushButton:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::style := WS_CHILD + BS_PUSHBUTTON /*+ BS_NOTIFY + BS_PUSHLIKE */ + ::style := WS_CHILD + BS_PUSHBUTTON /* + BS_NOTIFY + BS_PUSHLIKE */ ::className := "BUTTON" ::objType := objTypePushButton @@ -122,19 +122,35 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgPushB /*----------------------------------------------------------------------*/ -METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgPushButton +METHOD WvgPushButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + IF hb_isNumeric( ::caption ) + ::style += BS_BITMAP + ELSEIF hb_isChar( ::caption ) + IF ".ICO" == upper( right( ::caption, 4 ) ) + ::style += BS_ICON + ELSEIF ".BMP" == upper( right( ::caption, 4 ) ) + ::style += BS_BITMAP + ENDIF + ENDIF + IF ! ::border + ::style += BS_FLAT + ENDIF + ::oParent:AddChild( SELF ) ::createControl() - ::SetWindowProcCallback() +// IF ::isParentCrt() + ::SetWindowProcCallback() +// ENDIF IF ::visible ::show() ENDIF + ::setPosAndSize() ::setCaption( ::caption ) @@ -142,25 +158,26 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgPu /*----------------------------------------------------------------------*/ -METHOD handleEvent( nMessage, aNM ) CLASS WvgPushButton - - hb_traceLog( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) +METHOD WvgPushButton:handleEvent( nMessage, aNM ) DO CASE CASE nMessage == HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ENDIF + ::sendMessage( WM_SIZE, 0, 0 ) IF hb_isBlock( ::sl_resize ) eval( ::sl_resize, NIL, NIL, self ) - RETURN EVENT_HANDELLED ENDIF CASE nMessage == HB_GTE_COMMAND IF hb_isBlock( ::sl_lbClick ) eval( ::sl_lbClick, NIL, NIL, self ) - RETURN EVENT_HANDELLED ENDIF CASE nMessage == HB_GTE_NOTIFY + // Will never be issued because pushbutton sends WM_COMMAND CASE nMessage == HB_GTE_CTLCOLOR IF hb_isNumeric( ::clr_FG ) @@ -171,44 +188,60 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgPushButton RETURN ::hBrushBG ENDIF + CASE nMessage == HB_GTE_ANY + IF aNM[ 1 ] == WM_LBUTTONUP + IF hb_isBlock( ::sl_lbClick ) + IF ::isParentCrt() + ::oParent:setFocus() + ENDIF + eval( ::sl_lbClick, NIL, NIL, Self ) + ENDIF + ENDIF + ENDCASE RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ -METHOD destroy() CLASS WvgPushButton - - hb_traceLog( " %s:destroy()", __objGetClsName() ) - +METHOD WvgPushButton:destroy() ::wvgWindow:destroy() - RETURN NIL /*----------------------------------------------------------------------*/ -METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgPushButton - +METHOD WvgPushButton:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - RETURN Self /*----------------------------------------------------------------------*/ -METHOD setCaption( xCaption, cDll ) CLASS WvgPushButton +METHOD WvgPushButton:setCaption( xCaption, cDll ) + DEFAULT xCaption TO ::caption HB_SYMBOL_UNUSED( cDll ) IF hb_isChar( xCaption ) ::caption := xCaption - WVG_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption ) + IF ".ICO" == upper( right( ::caption, 4 ) ) + WVG_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_ICON, WVG_LoadImage( ::caption, 2, IMAGE_ICON ) ) + ELSEIF ".BMP" == upper( right( ::caption, 4 ) ) + WVG_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, WVG_LoadImage( ::caption, 2, IMAGE_BITMAP ) ) + ELSE + WVG_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption ) + ENDIF + + ELSEIF hb_isNumeric( xCaption ) /* Handle to the bitmap */ + ::caption := xCaption + WVG_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, ::caption ) + ENDIF RETURN Self /*----------------------------------------------------------------------*/ -METHOD activate( xParam ) CLASS WvgPushButton +METHOD WvgPushButton:activate( xParam ) IF hb_isBlock( xParam ) .OR. ( xParam == NIL ) ::sl_lbClick := xParam @@ -218,7 +251,7 @@ METHOD activate( xParam ) CLASS WvgPushButton /*----------------------------------------------------------------------*/ -METHOD draw( xParam ) CLASS WvgPushButton +METHOD WvgPushButton:draw( xParam ) IF hb_isBlock( xParam ) .or. ( xParam == NIL ) ::sl_paint := xParam diff --git a/harbour/contrib/gtwvg/wvgradio.prg b/harbour/contrib/gtwvg/wvgradio.prg index 4bdd24298f..2f1790df3e 100644 --- a/harbour/contrib/gtwvg/wvgradio.prg +++ b/harbour/contrib/gtwvg/wvgradio.prg @@ -106,7 +106,7 @@ CLASS WvgRadioButton INHERIT WvgWindow, DataRef METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgRadioButton - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + BS_AUTORADIOBUTTON ::className := "BUTTON" diff --git a/harbour/contrib/gtwvg/wvgscrlb.prg b/harbour/contrib/gtwvg/wvgscrlb.prg index 9b982f13a3..71365b9382 100644 --- a/harbour/contrib/gtwvg/wvgscrlb.prg +++ b/harbour/contrib/gtwvg/wvgscrlb.prg @@ -151,7 +151,7 @@ CLASS WvgScrollBar INHERIT WvgWindow, DataRef METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgScrollBar - ::WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD /* + SBS_SIZEBOX + SBS_SIZEGRIP */ ::className := "SCROLLBAR" @@ -175,13 +175,16 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSc ::createControl() - ::SetWindowProcCallback() + IF ::isParentCrt() + ::SetWindowProcCallback() + ENDIF ::setRange( ::range ) IF ::visible ::show() ENDIF + ::setPosAndSize() #if 0 si IS SCROLLINFO @@ -189,9 +192,9 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSc cSI := si:value IF WAPI_GetScrollInfo( ::pWnd, SB_CTL, @cSI ) si:buffer( cSI ) -hb_traceLog( "scrollinfo nMin=%i nMax=%i", si:nMin, si:nMax ) ENDIF #endif + RETURN Self /*----------------------------------------------------------------------*/ @@ -203,6 +206,12 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgScrollBar DO CASE + CASE nMessage == HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ENDIF + ::sendMessage( WM_SIZE, 0, 0 ) + CASE nMessage == HB_GTE_CTLCOLOR IF hb_isNumeric( ::hBrushBG ) WVG_SetBkMode( aNM[ 1 ], 1 ) diff --git a/harbour/contrib/gtwvg/wvgsle.prg b/harbour/contrib/gtwvg/wvgsle.prg index fcade52066..3209fca003 100644 --- a/harbour/contrib/gtwvg/wvgsle.prg +++ b/harbour/contrib/gtwvg/wvgsle.prg @@ -6,7 +6,7 @@ * Harbour Project source code: * Source file for the Wvg*Classes * - * Copyright 2008 Pritpal Bedi + * Copyright 2008-2011 Pritpal Bedi * http://harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -58,7 +58,7 @@ * * Xbase++ xbpSLE compatible Class * - * Pritpal Bedi + * Pritpal Bedi * 07Dec2008 */ /*----------------------------------------------------------------------*/ @@ -93,17 +93,15 @@ CLASS WvgSLE INHERIT WvgWindow, DataRef DATA editable INIT .T. DATA unReadable INIT .F. - DATA changed INIT .F. - METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) VIRTUAL METHOD destroy() METHOD handleEvent( nMessage, aNM ) - METHOD clear() VIRTUAL - METHOD copyMarked() VIRTUAL - METHOD cutMarked() VIRTUAL + METHOD clear() + METHOD copyMarked() + METHOD cutMarked() METHOD delMarked() VIRTUAL METHOD editBuffer() VIRTUAL METHOD pasteMarked() VIRTUAL @@ -122,13 +120,18 @@ CLASS WvgSLE INHERIT WvgWindow, DataRef ACCESS typeOut INLINE ::sl_typeOut ASSIGN typeOut( bBlock ) INLINE ::sl_typeOut := bBlock + METHOD changed( lChanged ) SETGET + + DATA sl_returnPressed + METHOD returnPressed( ... ) SETGET + ENDCLASS /*----------------------------------------------------------------------*/ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSLE - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD ::className := "EDIT" @@ -171,6 +174,7 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSL IF ::visible ::show() ENDIF + ::setPosAndSize() IF hb_isObject( ::datalink ) eval( ::datalink ) @@ -187,10 +191,16 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgSLE hb_traceLog( " %s:handleEvent( %i )", __objGetClsName( self ), nMessage ) DO CASE + CASE nMessage == HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ::oParent:sendMessage( WM_SETFOCUS, 0, 0 ) + ENDIF + ::sendMessage( WM_SIZE, 0, 0 ) + CASE nMessage == HB_GTE_COMMAND DO CASE CASE aNM[ NMH_code ] == EN_CHANGE - ::changed := .t. CASE aNM[ NMH_code ] == EN_UPDATE @@ -219,9 +229,36 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgSLE RETURN WVG_GetCurrentBrush( aNM[ 1 ] ) ENDIF + CASE nMessage == HB_GTE_ANY + IF ::IsParentCrt() + DO CASE + CASE aNM[ NMH_code ] == WM_KILLFOCUS + IF hb_isBlock( ::sl_killInputFocus ) + eval( ::sl_killInputFocus, NIL, NIL, Self ) + ENDIF + + CASE aNM[ NMH_code ] == WM_SETFOCUS + IF hb_isBlock( ::sl_setInputFocus ) + eval( ::sl_setInputFocus, NIL, NIL, Self ) + ENDIF + + CASE aNM[ NMH_code ] == WM_KEYDOWN + IF aNM[ 2 ] == K_ENTER + ::oParent:setFocus() + IF hb_isBlock( ::sl_returnPressed ) + eval( ::sl_returnPressed, NIL, NIL, Self ) + ENDIF + ELSEIF aNM[ 2 ] == VK_TAB + ::oParent:setFocus() + RETURN EVENT_HANDELLED + ENDIF + + ENDCASE + ENDIF + ENDCASE - RETURN 1 + RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ @@ -234,3 +271,66 @@ METHOD destroy() CLASS WvgSLE RETURN NIL /*----------------------------------------------------------------------*/ + +METHOD WvgSLE:changed( lChanged ) + LOCAL lChg := ::sendMessage( EM_GETMODIFY, 0, 0 ) + + IF hb_isLogical( lChanged ) + ::sendMessage( EM_SETMODIFY, iif( lChanged, 0, 1 ), 0 ) + ENDIF + + RETURN lChg + +/*----------------------------------------------------------------------*/ + +METHOD WvgSLE:clear() + LOCAL cText := ::getData() + + ::setData( "" ) + + RETURN len( cText ) + +/*----------------------------------------------------------------------*/ + +METHOD WvgSLE:copyMarked() + LOCAL n, nB, nE + + n := ::sendMessage( EM_GETSEL ) + nB := WVG_LOWORD( n ) + nE := WVG_HIWORD( n ) + + IF ( n := nE - nB ) > 0 + Wvt_SetClipboard( substr( ::getData(), nB, n ) ) + ENDIF + + RETURN n + +/*----------------------------------------------------------------------*/ + +METHOD WvgSLE:cutMarked() + LOCAL n, nB, nE, cText + + n := ::sendMessage( EM_GETSEL ) + nB := WVG_LOWORD( n ) + nE := WVG_HIWORD( n ) + + IF ( n := nE - nB ) > 0 + cText := ::getData() + ::setData( substr( cText, 1, nB-1 ) + substr( cText, nE ) ) + ENDIF + + RETURN n + +/*----------------------------------------------------------------------*/ + +METHOD WvgSLE:returnPressed( ... ) + LOCAL a_:= hb_aParams() + IF len( a_ ) == 1 .AND. hb_isBlock( a_[ 1 ] ) + ::sl_returnPressed := a_[ 1 ] + ELSEIF len( a_ ) >= 0 .AND. hb_isBlock( ::sl_returnPressed ) + eval( ::sl_returnPressed, NIL, NIL, Self ) + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/gtwvg/wvgstatb.prg b/harbour/contrib/gtwvg/wvgstatb.prg index 218e148301..e5eb4ff2a5 100644 --- a/harbour/contrib/gtwvg/wvgstatb.prg +++ b/harbour/contrib/gtwvg/wvgstatb.prg @@ -110,7 +110,7 @@ CLASS WvgStatusBar INHERIT WvgWindow /* WvgActiveXControl */ METHOD WvgStatusBar:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + WS_BORDER + SBARS_TOOLTIPS ::className := STATUSCLASSNAME diff --git a/harbour/contrib/gtwvg/wvgstatc.prg b/harbour/contrib/gtwvg/wvgstatc.prg index daf3834815..2092411f74 100644 --- a/harbour/contrib/gtwvg/wvgstatc.prg +++ b/harbour/contrib/gtwvg/wvgstatc.prg @@ -107,7 +107,7 @@ CLASS WvgStatic INHERIT WvgWindow METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgStatic - ::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /* SS_NOTIFY SS_ETCHEDFRAME SS_SUNKEN SS_WHITERECT */ @@ -205,7 +205,7 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSt EXIT CASE WVGSTATIC_TYPE_RECESSEDLINE EXIT - END /* ::type */ + ENDSWITCH /* ::type */ #if 1 /* Options */ @@ -233,11 +233,12 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSt ::createControl() - ::SetWindowProcCallback() + ::SetWindowProcCallback() /* Static must not be subject to GT dependent */ IF ::visible ::show() ENDIF + ::setPosAndSize() ::setCaption( ::caption ) @@ -247,15 +248,16 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSt METHOD handleEvent( nMessage, aNM ) CLASS WvgStatic - hb_traceLog( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) - DO CASE CASE nMessage == HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ENDIF IF hb_isBlock( ::sl_resize ) eval( ::sl_resize, NIL, NIL, self ) aeval( ::aChildren, {|o| o:handleEvent( HB_GTE_RESIZED, { 0, 0, 0, 0, 0 } ) } ) - RETURN 0 + RETURN EVENT_HANDELLED ENDIF CASE nMessage == HB_GTE_CTLCOLOR @@ -269,20 +271,22 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgStatic RETURN WVG_GetCurrentBrush( aNM[ 1 ] ) ENDIF + CASE nMessage == HB_GTE_ANY + IF ::IsParentCrt() + + ENDIF + ENDCASE - RETURN 1 + RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ METHOD destroy() CLASS WvgStatic - hb_traceLog( " %s:destroy()", __objGetClsName() ) - IF ::hBitmap <> nil WVG_DeleteObject( ::hBitmap ) ENDIF - ::wvgWindow:destroy() RETURN NIL @@ -290,9 +294,7 @@ METHOD destroy() CLASS WvgStatic /*----------------------------------------------------------------------*/ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgStatic - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgsysw.prg b/harbour/contrib/gtwvg/wvgsysw.prg index 486f73c0a8..a0b7dac77b 100644 --- a/harbour/contrib/gtwvg/wvgsysw.prg +++ b/harbour/contrib/gtwvg/wvgsysw.prg @@ -126,7 +126,7 @@ METHOD WvgSysWindow:new( oParent, oOwner, aPos ) ::oOwner := oOwner ::aPos := aPos - ::WvgPartHandler:INIT( oParent, oOwner ) + ::WvgPartHandler:new( oParent, oOwner ) RETURN Self diff --git a/harbour/contrib/gtwvg/wvgtoolb.prg b/harbour/contrib/gtwvg/wvgtoolb.prg index be16c7d6a8..fbc83fb06b 100644 --- a/harbour/contrib/gtwvg/wvgtoolb.prg +++ b/harbour/contrib/gtwvg/wvgtoolb.prg @@ -135,7 +135,7 @@ METHOD WvgToolBar:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) #if 0 + TBSTYLE_LIST caption to the right, otherwise caption to the bottom - ::style := WS_CHILD + TBSTYLE_FLAT + CCS_ADJUSTABLE + CCS_NODIVIDER +CCS_VERT + ::style := WS_CHILD + TBSTYLE_FLAT + CCS_ADJUSTABLE + CCS_NODIVIDER + CCS_VERT #endif ::exStyle := TBSTYLE_EX_DOUBLEBUFFER + TBSTYLE_EX_MIXEDBUTTONS @@ -182,7 +182,7 @@ METHOD WvgToolBar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) * so the parent of toolbar will process them anyway * All other functionality should be default until ownerdraw is introduced. */ - ::SetWindowProcCallback() + ::SetWindowProcCallback() #endif IF !empty( ::hWnd ) @@ -209,18 +209,18 @@ METHOD WvgToolBar:handleEvent( nMessage, aNM ) SWITCH nMessage CASE HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ENDIF ::sendMessage( WM_SIZE, 0, 0 ) - RETURN 0 + RETURN EVENT_HANDELLED CASE HB_GTE_COMMAND EXIT CASE HB_GTE_NOTIFY aNMMouse := Wvg_GetNMMouseInfo( aNM[ 2 ] ) - #if 0 - hb_traceLog( " %s:handleEvent( %i ) %i %i", __ObjGetClsName( self ), nMessage,; - aNMMouse[ NMH_code ], TBN_GETINFOTIPA ) - #endif + DO CASE CASE aNMMouse[ NMH_code ] == NM_CLICK @@ -232,14 +232,6 @@ METHOD WvgToolBar:handleEvent( nMessage, aNM ) ENDIF RETURN EVENT_HANDELLED - #if 0 - CASE aNMMouse[ NMH_code ] == TBN_GETINFOTIPA - IF ( nObj := ascan( ::aItems, {|e_| e_[ 1 ] == aNMMouse[ NMH_dwItemSpec ] } ) ) > 0 - Wvg_SetToolbarButtonTip( aNM[ 2 ], "This is grand tooltip" ) - RETURN EVENT_HANDELLED - ENDIF - #endif - OTHERWISE RETURN EVENT_UNHANDELLED diff --git a/harbour/contrib/gtwvg/wvgtreev.prg b/harbour/contrib/gtwvg/wvgtreev.prg index 2e5dc19222..517dd657eb 100644 --- a/harbour/contrib/gtwvg/wvgtreev.prg +++ b/harbour/contrib/gtwvg/wvgtreev.prg @@ -119,8 +119,9 @@ CLASS WvgTreeView INHERIT WvgWindow, DataRef DATA textParentSelected INIT "" DATA textItemSelected INIT "" - METHOD setColorFG( nRGB ) INLINE WVG_TreeView_SetTextColor( ::hWnd, nRGB ) - METHOD setColorBG( nRGB ) INLINE WVG_TreeView_SetBkColor( ::hWnd, nRGB ) + METHOD getSelectionInfo( nlParam ) + METHOD setColorFG( nRGB ) INLINE WVG_TreeView_SetTextColor( ::hWnd, iif( hb_isChar( nRGB ), Wvt_GetRGBColorByString( nRGB, 0 ), nRGB ) ) + METHOD setColorBG( nRGB ) INLINE WVG_TreeView_SetBkColor( ::hWnd, iif( hb_isChar( nRGB ), Wvt_GetRGBColorByString( nRGB, 1 ), nRGB ) ) METHOD setColorLines( nRGB ) INLINE WVG_TreeView_SetLineColor( ::hWnd, nRGB ) METHOD showExpanded( lExpanded, nLevels ) INLINE Wvg_TreeView_ShowExpanded( ::hWnd, ; iif( hb_isNil( lExpanded ), .f., lExpanded ), nLevels ) @@ -129,12 +130,12 @@ CLASS WvgTreeView INHERIT WvgWindow, DataRef /*----------------------------------------------------------------------*/ -METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTreeView +METHOD WvgTreeView:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::style := WS_CHILD + WS_TABSTOP + WS_CLIPSIBLINGS - ::exStyle := WS_EX_STATICEDGE /*+ TVS_EX_FADEINOUTEXPANDOS */ + ::exStyle := WS_EX_CLIENTEDGE // WS_EX_STATICEDGE /*+ TVS_EX_FADEINOUTEXPANDOS */ ::className := "SysTreeView32" ::objType := objTypeTreeView @@ -143,7 +144,7 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTreeV /*----------------------------------------------------------------------*/ -METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTreeView +METHOD WvgTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -161,24 +162,43 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTr ::createControl() - ::SetWindowProcCallback() - - IF ::visible - ::show() - ENDIF + // ::SetWindowProcCallback() /* Let parent control the events */ ::oRootItem := WvgTreeViewItem():New() ::oRootItem:hTree := ::hWnd ::oRootItem:oWnd := Self + IF ::visible + ::show() + ENDIF + ::setPosAndSize( ::aPos, ::aSize ) + RETURN Self /*----------------------------------------------------------------------*/ -METHOD handleEvent( nMessage, aNM ) CLASS WvgTreeView - LOCAL hItemSelected, hParentOfSelected, n, aNMHdr +METHOD WvgTreeView:getSelectionInfo( nlParam ) + LOCAL hItemSelected, hParentOfSelected LOCAL cParent := space( 20 ) LOCAL cText := space( 20 ) + LOCAL n + + Wvg_TreeView_GetSelectionInfo( ::hWnd, nlParam, @cParent, @cText, @hParentOfSelected, @hItemSelected ) + + ::hParentSelected := hParentOfSelected + ::hItemSelected := hItemSelected + ::textParentSelected := trim( cParent ) + ::textItemSelected := trim( cText ) + + IF ( n := ascan( ::aItems, {|o| o:hItem == hItemSelected } ) ) > 0 + ::oItemSelected := ::aItems[ n ] + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD WvgTreeView:handleEvent( nMessage, aNM ) LOCAL aHdr hb_traceLog( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) @@ -186,8 +206,10 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgTreeView SWITCH nMessage CASE HB_GTE_RESIZED + IF ::isParentCrt() + ::rePosition() + ENDIF ::sendMessage( WM_SIZE, 0, 0 ) - RETURN EVENT_HANDELLED CASE HB_GTE_COMMAND IF hb_isBlock( ::sl_lbClick ) @@ -197,52 +219,68 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgTreeView EXIT CASE HB_GTE_NOTIFY - aHdr := Wvg_GetNMHdrInfo( aNM[ 2 ] ) - aNMHdr := Wvg_GetNMTreeViewInfo( aNM[ 2 ] ) + aHdr := Wvg_GetNMTreeViewInfo( aNM[ 2 ] ) DO CASE - CASE aHdr[ NMH_code ] == NM_DBLCLK .OR. aHdr[ NMH_code ] == NM_RETURN ::editBuffer := ::oItemSelected IF hb_isBlock( ::sl_itemSelected ) + IF ::isParentCrt() + ::oParent:setFocus() + ENDIF Eval( ::sl_itemSelected, ::oItemSelected, { 0,0,0,0 }, Self ) + IF ::isParentCrt() + ::setFocus() + ENDIF ENDIF + RETURN .f. - RETURN .t. - - CASE aNMHdr[ NMH_code ] == TVN_SELCHANGED - Wvg_TreeView_GetSelectionInfo( ::hWnd, aNM[ 2 ], @cParent, @cText, @hParentOfSelected, @hItemSelected ) - - ::hParentSelected := hParentOfSelected - ::hItemSelected := hItemSelected - ::textParentSelected := trim( cParent ) - ::textItemSelected := trim( cText ) - - IF ( n := ascan( ::aItems, {|o| o:hItem == hItemSelected } ) ) > 0 - ::oItemSelected := ::aItems[ n ] - ELSE - ::oItemSelected := NIL - ENDIF + CASE aHdr[ NMH_code ] == TVN_SELCHANGED + ::getSelectionInfo( aNM[ 2 ] ) IF hb_isBlock( ::sl_itemMarked ) Eval( ::sl_itemMarked, ::oItemSelected, { 0,0,0,0 }, Self ) ENDIF - RETURN .t. OTHERWISE RETURN .f. ENDCASE - EXIT - END + + CASE HB_GTE_ANY + IF ::isParentCrt() + IF aNM[ 1 ] == WM_LBUTTONUP + ::getSelectionInfo( aNM[ 2 ] ) + IF hb_isBlock( ::sl_lbClick ) + ::oParent:setFocus() + eval( ::sl_lbClick, NIL, NIL, Self ) + ::setFocus() + ENDIF + + ELSEIF aNM[ 1 ] == WM_LBUTTONDBLCLK + ::editBuffer := ::oItemSelected + IF hb_isBlock( ::sl_itemSelected ) + ::oParent:setFocus() + Eval( ::sl_itemSelected, ::oItemSelected, { 0,0,0,0 }, Self ) + ::setFocus() + ENDIF + + ELSEIF aNM[ 1 ] == WM_KEYDOWN .AND. aNM[ 2 ] == K_ENTER + ::getSelectionInfo( aNM[ 2 ] ) + + ENDIF + ENDIF + EXIT + + ENDSWITCH RETURN EVENT_UNHANDELLED /*----------------------------------------------------------------------*/ -METHOD destroy() CLASS WvgTreeView +METHOD WvgTreeView:destroy() hb_traceLog( " %s:destroy()", __objGetClsName() ) @@ -252,7 +290,7 @@ METHOD destroy() CLASS WvgTreeView /*----------------------------------------------------------------------*/ -METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTreeView +METHOD WvgTreeView:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -260,7 +298,7 @@ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS Wv /*----------------------------------------------------------------------*/ -METHOD itemFromPos( aPos ) CLASS WvgTreeView +METHOD WvgTreeView:itemFromPos( aPos ) HB_SYMBOL_UNUSED( aPos ) @@ -268,7 +306,7 @@ METHOD itemFromPos( aPos ) CLASS WvgTreeView /*----------------------------------------------------------------------*/ -METHOD itemCollapsed( xParam ) CLASS WvgTreeView +METHOD WvgTreeView:itemCollapsed( xParam ) IF hb_isBlock( xParam ) .or. ( xParam == NIL ) ::sl_paint := xParam @@ -278,7 +316,7 @@ METHOD itemCollapsed( xParam ) CLASS WvgTreeView /*----------------------------------------------------------------------*/ -METHOD itemExpanded( xParam ) CLASS WvgTreeView +METHOD WvgTreeView:itemExpanded( xParam ) IF hb_isBlock( xParam ) .or. ( xParam == NIL ) ::sl_itemExpanded := xParam @@ -288,7 +326,7 @@ METHOD itemExpanded( xParam ) CLASS WvgTreeView /*----------------------------------------------------------------------*/ -METHOD itemMarked( xParam ) CLASS WvgTreeView +METHOD WvgTreeView:itemMarked( xParam ) IF hb_isBlock( xParam ) .or. ( xParam == NIL ) ::sl_itemMarked := xParam @@ -298,7 +336,7 @@ METHOD itemMarked( xParam ) CLASS WvgTreeView /*----------------------------------------------------------------------*/ #if 0 -METHOD itemSelected( xParam ) CLASS WvgTreeView +METHOD WvgTreeView:itemSelected( xParam ) IF hb_isBlock( xParam ) .or. ( xParam == NIL ) ::sl_itemSelected := xParam diff --git a/harbour/contrib/gtwvg/wvgwin.c b/harbour/contrib/gtwvg/wvgwin.c index d0d05551b0..faa5b536b2 100644 --- a/harbour/contrib/gtwvg/wvgwin.c +++ b/harbour/contrib/gtwvg/wvgwin.c @@ -383,7 +383,7 @@ HB_FUNC( WVG_LOADICON ) */ HB_FUNC( WVG_LOADIMAGE ) { - HBITMAP hImage = 0; + HANDLE hImage = 0; LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); int iSource = hb_parni( 2 ); @@ -398,7 +398,10 @@ HB_FUNC( WVG_LOADIMAGE ) break; case 2: - hImage = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL, lpBuffer, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + if( HB_ISNUM( 3 ) && hb_parni( 3 ) == IMAGE_ICON ) + hImage = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpBuffer, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + else + hImage = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL, lpBuffer, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); break; } @@ -1135,7 +1138,7 @@ HB_FUNC( WVG_SETWINDOWPOSANDSIZE ) { hb_retl( SetWindowPos( wvg_parhwnd( 1 ), NULL, hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), - ( hb_parl( 6 ) ? 0 : SWP_NOREDRAW ) | SWP_NOZORDER | SWP_NOACTIVATE ) ); + ( hb_parl( 6 ) ? 0 : SWP_NOREDRAW ) | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED ) ); } /*----------------------------------------------------------------------*/ @@ -1345,3 +1348,24 @@ HB_FUNC( WVG_SENDTOOLBARMESSAGE ) } /* #endif */ } + +/*----------------------------------------------------------------------*/ + +HB_FUNC( WVG_SENDEDITCONTROLMESSAGE ) +{ + HWND hED = hbwapi_par_raw_HWND( 1 ); + int msg = hbwapi_par_INT( 2 ); + + switch( msg ) + { + case EM_GETSEL: + { + DWORD min = 0; + DWORD max = 0; + SendMessage( hED, EM_GETSEL, ( WPARAM ) &min, ( LPARAM ) &max ); + break; + } + } +} + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgwing.c b/harbour/contrib/gtwvg/wvgwing.c index 94ada03887..a4fafdbd69 100644 --- a/harbour/contrib/gtwvg/wvgwing.c +++ b/harbour/contrib/gtwvg/wvgwing.c @@ -660,7 +660,6 @@ HB_FUNC( WVG_GETNMTREEVIEWINFO ) hb_itemReturnRelease( pEvParams ); } /*----------------------------------------------------------------------*/ - /* * Wvg_TreeView_GetSelectionInfo( ::hWnd, nlParam, @cParent, @cText, @hParentOfSelected, @hItemSelected ) */ @@ -1263,3 +1262,55 @@ HB_FUNC( WVG_RELEASEWINDOWPROCBLOCK ) } /*----------------------------------------------------------------------*/ +/* + WVG_CreateTooltipWindow( hControl ) -> hWndTT +*/ +HB_FUNC( WVG_CREATETOOLTIPWINDOW ) +{ + HWND hwndTip; + TOOLINFO toolInfo; + LPTSTR pszText = HB_TCHAR_CONVTO( "" ); + + hwndTip = CreateWindowEx( ( DWORD ) NULL, TOOLTIPS_CLASS, NULL, + WS_POPUP |TTS_ALWAYSTIP, // | TTS_BALLOON, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + wvg_parhwnd( 1 ), NULL, + wvg_hInstance(), NULL); + if ( ! hwndTip ) + return; + + toolInfo.cbSize = sizeof( toolInfo ); + toolInfo.hwnd = ( HWND ) wvg_parhwnd( 1 ); + toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + toolInfo.uId = ( UINT_PTR ) ( HWND ) wvg_parhwnd( 1 ); + toolInfo.lpszText = pszText; + + if( SendMessage( hwndTip, TTM_ADDTOOL, 0, ( LPARAM ) &toolInfo ) ) + wvg_rethandle( hwndTip ); + else + wvg_rethandle( NULL ); + + HB_TCHAR_FREE( pszText ); +} + +/*----------------------------------------------------------------------*/ + +HB_FUNC( WVG_SETTOOLTIPTEXT ) +{ + TOOLINFO toolInfo; + LPTSTR pszText = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); + + toolInfo.cbSize = sizeof( toolInfo ); + toolInfo.hwnd = ( HWND ) wvg_parhwnd( 1 ); + toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + toolInfo.uId = ( UINT_PTR ) ( HWND ) wvg_parhwnd( 1 ); + toolInfo.lpszText = pszText; + + SendMessage( wvg_parhwnd( 2 ), TTM_SETTOOLINFO, ( WPARAM ) 0, ( LPARAM ) &toolInfo ); + + HB_TCHAR_FREE( pszText ); +} + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/gtwvg/wvgwnd.prg b/harbour/contrib/gtwvg/wvgwnd.prg index fe6827d025..4aaf396af7 100644 --- a/harbour/contrib/gtwvg/wvgwnd.prg +++ b/harbour/contrib/gtwvg/wvgwnd.prg @@ -104,7 +104,8 @@ CLASS WvgWindow INHERIT WvgPartHandler /* RUNTIME DATA */ DATA dropZone INIT .F. DATA helpLink - DATA tooltipText INIT "" + DATA s_tooltipText INIT "" + METHOD tooltipText SETGET DATA clr_FG DATA clr_BG @@ -180,7 +181,14 @@ CLASS WvgWindow INHERIT WvgPartHandler DATA oMenu - METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + DATA nTop + DATA nLeft + DATA nBottom + DATA nRight + + DATA hWndTT + + METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD destroy() @@ -219,14 +227,12 @@ CLASS WvgWindow INHERIT WvgPartHandler METHOD setFocus() METHOD sendMessage( nMessage, nlParam, nwParam ) METHOD findObjectByHandle( hWnd ) - METHOD createControl() - METHOD ControlWndProc( hWnd, nMessage, nwParam, nlParam ) METHOD getControlID() INLINE ++::nControlID - METHOD HandleEvent() INLINE ( 1 ) + METHOD HandleEvent() INLINE EVENT_UNHANDELLED METHOD isEnabled() INLINE ::is_enabled - METHOD isVisible() INLINE !( ::is_hidden ) - METHOD setColorFG( nRGB ) INLINE ::clr_FG := nRGB, ::invalidateRect() + METHOD isVisible() INLINE ! ::is_hidden + METHOD setColorFG( nRGB ) INLINE ::clr_FG := iif( hb_isChar( nRGB ), Wvt_GetRGBColorByString( nRGB, 0 ), nRGB ), ::invalidateRect() METHOD enter( xParam ) SETGET METHOD leave( xParam ) SETGET @@ -259,12 +265,18 @@ CLASS WvgWindow INHERIT WvgPartHandler METHOD dragMotion( xParam ) SETGET METHOD dragLeave( xParam ) SETGET METHOD dragDrop( xParam, xParam1 ) SETGET - + METHOD getPosAndSize( aPs, aSz ) + METHOD isParentCrt() INLINE ( __objGetClsName( ::oParent ) == "WVGCRT" ) + METHOD rePosition() +#if 1 + METHOD createControl() + METHOD controlWndProc( hWnd, nMessage, nwParam, nlParam ) +#endif ENDCLASS /*----------------------------------------------------------------------*/ -METHOD WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) +METHOD WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) DEFAULT oParent TO ::oParent DEFAULT oOwner TO ::oOwner @@ -280,7 +292,7 @@ METHOD WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::aPresParams := aPresParams ::visible := lVisible - ::WvgPartHandler:init( oParent, oOwner ) + ::WvgPartHandler:new( oParent, oOwner ) RETURN Self @@ -302,6 +314,12 @@ METHOD WvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::aPresParams := aPresParams ::visible := lVisible + IF empty( ::oParent ) + IF ! ( __objGetClsName( Self ) $ "WVGCRT,WVGDIALOG" ) + ::oParent := SetAppWindow() + ENDIF + ENDIF + ::WvgPartHandler:create( oParent, oOwner ) RETURN Self @@ -317,7 +335,6 @@ METHOD WvgWindow:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible DEFAULT aPresParams TO ::aPresParams DEFAULT lVisible TO ::visible - RETURN Self /*----------------------------------------------------------------------*/ @@ -334,6 +351,9 @@ METHOD WvgWindow:destroy() WVG_ReleaseWindowProcBlock( ::pWnd ) + IF WVG_IsWindow( ::hWndTT ) + WVG_DestroyWindow( ::hWndTT ) + ENDIF IF WVG_IsWindow( ::hWnd ) WVG_DestroyWindow( ::hWnd ) ENDIF @@ -343,6 +363,7 @@ METHOD WvgWindow:destroy() ENDIF ::hWnd := NIL + ::hWndTT := NIL ::pWnd := NIL ::aPos := NIL ::aSize := NIL @@ -408,15 +429,12 @@ METHOD WvgWindow:destroy() /*----------------------------------------------------------------------*/ METHOD WvgWindow:SetWindowProcCallback() - ::nOldProc := WVG_SetWindowProcBlock( ::pWnd, {|h,m,w,l| ::ControlWndProc( h,m,w,l ) } ) - RETURN Self /*----------------------------------------------------------------------*/ METHOD WvgWindow:captureMouse() - RETURN Self /*----------------------------------------------------------------------*/ @@ -475,13 +493,16 @@ METHOD WvgWindow:lockUpdate() METHOD WvgWindow:setColorBG( nRGB ) LOCAL hBrush + IF hb_isChar( nRGB ) + nRGB := Wvt_GetRGBColorByString( nRGB, 1 ) + ENDIF IF hb_isNumeric( nRGB ) hBrush := WVG_CreateBrush( BS_SOLID, nRGB, 0 ) IF hBrush <> 0 ::clr_BG := nRGB ::hBrushBG := hBrush - IF ::className == "WVGDIALOG" + IF ::className == "WVGDIALOG" .OR. __ObjGetClsName( Self ) == "WVGCHECKBOX" Wvg_SetCurrentBrush( ::hWnd, ::hBrushBG ) ENDIF ENDIF @@ -510,6 +531,7 @@ METHOD WvgWindow:setTrackPointer() /*----------------------------------------------------------------------*/ METHOD WvgWindow:setPos( aPos, lPaint ) + LOCAL aPosSz IF hb_isArray( aPos ) DEFAULT lPaint TO .T. @@ -517,10 +539,11 @@ METHOD WvgWindow:setPos( aPos, lPaint ) SWITCH ::objType CASE objTypeCrt - exit + EXIT OTHERWISE - WVG_SetWindowPosition( ::hWnd, aPos[ 1 ], aPos[ 2 ], lPaint ) + aPosSz := ::getPosAndSize( aPos ) + WVG_SetWindowPosition( ::hWnd, aPosSz[ 1 ], aPosSz[ 2 ], lPaint ) EXIT END @@ -529,21 +552,32 @@ METHOD WvgWindow:setPos( aPos, lPaint ) RETURN Self +/*----------------------------------------------------------------------*/ +/* This will always be called from HB_GTE_RESIZED message of WVG engine */ + +METHOD WvgWindow:rePosition() + + RETURN ::setPosAndSize( ::aPos, ::aSize ) + /*----------------------------------------------------------------------*/ METHOD WvgWindow:setPosAndSize( aPos, aSize, lPaint ) + LOCAL aPosSz - IF hb_isArray( aPos ) .and. hb_isArray( aSize ) + DEFAULT aPos TO ::aPos + DEFAULT aSize TO ::aSize + + IF hb_isArray( aPos ) .AND. hb_isArray( aSize ) DEFAULT lPaint TO .T. SWITCH ::objType CASE objTypeCrt - exit + EXIT OTHERWISE - /*WVG_MoveWindow( ::hWnd, aPos[ 1 ], aPos[ 2 ], aSize[ 1 ], aSize[ 2 ], lPaint ) */ - WVG_SetWindowPosAndSize( ::hWnd, aPos[ 1 ], aPos[ 2 ], aSize[ 1 ], aSize[ 2 ], lPaint ) + aPosSz := ::getPosAndSize( aPos, aSize ) + WVG_SetWindowPosAndSize( ::hWnd, aPosSz[ 1 ], aPosSz[ 2 ], aPosSz[ 3 ], aPosSz[ 4 ], lPaint ) EXIT END @@ -554,15 +588,19 @@ METHOD WvgWindow:setPosAndSize( aPos, aSize, lPaint ) /*----------------------------------------------------------------------*/ METHOD WvgWindow:setSize( aSize, lPaint ) + LOCAL aPosSz IF hb_isArray( aSize ) DEFAULT lPaint TO .T. SWITCH ::objType - CASE objTypeDialog - /*WVG_MoveWindow( ::hWnd, 0, 0, aSize[ 1 ], aSize[ 2 ], lPaint ) */ - WVG_SetWindowSize( ::hWnd, aSize[ 1 ], aSize[ 2 ], lPaint ) + CASE objTypeCrt + EXIT + + OTHERWISE + aPosSz := ::getPosAndSize( , aSize ) + WVG_SetWindowSize( ::hWnd, aPosSz[ 3 ], aPosSz[ 4 ], lPaint ) EXIT END @@ -680,9 +718,7 @@ METHOD WvgWindow:setPresParam() /*----------------------------------------------------------------------*/ METHOD WvgWindow:currentPos() - LOCAL aRect - - aRect := WVG_GetWindowRect( ::hWnd ) + LOCAL aRect := WVG_GetWindowRect( ::hWnd ) RETURN { aRect[ 1 ], aRect[ 2 ] } @@ -1237,15 +1273,12 @@ METHOD WvgWindow:Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible /*----------------------------------------------------------------------*/ METHOD WvgWindow:setFocus() - - ::sendMessage( WM_ACTIVATE, 1, 0 ) - + WVG_SetFocus( ::hWnd ) RETURN Self /*----------------------------------------------------------------------*/ METHOD WvgWindow:sendMessage( nMessage, nlParam, nwParam ) - RETURN WVG_SendMessage( ::hWnd, nMessage, nlParam, nwParam ) /*----------------------------------------------------------------------*/ @@ -1263,43 +1296,108 @@ METHOD WvgWindow:findObjectByHandle( hWnd ) /*----------------------------------------------------------------------*/ +METHOD WvgWindow:getPosAndSize( aPs, aSz ) + LOCAL nX, nY, nW, nH, aXY + LOCAL aPos, aSize + LOCAL nFH, nFW + + DEFAULT aPs TO aclone( ::aPos ) + DEFAULT aSz TO aclone( ::aSize ) + + aPos := aclone( aPs ) + aSize := aclone( aSz ) + + IF ::isParentCrt() + IF hb_isBlock( aPos[ 1 ] ) + aPos[ 1 ] := eval( aPos[ 1 ] ) + ENDIF + IF hb_isBlock( aPos[ 2 ] ) + aPos[ 2 ] := eval( aPos[ 2 ] ) + ENDIF + IF hb_isBlock( aSize[ 1 ] ) + aSize[ 1 ] := eval( aSize[ 1 ] ) + ENDIF + IF hb_isBlock( aSize[ 2 ] ) + aSize[ 2 ] := eval( aSize[ 2 ] ) + ENDIF + + IF aPos[ 1 ] < 0 .AND. aPos[ 2 ] < 0 .AND. aSize[ 1 ] < 0 .AND. aSize[ 2 ] < 0 + nX := abs( aPos[ 2 ] ) + IF nX < 1 + nX := 0 + ENDIF + nY := abs( aPos[ 1 ] ) + IF nY < 1 + nY := 0 + ENDIF + nW := abs( aSize[ 2 ] ) + IF nW < 1 + nW := 0 + ENDIF + nH := abs( aSize[ 1 ] ) + IF nH < 1 + nH := 0 + ENDIF + aXY := Wvt_GetXYFromRowCol( nY, nX ) + nFH := Wvt_GetFontInfo()[ 6 ] + nFW := Wvt_GetFontInfo()[ 7 ] + RETURN { aXY[ 1 ], aXY[ 2 ], nW * nFW, nH * nFH } + ENDIF + ENDIF + + RETURN { aPos[ 1 ], aPos[ 2 ], aSize[ 1 ], aSize[ 2 ] } + +/*----------------------------------------------------------------------*/ + +METHOD WvgWindow:toolTipText( cText ) + + IF hb_isChar( cText ) + ::s_toolTipText := cText + IF WVG_IsWindow( ::hWndTT ) + WVG_SetTooltipText( ::hWnd, ::hWndTT, ::s_toolTipText ) + ENDIF + ENDIF + + RETURN ::s_toolTipText + +/*----------------------------------------------------------------------*/ + METHOD WvgWindow:createControl() - LOCAL hWnd + LOCAL hWnd, aPosSz ::nID := ::oParent:GetControlId() + aPosSz := ::getPosAndSize( ::aPos, ::aSize ) + hWnd := WVG_CreateWindowEx( ::exStyle, ; ::className, ; "", ; /* window name */ ::style, ; - ::aPos[ 1 ], ::aPos[ 2 ],; - ::aSize[ 1 ], ::aSize[ 2 ],; - ::oParent:hWnd,; - ::nID,; /* hMenu */ - NIL,; /* hInstance */ + aPosSz[ 1 ], aPosSz[ 2 ], ; + aPosSz[ 3 ], aPosSz[ 4 ], ; + ::oParent:hWnd, ; + ::nID, ; /* hMenu */ + NIL, ; /* hInstance */ NIL ) /* lParam */ - - - IF ( hWnd <> 0 ) + IF WVG_IsWindow( hWnd ) ::hWnd := hWnd ::pWnd := WIN_N2P( hWnd ) ::sendMessage( WM_SETFONT, WVG_GetStockObject( DEFAULT_GUI_FONT ), 1 ) + + ::hWndTT := WVG_CreateTooltipWindow( ::hWnd ) ENDIF RETURN Self + /*----------------------------------------------------------------------*/ -METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) +METHOD WvgWindow:controlWndProc( hWnd, nMessage, nwParam, nlParam ) LOCAL nCtrlID, nNotifctn, hWndCtrl, nObj, aMenuItem, oObj, nReturn - #if 1 - hb_traceLog( "%s:wndProc( %i %i %i %i )", __ObjGetClsName( self ), hWnd, nMessage, nwParam, nlParam ) - #endif - SWITCH nMessage CASE WM_ERASEBKGND - IF ::objType == objTypeDA .and. !empty( ::hBrushBG ) + IF ::objType == objTypeDA .AND. ! empty( ::hBrushBG ) ::handleEvent( HB_GTE_CTLCOLOR, { nwParam, nlParam } ) ENDIF EXIT @@ -1325,7 +1423,7 @@ METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) ELSE IF ( nObj := ascan( ::aChildren, {|o| o:nID == nCtrlID } ) ) > 0 nReturn := ::aChildren[ nObj ]:handleEvent( HB_GTE_COMMAND, { nNotifctn, nCtrlID, hWndCtrl } ) - IF hb_isNumeric( nReturn ) .and. nReturn == 0 + IF hb_isNumeric( nReturn ) .AND. nReturn == 0 RETURN 0 ENDIF ENDIF @@ -1335,8 +1433,10 @@ METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CASE WM_NOTIFY IF ( nObj := ascan( ::aChildren, {| o | o:nID == nwParam } ) ) > 0 nReturn := ::aChildren[ nObj ]:handleEvent( HB_GTE_NOTIFY, { nwParam, nlParam } ) - IF hb_isNumeric( nReturn ) .and. nReturn == EVENT_HANDELLED - RETURN EVENT_HANDELLED + IF hb_isNumeric( nReturn ) .AND. nReturn == EVENT_HANDELLED + RETURN 0 + ELSEIF hb_isLogical( nReturn ) + RETURN nReturn ENDIF ENDIF EXIT @@ -1348,12 +1448,10 @@ METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CASE WM_CTLCOLORDLG CASE WM_CTLCOLORSCROLLBAR CASE WM_CTLCOLORSTATIC - oObj := ::findObjectByHandle( nlParam ) IF hb_isObject( oObj ) nReturn := oObj:handleEvent( HB_GTE_CTLCOLOR, { nwParam, nlParam } ) - - IF nReturn == 1 + IF nReturn == EVENT_UNHANDELLED RETURN WVG_CallWindowProc( ::nOldProc, hWnd, nMessage, nwParam, nlParam ) ELSE RETURN nReturn @@ -1366,8 +1464,7 @@ METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) RETURN 0 CASE WM_VSCROLL - nReturn := ::handleEvent( HB_GTE_VSCROLL, { WVG_LOWORD( nwParam ), WVG_HIWORD( nwParam ), nlParam } ) - IF nReturn == EVENT_HANDELLED + IF ::handleEvent( HB_GTE_VSCROLL, { WVG_LOWORD( nwParam ), WVG_HIWORD( nwParam ), nlParam } ) == EVENT_HANDELLED RETURN 0 ENDIF EXIT @@ -1377,7 +1474,7 @@ METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) #if 0 CASE WM_MOUSEMOVE IF ::objType == objTypeScrollBar - IF !( ::lTracking ) + IF ! ::lTracking ::lTracking := Wvg_BeginMouseTracking( ::hWnd ) ENDIF ENDIF @@ -1401,8 +1498,16 @@ METHOD WvgWindow:ControlWndProc( hWnd, nMessage, nwParam, nlParam ) ENDIF EXIT #endif - END + + OTHERWISE + IF ::handleEvent( HB_GTE_ANY, { nMessage, nwParam, nlParam } ) == EVENT_HANDELLED + RETURN 0 + ENDIF + EXIT + + ENDSWITCH RETURN WVG_CallWindowProc( ::nOldProc, hWnd, nMessage, nwParam, nlParam ) /*----------------------------------------------------------------------*/ +