Bitmap sizes in DCSUBMENU/DCMENUITEM

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

Bitmap sizes in DCSUBMENU/DCMENUITEM

#1 Post by SvenVazan »

Hey all,

Having an issue with large bitmaps/icons in this combination.

If I have code on the DCBROWSE (oBrowse) with a menu attached to the right-click:

Code: Select all

    
DCSUBMENU oMenu ;
        PROMPT "Open Items" ;
        PARENT oBrowse ;
        OWNERDRAW

//menu items
DCMENUITEM "Change" ;
        BITMAP dBITMAP_FILE ;
        PARENT oMenu ;
        ACTION { || DO_SOMETHING() }
The bitmap file comes out way too big and stretched. Looks like my 16x16 bitmap or icon is gets warped to around 22x22 or so. So I went searching...

I adjusted your _dcclass.prg from (notice the 22s):

Code: Select all

IF oBmp != NIL .AND. ::bitmaps
      nY := ((aInfo[4][4] - 1 - aInfo[4][2]) - 22) /2
//      nY := ((aInfo[4][4] - 1 - aInfo[4][2]) - oBmp:ySize) /2
      IF oBmp:isDerivedFrom('XbpIcon')
        nY += aInfo[4][2]+3
        x := aInfo[4][1] + ::BarWidth + ITEM_SPACING *2
        y := nY
        oBmp:draw( oPS, { x, y, x + 22, y + 22 } )
      ELSE
        // nY += aInfo[4][2]
        // oBmp:draw( oPS, {aInfo[4][1] + ::BarWidth + ITEM_SPACING*2, nY} )

        nY += aInfo[4][2]+2
        x := aInfo[4][1] + ::BarWidth + ITEM_SPACING *2
        y := nY
        oBmp:draw( oPS, { x, y, x + 22, y +22} )
      ENDIF

   ENDIF
to (changed all the 22s to 16s):

Code: Select all

IF oBmp != NIL .AND. ::bitmaps
      nY := ((aInfo[4][4] - 1 - aInfo[4][2]) - 16) /2
//      nY := ((aInfo[4][4] - 1 - aInfo[4][2]) - oBmp:ySize) /2
      IF oBmp:isDerivedFrom('XbpIcon')
        nY += aInfo[4][2]+3
        x := aInfo[4][1] + ::BarWidth + ITEM_SPACING *2
        y := nY
        oBmp:draw( oPS, { x, y, x + 16, y + 16 } )
      ELSE
        // nY += aInfo[4][2]
        // oBmp:draw( oPS, {aInfo[4][1] + ::BarWidth + ITEM_SPACING*2, nY} )

        nY += aInfo[4][2]+2
        x := aInfo[4][1] + ::BarWidth + ITEM_SPACING *2
        y := nY
        oBmp:draw( oPS, { x, y, x + 16, y +16 } )
      ENDIF

   ENDIF

That seemed to fix it everywhere. Is there a reason that you set it to 22?

Sven

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Bitmap sizes in DCSUBMENU/DCMENUITEM

#2 Post by rdonnay »

It was always at 22 because that seemed to satisfy all requirements. It has been this way for over 10 years.

If you need it to be 16, then I suggest that I write a Get-Set function that sets the size for the application.

Here is an updated _DCCLASS.PRG.

You need to call DC_MenuBitmapSize(16) at the start of your program.
Attachments
_dcclass.zip
(42.1 KiB) Downloaded 686 times
The eXpress train is coming - and it has more cars.

Post Reply