Page 1 of 1

XBrowse 2101: bBmpData : enhancment

Posted: Mon Feb 01, 2021 6:25 am
by nageswaragunupudi
We are aware that we use oCol:bBmpData to return a numeric value, which is an index value into the list of bitmaps already attached to the column with oCol:AddBitmap( aBitmaps ). If the value returned is not numeric or exceeds the length of the bitmap list, no bitmap is painted.

In some cases, it may not be possible to anticipate all the bitmaps that need to be displayed in advance and attach to the column with oCol:AddBitmap() method. We may have to decide the image at the time of runtime.

From FWH2101, bBmpData can either return a number which is an index of the list of bitmaps already loaded or return any other image source.
The image source can be name of any image file, resource, web ref, image buffer, symbol or shape.

The revised fwh\samples\xbrwdisk.prg uses this enhancement to display the icons of the files. If the file is an image file like bmp,jpg,png,gif,ico, etc the image is displayed as icon. If the file is exe, the icon of the exe and in other cases, the icon of the associated program is displayed.

This is how the bBmpData is programmed:

Code: Select all

oBrw:bBmpData  := ;
   { || If( Right( oBrw:oTreeItem:cPrompt, 1 ) == ":", 4, ;
        If( "D" $ oBrw:oTreeItem:Cargo[ 5 ], ;
        If( oBrw:oTreeItem:lOpened, 1, 2 ), ;
            oBrw:oTreeItem:Cargo[ 6 ] ; // file name with full path.
          ) ) ;
   }
 
Image

Re: XBrowse 2101: bBmpData : enhancment

Posted: Mon Feb 01, 2021 4:30 pm
by Armando
Mr. Rao:

Great job.

Regards

Re: XBrowse 2101: bBmpData : enhancment

Posted: Wed Feb 03, 2021 8:11 am
by nageswaragunupudi

Code: Select all

#include "fivewin.ch"

function Main()

   local aZodiac  := { "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", ;
                       "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces" }

   local oDlg, oFont, oBrw

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0,-32
   DEFINE DIALOG oDlg SIZE 300,720 PIXEL TRUEPIXEL FONT oFont TITLE FWVERSION

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aZodiac COLUMNS 1 HEADERS "Zodiac" ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :lRecordSelector := .f.
      :lVScroll      := .f.
      :lHScroll      := .f.
      WITH OBJECT :aCols[ 1 ]
         :bBmpData      := { || oBrw:nArrayAt + 93 }
         :nClrBmpBack   := METRO_LIME
         :nHeadBmpNo    := 93
      END
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 
Image

Re: XBrowse 2101: bBmpData : enhancment

Posted: Wed Feb 03, 2021 12:40 pm
by Silvio.Falconi
Finally. very nice