Ownerdraw question

This forum is for general support of Xbase++
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Ownerdraw question

#1 Post by rdonnay »

Capture.JPG
Capture.JPG (11.62 KiB) Viewed 11799 times
I am putting together a few sample programs for my Ownerdraw session in Hanover.

I have always had problems with transparency using Ownerdraw.
Here is a sample program I wrote that would show how to create a dialog window using XbpStatic() and ownerdraw.
The idea is to create a modal dialog with a gradient filled title bar and rounded edges.

I'm having problems with background transparency on the edges. Any ideas?

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL oStatic, mp1, mp2, oXbp, nEvent, oDlg

oDlg := XbpDialog():new(,,{100,100},{200,200})
oDlg:border := XBPDLG_NO_BORDER
oDlg:titleBar := .f.
oDlg:drawingArea:colorBG := XBPSYSCLR_TRANSPARENT
oDlg:create()

oStatic := CustomStatic():new( oDlg:drawingArea,,{0,0},oDlg:drawingArea:currentSize())
oStatic:drawMode := XBP_DRAW_OWNER
oStatic:radius := 20
oStatic:create()
oStatic:setColorBG(XBPSYSCLR_TRANSPARENT)
oStatic:lbDown := {|a,b,c|DC_MoveParentWindow(a,b,c)}
oStatic:show()

DO WHILE .t.
  nEvent := AppEvent(@mp1,@mp2,@oXbp,.1)
  IF nEvent > 0
    oXbp:handleEvent(nEvent,mp1,mp2)
  ENDIF
  IF nEvent == xbeP_Keyboard .AND. mp1 == xbeK_ESC
    EXIT
  ENDIF
ENDDO

RETURN nil

PROC appsys ; return

* ------------

CLASS CustomStatic FROM XbpStatic

EXPORTED:

   VAR titleColor
   VAR titleHeight
   VAR fillColor
   VAR radius
   VAR gradientStep
   VAR titleCaption

INLINE METHOD Init(a,b,c,d,e,f,g,h)

   ::titleColor := { 200, 200, 200 }
   ::titleHeight := 30
   ::fillColor := { 200, 245, 245 }
   ::radius := 20
   ::gradientStep := 2
   ::titleCaption := 'Testing'
   ::XbpStatic:init(a,b,c,d,e,f,g,h)

RETURN self

INLINE METHOD Draw( oPS, aInfo )

LOCAL aStringAttr, i, oFont, aPos, aRect, aSize, nTmp
LOCAL aColors, nColor
LOCAL aStartPos := {aInfo[4][1],aInfo[4][2]}
LOCAL aEndPos   := {aInfo[4][3],aInfo[4][4]}
LOCAL aStartPosSave, aEndPosSave
LOCAL aAttrArea := Array(GRA_AA_COUNT)

aColors := AClone(::titleColor)

aStartPosSave := AClone(aStartPos)
aEndPosSave := AClone(aEndPos)
FOR i := 1 TO ::titleHeight
  aColors[1] += ::gradientStep
  aColors[2] += ::gradientStep
  aColors[3] += ::gradientStep
  GraSetColor( oPS, GraMakeRGBColor(aColors), XBPSYSCLR_TRANSPARENT )
  GraBox( oPS, aStartPos, aEndPos, GRA_OUTLINEFILL, ::radius, ::radius )
  aStartPos[2]++
  aEndPos[2]--
NEXT

aStartPos := aStartPosSave
aEndPos := aEndPosSave
aEndPos[2] -= ::titleHeight

GraSetColor( oPS, GraMakeRGBColor( ::fillColor ), XBPSYSCLR_TRANSPARENT )
GraBox( oPS, aStartPos, aEndPos, GRA_OUTLINEFILL, ::radius, ::radius)
aStartPos[2] += ::titleHeight
GraBox( oPS, aStartPos, aEndPos, GRA_OUTLINEFILL, 0, 0)

aStringAttr := Array( GRA_AS_COUNT )
aStringAttr[GRA_AS_COLOR]     := GRA_CLR_BLACK
aStringAttr[GRA_AS_VERTALIGN] := GRA_VALIGN_TOP
GraSetAttrString( oPS, aStringAttr )

aSize := ::CurrentSize()

aPos := {40,::CurrentSize()[2]-::titleHeight/2+10}

GraPos( oPS, aPos )

GraStringAt( oPS,,::titleCaption )

RETURN self

ENDCLASS
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Ownerdraw question

#2 Post by Auge_Ohr »

rdonnay wrote:I'm having problems with background transparency on the edges. Any ideas?

Code: Select all

GraBox( oPS, aStartPos, aEndPos, GRA_OUTLINEFILL, ::radius, ::radius )
as i see you use 5th/6th Parameter of GraBox() but where is your GraEdge() ?
without GraEdge() it will look like this
GraBoxRadius.jpg
GraBoxRadius.jpg (5.24 KiB) Viewed 11794 times
Last edited by Auge_Ohr on Fri Feb 17, 2012 5:30 pm, edited 1 time in total.
greetings by OHR
Jimmy

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

Re: Ownerdraw question

#3 Post by rdonnay »

My sample is based on XbpStatic(), not XbpCellGroup().
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Ownerdraw question

#4 Post by Auge_Ohr »

rdonnay wrote:My sample is based on XbpStatic(), not XbpCellGroup().
sorry, you are right. i have correct my Answer to short Detail.
greetings by OHR
Jimmy

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

Re: Ownerdraw question

#5 Post by rdonnay »

I don't see how GraEdge() solves this problem. There are no samples.
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Ownerdraw question

#6 Post by Auge_Ohr »

rdonnay wrote:I don't see how GraEdge() solves this problem. There are no samples.
Xbase++ "Service Pack 2" Sample XbpFormattedLabel() which is based on XbpStatic
greetings by OHR
Jimmy

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

Re: Ownerdraw question

#7 Post by rdonnay »

I know about formatted label. I used it as a new option to eXpress++ in my last build.

I also see how GraEdge is used, but it only is for rectangular borders, not borders with a radius.
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Ownerdraw question

#8 Post by Auge_Ohr »

hi,

you are right. i always get mixed up GraEdge() with GraBackground() while the problem is a "Edge".
greetings by OHR
Jimmy

Post Reply