LISTBOX HEADERS special characters

LISTBOX HEADERS special characters

Postby MarcoBoschi » Tue Oct 17, 2006 6:35 am

To put in evidence if order type is descending or not I need to write in headers of my listboxs a character like down arrow or up arrow (in outlook there are triangles )
I use "MS Sans Serif" font and the only two characters approximately seem an arrow are "<" and ">" but they are horizontal. I need vertical
character.
Any ideas?
Thanks
Marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby Gale FORd » Tue Oct 17, 2006 10:39 pm

How about \/ and /\ which are the left and right slashes
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby MarcoBoschi » Wed Oct 18, 2006 6:46 am

You are in right!
Yesterday I analized my keyboard and thinked up the same idea

In my opinion all developer would appreciate this feature of twbrowse class:

two (up&down) 3d triangle in every index column header.
Like outlook and all other popular software.
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby James Bott » Wed Oct 18, 2006 7:04 pm

Marco,

You can also use a bitmap graphic that contains both the symbol and the text.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Wed Oct 18, 2006 9:27 pm

And where would you put those bitmaps? Please note that Marco needs to put them on the TWBrowse headers.

Anyway, I solved the problem using DIALOG's ON PAINT clause.

If Marco doesn't mind I can put the sample here. Marco?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Oct 19, 2006 12:04 am

Enrico,

You can use bitmaps as headers just like you can use them as data.

hBMP1:=loadbitmap( getresources(),"cust")

@ 0,0 listbox...headers hBMP1, "Address"...

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Thu Oct 19, 2006 7:06 am

Wow! I absolutely wasn't aware of that feature!

Thank you!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Thu Oct 19, 2006 7:12 am

Anyway, my solution can still be useful as it doesn't require to put the text inside the bitmap (text in bitmap will not get the font of the browse).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Biel EA6DD » Thu Oct 19, 2006 10:13 am

Anyway, I solved the problem using DIALOG's ON PAINT clause.

If Marco doesn't mind I can put the sample here. Marco?

Hi Enrico, will be nice to see your solution.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby Enrico Maria Giordano » Fri Oct 20, 2006 8:43 am

Here it is:

Code: Select all  Expand view
#include "Fivewin.ch"


#define MO_NONE 0
#define MO_ASC  1
#define MO_DESC 2


FUNCTION MAIN()

    LOCAL oDlg, oBrw, oFnt

    LOCAL hBmp1 := READBITMAP( 0, "\fwharbour\bitmaps\checkon.bmp" )
    LOCAL hBmp2 := READBITMAP( 0, "\fwharbour\bitmaps\checkoff.bmp" )

    LOCAL aOrd := { MO_ASC, MO_DESC, MO_NONE, MO_NONE }

    OVERRIDE METHOD SetPos CLASS TScrollbar WITH MySetPos

    USE TEST

    DEFINE DIALOG oDlg SIZE 400, 300

    DEFINE FONT oFnt NAME "Arial" SIZE 0, -12

    @ 0, 0 LISTBOX oBrw FIELDS TEST -> last,;
                               TEST -> first,;
                               IF( TEST -> last = "S", hBmp1, hBmp2 ),;
                               "";
           HEADER "LAST", "FIRST", " S", hBmp1;
           SIZES 100, 100, 16, 0;
           FONT oFnt

    oBrw:lCellStyle = .T.

    oBrw:bLClicked = { | nRow, nCol | If( oBrw:nAtCol( nCol ) = 3, Cambia( oDlg, oBrw, nRow ), ) }

    oBrw:bLButtonUp = { || oDlg:Refresh( .F. ) }

    oDlg:bStart = { || oBrw:oHScroll:bGoUp := { || oDlg:Refresh( .F. ) },;
                       oBrw:oHScroll:bGoDown := { || oDlg:Refresh( .F. ) },;
                       oBrw:bChange := { || oDlg:Refresh( .F. ) } }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             ON PAINT MARCAORDINE( oDlg, hDC, oBrw, aOrd );
             CENTER

    CLOSE

    DELETEOBJECT( hBmp1 )
    DELETEOBJECT( hBmp2 )

    RELEASE FONT oFnt

    RETURN NIL


STATIC FUNCTION CAMBIA( oDlg, oBrw, nRow )

    IF NWROW( oBrw:hWnd, oBrw:hDC, nRow, IF( oBrw:oFont != nil, oBrw:oFont:hFont, 0 ) ) = 0
        RETURN NIL
    ENDIF

    ? "Qui cambi il valore che determina la spunta"

    oBrw:Refresh( .F. )

    oDlg:Refresh( .F. )

    RETURN NIL


#define SM_CYHSCROLL 3


