diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cd8ae5170d..bb9d2fb59e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,47 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-16 00:10 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/gtwvg/common.mak + * harbour/contrib/gtwvg/Makefile + + Added wvgdarea.prg + + * harbour/contrib/gtwvg/wvgwin.c + + Added more functions. + + + harbour/contrib/gtwvg/wvgdarea.prg + + Added WvgDrawingArea(), a helper class to WvgDialog(). + * harbour/contrib/gtwvg/wvgdlg.prg + * harbour/contrib/gtwvg/wvgparts.ch + * harbour/contrib/gtwvg/wvgphdlr.prg + * harbour/contrib/gtwvg/wvgstatc.prg + * harbour/contrib/gtwvg/wvgtoolb.prg + * harbour/contrib/gtwvg/wvgwnd.prg + * harbour/contrib/gtwvg/wvtwin.ch + ! Numerous class structure enhancements. More Xbase++ compatibility + XbpDialog:drawingArea concept implemented in greater details. + WvgToolbarButtons() now take use of WAPI_ImageList_*() functions. + + * harbour/contrib/hbwin/hbwapi.h + ! Defines updated to respect pointers also. + + harbour/contrib/hbwin/wapi_commctrl.c + + Implemented WAPI ImageList_*() family of functions. + + * harbour/contrib/hbwin/Makefile + * harbour/contrib/hbwin/common.mak + + Added wapi_commctrl.c + + * harbour/contrib/gtwvg/tests/demowvg.prg + * harbour/contrib/gtwvg/tests/demoxbp.prg + ! Updated TO respect new changes in class structures. + Xbase++ related components are more compatible now. + + ; TODO: Tooltips on Toolbar Buttons. WHILE implemeting + XbpDialog:drawingArea concept I have lost track of this + feature as buttons are now created via image lists and + Toolbar window is created with CreateWindowEx() instead of + CreateToolbarWindow(). + 2009-02-17 09:25 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/hbapollo/tests/hbapollo.hbp + Added filters. diff --git a/harbour/contrib/gtwvg/Makefile b/harbour/contrib/gtwvg/Makefile index fd03a72cf0..88d7461bcf 100644 --- a/harbour/contrib/gtwvg/Makefile +++ b/harbour/contrib/gtwvg/Makefile @@ -17,6 +17,7 @@ C_SOURCES=\ wvggui.c \ wincallb.c \ + PRG_SOURCES=\ wvgclass.prg \ wvgpaint.prg \ @@ -43,6 +44,8 @@ PRG_SOURCES=\ wvgmle.prg \ wvghtmlv.prg \ wvgsysw.prg \ + wvgdarea.prg \ + PRG_HEADERS=\ hbgtwvg.ch \ diff --git a/harbour/contrib/gtwvg/common.mak b/harbour/contrib/gtwvg/common.mak index 9eaf7d3ff6..a5b801255c 100644 --- a/harbour/contrib/gtwvg/common.mak +++ b/harbour/contrib/gtwvg/common.mak @@ -37,6 +37,7 @@ LIB_OBJS = \ $(OBJ_DIR)wvgmle$(OBJEXT) \ $(OBJ_DIR)wvghtmlv$(OBJEXT) \ $(OBJ_DIR)wvgsysw$(OBJEXT) \ + $(OBJ_DIR)wvgdarea$(OBJEXT) \ \ $(OBJ_DIR)gtwvg$(OBJEXT) \ $(OBJ_DIR)wvgcore$(OBJEXT) \ diff --git a/harbour/contrib/gtwvg/tests/demowvg.prg b/harbour/contrib/gtwvg/tests/demowvg.prg index 9abe184179..9e9e84a195 100644 --- a/harbour/contrib/gtwvg/tests/demowvg.prg +++ b/harbour/contrib/gtwvg/tests/demowvg.prg @@ -1436,6 +1436,8 @@ FUNCTION CreateMainMenu() oMenu:AddItem( "ActiveX - RMChart" , {|| Hb_ThreadStart( {|| ExecuteActiveX( 4 ) } ) } ) oMenu:AddItem( "-") oMenu:AddItem( "ActiveX - Analog Clock" , {|| Hb_ThreadStart( {|| ExecuteActiveX( 2 ) } ) } ) + oMenu:AddItem( "-") + oMenu:AddItem( "ActiveX - Image Viewer" , {|| Hb_ThreadStart( {|| ExecuteActiveX( 5 ) } ) } ) g_oMenuBar:addItem( "",oMenu) RETURN g_oMenuBar @@ -2346,7 +2348,7 @@ FUNCTION GoogleMap() // Function ExecuteActiveX( nActiveX, xParam ) Local oCrt, oTBar, oSBar, oStatic, oCom, oXbp, oTree, oItem1, oItem2 - LOCAL oListBox, oCheck, oRadio, oStatic2, oMLE + LOCAL oListBox, oCheck, oRadio, oStatic2, oMLE, oDA LOCAL oPanel, oPanel1, oPanel2, cText LOCAL cVarA := "Test A", cVarB := "Test B" LOCAL aState := {"not selected", "selected", "undefined"} @@ -2368,6 +2370,8 @@ Function ExecuteActiveX( nActiveX, xParam ) SetCursor( .f. ) #endif + oDA := oCrt:drawingArea + //--------------------------- Menu --------------------------------\\ ActiveXBuildMenu( oCrt, @oStatic, @oStatic2 ) @@ -2375,7 +2379,7 @@ Function ExecuteActiveX( nActiveX, xParam ) oTBar := ActiveXBuildToolBar( oCrt, nActiveX ) //--------------------------- StatusBar ---------------------------\\ - oSBar := WvgStatusBar():new( oCrt ):create( , , , , , .t. ) + oSBar := WvgStatusBar():new( oDA ):create( , , , , , .t. ) oSBar:panelClick := {|oPanel| Win_MessageBox( , oPanel:caption ) } oPanel := oSBar:getItem( 1 ) oPanel:caption := 'My Root Panel' @@ -2385,15 +2389,16 @@ Function ExecuteActiveX( nActiveX, xParam ) oPanel2:caption := 'Click on any part!' //--------------------------- Static ------------------------------\\ - oStatic := WvgStatic():new( oCrt ) + oStatic := WvgStatic():new( oDA ) oStatic:type := WVGSTATIC_TYPE_TEXT oStatic:options := WVGSTATIC_TEXT_CENTER oStatic:caption := chr(13)+'Implemented Xbase++ Parts' oStatic:create( , , { 0, oTBar:currentSize()[2]+3 }, { 120, oCrt:currentSize()[2]-; oTBar:currentSize()[2]-oSBar:currentSize()[2]-4 }, , .t. ) + oStatic:setColorBG( RGB( 198,198,198 ) ) //--------------------------- Static + Radio + Checkbox ----------\\ - oStatic2:= WvgStatic():New( oCrt, , { 150, 150 }, { 500,310 }, , .f. ) + oStatic2:= WvgStatic():New( oDA, , { 150, 150 }, { 500,310 }, , .f. ) //oStatic2:type := WVGSTATIC_TYPE_RAISEDBOX //BGNDFRAME oStatic2:exStyle += WS_EX_WINDOWEDGE //oStatic2:options := WVGSTATIC_FRAMETHICK @@ -2500,7 +2505,7 @@ Function ExecuteActiveX( nActiveX, xParam ) oXbp:activate:= {|| oStatic:hide(), oCrt:sendMessage( WM_SIZE, 0, 0 ) } //--------------------------- TreeView ---------------------------\\ - oTree := WvgTreeView():new( oCrt, , { oCrt:currentSize()[1]-160,oTBar:currentSize()[2]+3 }, ; + oTree := WvgTreeView():new( oDA, , { oCrt:currentSize()[1]-160,oTBar:currentSize()[2]+3 }, ; { 160, oCrt:currentSize()[2]-; oTBar:currentSize()[2]-oSBar:currentSize()[2]-4 }, , .t. ) oTree:hasLines := .T. @@ -2536,7 +2541,8 @@ Function ExecuteActiveX( nActiveX, xParam ) IF( oBtn:caption == 'Tools', oStatic2:show():toFront(), nil ),; IF( oBtn:caption $ 'Hide,Show', oCrt:sendMessage( WM_SIZE, 0, 0 ), NIL ),; oPanel2:caption := "Button [ " + oBtn:caption + " ] clicked!" } - oCrt:resize := {|| ResizeDialog( oCrt, oTBar, oSBar, oStatic, oCom, oTree ) } + //oCrt:resize := {|| ResizeDialog( oCrt, oTBar, oSBar, oStatic, oCom, oTree ) } + oDA:resize := {|| ResizeDialog( oCrt, oTBar, oSBar, oStatic, oCom, oTree ) } #if 1 //--------------------------- Active-X ---------------------------\\ @@ -2624,11 +2630,12 @@ STATIC FUNCTION ActiveXBuildToolBar( oCrt, nActiveX ) DEFAULT nActiveX TO 0 - oTBar := WvgToolBar():new( oCrt , , { 0,0 }, { oCrt:currentSize()[ 1 ], 30 }, , .T. ) + oTBar := WvgToolBar():new( oCrt:drawingArea , , { 0,0 }, { oCrt:currentSize()[ 1 ], 30 }, , .T. ) + //oTBar := WvgToolBar():new( oCrt, , { 0,0 }, { oCrt:currentSize()[ 1 ], 30 }, , .T. ) oTBar:borderStyle := WVGFRAME_RECT - oTBar:buttonWidth := 28 + oTBar:buttonWidth := 40 //28 oTBar:buttonHeight := 26 oTBar:imageWidth := 26 @@ -2656,7 +2663,7 @@ STATIC FUNCTION BuildActiveXControl( nActiveX, oCrt ) DEFAULT nActiveX TO 2 - oCom := WvgActiveXControl():New( oCrt, , { 0, 0 }, { 100, 100 }, , .t. ) + oCom := WvgActiveXControl():New( oCrt:drawingArea, , { 0, 0 }, { 100, 100 }, , .t. ) do case case nActiveX == 1 @@ -2704,6 +2711,10 @@ STATIC FUNCTION BuildActiveXControl( nActiveX, oCrt ) // Trying to set it generates GPF. // Please download RMChart.ocx from http://www.rmchart.com/ . It is free in everysense. + case nActiveX == 5 + hb_gtInfo( HB_GTI_WINTITLE, 'Image Viewer' ) + oCom:CLSID := 'SCRIBBLE.ScribbleCtrl.1' + endcase oCom:create() @@ -2727,6 +2738,16 @@ Static Function ExeActiveX( nActiveX, oCom, xParam ) oCom:Draw( .t. ) oCom:Draw2Clipboard() + elseif nActiveX == 5 + oCom:loadMultiPage( 'c:\myharu.pdf', 2 ) + oCom:addGradientBorder( 10, RGB( 12,20,233 ), RGB( 100,255,20 ), 0 ) + oCom:drawText( 10,10,'Vouch' ) + //oCom:emboss( 3,0 ) + oCom:copy2ClipBoard() + oCom:view := 11 + oCom:setBackGroundColor( rgb( 225,225,225 ) ) + //oCom:rotate90() +//hb_toOutDebug( str( oCom:getTotalPage() ) ) endif do while .t. diff --git a/harbour/contrib/gtwvg/tests/demoxbp.prg b/harbour/contrib/gtwvg/tests/demoxbp.prg index 5f15fba323..851f6a8be0 100644 --- a/harbour/contrib/gtwvg/tests/demoxbp.prg +++ b/harbour/contrib/gtwvg/tests/demoxbp.prg @@ -282,15 +282,16 @@ STATIC FUNCTION HB_GTSYS() //----------------------------------------------------------------------// STATIC FUNCTION ResizeDialog( oCrt, oTBar, oSBar, oStatic, oCom, oTree, oAddr ) - LOCAL aCrt, aTBar, aSBar, aStatic, aCom, aTree + LOCAL aCrt, aTBar, aSBar + //LOCAL aStatic, aCom, aTree LOCAL nH, nT aCrt := oCrt:currentSize() aTBar := oTBar:currentSize() aSBar := oSBar:currentSize() - aStatic := oStatic:currentSize() - aTree := oTree:currentSize() - aCom := oCom:currentSize() + //aStatic := oStatic:currentSize() + //aTree := oTree:currentSize() + //aCom := oCom:currentSize() nT := aTBar[2] nH := aCrt[2]-aTBar[2]-aSBar[2] @@ -421,7 +422,7 @@ Static Function MyFunction( nMode ) //----------------------------------------------------------------------// STATIC FUNCTION ExeFontDialog( oCrt ) - LOCAL oFontDlg, oWvgFont + LOCAL oFontDlg STATIC nMode := 0 @@ -441,13 +442,18 @@ STATIC FUNCTION ExeFontDialog( oCrt ) //oFontDlg:style := .f. oFontDlg:create() - // Every 2nd FontDialog will be MODAL - oWvgFont := oFontDlg:display( ++nMode % 2 ) - oFontDlg:destroy() #if 0 + // Every 2nd FontDialog will be MODAL + oWvgFont := oFontDlg:display( ++nMode % 2 ) hb_ToOutDebug( '%s %i', oWvgFont:compoundName, oWvgFont:nominalPointSize ) #endif + + oFontDlg:destroy() + RETURN nil //----------------------------------------------------------------------// + + + diff --git a/harbour/contrib/gtwvg/wvgdarea.prg b/harbour/contrib/gtwvg/wvgdarea.prg new file mode 100644 index 0000000000..0b62690468 --- /dev/null +++ b/harbour/contrib/gtwvg/wvgdarea.prg @@ -0,0 +1,179 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Wvg*Classes + * + * Copyright 2009 Pritpal Bedi + * http://www.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++ WvgDialog's Helper Class +// +// Pritpal Bedi +// 15Feb2009 +// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// + +#include 'hbclass.ch' +#include 'common.ch' +#include 'inkey.ch' +#include 'hbgtinfo.ch' + +#include 'hbgtwvg.ch' +#include 'wvtwin.ch' +#include 'wvgparts.ch' + +//----------------------------------------------------------------------// + +#ifndef __DBG_PARTS__ +#xtranslate hb_ToOutDebug( [] ) => +#endif + +//----------------------------------------------------------------------// + +CLASS WvgDrawingArea INHERIT WvgWindow + + DATA caption INIT '' + DATA clipParent INIT .T. + DATA clipSiblings INIT .T. + + METHOD new() + METHOD create() + METHOD destroy() + METHOD handleEvent() + + ENDCLASS +//----------------------------------------------------------------------// + +METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDrawingArea + + ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::style := WS_CHILD + ::exStyle := 0 + ::className := 'DrawingArea' + ::objType := objTypeDA + ::visible := .f. + + RETURN Self + +//----------------------------------------------------------------------// + +METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDrawingArea + + HB_SYMBOL_UNUSED( lVisible ) + + ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, .f. ) + + ::oParent:addChild( SELF ) + + Wvg_RegisterClass_ByName( ::className ) + + ::createControl() + + ::nWndProc := hb_AsCallBack( 'CONTROLWNDPROC', Self, 4 ) + ::nOldProc := Win_SetWndProc( ::hWnd, ::nWndProc ) + + RETURN Self + +//----------------------------------------------------------------------// + +METHOD handleEvent( nMessage, aNM ) CLASS WvgDrawingArea + LOCAL hDC + + hb_ToOutDebug( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) + + DO CASE + + CASE nMessage == HB_GTE_RESIZED + IF hb_isBlock( ::sl_resize ) + eval( ::sl_resize, NIL, NIL, self ) + ENDIF + aeval( ::aChildren, {|o| o:handleEvent( HB_GTE_RESIZED, { 0, 0, 0, 0, 0 } ) } ) + RETURN ( 0 ) + + CASE nMessage == HB_GTE_CTLCOLOR + hDC := aNM[ 1 ] + + IF hb_isNumeric( ::clr_FG ) + Win_SetTextColor( hDC, ::clr_FG ) + ENDIF + IF hb_isNumeric( ::hBrushBG ) + Win_SetBkMode( hDC, 1 ) + + Win_FillRect( hDC, { 0,0,::currentSize()[1],::currentSize()[1]}, ::hBrushBG ) + RETURN ( 0 ) + ENDIF + + CASE nMessage == HB_GTE_NOTIFY + + + ENDCASE + + RETURN ( 1 ) + +//----------------------------------------------------------------------// + +METHOD destroy() CLASS WvgDrawingArea + + hb_ToOutDebug( " %s:destroy()", __objGetClsName( self ) ) + + ::WvgWindow:destroy() + + RETURN NIL + +//----------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/wvgdlg.prg b/harbour/contrib/gtwvg/wvgdlg.prg index 111fabb27c..192eec44b5 100644 --- a/harbour/contrib/gtwvg/wvgdlg.prg +++ b/harbour/contrib/gtwvg/wvgdlg.prg @@ -113,11 +113,10 @@ METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDial ::style := WS_THICKFRAME+WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX; - //::drawingArea := Self - RETURN Self //----------------------------------------------------------------------// METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDialog + LOCAL oW ::WvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -162,11 +161,23 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDi ::lHasInputFocus := .t. endif - #if 0 - ::drawingArea := WvgStatic():New( self, , {0,0}, {self:currentSize()[1],self:currentSize()[2]}, , .t. ) - ::drawingArea:create() + #if 1 + oW := WvgDrawingArea():new( self ):create( , , {0,0}, self:currentSize(), , .f. ) + IF !empty( oW:hWnd ) + //Win_SetLayeredWindowAttributes( oW:hWnd, RGB( 255,255,255 ), 0 ) // transparent + ::drawingArea := oW + ELSE + #if 1 + ::drawingArea := WvgStatic():New( self, , {0,0}, self:currentSize(), , .f. ) + ::drawingArea:create() + //Win_SetLayeredWindowAttributes( ::drawingArea:hWnd, RGB( 255,255,255 ), 0 ) // transparent + #else + ::drawingArea := Self + #endif + ENDIF + ::drawingArea:show() #else - ::drawingArea := Self + ::drawingArea := Self #endif hb_gtInfo( HB_GTI_NOTIFIERBLOCK, {|nEvent, ...| ::notifier( nEvent, ... ) } ) @@ -188,6 +199,10 @@ METHOD destroy() CLASS WvgDialog aeval( ::aChildren, {|o| o:destroy() } ) ENDIF + IF !empty( ::hBrushBG ) + Win_DeleteObject( ::hBrushBG ) + ENDIF + ::pGT := NIL ::pGTp := NIL diff --git a/harbour/contrib/gtwvg/wvgparts.ch b/harbour/contrib/gtwvg/wvgparts.ch index b76c41a6d9..f58666a425 100644 --- a/harbour/contrib/gtwvg/wvgparts.ch +++ b/harbour/contrib/gtwvg/wvgparts.ch @@ -59,6 +59,8 @@ //----------------------------------------------------------------------// +#define DA_MODE 1 // Experimental + #define objTypeNone 0 #define objTypeCrt 1 #define objTypeWindow 2 @@ -79,6 +81,7 @@ #define objType3State 17 #define objTypeSLE 18 #define objTypeMLE 19 +#define objTypeDA 20 //----------------------------------------------------------------------// // NMHDR info diff --git a/harbour/contrib/gtwvg/wvgphdlr.prg b/harbour/contrib/gtwvg/wvgphdlr.prg index 5344ccca9b..ddb61b7c66 100644 --- a/harbour/contrib/gtwvg/wvgphdlr.prg +++ b/harbour/contrib/gtwvg/wvgphdlr.prg @@ -169,6 +169,7 @@ METHOD status() CLASS WvgPartHandler METHOD addChild( oWvg ) CLASS WvgPartHandler + oWvg:nNameID := oWvg:nID aadd( ::aChildren, oWvg ) RETURN Self @@ -176,26 +177,33 @@ METHOD addChild( oWvg ) CLASS WvgPartHandler //----------------------------------------------------------------------// METHOD childFromName( nNameId ) CLASS WvgPartHandler - LOCAL oWvg + LOCAL i, oWvg - IF ::hChildren[ nNameId ] <> NIL - oWvg := ::hChildren[ nNameId ] // ??? - ENDIF + FOR i := 1 TO len( ::aChildren ) + IF ::aChildren[ i ]:nNameID <> NIL .and. ::aChildren[ i ]:nNameID == nNameID + oWvg := ::aChildren[ i ] + ENDIF + NEXT RETURN oWvg //----------------------------------------------------------------------// METHOD childList() CLASS WvgPartHandler - LOCAL aChildList := {} - RETURN aChildList + RETURN ::aChildren //----------------------------------------------------------------------// METHOD delChild( oWvg ) CLASS WvgPartHandler + LOCAL n - HB_SYMBOL_UNUSED( oWvg ) + n := ascan( ::aChildren, {|o| o == oWvg } ) + IF n > 0 + oWvg:destroy() + adel( ::aChildren, n ) + asize( ::aChildren, len( ::aChildren )-1 ) + endif RETURN Self @@ -205,7 +213,7 @@ METHOD setName( nNameId ) CLASS WvgPartHandler LOCAL nOldNameId := ::nNameId IF Valtype( nNameId ) == 'N' - ::nNameId := nNameId + ::nNameID := nNameId ENDIF RETURN nOldNameId @@ -370,6 +378,11 @@ METHOD notifier( nEvent, xParams ) CLASS WvgPartHandler ENDCASE CASE nEvent == HB_GTE_RESIZED + IF ::objType == objTypeDialog + IF ::drawingArea:objType == objTypeDA + ::drawingArea:setPosAndSize( {0,0}, ::currentSize(), .f. ) + ENDIF + ENDIF IF hb_isBlock( ::sl_resize ) eval( ::sl_resize, { xParams[ 1 ], xParams[ 2 ] }, { xParams[ 3 ], xParams[ 4 ] }, Self ) ENDIF diff --git a/harbour/contrib/gtwvg/wvgstatc.prg b/harbour/contrib/gtwvg/wvgstatc.prg index 76e1d51b6b..8e568a6b79 100644 --- a/harbour/contrib/gtwvg/wvgstatc.prg +++ b/harbour/contrib/gtwvg/wvgstatc.prg @@ -262,6 +262,7 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgStatic CASE nMessage == HB_GTE_RESIZED 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 ) ENDIF @@ -287,19 +288,11 @@ METHOD destroy() CLASS WvgStatic hb_ToOutDebug( " %s:destroy()", __objGetClsName() ) ::WvgWindow:destroy() + IF ::hBitmap <> nil Win_DeleteObject( ::hBitmap ) ENDIF - #if 0 - IF len( ::aChildren ) > 0 - aeval( ::aChildren, {|o| o:destroy() } ) - ENDIF - IF Win_IsWindow( ::hWnd ) - Win_DestroyWindow( ::hWnd ) - ENDIF - HB_FreeCallback( ::nWndProc ) - #endif RETURN NIL //----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/wvgtoolb.prg b/harbour/contrib/gtwvg/wvgtoolb.prg index 10c8f4f288..0d189e6255 100644 --- a/harbour/contrib/gtwvg/wvgtoolb.prg +++ b/harbour/contrib/gtwvg/wvgtoolb.prg @@ -99,6 +99,7 @@ CLASS WvgToolBar INHERIT WvgWindow //WvgActiveXControl DATA transparentColor INIT 0 DATA aItems INIT {} + DATA hImageList METHOD new() METHOD create() @@ -125,7 +126,7 @@ CLASS WvgToolBar INHERIT WvgWindow //WvgActiveXControl METHOD change() SETGET METHOD buttonMenuClick() SETGET METHOD buttonDropDown() SETGET - + METHOD sendToolbarMessage() METHOD handleEvent( nMessage, aInfo ) ENDCLASS @@ -137,9 +138,9 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgToolB //::WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - - ::style := WS_CHILD + TBSTYLE_FLAT + CCS_ADJUSTABLE //+ CCS_NODIVIDER //+CCS_VERT - ::exStyle := TBSTYLE_EX_DOUBLEBUFFER + // + TBSTYLE_LIST caption to the right, otherwise caption to the bottom + ::style := WS_CHILD + TBSTYLE_FLAT + TBSTYLE_TOOLTIPS + CCS_ADJUSTABLE //+ CCS_NODIVIDER //+CCS_VERT + ::exStyle := TBSTYLE_EX_DOUBLEBUFFER //+ TBSTYLE_EX_MIXEDBUTTONS ::className := TOOLBARCLASSNAME ::objType := objTypeToolBar @@ -172,17 +173,32 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTo ::createControl() - ::nWndProc := HB_AsCallBack( 'CONTROLWNDPROC', Self ) + #if 0 + // Should not be defined as we only require its notifications + // so the parent of toolbar will process them anyway + // All other functionality should be default until ownerdraw is introduced. + // + ::nWndProc := hb_AsCallBack( 'CONTROLWNDPROC', Self ) ::nOldProc := Win_SetWndProc( ::hWnd, ::nWndProc ) + #endif + + IF !empty( ::hWnd ) + #define ILC_COLOR8 8 + + ::hImageList := WAPI_ImageList_Create( ::imageWidth, ::imageHeight, ILC_COLOR8, 0, 20 ) + ::SendToolbarMessage( TB_SETIMAGELIST, ::hImageList ) + + ::SendToolbarMessage( TB_BUTTONSTRUCTSIZE ) + ::SendToolbarMessage( TB_SETBUTTONSIZE, ::buttonWidth+20, ::buttonHeight ) + + ::SendToolbarMessage( TB_AUTOSIZE ) + ENDIF + ::sendToolbarMessage( TB_SETMAXTEXTROWS, IF( ::showToolTips, 0, 1 ) ) IF ::visible ::show() ENDIF - IF ::showToolTips - ::sendMessage( TB_SETMAXTEXTROWS, 0, 0 ) - ENDIF - RETURN Self //----------------------------------------------------------------------// @@ -191,7 +207,7 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgToolBar LOCAL nHandled := 1 LOCAL nObj, aNMMouse - hb_ToOutDebug( " %s:handleEvent( %i )", __ObjGetClsName( self ), nMessage ) + //hb_ToOutDebug( " %s:handleEvent( %i ) %i", __ObjGetClsName( self ), nMessage, ) SWITCH nMessage @@ -204,6 +220,8 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgToolBar CASE HB_GTE_NOTIFY aNMMouse := Wvg_GetNMMouseInfo( aNM[ 2 ] ) +hb_ToOutDebug( " %s:handleEvent( %i ) %i %i", __ObjGetClsName( self ), nMessage,; + aNMMouse[ NMH_code ], NM_CLICK ) DO CASE @@ -231,7 +249,7 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgToolBar METHOD destroy() CLASS WvgToolBar LOCAL i, nItems - hb_ToOutDebug( " %s:destroy()", __objGetClsName() ) + hb_ToOutDebug( " %s:destroy()", __objGetClsName( self ) ) IF ( nItems := Len( ::aItems ) ) > 0 FOR i := 1 TO nItems @@ -247,10 +265,7 @@ METHOD destroy() CLASS WvgToolBar NEXT ENDIF - IF Win_IsWindow( ::hWnd ) - Win_DestroyWindow( ::hWnd ) - ENDIF - HB_FreeCallback( ::nWndProc ) + ::WvgWindow:destroy() RETURN NIL @@ -264,8 +279,14 @@ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS Wv //----------------------------------------------------------------------// +METHOD sendToolbarMessage( nMsg, p1, p2, p3, p4, p5 ) CLASS WvgToolBar + + RETURN Win_SendToolbarMessage( ::hWnd, nMsg, p1, p2, p3, p4, p5 ) + +//----------------------------------------------------------------------// + METHOD addItem( cCaption, xImage, xDisabledImage, xHotImage, cDLL, nStyle, cKey ) CLASS WvgToolBar - LOCAL oBtn, hBitmap, cType + LOCAL oBtn, hBitmap, cType, nBtn HB_SYMBOL_UNUSED( xDisabledImage ) HB_SYMBOL_UNUSED( xHotImage ) @@ -295,10 +316,21 @@ METHOD addItem( cCaption, xImage, xDisabledImage, xHotImage, cDLL, nStyle, cKey IF hBitmap <> 0 oBtn:image := hBitmap - Wvg_AddToolbarButton( ::hWnd, oBtn:image, oBtn:caption, oBtn:command, 1 ) + nBtn := WAPI_ImageList_Add( ::hImageList, hBitmap ) + //nBtn := WAPI_ImageList_AddMasked( ::hImageList, hBitmap, RGB( 198,198,198 ) ) + /* Now as we are using ImageList, this will duplicate bitmaps */ + //nBtn := Win_SendToolbarMessage( ::hWnd, TB_ADDBITMAP, hBitmap ) + + //nStr := ::sendToolbarMessage( TB_ADDSTRING, oBtn:caption ) + + //lRet := ::sendToolbarMessage( TB_ADDBUTTONS, nBtn, oBtn:command, nStr ) + + Wvg_AddToolbarButton( ::hWnd, nBtn/*hBitmap*/, oBtn:caption, oBtn:command, 1, ::showToolTips ) + + ::sendToolbarMessage( TB_AUTOSIZE ) ELSE - Wvg_AddToolbarButton( ::hWnd, , , oBtn:command, 3 ) + Wvg_AddToolbarButton( ::hWnd, , , oBtn:command, 3, .f. ) ENDIF diff --git a/harbour/contrib/gtwvg/wvgwin.c b/harbour/contrib/gtwvg/wvgwin.c index 3d7e5e14fb..49c156bd0f 100644 --- a/harbour/contrib/gtwvg/wvgwin.c +++ b/harbour/contrib/gtwvg/wvgwin.c @@ -77,6 +77,7 @@ #define HB_OS_WIN_USED #include "gtwvg.h" +#include "hbwapi.h" #include #define WIN_STATUSBAR_MAX_PARTS 256 @@ -1261,70 +1262,6 @@ HB_FUNC( WVG_PREPAREBITMAPFROMRESOURCENAME ) hb_retnint( ( HB_PTRDIFF ) hBitmap ); } - -//----------------------------------------------------------------------// -// -// Wvg_AddToolbarButton( hWndTB, hBitmap, cCaption, nButtonID, nMode ) -// -HB_FUNC( WVG_ADDTOOLBARBUTTON ) -{ - TBBUTTON tbb; - TBADDBITMAP tbab; - BOOL bSuccess; - HWND hWndTB = ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ); - int iCommand = hb_parni( 4 ); - TCHAR * szCaption; - - switch( hb_parni( 5 ) ) - { - case 1: // button from image - { - HBITMAP hBitmap = ( HBITMAP ) ( HB_PTRDIFF ) hb_parnint( 2 ); - int iNewBitmap, iNewString; - - // set bitmap - tbab.hInst = NULL; - tbab.nID = ( UINT ) hBitmap; - iNewBitmap = SendMessage( hWndTB, TB_ADDBITMAP, ( WPARAM ) 1, ( LPARAM ) &tbab ); - - // set string - // - szCaption = HB_TCHAR_CONVTO( hb_parc( 3 ) ); - iNewString = SendMessage( hWndTB, TB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) szCaption ); - HB_TCHAR_FREE( szCaption ); - - // add button - tbb.iBitmap = iNewBitmap; - tbb.idCommand = iCommand; - tbb.fsState = TBSTATE_ENABLED; - tbb.fsStyle = TBSTYLE_BUTTON; - tbb.dwData = 0; - tbb.iString = iNewString; - - bSuccess = SendMessage( hWndTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb ); - - hb_retl( bSuccess ); - return; - } - - case 2: // system bitmap - - - case 3: // separator - { - tbb.iBitmap = 0; - tbb.idCommand = 0; - tbb.fsState = TBSTATE_ENABLED; - tbb.fsStyle = TBSTYLE_SEP; - tbb.dwData = 0; - tbb.iString = 0; - - bSuccess = SendMessage( hWndTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb ); - hb_retl( bSuccess ); - return; - } - } -} //----------------------------------------------------------------------// HB_FUNC( WVG_STATUSBARCREATEPANEL ) @@ -2097,3 +2034,585 @@ HB_FUNC( WVG_SETCURRENTBRUSH ) SetClassLong( wvg_parhwnd( 1 ), GCL_HBRBACKGROUND, ( DWORD ) hb_parnint( 2 ) ); } //----------------------------------------------------------------------// +// Win_SetLayeredWindowAttributes( hWnd, nRGB, nOpacityFactor [0-255] ) +// +HB_FUNC( WIN_SETLAYEREDWINDOWATTRIBUTES ) +{ +#if ( _WIN32_WINNT >= 0x0500 ) + HINSTANCE h; + wvtSetLayeredWindowAttributes pfnLayered; + + h = LoadLibraryEx( TEXT( "user32.dll" ), NULL, 0 ); + if( h ) + { +#if defined( UNICODE ) && defined( GetProcAddress ) + pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddressW( h, TEXT( "SetLayeredWindowAttributes" ) ); +#else + pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddress( h, "SetLayeredWindowAttributes" ); +#endif + if( pfnLayered ) + { + HWND hWnd = wapi_par_HWND( 1 ); + COLORREF cr = ISNIL( 2 ) ? RGB( 255,255,255 ) : wapi_par_COLORREF( 2 ); + + SetWindowLong( hWnd, GWL_EXSTYLE, GetWindowLong( hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED ); + + if( pfnLayered( hWnd, cr, hb_parni( 3 ), /*LWA_COLORKEY |*/ LWA_ALPHA ) == 0 ); + { +//hb_ToOutDebug( "ysyysys" ); + } + } + FreeLibrary( h ); + } +#endif +} +//----------------------------------------------------------------------// +// IL | DL +// Wvg_AddToolbarButton( hWndTB, nBtn|hBitmap, cCaption, nButtonID, nMode, lIsTooltip ) +// +HB_FUNC( WVG_ADDTOOLBARBUTTON ) +{ + TBBUTTON tbb; + TBADDBITMAP tbab; + BOOL bSuccess; + HWND hWndTB = ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ); + int iCommand = hb_parni( 4 ); + TCHAR * szCaption; + + switch( hb_parni( 5 ) ) + { + case 1: // button from image + { + int iNewBitmap, iNewString; + + // set bitmap + // + tbab.hInst = NULL; + tbab.nID = ( UINT ) wapi_par_HBITMAP( 2 ); + iNewBitmap = SendMessage( hWndTB, TB_ADDBITMAP, ( WPARAM ) 1, ( LPARAM ) &tbab ); + + // set string + // + szCaption = HB_TCHAR_CONVTO( hb_parc( 3 ) ); + iNewString = SendMessage( hWndTB, TB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) szCaption ); + HB_TCHAR_FREE( szCaption ); + + // add button + // + tbb.iBitmap = iNewBitmap; + tbb.idCommand = iCommand; + tbb.fsState = TBSTATE_ENABLED; + if( ISLOG( 6 ) && hb_parl( 6 ) ) + tbb.fsStyle = TBSTYLE_BUTTON; + else + tbb.fsStyle = TBSTYLE_BUTTON;// | TBSTYLE_SHOWTEXT; + + tbb.dwData = 0; + tbb.iString = iNewString; + + bSuccess = SendMessage( hWndTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb ); + + hb_retl( bSuccess ); + return; + } + + case 2: // system bitmap + + + case 3: // separator + { + tbb.iBitmap = 0; + tbb.idCommand = 0; + tbb.fsState = TBSTATE_ENABLED; + tbb.fsStyle = TBSTYLE_SEP; + tbb.dwData = 0; + tbb.iString = 0; + + bSuccess = SendMessage( hWndTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb ); + hb_retl( bSuccess ); + return; + } + } +} +//----------------------------------------------------------------------// + +HB_FUNC( WIN_SENDTOOLBARMESSAGE ) +{ + HWND hTB = wapi_par_HWND( 1 ); + int msg = wapi_par_INT( 2 ); + + + switch( msg ) + { + case TB_ADDBITMAP : + { + TBADDBITMAP tbab; + int iBitmap; + + tbab.hInst = NULL; + tbab.nID = ( UINT ) wapi_par_HBITMAP( 3 ); + + iBitmap = SendMessage( hTB, TB_ADDBITMAP, ( WPARAM ) 1, ( LPARAM ) &tbab ); + + wapi_ret_NI( iBitmap ); + } + break; + case TB_ADDBUTTONS : + { + TBBUTTON tbb; + + tbb.iBitmap = wapi_par_INT( 3 ); + tbb.idCommand = wapi_par_INT( 4 ); + tbb.fsState = TBSTATE_ENABLED; + tbb.fsStyle = TBSTYLE_BUTTON ; + tbb.dwData = 0; + tbb.iString = wapi_par_INT( 5 ); + + wapi_ret_L( SendMessage( hTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb ) ); + } + break; + case TB_ADDSTRING : + { + int iString; + LPTSTR szCaption; + + szCaption = HB_TCHAR_CONVTO( hb_parc( 3 ) ); + iString = SendMessage( hTB, TB_ADDSTRING, ( WPARAM ) NULL, ( LPARAM ) szCaption ); + HB_TCHAR_FREE( szCaption ); + + wapi_ret_NI( iString ); + } + break; + case TB_AUTOSIZE : + { + SendMessage( hTB, TB_AUTOSIZE, ( WPARAM ) 0, ( LPARAM ) 0 ); + } + break; + case TB_BUTTONCOUNT : + { + } + break; + case TB_BUTTONSTRUCTSIZE : + { + SendMessage( hTB, TB_BUTTONSTRUCTSIZE, sizeof( TBBUTTON ), 0 ); + } + break; + case TB_CHANGEBITMAP : + { + } + break; + case TB_CHECKBUTTON : + { + } + break; + case TB_COMMANDTOINDEX : + { + } + break; + case TB_CUSTOMIZE : + { + } + break; + case TB_DELETEBUTTON : + { + } + break; + case TB_ENABLEBUTTON : + { + } + break; + case TB_GETANCHORHIGHLIGHT : + { + } + break; + case TB_GETBITMAP : + { + } + break; + case TB_GETBITMAPFLAGS : + { + } + break; + case TB_GETBUTTON : + { + } + break; + case TB_GETBUTTONINFO : + { + } + break; + case TB_GETBUTTONSIZE : + { + } + break; + case TB_GETBUTTONTEXT : + { + } + break; + case TB_GETCOLORSCHEME : + { + } + break; + case TB_GETDISABLEDIMAGELIST : + { + } + break; + case TB_GETEXTENDEDSTYLE : + { + } + break; + case TB_GETHOTIMAGELIST : + { + } + break; + case TB_GETHOTITEM : + { + } + break; + #if 0 + case TB_GETIDEALSIZE : + { + } + break; + #endif + case TB_GETIMAGELIST : + { + } + break; + #if 0 + case TB_GETIMAGELISTCOUNT : + { + } + break; + #endif + case TB_GETINSERTMARK : + { + } + break; + case TB_GETINSERTMARKCOLOR : + { + } + break; + #if 0 + case TB_GETITEMDROPDOWNRECT : + { + } + break; + #endif + case TB_GETITEMRECT : + { + } + break; + case TB_GETMAXSIZE : + { + } + break; + #if 0 + case TB_GETMETRICS : + { + } + break; + #endif + case TB_GETOBJECT : + { + } + break; + case TB_GETPADDING : + { + } + break; + #if 0 + case TB_GETPRESSEDIMAGELIST : + { + } + break; + #endif + case TB_GETRECT : + { + } + break; + case TB_GETROWS : + { + } + break; + case TB_GETSTATE : + { + } + break; + #if 0 + case TB_GETSTRING : + { + } + break; + #endif + case TB_GETSTYLE : + { + } + break; + case TB_GETTEXTROWS : + { + } + break; + case TB_GETTOOLTIPS : + { + } + break; + case TB_GETUNICODEFORMAT : + { + } + break; + case TB_HIDEBUTTON : + { + } + break; + case TB_HITTEST : + { + } + break; + case TB_INDETERMINATE : + { + } + break; + case TB_INSERTBUTTON : + { + } + break; + case TB_INSERTMARKHITTEST : + { + } + break; + case TB_ISBUTTONCHECKED : + { + } + break; + case TB_ISBUTTONENABLED : + { + } + break; + case TB_ISBUTTONHIDDEN : + { + } + break; + case TB_ISBUTTONHIGHLIGHTED : + { + } + break; + case TB_ISBUTTONINDETERMINATE: + { + } + break; + case TB_ISBUTTONPRESSED : + { + } + break; + case TB_LOADIMAGES : + { + } + break; + case TB_MAPACCELERATOR : + { + } + break; + case TB_MARKBUTTON : + { + SendMessage( hTB, TB_MARKBUTTON, ( WPARAM ) wapi_par_INT( 3 ), ( LPARAM ) MAKELONG( hb_parl( 4 ),0 ) ); + } + break; + case TB_MOVEBUTTON : + { + } + break; + case TB_PRESSBUTTON : + { + } + break; + case TB_REPLACEBITMAP : + { + } + break; + case TB_SAVERESTORE : + { + } + break; + case TB_SETANCHORHIGHLIGHT : + { + } + break; + case TB_SETBITMAPSIZE : + { + } + break; + case TB_SETBUTTONINFO : + { + } + break; + case TB_SETBUTTONSIZE : + { + SendMessage( hTB, TB_SETBUTTONSIZE, ( WPARAM ) 0, + ( LPARAM ) MAKELONG( wapi_par_INT( 3 ), wapi_par_INT( 4 ) ) ); + } + break; + case TB_SETBUTTONWIDTH : + { + } + break; + case TB_SETCMDID : + { + } + break; + case TB_SETCOLORSCHEME : + { + } + break; + case TB_SETDISABLEDIMAGELIST : + { + } + break; + case TB_SETDRAWTEXTFLAGS : + { + } + break; + case TB_SETEXTENDEDSTYLE : + { + } + break; + case TB_SETHOTIMAGELIST : + { + } + break; + case TB_SETHOTITEM : + { + } + break; + #if 0 + case TB_SETHOTITEM2 : + { + } + break; + #endif + case TB_SETIMAGELIST : + { + SendMessage( hTB, TB_SETIMAGELIST, ( WPARAM ) 0, ( LPARAM ) wapi_par_HIMAGELIST( 3 ) ); + } + break; + case TB_SETINDENT : + { + } + break; + case TB_SETINSERTMARK : + { + } + break; + case TB_SETINSERTMARKCOLOR : + { + } + break; + #if 0 + case TB_SETLISTGAP : + { + } + break; + #endif + case TB_SETMAXTEXTROWS : + { + SendMessage( hTB, TB_SETMAXTEXTROWS, ( WPARAM ) wapi_par_INT( 2 ), ( LPARAM ) 0 ); + } + break; + #if 0 + case TB_SETMETRICS : + { + } + break; + #endif + case TB_SETPADDING : + { + } + break; + case TB_SETPARENT : + { + } + break; + #if 0 + case TB_SETPRESSEDIMAGELIST : + { + } + break; + #endif + case TB_SETROWS : + { + } + break; + case TB_SETSTATE : + { + } + break; + case TB_SETSTYLE : + { + } + break; + case TB_SETTOOLTIPS : + { + } + break; + case TB_SETUNICODEFORMAT : + { + } + break; + #if 0 + case TB_SETWINDOWTHEME : + { + } + break; + case TB_TRANSLATEACCELERATOR : + { + } + break; + #endif + } + +} + +//----------------------------------------------------------------------// +// Wvg_RegisterClass( cClassName, +// +HB_FUNC( WVG_REGISTERCLASS_BYNAME ) +{ + WNDCLASS wndclass; + LPTSTR szClass = HB_TCHAR_CONVTO( hb_parc( 1 ) ); + + memset( &wndclass, 0, sizeof( WNDCLASS ) ); + wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + wndclass.lpfnWndProc = DefWindowProc; + wndclass.hInstance = wvg_hInstance(); + wndclass.hIcon = NULL; + wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); + wndclass.hbrBackground = NULL; + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = szClass; + + if( ! RegisterClass( &wndclass ) ) + { + int iError = GetLastError(); + if( iError != 1410 ) + { + hb_errInternal( 10001, "Failed to register DA window class", NULL, NULL ); + } + } + HB_TCHAR_FREE( szClass ); +} + +//----------------------------------------------------------------------// + +HB_FUNC( WIN_FILLRECT ) +{ + RECT rc; + + rc.left = hb_parni( 2,1 ); + rc.top = hb_parni( 2,2 ); + rc.right = hb_parni( 2,3 ); + rc.bottom = hb_parni( 2,4 ); + + FillRect( wapi_par_HDC( 1 ), &rc, wapi_par_HBRUSH( 3 ) ); +} + +//----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/wvgwnd.prg b/harbour/contrib/gtwvg/wvgwnd.prg index 4b2ea1155d..5ef1d424f8 100644 --- a/harbour/contrib/gtwvg/wvgwnd.prg +++ b/harbour/contrib/gtwvg/wvgwnd.prg @@ -269,6 +269,8 @@ EXPORTED: METHOD ControlWndProc() METHOD findObjectByHandle( hWnd ) + + METHOD isDerivedFrom() ENDCLASS //----------------------------------------------------------------------// @@ -332,6 +334,9 @@ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS Wv //----------------------------------------------------------------------// METHOD destroy() CLASS WvgWindow + #if 0 + hb_ToOutDebug( " %s:destroy() WvgWindow()", __objGetClsName( self ) ) + #endif IF Len( ::aChildren ) > 0 aeval( ::aChildren, {|o| o:destroy() } ) @@ -340,7 +345,9 @@ METHOD destroy() CLASS WvgWindow IF Win_IsWindow( ::hWnd ) Win_DestroyWindow( ::hWnd ) ENDIF - hb_FreeCallBack( ::nWndProc ) + IF !empty( ::nWndProc ) + hb_FreeCallBack( ::nWndProc ) + ENDIF IF ::hBrushBG <> NIL Win_DeleteObject( ::hBrushBG ) @@ -511,6 +518,27 @@ METHOD setSize( aSize, lPaint ) CLASS WvgWindow //----------------------------------------------------------------------// +METHOD isDerivedFrom( cClassORoObject ) CLASS WvgWindow + LOCAL lTrue := .f. + LOCAL cCls := __ObjGetClsName( self ) + + // Compares without Xbp or Wvg prefixes + + IF hb_isChar( cClassORoObject ) + IF upper( substr( cClassORoObject,4 ) ) == upper( substr( cCls,4 ) ) + lTrue := .t. + ENDIF + + ELSEIF hb_isObject( cClassORoObject ) + IF upper( substr( cClassORoObject:className,4 ) ) == upper( substr( cCls,4 ) ) + lTrue := .t. + ENDIF + ENDIF + + RETURN lTrue + +//----------------------------------------------------------------------// + METHOD show() CLASS WvgWindow Win_ShowWindow( ::hWnd, SW_NORMAL ) @@ -1024,12 +1052,12 @@ METHOD quit( xParam, xParam1 ) CLASS WvgWindow METHOD resize( xParam, xParam1 ) CLASS WvgWindow - if hb_isArray( xParam ) .and. hb_isBlock( ::sl_resize ) + if hb_isArray( xParam ) .and. hb_isArray( xParam1 ) .and. hb_isBlock( ::sl_resize ) eval( ::sl_resize, xParam, xParam1, Self ) RETURN Self endif - if hb_isBlock( xParam ) .or. hb_isNil( xParam ) + if hb_isBlock( xParam ) //.or. hb_isNil( xParam ) ::sl_resize := xParam RETURN NIL endif @@ -1187,35 +1215,17 @@ METHOD createControl() CLASS WvgWindow ::nID := ::oParent:GetControlId() - DO CASE + hWnd := Win_CreateWindowEx( ::exStyle, ; + ::className, ; + "", ; // window name + ::style, ; + ::aPos[ 1 ], ::aPos[ 2 ],; + ::aSize[ 1 ], ::aSize[ 2 ],; + ::oParent:hWnd,; + ::nID,; // hMenu + NIL,; // hInstance + NIL ) // lParam - CASE ::objType == objTypeToolBar - - hWnd := Win_CreateToolBarEx( ::oParent:hWnd,; // hWnd - window handle hosting the toolbar - ::style,; // ws - style of the toolbar - ::nID,; // wID - control identifier supplied with WM_COMMAND - 0,; // nBitmaps - number of button images - NIL,; // hBMInst - mudule instance which hosts the bitmap resource - NIL,; // wBPID - resource identifier of the bitmap - NIL,; // lpButton - TBUTTON structure - 0,; // number of buttons - ::buttonWidth,; // - ::buttonHeight,; - ::imageWidth,; - ::imageHeight ) - OTHERWISE - - hWnd := Win_CreateWindowEx( ::exStyle, ; - ::className, ; - "", ; // window name - ::style, ; - ::aPos[ 1 ], ::aPos[ 2 ],; - ::aSize[ 1 ], ::aSize[ 2 ],; - ::oParent:hWnd,; - ::nID,; // hMenu - NIL,; // hInstance - NIL ) // lParam - ENDCASE IF ( hWnd <> 0 ) ::hWnd := hWnd @@ -1234,6 +1244,12 @@ METHOD ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CLASS WvgWindow SWITCH nMessage + CASE WM_ERASEBKGND + IF ::objType == objTypeDA .and. !empty( ::hBrushBG ) + ::handleEvent( HB_GTE_CTLCOLOR, { nwParam, nlParam } ) + ENDIF + EXIT + CASE WM_COMMAND nCtrlID := Win_LOWORD( nwParam ) nNotifctn := Win_HIWORD( nwParam ) @@ -1254,16 +1270,20 @@ METHOD ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CLASS WvgWindow RETURN 0 ELSE IF ( nObj := ascan( ::aChildren, {|o| o:nID == nCtrlID } ) ) > 0 - RETURN ::aChildren[ nObj ]:handleEvent( HB_GTE_COMMAND, { nNotifctn, nCtrlID, hWndCtrl } ) - + nReturn := ::aChildren[ nObj ]:handleEvent( HB_GTE_COMMAND, { nNotifctn, nCtrlID, hWndCtrl } ) + IF hb_isNumeric( nReturn ) .and. nReturn == 0 + RETURN 0 + ENDIF ENDIF ENDIF EXIT CASE WM_NOTIFY IF ( nObj := ascan( ::aChildren, {| o | o:nID == nwParam } ) ) > 0 - RETURN ::aChildren[ nObj ]:handleEvent( HB_GTE_NOTIFY, { nwParam, nlParam } ) - + nReturn := ::aChildren[ nObj ]:handleEvent( HB_GTE_NOTIFY, { nwParam, nlParam } ) + IF hb_isNumeric( nReturn ) .and. nReturn == 0 + RETURN 0 + ENDIF ENDIF EXIT @@ -1285,7 +1305,6 @@ METHOD ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CLASS WvgWindow RETURN nReturn ENDIF ENDIF - EXIT END diff --git a/harbour/contrib/gtwvg/wvtwin.ch b/harbour/contrib/gtwvg/wvtwin.ch index b2cf1b834c..1a509b563a 100644 --- a/harbour/contrib/gtwvg/wvtwin.ch +++ b/harbour/contrib/gtwvg/wvtwin.ch @@ -1323,6 +1323,7 @@ #define STATUSCLASSNAME "msctls_statusbar32" /* Toolbar messages */ +#define TB_ADDBITMAP (WM_USER + 19) #define TB_SAVERESTOREA (WM_USER + 26) #define TB_SAVERESTOREW (WM_USER + 76) #define TB_CUSTOMIZE (WM_USER + 27) @@ -1409,7 +1410,6 @@ #define TBBF_LARGE 1 - #define TBIF_IMAGE 1 #define TBIF_TEXT 2 #define TBIF_STATE 4 @@ -1442,6 +1442,7 @@ #define TB_INSERTBUTTONW (WM_USER + 67) #define TB_ADDBUTTONSW (WM_USER + 68) +#define TB_ADDBUTTONSA (WM_USER + 20) #define TB_HITTEST (WM_USER + 69) #ifdef UNICODE #define TB_INSERTBUTTON TB_INSERTBUTTONW @@ -1454,6 +1455,7 @@ #define TB_SETDRAWTEXTFLAGS (WM_USER + 70) #define TB_GETSTRING (WM_USER + 92) +#define TBN_FIRST (-700) #define TBN_GETBUTTONINFOA (TBN_FIRST-0) #define TBN_BEGINDRAG (TBN_FIRST-1) #define TBN_ENDDRAG (TBN_FIRST-2) @@ -1466,6 +1468,18 @@ #define TBN_CUSTHELP (TBN_FIRST-9) #define TBN_DROPDOWN (TBN_FIRST-10) #define TBN_GETOBJECT (TBN_FIRST-12) +#define TBN_HOTITEMCHANGE (TBN_FIRST-13) +#define TBN_DRAGOUT (TBN_FIRST-14) +#define TBN_DELETINGBUTTON (TBN_FIRST-15) +#define TBN_GETDISPINFOA (TBN_FIRST-16) +#define TBN_GETDISPINFOW (TBN_FIRST-17) +#define TBN_GETINFOTIPA (TBN_FIRST-18) +#define TBN_GETINFOTIPW (TBN_FIRST-19) +#define TBN_GETBUTTONINFOW (TBN_FIRST-20) +#define TBN_RESTORE (TBN_FIRST-21) +#define TBN_SAVE (TBN_FIRST-22) +#define TBN_INITCUSTOMIZE (TBN_FIRST-23) + /* Toolbar Control Constants */ #define TBSTATE_CHECKED 1 diff --git a/harbour/contrib/hbwin/Makefile b/harbour/contrib/hbwin/Makefile index 77eb1bc783..ced4efeb10 100644 --- a/harbour/contrib/hbwin/Makefile +++ b/harbour/contrib/hbwin/Makefile @@ -17,6 +17,7 @@ C_SOURCES=\ win_prn2.c \ win_prt.c \ win_regc.c \ + wapi_commctrl.c \ PRG_SOURCES=\ win_os.prg \ diff --git a/harbour/contrib/hbwin/common.mak b/harbour/contrib/hbwin/common.mak index c0e0f7d276..1ed86e5232 100644 --- a/harbour/contrib/hbwin/common.mak +++ b/harbour/contrib/hbwin/common.mak @@ -22,6 +22,7 @@ LIB_OBJS = \ $(OBJ_DIR)win_prn2$(OBJEXT) \ $(OBJ_DIR)win_prt$(OBJEXT) \ $(OBJ_DIR)win_regc$(OBJEXT) \ + $(OBJ_DIR)wapi_commctrl$(OBJEXT) \ \ $(OBJ_DIR)win_os$(OBJEXT) \ $(OBJ_DIR)win_reg$(OBJEXT) \ diff --git a/harbour/contrib/hbwin/hbwapi.h b/harbour/contrib/hbwin/hbwapi.h index 46c8999d3b..662b00603d 100644 --- a/harbour/contrib/hbwin/hbwapi.h +++ b/harbour/contrib/hbwin/hbwapi.h @@ -54,9 +54,6 @@ #define __HBWAPI_H - #include "hbapi.h" - #include "hbapiitm.h" - /* If we implement pointers than we need to return back pointers in all those functions which return a handle. My existing code checks for the @@ -66,21 +63,21 @@ #define wapi_par_WPARAM( n ) ( ( WPARAM ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : hb_parptr( n ) ) ) */ - #define wapi_par_WNDPROC( n ) ( ( WNDPROC ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_WPARAM( n ) ( ( WPARAM ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_LPARAM( n ) ( ( LPARAM ) ( HB_PTRDIFF ) hb_parnint( n ) ) + #define wapi_par_WNDPROC( n ) ( ( WNDPROC ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_WPARAM( n ) ( ( WPARAM ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_LPARAM( n ) ( ( LPARAM ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HWND( n ) ( ( HWND ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HDC( n ) ( ( HDC ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HANDLE( n ) ( ( HANDLE ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HGDIOBJ( n ) ( ( HGDIOBJ ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HBRUSH( n ) ( ( HBRUSH ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HBITMAP( n ) ( ( HBITMAP ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HICON( n ) ( ( HICON ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HIMAGELIST( n ) ( ( HIMAGELIST ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HFONT( n ) ( ( HFONT ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_HINSTANCE( n ) ( ( HINSTANCE ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) + #define wapi_par_COLORREF( n ) ( ( COLORREF ) ( ISNUM( n ) ? ( HB_PTRDIFF ) hb_parnint( n ) : ( HB_PTRDIFF ) hb_parptr( n ) ) ) - #define wapi_par_HWND( n ) ( ( HWND ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HDC( n ) ( ( HDC ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HANDLE( n ) ( ( HANDLE ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HGDIOBJ( n ) ( ( HGDIOBJ ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HBITMAP( n ) ( ( HBITMAP ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HICON( n ) ( ( HICON ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HIMAGELIST( n ) ( ( HIMAGELIST ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HFONT( n ) ( ( HFONT ) ( HB_PTRDIFF ) hb_parnint( n ) ) - #define wapi_par_HINSTANCE( n ) ( ( HINSTANCE ) ( HB_PTRDIFF ) hb_parnint( n ) ) - - #define wapi_par_COLORREF( n ) ( ( COLORREF ) ( HB_PTRDIFF ) hb_parnint( n ) ) #define wapi_par_STRUCT( n ) ( hb_parc( n ) ) #define wapi_par_INT( n ) ( hb_parni( n ) ) @@ -88,9 +85,10 @@ #define wapi_ret_NI( i ) ( hb_retni( i ) ) #define wapi_ret_L( b ) ( hb_retl( b ) ) - #define wapi_ret_HANDLE( n ) ( hb_retnint( ( HB_PTRDIFF ) n ) ) - #define wapi_ret_HRESULT( hr ) ( hb_retnint( ( HB_PTRDIFF ) hr ) ) - #define wapi_ret_COLORREF( n ) ( hb_retnint( ( HB_PTRDIFF ) n ) ) + + #define wapi_ret_HANDLE( h ) ( hb_retptr( h ) ) + #define wapi_ret_HRESULT( hr ) ( hb_retptr( hr ) ) + #define wapi_ret_COLORREF( cr ) ( hb_retnint( ( HB_PTRDIFF ) cr ) ) #endif //__HBWAPI_H diff --git a/harbour/contrib/hbwin/wapi_commctrl.c b/harbour/contrib/hbwin/wapi_commctrl.c index 9cf974a461..ba5ad8c2e0 100644 --- a/harbour/contrib/hbwin/wapi_commctrl.c +++ b/harbour/contrib/hbwin/wapi_commctrl.c @@ -51,23 +51,13 @@ #define HB_OS_WIN_USED -#ifndef CINTERFACE - #define CINTERFACE 1 -#endif - -#define _WIN32_WINNT 0x0400 -#define _WIN32_IE 0x0500 - -#include -#include #include "hbapi.h" #include "hbwapi.h" +#include -extern BOOL Array2Point( PHB_ITEM aPoint, POINT *pt ); - -//----------------------------------------------------------------------// -// BEGIN - ImageList_* - API -//----------------------------------------------------------------------// +/*----------------------------------------------------------------------// + BEGIN - ImageList_* - API +//----------------------------------------------------------------------*/ /* int ImageList_Add( HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask ); */ @@ -75,7 +65,7 @@ HB_FUNC( WAPI_IMAGELIST_ADD ) { wapi_ret_NI( ImageList_Add( wapi_par_HIMAGELIST( 1 ), wapi_par_HBITMAP( 2 ), - wapi_par_HBITMAP( 3 ) ) ); + ISNIL( 3 ) ? NULL : wapi_par_HBITMAP( 3 ) ) ); } //----------------------------------------------------------------------// /* @@ -125,11 +115,25 @@ HIMAGELIST ImageList_Create( int cx, int cy, UINT flags, int cInitial, int cGrow */ HB_FUNC( WAPI_IMAGELIST_CREATE ) { + #if 0 /* Test */ + HIMAGELIST il; + + il = ImageList_Create( wapi_par_INT( 1 ), + wapi_par_INT( 2 ), + wapi_par_UINT( 3 ), + wapi_par_INT( 4 ), + wapi_par_INT( 5 ) ); + if( il ) + { + wapi_ret_HANDLE( il ); + } + #else wapi_ret_HANDLE( ImageList_Create( wapi_par_INT( 1 ), wapi_par_INT( 2 ), wapi_par_UINT( 3 ), wapi_par_INT( 4 ), wapi_par_INT( 5 ) ) ); + #endif } //----------------------------------------------------------------------// /* @@ -463,7 +467,7 @@ HB_FUNC( WAPI_IMAGELIST_WRITEEX ) { } #endif -//----------------------------------------------------------------------// +/*----------------------------------------------------------------------// // END - ImageList_* - API -//----------------------------------------------------------------------// +//----------------------------------------------------------------------*/