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 <Miscellaneous> main menu prompt then click on 
      <Convert Images>. 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.
This commit is contained in:
Pritpal Bedi
2009-07-05 03:37:07 +00:00
parent 4136852121
commit 8c1b7ab5ae
17 changed files with 675 additions and 90 deletions

View File

@@ -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 <Miscellaneous> main menu prompt then click on
<Convert Images>. 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

View File

@@ -66,6 +66,7 @@ PRG_SOURCES=\
xbphtmlviewer.prg \
xbpfiledialog.prg \
xbpfontdialog.prg \
xbpbitmap.prg \
PRG_HEADERS=\

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

View File

@@ -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( '<html><h1>Direct HTML Injection</h1><p><font color="#ab00ff" size="16">'+;
'This HTML content</font> is pushed dynamically with<br><br>:setHTML()</br></br>.</html>' )
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
/*----------------------------------------------------------------------*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

View File

@@ -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

View File

@@ -0,0 +1,238 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Source file for the Xbp*Classes
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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 <pritpal@vouchcac.com>
* 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
/*----------------------------------------------------------------------*/

View File

@@ -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 )

View File

@@ -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
/*----------------------------------------------------------------------*/

View File

@@ -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

View File

@@ -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
/*----------------------------------------------------------------------*/

View File

@@ -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

View File

@@ -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

View File

@@ -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