diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0f9ba60163..3849f68eb2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,40 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-04 20:09 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/hbxbp/Makefile + + * harbour/contrib/hbxbp/xbp.ch + + + harbour/contrib/hbxbp/xbpbitmap.prg + * harbour/contrib/hbxbp/xbpdialog.prg + * harbour/contrib/hbxbp/xbpfiledialog.prg + * harbour/contrib/hbxbp/xbpfontdialog.prg + * harbour/contrib/hbxbp/xbphtmlviewer.prg + * harbour/contrib/hbxbp/xbpstatic.prg + * harbour/contrib/hbxbp/xbpstyle.prg + * harbour/contrib/hbxbp/xbpwindow.prg + + Implemented XbpBitmap() class. + + More advances in XbpFontDialog() class. + + Implemented XbpStatic():type == XBPSTATIC_TYPE_ICON. + + * harbour/contrib/hbxbp/tests/abs1.png + * harbour/contrib/hbxbp/tests/abs2.png + * harbour/contrib/hbxbp/tests/abs3.png + * harbour/contrib/hbxbp/tests/abs4.png + * harbour/contrib/hbxbp/tests/vr.png + + Few more .png(s) for futuristic demo concepts. + + * harbour/contrib/hbxbp/tests/demoxbp.prg + + Demonstrated the use of XbpBitmap() class as a image conversion + menu option. Click on main menu prompt then click on + . Harbour-QT provides more formats to convert from/to + whereas Xbase++ is limiting. However Harbour cannot write to .GIF + format, may be it has something to do with GIF licensing. + + + Demonstrated XBPSTATIC_TYPE_ICON ::type of XbpStatic() class. + The only difference is load from file/resource. + 2009-07-04 20:03 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbqt/hbqt.ch * harbour/contrib/hbqt/hbqt_slots.h diff --git a/harbour/contrib/hbxbp/Makefile b/harbour/contrib/hbxbp/Makefile index 8acc57a324..8c0bdd8793 100644 --- a/harbour/contrib/hbxbp/Makefile +++ b/harbour/contrib/hbxbp/Makefile @@ -66,6 +66,7 @@ PRG_SOURCES=\ xbphtmlviewer.prg \ xbpfiledialog.prg \ xbpfontdialog.prg \ + xbpbitmap.prg \ PRG_HEADERS=\ diff --git a/harbour/contrib/hbxbp/tests/abs1.png b/harbour/contrib/hbxbp/tests/abs1.png new file mode 100644 index 0000000000..19d06f1b28 Binary files /dev/null and b/harbour/contrib/hbxbp/tests/abs1.png differ diff --git a/harbour/contrib/hbxbp/tests/abs2.png b/harbour/contrib/hbxbp/tests/abs2.png new file mode 100644 index 0000000000..e7915ea790 Binary files /dev/null and b/harbour/contrib/hbxbp/tests/abs2.png differ diff --git a/harbour/contrib/hbxbp/tests/abs3.png b/harbour/contrib/hbxbp/tests/abs3.png new file mode 100644 index 0000000000..ccdeea1425 Binary files /dev/null and b/harbour/contrib/hbxbp/tests/abs3.png differ diff --git a/harbour/contrib/hbxbp/tests/abs4.png b/harbour/contrib/hbxbp/tests/abs4.png new file mode 100644 index 0000000000..f849d4e14e Binary files /dev/null and b/harbour/contrib/hbxbp/tests/abs4.png differ diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index d75ef4b79f..668e608f12 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -56,6 +56,10 @@ #include "inkey.ch" #include "gra.ch" +#ifdef __XPP__ +#pragma library("XppUi2") +#endif + /*----------------------------------------------------------------------*/ #define TAB_1 1 @@ -78,7 +82,7 @@ PROCEDURE BuildADialog() LOCAL oDlg, mp1, mp2, oXbp, nEvent, aSize, aTabs, oDa LOCAL nThread := ThreadID() LOCAL cThread := hb_ntos( nThread ) - LOCAL aPP + LOCAL aPP, oHtm /* Create Application Window */ oDlg := GuiStdDialog( "Harbour - Xbase++ - QT Dialog [ "+ hb_ntos( nThread )+" ]" ) @@ -104,7 +108,7 @@ PROCEDURE BuildADialog() oDa:setColorFG( GraMakeRGBColor( { 255,255,255 } ) ) /* Install menu system */ - Build_MenuBar() + Build_MenuBar( oDlg ) /* Install Statusbar */ Build_StatusBar( oDa ) @@ -116,16 +120,16 @@ PROCEDURE BuildADialog() aTabs := Build_TabPages( oDa ) /* Install checkboxes */ - Build_CheckBox( aTabs[ 3 ] ) + Build_CheckBox( aTabs[ TAB_3 ] ) /* Install 3state checkboxes */ - Build_3State( aTabs[ 3 ] ) + Build_3State( aTabs[ TAB_3 ] ) /* Install Radio Buttons */ - Build_RadioButton( aTabs[ 3 ] ) + Build_RadioButton( aTabs[ TAB_3 ] ) /* Install ListBox */ - Build_ListBox( aTabs[ 5 ] ) + Build_ListBox( aTabs[ TAB_5 ] ) /* Install Push Buttons */ Build_PushButton( oDa ) @@ -140,19 +144,19 @@ PROCEDURE BuildADialog() Build_ScrollBar( aTabs[ 5 ] ) /* Install Spin Buttons */ - Build_SpinButtons( aTabs[ 3 ] ) + Build_SpinButtons( aTabs[ TAB_3 ] ) /* Install Combo Box */ Build_ComboBox( oDa ) /* Install TreeView */ - Build_TreeView( aTabs[ 4 ] ) + Build_TreeView( aTabs[ TAB_4 ] ) /* Build Statics */ Build_Statics( oDA ) /* Build HTML Viewer */ - Build_HTMLViewer( aTabs[ 1 ] ) + oHtm := Build_HTMLViewer( aTabs[ TAB_1 ] ) /* Present the dialog on the screen */ oDlg:Show() @@ -163,6 +167,9 @@ PROCEDURE BuildADialog() IF ( nEvent == xbeP_Close ) .OR. ( nEvent == xbeP_Keyboard .and. mp1 == xbeK_ESC ) hb_outDebug( " WOW " ) EXIT + ELSEIF nEvent == xbeP_Keyboard .and. mp1 == xbeK_F1 + oHtm:setHTML( '

