ich versuche gerade ein Klasse für ein PopUp-Fenster zu erstellen. Dabei verwende ich folgenden Code (ausgelagert):
Code: Alles auswählen
#include "gra.ch"
#include "font.ch"
#include "appevent.ch"
procedure Main
local oWin, oPart, oFnt, oFont, cLines, nCnt, aSize, aPos, fontHeight, ;
winWidth, winHeight, winPadVert, winPadHoriz, winPS
winWidth := 50
winHeight := 50
winPadVert := 20
winPadHoriz := 30
msgText := "some text to show"
title := "any title"
oFnt := NIL
backColor := NIL
fontColor := NIL
oWin := XbpDialog():new( AppDesktop() , , { 1,1 }, { winWidth, winHeight } )
oWin:title := title
oWin:create()
drawingArea:= oWin:drawingArea
if backColor==NIL
drawingArea:setColorBG( GRA_CLR_WHITE )
else
drawingArea:SetColorBG ( backColor )
endif
if fontColor==NIL
drawingArea:setColorFG ( GRA_CLR_BLACK )
else
drawingArea:setColorFG ( fontColor )
endif
SetAppWindow(oWin)
winPS := XbpPresSpace():new()
winPS:create( oWin:winDevice() , {850,850}, GRA_PU_PIXEL )
if oFnt==NIL
cFntName := oWin:setFontCompoundName()
oFnt := GraSetFont( winPS )
else
GraSetFont( winPS, oFnt )
endif
// Nachricht der Pop-Notiz bearbeiten bzgl.Laenge
cLines := {}
maxLineWidth := 0
if valtype( msgText ) == "A"
for nCnt:=1 to len( msgText )
AAdd( cLines, msgText[nCnt] )
aSize := GraQueryTextBox( winPS, msgText[nCnt] )
if aSize[3][1] > (maxLineWidth)
maxLineWidth := aSize[3][1]
endif
next
fontHeight := aSize[1][2]
else
nCnt := AScan( msgText, chr(13) )
if nCnt==0
AAdd( cLines, msgText )
aSize := GraQueryTextBox( winPS, msgText )
maxLineWidth := aSize[3][1]
else
do while nCnt>0
cDum := substr( msgText, 1, nCnt-1 )
AAdd( cLines, cDum )
aSize := GraQueryTextBox( winPS, cDum )
if aSize[3][1] > maxLineWidth
maxLineWidth := aSize[3][1]
endif
msgText := substr( msgText, nCnt+1 )
nCnt := AScan( msgText, chr(13) )
enddo
endif
fontHeight := aSize[1][2]
endif
winWidth := maxLineWidth+2*winPadHoriz
oWin:unlockPS()
winHeight := (len( cLines )+1) * fontHeight*1.3 + 2*winPadVert
oWin:setSize( { winWidth, winHeight } )
oPart := oWin:setParent()
if oPart==NIL
oPart := AppDesktop()
endif
aSize := oPart:currentSize()
oWin:setPos( { aSize[1]/2 - winWidth/2, aSize[2]/2 - winHeight/2 } )
aPos := oWin:currentPos()
aSize := oWin:currentSize()
// Nachrichten als XbpStatics in XbpDialog erstellen
for nCnt:=1 to len( cLines )
msgText := cLines[ len(cLines)-(nCnt-1) ]
oPart := XbpStatic():new( drawingArea, , { winPadHoriz, winPadVert+(nCnt-1)*fontHeight }, ;
{ maxLineWidth, fontHeight } )
oPart:setFont( oFnt )
oPart:caption := msgText
oPart:create()
next
winPS := oWin:lockPS()
GraSetColor( winPS, GRA_CLR_BLACK, GRA_CLR_WHITE )
GraLine( winPS, { winPadHoriz, 1 }, { winPadHoriz, winHeight } )
GraLine( winPS, { winPadHoriz+maxLineWidth, 1 }, { winPadHoriz+maxLineWidth, winHeight } )
oWin:unlockPS()
oWin:show()
nEvent := xbe_None
do while nEvent<>xbeP_Close
nEvent := AppEvent( @mp1, @mp2, @oPart )
oPart:handleEvent( nEvent, mp1,mp2 )
enddo
return
Zur Überprüfung wollte ich zwei Linien zeichnen, aber die werden nicht im Fenster dargestellt!?
Kann jmd.bitte helfen und mir sagen was ich hier falsch mache?