STATIC FUNCTION MARCAORDINE( oDlg, hDC, oBrw, aOrd )

    LOCAL aValues   := oBrw:aHeaders
    LOCAL aColSizes := oBrw:GetColSizes()

    LOCAL nWidth := WNDWIDTH( oBrw:hWnd ) - IF( oBrw:oVScroll != nil .AND. EVAL( oBrw:bLogicLen ) > 1, GETSYSMETRICS( SM_CYHSCROLL ) + 3, 0 )

    LOCAL nColStart := -1

    LOCAL nTop, nLeft, nRight

    LOCAL hGPen, hWPen

    LOCAL i

    SYSREFRESH()

    hGPen = CREATEPEN( 0, 1, CLR_GRAY )
    hWPen = CREATEPEN( 0, 1, CLR_WHITE )

    nTop = oBrw:nTop + 6

    FOR i = oBrw:nColPos TO LEN( aValues )
        nLeft  = nColStart + 1
        nRight = MIN( nColStart := ( nLeft + aColSizes[ i ] - 1 ), nWidth )

        IF nLeft > nWidth
            EXIT
        ENDIF

        IF i == LEN( aValues )
           nRight = nWidth
        ENDIF

        nRight -= 12

        IF aOrd[ i ] = MO_ASC
            MOVETO( hDC, nRight, nTop )

            LINETO( hDC, nRight + 6, nTop, hGPen )
            LINETO( hDC, nRight + 3, nTop + 6, hWPen )
            LINETO( hDC, nRight, nTop, hGPen )
        ENDIF

        IF aOrd[ i ] = MO_DESC
            MOVETO( hDC, nRight, nTop + 6 )

            LINETO( hDC, nRight + 6, nTop + 6, hGPen )
            LINETO( hDC, nRight + 3, nTop, hWPen )
            LINETO( hDC, nRight, nTop + 6, hGPen )
        ENDIF
    NEXT

    DELETEOBJECT( hWPen )
    DELETEOBJECT( hGPen )

    RETURN NIL


#define SB_HORZ         0
#define SB_VERT         1
#define SB_CTL          2


STATIC FUNCTION MYSETPOS( nPos )

    LOCAL Self := HB_QSELF()

    ::oWnd:oWnd:Refresh( .F. )

    RETURN SETSCROLLPOS( IF( ::lIsChild, ::oWnd:hWnd, ::hWnd ), IF( ::lIsChild, IF( ::lVertical, SB_VERT, SB_HORZ ), SB_CTL ), nPos, ::lReDraw )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Taiwan » Fri Oct 20, 2006 12:42 pm

Hello EMG,

Looks nice job.
Could you show me this sample screen shot?

Thank you.

Richard
User avatar
Taiwan
 
Posts: 218
Joined: Fri Oct 07, 2005 1:55 am
Location: Taipei, Taiwan

Postby Enrico Maria Giordano » Fri Oct 20, 2006 1:53 pm

Sent to your private email.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Sun Oct 22, 2006 2:20 pm

This is a much better version using inheritance:

Code: Select all  Expand view
#include "Fivewin.ch"


#define MO_NONE 0
#define MO_ASC  1
#define MO_DESC 2


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    USE TEST

    DEFINE DIALOG oDlg SIZE 400, 300

    oBrw = TMyWBrowse():New( 0, 0, , ,;
                             { || { TEST -> last, TEST -> first, "" } },;
                             { "LAST", "FIRST", "" },;
                             { 150, 150, 0 } )

    oBrw:lCellStyle = .T.

    oBrw:aOrd = { { || MO_ASC }, { || MO_DESC }, { || MO_NONE }, { || MO_NONE } }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    CLOSE

    RETURN NIL


CLASS TMyWBrowse FROM TWBrowse

    DATA aOrd

    METHOD Paint()

ENDCLASS


METHOD Paint() CLASS TMyWBrowse

    Super:Paint()

    MARCAORDINE( ::oWnd, ::hDC, Self, ::aOrd )

    RETURN 0


#define SM_CYHSCROLL 3


STATIC FUNCTION MARCAORDINE( oDlg, hDC, oBrw, abOrd )

    LOCAL aValues   := oBrw:aHeaders
    LOCAL aColSizes := oBrw:GetColSizes()

    LOCAL nWidth := WNDWIDTH( oBrw:hWnd ) - IF( oBrw:oVScroll != nil .AND. EVAL( oBrw:bLogicLen ) > 1, GETSYSMETRICS( SM_CYHSCROLL ) + 3, 0 )

    LOCAL nColStart := -1

    LOCAL nTop, nLeft, nRight

    LOCAL hGPen, hWPen

    LOCAL i

    hGPen = CREATEPEN( 0, 1, CLR_GRAY )
    hWPen = CREATEPEN( 0, 1, CLR_WHITE )

    nTop = oBrw:nTop + 5

    FOR i = oBrw:nColPos TO LEN( aValues )
        nLeft  = nColStart + 1
        nRight = MIN( nColStart := ( nLeft + aColSizes[ i ] - 1 ), nWidth )

        IF nLeft > nWidth
            EXIT
        ENDIF

        IF i == LEN( aValues )
           nRight = nWidth
        ENDIF

        nRight -= 10

        IF EVAL( abOrd[ i ] ) = MO_ASC
            MOVETO( hDC, nRight, nTop )

            LINETO( hDC, nRight + 6, nTop, hGPen )
            LINETO( hDC, nRight + 3, nTop + 6, hWPen )
            LINETO( hDC, nRight, nTop, hGPen )
        ENDIF

        IF EVAL( abOrd[ i ] ) = MO_DESC
            MOVETO( hDC, nRight, nTop + 6 )

            LINETO( hDC, nRight + 6, nTop + 6, hGPen )
            LINETO( hDC, nRight + 3, nTop, hWPen )
            LINETO( hDC, nRight, nTop + 6, hGPen )
        ENDIF
    NEXT

    DELETEOBJECT( hWPen )
    DELETEOBJECT( hGPen )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Sun Oct 22, 2006 10:03 pm

Enrico,

May I ask why did you subclass then put all the code in a static function?

Wouldn't it be better to put all the code in the new Paint method?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Sun Oct 22, 2006 10:42 pm

Yes, it was just an experiment.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 79 guests