Direct HTML Injection

'+; + 'This HTML content is pushed dynamically with

:setHTML()

.' ) ENDIF oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO @@ -227,7 +234,7 @@ STATIC FUNCTION GuiStdDialog( cTitle ) /*----------------------------------------------------------------------*/ -STATIC FUNCTION Build_MenuBar() +STATIC FUNCTION Build_MenuBar( oDlg ) LOCAL oMenuBar, oSubMenu //oMenuBar := XbpMenuBar():new( oDlg ):create() @@ -276,10 +283,14 @@ STATIC FUNCTION Build_MenuBar() #else oSubMenu:addItem( { "~One More Instance"+ chr( K_TAB )+ "Ctrl+M", {|| BuildADialog() } } ) #endif + #endif + #endif + oMenuBar:addItem( { oSubMenu, NIL } ) - oMenuBar:addItem( { oSubMenu, NIL } ) - #endif - #endif + oSubMenu := XbpMenu():new( oMenuBar ):create() + oSubMenu:title := "~Miscellaneous" + oSubMenu:addItem( { "Convert Images - XbpBitmap()", {|| Build_Bitmap( oDlg ) } } ) + oMenuBar:addItem( { oSubMenu, NIL } ) Return nil @@ -332,16 +343,33 @@ FUNCTION Build_ToolBar( oDA ) /* Harbour does not support resource IDs so giving bitmap files */ #ifdef __HARBOUR__ - oTBar:addItem( "Save", "new.png" ) - oTBar:addItem( "Open", "open.png" ) + oTBar:addItem( "Save" , "new.png" , , , , , "1" ) + oTBar:addItem( "Open" , "open.png", , , , , "2" ) + oTBar:addItem( "Font Dialog", "copy.png", , , , , "3" ) + #else - oTBar:addItem( "Button #1" )//, 100 ) - oTBar:addItem( "Button #2" )//, 101 ) + oTBar:addItem( "Save" )//, 100 ) + oTBar:addItem( "Open" )//, 101 ) + oTBar:addItem( "Font Dialog" ) #endif oTBar:transparentColor := GRA_CLR_INVALID - oTBar:buttonClick := {|oButton| IF( oButton:caption == "Open", Build_FileDialog( oDA,"open" ), ; - Build_FileDialog( oDA,"save" ) ) } + oTBar:buttonClick := {|oButton| ExeToolbar( oButton, oDa ) } + + RETURN nil + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION ExeToolbar( oButton, oDa ) + + DO CASE + CASE oButton:caption == "Save" + Build_FileDialog( oDA,"save" ) + CASE oButton:caption == "Open" + Build_FileDialog( oDA,"open" ) + CASE oButton:caption == "Font Dialog" + Build_FontDialog( oDa ) + ENDCASE RETURN nil @@ -913,21 +941,39 @@ FUNCTION Build_Statics( oWnd ) oBox:setColorBG( GraMakeRGBColor( { 100,0,100 } ) ) #endif + + #if 0 /* Does not work - despite best efforts :-((( */ + oBox := XbpStatic():new( oGrp, , {nC4,nT+(nH+nG)*4}, {nW,nH} ) + oBox:type := XBPSTATIC_TYPE_SYSICON + oBox:caption := XBPSTATIC_SYSICON_ICONINFORMATION + oBox:create() + #endif + + #if 1 + #ifdef __HARBOUR__ /* Differes from Xbase++ by Disk File | Resource Name, ID */ + oBox := XbpStatic():new( oGrp, , {nC4,nT+(nH+nG)*4}, {nW,nH} ) + oBox:type := XBPSTATIC_TYPE_ICON + oBox:caption := "vr.png" + oBox:create() + oBox:setColorBG( GraMakeRGBColor( { 255,255,0 } ) ) + #endif + #endif + #define CRLF chr(13)+chr(10) oLbl := XbpStatic():new( oWnd, , {30,60}, {200,240} ) oLbl:type := XBPSTATIC_TYPE_TEXT oLbl:options := XBPSTATIC_TEXT_CENTER + XBPSTATIC_TEXT_VCENTER + XBPSTATIC_TEXT_WORDBREAK oLbl:caption := "The GroupBox at the right demonstrates many static controls" + CRLF + ; - " " + CRLF +; + " " + CRLF + ; "XBPSTATIC_TYPE_TEXT" + CRLF + ; "XBPSTATIC_TYPE_*LINE" + CRLF + ; "XBPSTATIC_TYPE_*BOX" + CRLF + ; "XBPSTATIC_TYPE_*RECT" + CRLF + ; "XBPSTATIC_TYPE_*FRAME" + CRLF + ; "XBPSTATIC_TYPE_BITMAP" + CRLF + ; - " " + CRLF +; - "BITMAP"+ CRLF +; + " " + CRLF + ; + "BITMAP" + CRLF + ; "though, is not exactly Xbase++ compatible in the sense " +; "that it is not pulled from a resource" + CRLF + ; "( to be addressed later )" @@ -943,15 +989,25 @@ FUNCTION Build_Statics( oWnd ) /*----------------------------------------------------------------------*/ FUNCTION Build_HTMLViewer( oWnd ) - LOCAL oHtm, sz_:= oWnd:currentSize() + LOCAL oFrm, oHtm, sz_:= oWnd:currentSize() - oHtm := XbpHTMLViewer():new( oWnd, , {10,10}, {sz_[1]-25,sz_[2]-30-15} ) + oFrm := XbpStatic():new( oWnd, , {5,5}, {sz_[1]-5-10,sz_[2]-30-7} ) + oFrm:type := XBPSTATIC_TYPE_RECESSEDBOX + oFrm:options := XBPSTATIC_FRAMETHICK + oFrm:create() + #ifdef __HARBOUR__ + //oFrm:setStyleSheet( "border: 2px solid yellow;" ) + #endif + + sz_:= oFrm:currentSize() + // oHtm := XbpHTMLViewer():new( oWnd, , {10,10}, {sz_[1]-25,sz_[2]-30-15} ) + oHtm := XbpHTMLViewer():new( oFrm, , {10,10}, {sz_[1]-10-10,sz_[2]-10-10} ) oHtm:create() oHtm:navigate( "http://www.harbour-project.org" ) oHtm:titleChange := {|e| hb_outDebug( e ) } - oHtm:progressChange := {|nProg,nMax| hb_outDebug( "Downloaded: "+str( nProg*100/nMax,10,0 ) ) } + // oHtm:progressChange := {|nProg,nMax| hb_outDebug( "Downloaded: "+str( nProg*100/nMax,10,0 ) ) } - RETURN nil + RETURN oHtm /*----------------------------------------------------------------------*/ @@ -962,15 +1018,16 @@ FUNCTION Build_FileDialog( oWnd, cMode ) IF cMode == "open" oDlg:title := "Open Index or Database" oDlg:center := .t. - oDlg:fileFilters := { { 'Index Files', '*.ntx' }, { 'Database Files', '*.dbf' } } - oDlg:setColorBG( GraMakeRGBColor( { 170,170,170 } ) ) + oDlg:fileFilters := { { "Index Files", "*.ntx" }, { "Database Files", "*.dbf" } } + //oDlg:setColorBG( GraMakeRGBColor( { 170,170,170 } ) ) aFiles := oDlg:open( "c:\temp", , .t. ) IF !empty( aFiles ) aeval( aFiles, {|e| hb_outDebug( e ) } ) ENDIF ELSE oDlg:title := "Save this Database" - oDlg:fileFilters := { { 'Database Files', '*.dbf' } } + oDlg:fileFilters := { { "Database Files", "*.dbf" } } + oDlg:quit := {|| MsgBox( "Quitting the Dialog" ), 1 } cFile := oDlg:saveAs( "c:\temp\myfile.dbf" ) IF !empty( cFile ) hb_outDebug( cFile ) @@ -981,4 +1038,74 @@ FUNCTION Build_FileDialog( oWnd, cMode ) /*----------------------------------------------------------------------*/ +FUNCTION Build_FontDialog( oWnd ) + LOCAL oDlg + + oDlg := XbpFontDialog():new( oWnd, , , , { 20,20 } ) + oDlg:create() + oDlg:display( 0 ) + + RETURN nil + +/*----------------------------------------------------------------------*/ + +FUNCTION Build_Bitmap( oWnd ) + LOCAL oBmp, aFltr, cFile, cExt, nFrmt, oDlg + LOCAL cExtns := { "PNG","GIF","JPG","JPEG","BMP","TIFF" } + LOCAL nFrmts := { XBPBMP_FORMAT_PNG, XBPBMP_FORMAT_GIF, XBPBMP_FORMAT_JPG, ; + XBPBMP_FORMAT_JPG, XBPBMP_FORMAT_WIN3X } + + aFltr := {} + aadd( aFltr, { "Windows Bitmap ", "*.BMP" } ) + aadd( aFltr, { "Graphic Interchange Format ", "*.GIF" } ) + aadd( aFltr, { "Joint Photographic Experts ", "*.JPG; *.JPEG" } ) + aadd( aFltr, { "Portable Network Graphics ", "*.PNG" } ) + aadd( aFltr, { "Portable Pixmap ", "*.PPM" } ) + aadd( aFltr, { "Tagged Image File Format ", "*.TIFF" } ) + aadd( aFltr, { "X11 Bitmap ", "*.XBM" } ) + aadd( aFltr, { "X11 Pixmap ", "*.XPM" } ) + aeval( aFltr, {|e_,i| aFltr[ i,1 ] := trim( e_[ 1 ] ) } ) + + oDlg := XbpFileDialog():new( oWnd, , {10,10} ) + oDlg:title := "Select an image to be converted" + oDlg:fileFilters := aFltr + oDlg:create() + + cFile := oDlg:open( "c:\", , .f. ) + + IF !empty( cFile ) + oBmp := XbpBitmap():new():create() + IF oBmp:loadFile( cFile ) + MsgBox( "x = "+hb_ntos( oBmp:xSize ) +" y = "+hb_ntos( oBmp:ySize )+" b = "+hb_ntos( oBmp:bits ) ) + + aFltr := {} + aadd( aFltr, { "Windows Bitmap ", "*.BMP" } ) + aadd( aFltr, { "Joint Photographic Experts ", "*.JPG; *.JPEG" } ) + aadd( aFltr, { "Portable Network Graphics ", "*.PNG" } ) + aadd( aFltr, { "Portable Pixmap ", "*.PPM" } ) + aadd( aFltr, { "Tagged Image File Format ", "*.TIFF" } ) + aadd( aFltr, { "X11 Bitmap ", "*.XBM" } ) + aadd( aFltr, { "X11 Pixmap ", "*.XPM" } ) + + oDlg:title := "Specify how to save it !" + oDlg:fileFilters := aFltr + cFile := oDlg:saveAs() + + IF !empty( cFile ) + cExt := upper( substr( cFile, at( ".", cFile )+1 ) ) + IF !empty( cExt ) + nFrmt := nFrmts[ ascan( cExtns, cExt ) ] + + oBmp:saveFile( cFile, nFrmt ) + ENDIF + ENDIF + ENDIF + ENDIF + + RETURN nil + +/*----------------------------------------------------------------------*/ + + + diff --git a/harbour/contrib/hbxbp/tests/vr.png b/harbour/contrib/hbxbp/tests/vr.png new file mode 100644 index 0000000000..e67cc3183e Binary files /dev/null and b/harbour/contrib/hbxbp/tests/vr.png differ diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index 02e8a8742b..07b9f135bc 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -263,6 +263,23 @@ #define XBPSTATIC_SYSICON_PENFIRST 23 #define XBPSTATIC_SYSICON_PENLAST 39 + +#define XBP_REJECT 0 +#define XBP_ALLOW 1 + +#define XBPBMP_FORMAT_WIN2X 256 +#define XBPBMP_FORMAT_WIN3X 512 +#define XBPBMP_FORMAT_OS21X XBPBMP_FORMAT_WIN2X +#define XBPBMP_FORMAT_OS22X 1024 +#define XBPBMP_FORMAT_GIF 4096 +#define XBPBMP_FORMAT_JPG 8192 +#define XBPBMP_FORMAT_PNG 16384 + +#define XBPBMP_FORMAT_DEFAULT XBPBMP_FORMAT_WIN3X + +#define XBPBMP_DEF_COMPRESSION -1 + + /*----------------------------------------------------------------------*/ #define _XBP_CH #endif diff --git a/harbour/contrib/hbxbp/xbpbitmap.prg b/harbour/contrib/hbxbp/xbpbitmap.prg new file mode 100644 index 0000000000..70720760cf --- /dev/null +++ b/harbour/contrib/hbxbp/xbpbitmap.prg @@ -0,0 +1,238 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Xbp*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++ xbpBitmap compatible Class + * + * Pritpal Bedi + * 04Jul2009 + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "hbclass.ch" +#include "common.ch" + +#include "xbp.ch" +#include "gra.ch" +#include "appevent.ch" +#include "hbqt.ch" + +/*----------------------------------------------------------------------*/ + +CLASS XbpBitmap + + ACCESS bits INLINE ::oWidget:depth() + DATA bufferOffset INIT 0 + DATA planes INIT 0 + DATA transparentColor INIT GRA_CLR_INVALID + ACCESS xSize INLINE ::oWidget:width() + ACCESS ySize INLINE ::oWidget:height() + + + DATA oWidget + DATA oPS + DATA cImageFileName + + METHOD new() INLINE Self + METHOD create() + METHOD configure() VIRTUAL + METHOD destroy() VIRTUAL + + METHOD draw() + METHOD getColorTable( nNumColors ) + METHOD getDefaultBGColor() + METHOD load() + METHOD loadFile() + METHOD make() + METHOD presSpace( oPS ) + METHOD saveFile() + METHOD setBuffer() + METHOD getIPicture() + METHOD setIPicture( oPicture ) + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:create( oPS ) + + DEFAULT oPS TO ::oPS + ::oPS := oPS + + ::oWidget := QImage():new() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:draw() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:getColorTable( nNumColors ) + + HB_SYMBOL_UNUSED( nNumColors ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:getDefaultBGColor() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:load( cDLLName, cID ) + LOCAL lSuccess := .f. + + HB_SYMBOL_UNUSED( cDLLName ) + HB_SYMBOL_UNUSED( cID ) + + RETURN lSuccess + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:loadFile( cImageFileName ) + LOCAL lSuccess + + HB_SYMBOL_UNUSED( cImageFileName ) + // BMP, GIF, JPEG, PNG + + ::cImageFileName := cImageFileName + + lSuccess := ::oWidget:load( cImageFileName, 0, Qt_AutoColor ) + + RETURN lSuccess + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:make( nXsize, nYsize, nPlanes, nBits ) + + HB_SYMBOL_UNUSED( nXsize ) + HB_SYMBOL_UNUSED( nYsize ) + HB_SYMBOL_UNUSED( nPlanes ) + HB_SYMBOL_UNUSED( nBits ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:presSpace( oPS ) + LOCAL oPresSpace := NIL + + HB_SYMBOL_UNUSED( oPS ) + + RETURN oPresSpace + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:saveFile( cImageFileName, nFormat, nCompression ) + LOCAL lSuccess := .f. + + DEFAULT nCompression TO XBPBMP_DEF_COMPRESSION + + DO CASE + + CASE nFormat == XBPBMP_FORMAT_GIF + lSuccess := ::oWidget:save( cImageFileName, "GIF", nCompression ) /* QT Does not support writing to GIF */ + CASE nFormat == XBPBMP_FORMAT_JPG + lSuccess := ::oWidget:save( cImageFileName, "JPG", nCompression ) + CASE nFormat == XBPBMP_FORMAT_PNG + lSuccess := ::oWidget:save( cImageFileName, "PNG", nCompression ) + CASE nFormat == XBPBMP_FORMAT_WIN2X + lSuccess := ::oWidget:save( cImageFileName, "BMP", nCompression ) + CASE nFormat == XBPBMP_FORMAT_WIN3X + lSuccess := ::oWidget:save( cImageFileName, "BMP", nCompression ) + OTHERWISE + lSuccess := ::oWidget:save( cImageFileName ) + ENDCASE + + RETURN lSuccess + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:setBuffer( cBuffer, nFormat, nCompression ) + + HB_SYMBOL_UNUSED( cBuffer ) + HB_SYMBOL_UNUSED( nFormat ) + HB_SYMBOL_UNUSED( nCompression ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:getIPicture() + LOCAL oPicture := NIL + + RETURN oPicture + +/*----------------------------------------------------------------------*/ + +METHOD XbpBitmap:setIPicture( oPicture ) + LOCAL lSuccess := .f. + + HB_SYMBOL_UNUSED( oPicture ) + + RETURN lSuccess + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbxbp/xbpdialog.prg b/harbour/contrib/hbxbp/xbpdialog.prg index 407fadaade..1992ee5123 100644 --- a/harbour/contrib/hbxbp/xbpdialog.prg +++ b/harbour/contrib/hbxbp/xbpdialog.prg @@ -298,7 +298,7 @@ METHOD XbpDrawingArea:create( oParent, oOwner, aPos, aSize, aPresParams, lVisibl ::oWidget:setMouseTracking( .T. ) ::oWidget:setFocusPolicy( 2 ) - //::setQtProperty() /* Using it for one-to-one style sheet management */ + ::setQtProperty() /* Using it for one-to-one style sheet management */ ::oParent:addChild( SELF ) diff --git a/harbour/contrib/hbxbp/xbpfiledialog.prg b/harbour/contrib/hbxbp/xbpfiledialog.prg index 95ac24b19f..197baffb9d 100644 --- a/harbour/contrib/hbxbp/xbpfiledialog.prg +++ b/harbour/contrib/hbxbp/xbpfiledialog.prg @@ -131,10 +131,12 @@ CLASS XbpFileDialog INHERIT XbpWindow METHOD create() METHOD configure() VIRTUAL METHOD destroy() + METHOD exeBlock() METHOD open() METHOD saveAs() METHOD extractFileNames() + METHOD setStyle() ENDCLASS @@ -153,11 +155,46 @@ METHOD XbpFileDialog:create( oParent, oOwner, aPos ) ::xbpWindow:create( oParent, oOwner, aPos ) ::oWidget := QFileDialog():new( ::pParent ) + //::oWidget:setStyle( AppDesktop():style() ) + ::setStyle() + //::setColorBG( GraMakeRGBColor( { 255,255,255 } ) ) + //::setColorFG( GraMakeRGBColor( { 0,0,0 } ) ) + ::connect( ::pWidget, "accepted()" , {|o,p| ::exeBlock( 1, p, o ) } ) + ::connect( ::pWidget, "finished(int)" , {|o,p| ::exeBlock( 2, p, o ) } ) + ::connect( ::pWidget, "rejected()" , {|o,p| ::exeBlock( 3, p, o ) } ) + ::connect( ::pWidget, "currentChanged(QString)" , {|o,p| ::exeBlock( 4, p, o ) } ) + ::connect( ::pWidget, "directoryEntered(QString)" , {|o,p| ::exeBlock( 5, p, o ) } ) + ::connect( ::pWidget, "fileSelected(QString)" , {|o,p| ::exeBlock( 6, p, o ) } ) + ::connect( ::pWidget, "filesSelected(QStringList)", {|o,p| ::exeBlock( 7, p, o ) } ) + ::connect( ::pWidget, "filterSelected(QString)" , {|o,p| ::exeBlock( 8, p, o ) } ) + + ::oParent:addChild( Self ) RETURN Self /*----------------------------------------------------------------------*/ +METHOD XbpFileDialog:exeBlock( nEvent, p1 ) + LOCAL nRet := XBP_ALLOW + + HB_SYMBOL_UNUSED( p1 ) + + DO CASE + CASE nEvent == 3 + IF hb_isBlock( ::sl_quit ) + nRet := eval( ::sl_quit, 0, 0, Self ) + ENDIF + IF nRet == XBP_REJECT + ::oWidget:reject() + ELSE + ::oWidget:accept() + ENDIF + ENDCASE + + RETURN nRet + +/*----------------------------------------------------------------------*/ + METHOD XbpFileDialog:destroy() ::xbpWindow:destroy() @@ -223,6 +260,7 @@ METHOD XbpFileDialog:open( cDefaultFile, lCenter, lAllowMultiple, lCreateNewFile IF !( lCenter ) ::setPos() ENDIF + nResult := ::oWidget:exec() RETURN IF( nResult == QDialog_Accepted, ::extractFileNames( lAllowMultiple ), NIL ) @@ -254,6 +292,7 @@ METHOD XbpFileDialog:saveAs( cDefaultFile, lFileList, lCenter ) // oStyle := QApplication():style() // ::oWidget:setStyle( oStyle ) + ::setStyle() IF !( lCenter ) ::setPos() @@ -283,4 +322,22 @@ METHOD XbpFileDialog:extractFileNames( lAllowMultiple ) /*----------------------------------------------------------------------*/ +METHOD XbpFileDialog:setStyle() + LOCAL s := "", txt_:={} + + aadd( txt_, 'QDialog { background-color: rgb(198,198,198); }' ) + aadd( txt_, 'QDialog { color: rgb(0,0,0); }' ) + aadd( txt_, 'QLineEdit { background-color: rgb(255,255,255); }' ) + aadd( txt_, 'QAbstractScrollArea { background-color: rgb(240,240,240); }' ) + aadd( txt_, 'QLabel { background-color: rgb(198,198,198); }' ) + + aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } ) + + ::oWidget:setStyleSheet( "" ) + //::oWidget:setStyleSheet( s ) + //::setColorBG( GraMakeRGBColor( { 100,100,100 } ) ) + + RETURN self + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpfontdialog.prg b/harbour/contrib/hbxbp/xbpfontdialog.prg index 44c9379f73..d500d6d779 100644 --- a/harbour/contrib/hbxbp/xbpfontdialog.prg +++ b/harbour/contrib/hbxbp/xbpfontdialog.prg @@ -102,8 +102,8 @@ CLASS XbpFontDialog INHERIT XbpWindow DATA outLine INIT .T. - DATA previewBGClr INIT RGB( 255,255,255 ) - DATA previewFGClr INIT RGB( 0,0,0 ) + DATA previewBGClr INIT GraMakeRGBColor( {255,255,255} ) + DATA previewFGClr INIT GraMakeRGBColor( {0,0,0} ) DATA previewString INIT " " DATA printerPS INIT NIL DATA screenPS INIT NIL @@ -120,6 +120,7 @@ CLASS XbpFontDialog INHERIT XbpWindow METHOD create() METHOD destroy() METHOD display( nMode ) + METHOD exeBlock() DATA sl_activateApply ACCESS activateApply INLINE ::sl_activateApply @@ -193,15 +194,60 @@ METHOD XbpFontDialog:create( oParent, oOwner, oScreenPS, oPrinterPS, aPos ) ::xbpWindow:create( oParent, oOwner ) - ::oWidget := QFontDialog():new( ::pParent ) - - ::oOptions := QFontOptions() - ::oOptions:pPtr := ::oWidget:options() + ::oWidget := QFontDialog():new() + ::connect( ::pwidget, "accepted()" , {|o,p| ::exeBlock( 1, p, o ) } ) + ::connect( ::pwidget, "finished(int)" , {|o,p| ::exeBlock( 2, p, o ) } ) + ::connect( ::pwidget, "rejected()" , {|o,p| ::exeBlock( 3, p, o ) } ) + ::connect( ::pwidget, "currentFontChanged(QFont)", {|o,p| ::exeBlock( 4, p, o ) } ) + ::connect( ::pwidget, "fontSelected(QFont)" , {|o,p| ::exeBlock( 5, p, o ) } ) + IF ::aPos[ 1 ] + ::aPos[ 2 ] != 0 + ::setPos() + ENDIF + ::oParent:addChild( Self ) RETURN Self /*----------------------------------------------------------------------*/ + +METHOD XbpFontDialog:exeBlock( nEvent, p1 ) + LOCAL nRet := XBP_ALLOW + + HB_SYMBOL_UNUSED( p1 ) + + DO CASE + CASE nEvent == 3 + IF hb_isBlock( ::sl_quit ) + nRet := eval( ::sl_quit, 0, 0, Self ) + ENDIF + IF nRet == XBP_REJECT + ::oWidget:reject() + ELSE + ::oWidget:accept() + ENDIF + ENDCASE + + RETURN nRet + +/*----------------------------------------------------------------------*/ + +METHOD XbpFontDialog:display( nMode ) + LOCAL aInfo := nMode + LOCAL nResult + + //::setPosAndSize() + + IF nMode == 0 // Parent and modal + nResult := ::oWidget:exec() + nMode := nResult + ELSE // Non-modal + ::oWidget:show() + ENDIF + + RETURN ::GetXbpFont( aInfo ) + +/*----------------------------------------------------------------------*/ + #if 0 METHOD XbpFontDialog:wndProc( hWnd, nMessage, nwParam, nlParam ) LOCAL aRect, nL, nH @@ -282,30 +328,6 @@ METHOD XbpFontDialog:wndProc( hWnd, nMessage, nwParam, nlParam ) #endif /*----------------------------------------------------------------------*/ -METHOD XbpFontDialog:display( nMode ) - LOCAL aInfo := nMode - - #if 0 - - IF nMode == 0 - hWnd := ::oParent:hWnd - ELSE - hWnd := Win_GetDesktopWindow() - ENDIF - - ::ok := .f. - aInfo := Wvg_ChooseFont( hWnd, ::nWndProc, ::familyName, ; - ::nominalPointSize, ::viewScreenFonts, ::viewPrinterFonts ) - - IF !( ::ok ) - RETURN NIL - ENDIF - - RETURN ::GetXbpFont( aInfo ) - #endif - RETURN ::GetXbpFont( aInfo ) -/*----------------------------------------------------------------------*/ - METHOD XbpFontDialog:destroy() ::xbpWindow:destroy() @@ -450,7 +472,7 @@ METHOD XbpFont:list() /*----------------------------------------------------------------------*/ METHOD XbpFont:createFont() - LOCAL aFont + LOCAL aFont := {} IF ::hFont <> NIL // Win_DeleteObject( ::hFont ) @@ -458,7 +480,7 @@ METHOD XbpFont:createFont() ENDIF IF ::oPS <> NIL - ::height := xbp_PointSizeToHeight( ::oPS:hdc, ::nominalPointSize ) + //::height := xbp_PointSizeToHeight( ::oPS:hdc, ::nominalPointSize ) ENDIF ::aFontInfo := array( 15 ) @@ -478,7 +500,7 @@ METHOD XbpFont:createFont() ::aFontInfo[ 13 ] := 0 //DEFAULT_QUALITY ::aFontInfo[ 14 ] := NIL - aFont := Xbp_FontCreate( ::aFontInfo ) + //aFont := Xbp_FontCreate( ::aFontInfo ) IF empty( aFont[ 1 ] ) RETURN nil diff --git a/harbour/contrib/hbxbp/xbphtmlviewer.prg b/harbour/contrib/hbxbp/xbphtmlviewer.prg index 0e29942c35..036aec32b9 100644 --- a/harbour/contrib/hbxbp/xbphtmlviewer.prg +++ b/harbour/contrib/hbxbp/xbphtmlviewer.prg @@ -157,11 +157,6 @@ METHOD XbpHTMLViewer:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ::oWidget := QWebView():new( ::pParent ) - ::setPosAndSize() - IF ::visible - ::show() - ENDIF - ::Connect( QT_PTROF( ::oWidget ), "iconChanged()" , {|o,p| ::exeBlock( 1,p,o ) } ) ::Connect( QT_PTROF( ::oWidget ), "linkClicked(QUrl)" , {|o,p| ::exeBlock( 2,p,o ) } ) ::Connect( QT_PTROF( ::oWidget ), "loadFinished(bool)" , {|o,p| ::exeBlock( 3,p,o ) } ) @@ -175,13 +170,17 @@ METHOD XbpHTMLViewer:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ::mapEvent( evNavigateComplete, {| cURL | ::xNavigateComplete( cURL ) } ) #endif + ::setPosAndSize() + IF ::visible + ::show() + ENDIF + ::oParent:addChild( SELF ) RETURN Self /*----------------------------------------------------------------------*/ METHOD XbpHTMLViewer:exeBlock( nEvent, p1 ) -//hb_outDebug( str( nEvent ) ) DO CASE CASE nEvent == 1 IF hb_isBlock( ::sl_beforeNavigate ) @@ -193,7 +192,6 @@ METHOD XbpHTMLViewer:exeBlock( nEvent, p1 ) eval( ::sl_documentComplete, /*cURI*/, p1, Self ) ENDIF CASE nEvent == 4 -//hb_outDebug( str( p1 ) ) IF hb_isBlock( ::sl_progressChange ) eval( ::sl_progressChange, p1, 100, Self ) ENDIF @@ -204,7 +202,7 @@ METHOD XbpHTMLViewer:exeBlock( nEvent, p1 ) ENDIF CASE nEvent == 7 CASE nEvent == 8 - ::cSelectedText := ::oWidget:SelectedText() + ::cSelectedText := ::oWidget:selectedText() hb_outDebug( ::cSelectedText ) CASE nEvent == 9 IF hb_isBlock( ::sl_statusTextChange ) @@ -227,4 +225,43 @@ METHOD XbpHTMLViewer:navigate( cURL ) RETURN .t. /*----------------------------------------------------------------------*/ +#if 0 /* Some reference material */ + +// QWebView +"iconChanged()" +"linkClicked(QUrl)" +"loadFinished(bool)" +"loadProgress(int)" +"loadStarted()" +"titleChanged(QString)" +"urlChanged(QUrl)" +"selectionChanged()" +"statusBarMessage(QString)" + +// QWebPage +"contentsChanged()" +"databaseQuotaExceeded(QWebFrame,QString)" +"downloadRequested(QNetworkRequest)" +"frameCreated(QWebFrame)" +"geometryChangeRequested(QRect)" +"linkClicked(QUrl)" +"linkHovered(QString,QString,QString)" +"loadFinished(bool)" +"loadProgress(int)" +"loadStarted()" +"menuBarVisibilityChangeRequested(bool)" +"microFocusChanged()" +"printRequested(QWebFrame)" +"repaintRequested(QRect)" +"restoreFrameStateRequested(QWebFrame)" +"saveFrameStateRequested(QWebFrame,QWebHistoryItem)" +"scrollRequested(int,int,QRect)" +"statusBarMessage(QString)" +"statusBarVisibilityChangeRequested(bool)" +"toolBarVisibilityChangeRequested(bool)" +"unsupportedContent(QNetworkReply)" +"windowCloseRequested()" + +#endif +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpstatic.prg b/harbour/contrib/hbxbp/xbpstatic.prg index 57c059f284..e5c9b0c873 100644 --- a/harbour/contrib/hbxbp/xbpstatic.prg +++ b/harbour/contrib/hbxbp/xbpstatic.prg @@ -221,24 +221,25 @@ METHOD XbpStatic:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ENDIF CASE ::type == XBPSTATIC_TYPE_ICON - ::oWidget := QFrame():new( ::pParent ) + ::oWidget := QLabel():new( ::pParent ) CASE ::type == XBPSTATIC_TYPE_SYSICON - ::oWidget := QFrame():new( ::pParent ) + ::oWidget := QLabel():new( ::pParent ) CASE ::type == XBPSTATIC_TYPE_BITMAP ::oWidget := QFrame():new( ::pParent ) + OTHERWISE + ::oWidget := QFrame():new( ::pParent ) + ENDCASE + ::setCaption( ::caption ) ::setPosAndSize() IF ::visible ::show() ENDIF - - ::setCaption( ::caption ) - ::oParent:addChild( SELF ) RETURN Self @@ -271,6 +272,7 @@ METHOD XbpStatic:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible /*----------------------------------------------------------------------*/ METHOD XbpStatic:setCaption( xCaption, cDll ) + LOCAL oStyle, pPixmap, oIcon, oSize//, oPixmap HB_SYMBOL_UNUSED( cDll ) @@ -291,6 +293,35 @@ METHOD XbpStatic:setCaption( xCaption, cDll ) ELSE ::oWidget:setStyleSheet( 'background: url('+ ::caption +'); repeat-xy;' ) ENDIF + + CASE ::type == XBPSTATIC_TYPE_ICON + ::oWidget:setPixmap( QPixmap():new( ::caption ):scaled( ::aSize[ 1 ], ::aSize[ 2 ] ) ) + + CASE ::type == XBPSTATIC_TYPE_SYSICON + oIcon := QIcon() + oStyle := QStyle() + oStyle:pPtr := QApplication():style() + + DO CASE + CASE ::caption == XBPSTATIC_SYSICON_ICONINFORMATION + oIcon:pPtr := oStyle:standardIcon( QStyle_SP_MessageBoxInformation, 0, 0 ) +hb_outDebug( "2 "+ valtype( oIcon:pPtr ) ) + //pPixmap := oIcon:pixmap( ::aSize[ 1 ], ::aSize[ 2 ] ) + oSize := QSize():new() + oSize:setWidth( 16 ) + oSize:setHeight( 16 ) + pPixmap := oIcon:pixmap( QT_PTROF( oSize ), QIcon_Normal, QIcon_On ) +hb_outDebug( "5" ) + CASE ::caption == XBPSTATIC_SYSICON_ICONQUESTION + pPixmap := oStyle:standardPixmap( QStyle_SP_MessageBoxQuestion ) + CASE ::caption == XBPSTATIC_SYSICON_ICONERROR + pPixmap := oStyle:standardPixmap( QStyle_SP_MessageBoxCritical ) + CASE ::caption == XBPSTATIC_SYSICON_ICONWARNING + pPixmap := oStyle:standardPixmap( QStyle_SP_MessageBoxWarning ) + ENDCASE + + ::oWidget:setPixmap( pPixmap ) +hb_outDebug( "6" ) ENDCASE ENDIF diff --git a/harbour/contrib/hbxbp/xbpstyle.prg b/harbour/contrib/hbxbp/xbpstyle.prg index 50543aa120..7d79cb93b7 100644 --- a/harbour/contrib/hbxbp/xbpstyle.prg +++ b/harbour/contrib/hbxbp/xbpstyle.prg @@ -132,21 +132,22 @@ METHOD XbpStyle:create() /*----------------------------------------------------------------------*/ -STATIC FUNCTION xbpToQT( cXbpPart ) +FUNCTION Xbp_XbpToQTName( cXbpPart ) LOCAL aQt := {} LOCAL n, cQTWidget cXbpPart := upper( cXbpPart ) - aadd( aQt, { 'XBPDIALOG' , 'QWidget' } ) - aadd( aQt, { 'XBPPUSHBUTTON' , ' ' } ) - aadd( aQt, { 'XBPCHECKBOX' , ' ' } ) - aadd( aQt, { 'XBPTREEVIEW' , ' ' } ) + aadd( aQt, { 'XBPDIALOG' , 'QMainWindow' } ) + aadd( aQt, { 'XBPDRAWINGAREA' , 'QWidget' } ) + aadd( aQt, { 'XBPPUSHBUTTON' , 'QPushButton' } ) + aadd( aQt, { 'XBPCHECKBOX' , 'QCheckBox' } ) + aadd( aQt, { 'XBPTREEVIEW' , 'QTreeWidget' } ) aadd( aQt, { 'XBPTREEVIEWITEM', ' ' } ) - aadd( aQt, { 'XBPRADIOBUTTON' , ' ' } ) - aadd( aQt, { 'XBPSCROLLBAR' , ' ' } ) - aadd( aQt, { 'XBPSTATUSBAR' , ' ' } ) - aadd( aQt, { 'XBPTABPAGE' , ' ' } ) + aadd( aQt, { 'XBPRADIOBUTTON' , 'QRadioButton'} ) + aadd( aQt, { 'XBPSCROLLBAR' , 'QScrollBar' } ) + aadd( aQt, { 'XBPSTATUSBAR' , 'QStatusBar' } ) + aadd( aQt, { 'XBPTABPAGE' , 'QTabWidget' } ) aadd( aQt, { 'XBPSTATIC' , ' ' } ) IF ( n := ascan( aQt, {|e_| e_[ 1 ] == cXbpPart } ) ) > 0 diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index b8122a8334..1c8c2d4e9a 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -82,7 +82,7 @@ CLASS XbpWindow INHERIT XbpPartHandler /* Called in the initializer - Unique in the application */ METHOD getProperty() INLINE "PROP" + hb_ntos( ++::nProperty ) /* After object is physically created, set unique property to 1 */ - METHOD setQtProperty() INLINE ::oWidget:setProperty( ::qtProperty, 1 ) + METHOD setQtProperty() DATA cargo INIT "" DATA styleSheet INIT "" @@ -353,6 +353,19 @@ METHOD XbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ +METHOD XbpWindow:setQtProperty( cProperty ) + LOCAL oVariant := QVariant():new() + + DEFAULT cProperty TO "YES" + + oVariant:setValue( cProperty ) + + ::oWidget:setProperty( ::qtProperty, QT_PTROF( oVariant ) ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD XbpWindow:connect( pWidget, cSignal, bBlock ) LOCAL lSuccess @@ -795,13 +808,20 @@ STATIC FUNCTION Xbp_RgbToName( nRgb ) /*----------------------------------------------------------------------*/ METHOD XbpWindow:setColorBG( nRGB ) - LOCAL oldRGB, cName + LOCAL oldRGB, cName, cQTName - cName := Xbp_RgbToName( nRGB ) + cName := Xbp_RgbToName( nRGB ) IF hb_isNumeric( nRGB ) - oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_BGCLR, nRGB ) - ::setStyleSheet( "background-color: "+ cName +";" ) + oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_BGCLR, nRGB ) + cQTName := Xbp_XbpToQTName( __ObjGetClsName( self ) ) + + IF empty( cQTName ) + ::setStyleSheet( "background-color: "+ cName +";" ) + ELSE + ::setStyleSheet( "background-color: "+ cName +";" ) +// ::setStyleSheet( cQTName +'['+ ::qtProperty +'="YES"] '+ "{ background-color: "+ cName +" ; }" ) + ENDIF ELSE oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_BGCLR ) ENDIF