moin,
Wolfgang_B hat geschrieben: ↑Mo, 16. Jul 2018 13:15
ich versuche gerade eine Linie in ein oDlg-Objekt zu zeichnen. Es gelingt mir aber nicht.
zunächst mal XbpPresSpace():new() --> oPS hat KEINE weiteren Parameter
wenn du den oPS von einem XbPart haben willst wäre ist es normal
wie Hubert schon sagte
Code: Alles auswählen
oPS := drawingArea:lockPS()
GraLine( oPS, {10,50}, {100,200} ) // diagonal ? von x,y nach x,y
oPS:unlockPS()
sollte dann funktionieren ... bis du es mit einem anderen Fenster "überdeckst".
wenn das Fenster wieder den Focus bekommt wird deine GraLine() vermutlich nicht wiederhergestellt
die o:drawingArea ist gut als Parent für XbParts aber
NICHT für GRA Function
Hubert spach den o:Draw Callback Slot an den auch ein XbpStatic hat.
du nimmst also eine XbpStatic als "Linie". Breite ist klar und Höhe 1-3 Pixel (je nach Linie Type)
XbpStatic()
Slot: :draw := { |oPS,aInfo,oSelf| MyDraw(oPS,aInfo,oSelf) }
Code: Alles auswählen
FUNCTION MyDraw( oPS, aInfo, oSelf)
LOCAL aRect := aInfo [XBP_DRAWINFO_RECT]
LOCAL aAttr := Array( GRA_AL_COUNT ) // Array für Linien-
// attribute
aAttr[ GRA_AL_TYPE ] := GRA_LINETYPE_SOLID
aAttr[ GRA_AL_WIDTH] := aRect[4]-aRect[2]
GraSetAttrLine( oPS, aAttr ) // Attribute setzen
GraLine( oPS, {aRect[1],aRect[2]}, {aRect[3],aRect[4]} )
// Ist der Rückgabewert hingegen .F. (falsch) findet keine weitere Bearbeitung der Nachricht statt
RETURN .F.
so ein "Linie" würde sich jedes mal neu malen wenn nötig.
---
nun hast du sicherlich mehr als nur eine Linie in deinem Fenster sprich andere XbParts
wenn du nun ein "grosses" XbpStatic nimmst das als Parent für alle deine XbParts gilt dann kannst du es als Hintergrund mit mehrere GRA Functionen nehmen.
Code: Alles auswählen
GraLine( oPS, {10, 50}, {100, 50} )
GraLine( oPS, {10,150}, {100,150} )
auch für ein Hintergrund-Bild (Formular) wäre der o:Draw Slot der richtige Ort
Code: Alles auswählen
oBmp:draw( oPS, {aRect[1],aRect[2],aRect[3],aRect[4]},;
{0,0,oBmp:xSize,oBmp:ySize} )
und wenn das XbpStatic grösser o:DrawingArea ist kann man die XbpStatic auch im Fenster "scrollbar" machen
.