Painter
Previous topic  First topic  Next topic







The
PAINTER control implements a paint area into a window to draw shapes
El control PAINTER implementa un area de dibujo en una ventana para dibujar figuras

You can use it in that general way:
Usted puede usar este control de esta forma:

CREATE PAINTER myPainter [ OF myWin ]
   ROW nRow
   COL nCol
   WIDTH nWidth
   HEIGHT nHeight
   [ COLOR aColor ]
   [ BACKCOLOR aBackColor ]
   ...
   @ ... DRAW ...
   @ ... DRAW ...
   @ ... DRAW ...
   @ ... DRAW ...
   ...
END PAINTER


"@ ... DRAW" sub-commands outside of a CREATE PAINTER structure must be coded with WINDOW and CONTROL parameters
Los comandos "@ ... DRAW" codificados fuera de una estructura de CREATE PAINTER deben ser codificados con los parámetros WINDOW y CONTROL

e.g.:

inside:

dentro:
@ 10,10 DRAW RECTANGLE WIDTH 200 HEIGHT 100

outside:
fuera:
@ 10,10 DRAW RECTANGLE WINDOW "myWin" CONTROL "myPainter" WIDTH 200 HEIGHT 100



Draw sub-commands:


Note: to coded a DRAW sub-command you must respect the parameters order
Nota: para codificar un sub-comando DRAW es necesario respetar el orden de los parámetros

Note 2: The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360).
Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction.
Zero degrees is at the 3 o'clock position.

Nota 2: El startAngle y el spanAngle deben ser especificados en 1/16aba parte de grado, por ejemplo, un circulo completo es 5760 (16 * 360)
Valores positivos para angulos significan en direccion contraria al sentido de los relojes, mientras que valores negativos significa en el sentido de los relojes.
Cero grados es en la posicion 3 exacta.


//- Arc ----------------------------//

@ <nRow>,<nCol> TO <nRowBottom>,<nColRight> DRAW ARC [ WINDOW <cWindow> CONTROL <cControl> ] STARTANGLE <nStartAngle> SPANANGLE <nSpanAngle> [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ <nRow>,<nCol> DRAW ARC [ WINDOW <cWindow> CONTROL <cControl> ] WIDTH <nWidth> HEIGHT <nHeight> STARTANGLE <nStartAngle> SPANANGLE <nSpanAngle> [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Chord --------------------------//

@ <nRow>,<nCol> TO <nRowBottom>,<nColRight> DRAW CHORD [ WINDOW <cWindow> CONTROL <cControl> ] STARTANGLE <nStartAngle> SPANANGLE <nSpanAngle> [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ <nRow>,<nCol> DRAW CHORD [ WINDOW <cWindow> CONTROL <cControl> ] WIDTH <nWidth> HEIGHT <nHeight> STARTANGLE <nStartAngle> SPANANGLE <nSpanAngle> [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Ellipse ------------------------//

@ <nRow>,<nCol> TO <nRowBottom>,<nColRight> DRAW ELLIPSE [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ <nRow>,<nCol> DRAW ELLIPSE [ WINDOW <cWindow> CONTROL <cControl> ] WIDTH <nWidth> HEIGHT <nHeight>[ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Line ---------------------------//

@ <nRow>,<nCol> TO <nToRow>,<nToCol> DRAW LINE [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Pie ----------------------------//

@ <nRow>,<nCol> TO <nRowBottom>,<nColRight> DRAW PIE [ WINDOW <cWindow> CONTROL <cControl> ] STARTANGLE <nStartAngle> SPANANGLE <nSpanAngle> [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ <nRow>,<nCol> DRAW PIE [ WINDOW <cWindow> CONTROL <cControl> ] WIDTH <nWidth> HEIGHT <nHeight> STARTANGLE <nStartAngle> SPANANGLE <nSpanAngle> [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Point --------------------------//

@ <nRow>,<nCol> DRAW POINT [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ DRAW POINT <nRow>,<nCol> [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Points -------------------------//

@ DRAW POINTS <aPoints> [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Polygon ------------------------//

@ DRAW POLYGON <aPoints> [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- PolyLine -----------------------//

@ DRAW POLYLINE <aPoints> [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Rectangle ----------------------//

@ <nRow>,<nCol> TO <nRowBottom>,<nColRight> DRAW RECTANGLE [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ ROUNDED <nRounded> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ <nRow>,<nCol> DRAW RECTANGLE [ WINDOW <cWindow> CONTROL <cControl> ] WIDTH <nWidth> HEIGHT <nHeight>[ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ ROUNDED <nRounded> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

//- Text ---------------------------//

@ <nRow>,<nCol> TO <nRowBottom>,<nColRight> DRAW TEXT <cText> [ WINDOW <cWindow> CONTROL <cControl> ] [ COLOR <aColor> ] [ BACKCOLOR <aBackColor> ] [ FONTNAME <cFontName> ] [ FONTSIZE <nFontSize> ] [ FONTBOLD <lFontBold> ] [ FONTITALIC <lFontItalic> ] [ FONTUNDERLINE <lFontUnderline> ] [ FONTSTRIKEOUT <lFontStrikeOut> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;

@ <nRow>,<nCol> DRAW TEXT <cText> [ WINDOW <cWindow> CONTROL <cControl> ] WIDTH <nWidth> HEIGHT <nHeight> [ COLOR <aColor> ] [ FONTCOLOR <aFontColor> ] [ BACKCOLOR <aBackColor> ] [ FONTNAME <cFontName> ] [ FONTSIZE <nFontSize> ] [ FONTBOLD <lFontBold> ] [ FONTITALIC <lFontItalic> ] [ FONTUNDERLINE <lFontUnderline> ] [ FONTSTRIKEOUT <lFontStrikeOut> ] [ PENWIDTH <nPenWidth> ] [ STYLEPEN <nStylePen> ] ;



PenStyle:



Qt_NoPen No line at all. For example, DRAW RECTANGLE fills but does not draw any boundary line.
Qt_SolidLine A plain line.
Qt_DashLine Dashes separated by a few pixels.
Qt_DotLine Dots separated by a few pixels.
Qt_DashDotLine Alternate dots and dashes.
Qt_DashDotDotLine One dash, two dots, one dash, two dots.



Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE PAINTER cName | (cVarName) | &(cExpression) 
      [ PARENT cParentName ]
NIL
  
Parent window for this widget
      [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
      [ ROW nRow ]
0
  
Row position on container desktop in pixels coordinates
      [ COL nCol ]
0
  
Col position on container desktop in pixels coordinates
      [ WIDTH nWidth ]
?
  
The desired width size of the window in pixels
      [ HEIGHT nHeight ]
?
  
The desired height size of the window in pixels
      [ ROWBOTTOM nRow ]
n/a
  
Bottom Row position on container desktop in pixels coordinates. This property adjust the HEIGHT property according the ROW property.
      [ COLRIGHT nCol ]
n/a
  
Right Col position on container desktop in pixels coordinates. This property adjust the WIDTH property according the COL property.
      [ TOROW nBottom ]
n/a
  
Bottom ROW. Usually used with ROW, COL and TOCOL
      [ TOCOL nRight ]
n/a
  
Right COL. Usually used with ROW, COL and TOROW
      [ COORD { nLeft , nTop , nRight , nBottom } ]
n/a
  
Coordenates to painter area
      [ FROMXY { nLeft , nTop } ]
n/a
  
Coordenates to painter area (Usually used with TOXY property)
      [ TOXY { nRight , nBottom } ]
n/a
  
Coordenates to painter area (Usually used with FROMXY property)
      [ FONTNAME "cFontName" ]
Parent.Fontname
  
Font family for DRAW TEXT
      [ FONTSIZE nPoints ]
Parent.FontSize
  
Font size for DRAW TEXT
      [ FONTBOLD .T. | .F. ]
.F.
  
Set Bold attribute to DRAW TEXT
      [ FONTITALIC .T. | .F. ]
.F.
  
Set Italic attribute to DRAW TEXT
      [ FONTUNDERLINE .T. | .F. ]
.F.
  
Set Underline attribute to DRAW TEXT
      [ FONTSTRIKEOUT .T. | .F. ]
.F.
  
Set Strikeout attribute to DRAW TEXT
      [ PENWIDTH nPenWidth ]
1
  
Width of Pen used to DRAW
      [ STYLEPEN cStylePen ]
n/a
  
Set the Style Pen for DRAW.
      [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the DRAW area. Go to to learn more about it.
      [ COLOR {aColor} | aVarColor ]
OS.FontColor
  
Set foreground color
      [ FONTCOLOR {aFontColor} | aVarFontColor ]
OS.FontColor
  
Set foreground color. Only for TEXT color
      [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  
Set background color
      [ TOOLTIP cToolTip ]
NIL
  
Text for display into tooltip
      [ VISIBLE .T. | .F. ]
.T.
  
Show or hide DRAW area (like methods SHOW and HIDE)
      [ CREATE CONTEXT MENU [ cName ] ]   
CONTEXT MENU for control
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
      [ END MENU ]   
 
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
            [ @ DRAW ....... ]   
You can see properties for this menu in CONTEXT MENU topic
            [ @ DRAW ....... ]   
You can see properties for this menu in CONTEXT MENU topic
            [ @ DRAW ....... ]   
You can see properties for this menu in CONTEXT MENU topic
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
END PAINTER 

Jump to Context Menu topic



Methods


Methods
Status
Default
Planned
Started
Ready
Comments
    CLEAR
n/a
  
Clear DRAW area.
    RELEASE
n/a
  
Release DRAW area
    HIDE
n/a
  
Hide DRAW area.
    SHOW
n/a
  
Show DRAW area.
    UNSETCURSOR
n/a
  
Reset the cursor pointer shape for the DRAW area to default (Qt_ArrowCursor). Go to to learn more about it.



Example 1:

File: d_painter.prg


#include "marinas-gui.ch"

MEMVAR cPainterName
MEMVAR nNumber

Function main()

   PRIVATE cPainterName := "d_painter"
   PRIVATE nNumber     := 33

   SET APPLSTYLE TO "MarinasLooks"

   CREATE WINDOW d_window
      ROW 0 ; COL 0
      WIDTH 820 ; HEIGHT 480
      CAPTION "Marinas-GUI Sample for Painter Control"
      ICON "../resource/d_test.ico"
      BACKCOLOR {223,242,253}
      MAIN .T.

      d_painter_def()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

Return .T.


File: d_painter_def.prg

#include "marinas-gui.ch"

FUNCTION d_painter_def()
   LOCAL nDespX
   LOCAL nDespY
   LOCAL nPoint1
   LOCAL nPoint2
   LOCAL nPoint3
   LOCAL nPoint4
   LOCAL nPoint5

   // == Rectangle ==================================//

   nDespX := 60
   nDespY := 0

   CREATE FRAMEBOX fb_rectangle
      ROW nDespY + 10
      COL nDespX + 10
      WIDTH 220
      HEIGHT 145
      CAPTION "Rectangle"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_rectangle
      ROW mg_get( "d_window" , "fb_rectangle" , "row" ) + 20
      COL mg_get( "d_window" , "fb_rectangle" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_rectangle" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_rectangle" , "height" ) - 30
      PENWIDTH 1
      BACKCOLOR {255,201,14}
      COLOR {255,0,0}

      @ 10,10 TO 105,115 DRAW RECTANGLE BACKCOLOR {0,0,255} ROUNDED 20 PENWIDTH 2
      @ 15,125 DRAW RECTANGLE WIDTH 65 HEIGHT 30 COLOR {55,255,50}
      @ 70,125 TO 100,190 DRAW RECTANGLE COLOR {0,0,255} PENWIDTH 5

   END PAINTER

   // == Line =======================================//

   nDespX := mg_get( "d_window" , "fb_rectangle" , "colRight" )
   nDespY := mg_get( "d_window" , "fb_rectangle" , "row" )

   CREATE FRAMEBOX fb_line
      ROW nDespY
      COL nDespX + 10
      WIDTH 220
      HEIGHT 145
      CAPTION "Line"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_line
      ROW mg_get( "d_window" , "fb_line" , "row" ) + 20
      COL mg_get( "d_window" , "fb_line" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_line" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_line" , "height" ) - 30
      PENWIDTH 1

      @ 20,35 TO 90,90 DRAW LINE COLOR {255,0,0} PENWIDTH 2
      @ 40,135 TO 100,35 DRAW LINE PENWIDTH 3
      @ 100,15 TO 55,15 DRAW LINE COLOR {55,255,50} PENWIDTH 5
      @ 20,165 TO 100,150 DRAW LINE COLOR {0,0,255} PENWIDTH 10

   END PAINTER

   // == Arc ========================================//

   nDespX := mg_get( "d_window" , "fb_line" , "colRight" )
   nDespY := mg_get( "d_window" , "fb_line" , "row" )

   CREATE FRAMEBOX fb_arc
      ROW nDespY
      COL nDespX + 10
      WIDTH 220
      HEIGHT 145
      CAPTION "Arc"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_arc
      ROW mg_get( "d_window" , "fb_arc" , "row" ) + 20
      COL mg_get( "d_window" , "fb_arc" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_arc" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_arc" , "height" ) - 30

      @ 10,90 TO 30,150 DRAW ARC STARTANGLE 0 * 16 SPANANGLE -120 * 16 COLOR {255,220,120} PENWIDTH 3
      @ 20,15 TO 135,100 DRAW ARC STARTANGLE 10 * 16 SPANANGLE 120 * 16 COLOR {255,0,0}
      @ 85,10 DRAW ARC WIDTH 85 HEIGHT 30 STARTANGLE 30 * 16 SPANANGLE 120 * 16  COLOR {55,255,50} PENWIDTH 2
      @ 50,80  TO 100,150 DRAW ARC STARTANGLE 30 * 16 SPANANGLE -120 * 16 COLOR {0,0,255} PENWIDTH 10

   END PAINTER

   // == Chord ====================================//

   nDespX := mg_get( "d_window" , "fb_rectangle" , "col" )
   nDespY := mg_get( "d_window" , "fb_rectangle" , "rowBottom" )

   CREATE FRAMEBOX fb_chord
      ROW nDespY + 10
      COL nDespX
      WIDTH 220
      HEIGHT 145
      CAPTION "Chord"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_chord
      ROW mg_get( "d_window" , "fb_chord" , "row" ) + 20
      COL mg_get( "d_window" , "fb_chord" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_chord" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_chord" , "height" ) - 30

      @ 10,90 TO 30,150 DRAW CHORD STARTANGLE 0 * 16 SPANANGLE -120 * 16 COLOR {255,220,120} PENWIDTH 3
      @ 20,15 TO 135,100 DRAW CHORD STARTANGLE 10 * 16 SPANANGLE 120 * 16 COLOR {255,0,0} BACKCOLOR {255,255,255}
      @ 85,10 DRAW CHORD WIDTH 85 HEIGHT 30 STARTANGLE 30 * 16 SPANANGLE 120 * 16  COLOR {55,255,50} PENWIDTH 2
      @ 50,80  TO 100,150 DRAW CHORD STARTANGLE 30 * 16 SPANANGLE -120 * 16 COLOR {0,0,255} PENWIDTH 10

   END PAINTER

   // == Ellipse ====================================//

   nDespX := mg_get( "d_window" , "fb_chord" , "colRight" )
   nDespY := mg_get( "d_window" , "fb_chord" , "row" )

   CREATE FRAMEBOX fb_ellipse
      ROW nDespY
      COL nDespX + 10
      WIDTH 220
      HEIGHT 145
      CAPTION "Ellipse"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_ellipse
      ROW mg_get( "d_window" , "fb_ellipse" , "row" ) + 20
      COL mg_get( "d_window" , "fb_ellipse" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_ellipse" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_ellipse" , "height" ) - 30
      PENWIDTH 1
      BACKCOLOR {255,201,214}
      COLOR {255,0,0}

      @ 10,10 TO 105,105 DRAW ELLIPSE BACKCOLOR {255,255,255} PENWIDTH 2
      @ 15,145 DRAW ELLIPSE WIDTH 30 HEIGHT 45 COLOR {55,255,50} BACKCOLOR {0,0,0}
      @ 70,125 TO 100,190 DRAW ELLIPSE COLOR {0,0,255} PENWIDTH 5

   END PAINTER

   // == Pie ========================================//

   nDespX := mg_get( "d_window" , "fb_ellipse" , "colRight" )
   nDespY := mg_get( "d_window" , "fb_ellipse" , "row" )

   CREATE FRAMEBOX fb_pie
      ROW nDespY
      COL nDespX + 10
      WIDTH 220
      HEIGHT 145
      CAPTION "Pie"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_pie
      ROW mg_get( "d_window" , "fb_pie" , "row" ) + 20
      COL mg_get( "d_window" , "fb_pie" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_pie" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_pie" , "height" ) - 30

      @ 10,90 TO 30,150 DRAW PIE STARTANGLE 0 * 16 SPANANGLE -120 * 16 COLOR {255,220,120} PENWIDTH 3
      @ 20,15 TO 135,100 DRAW PIE STARTANGLE 10 * 16 SPANANGLE 120 * 16 COLOR {255,0,0} BACKCOLOR {255,255,255}
      @ 85,10 DRAW PIE WIDTH 85 HEIGHT 30 STARTANGLE 30 * 16 SPANANGLE 120 * 16  COLOR {55,255,50} PENWIDTH 2
      @ 50,80  TO 100,150 DRAW PIE STARTANGLE 30 * 16 SPANANGLE -120 * 16 COLOR {0,0,255} PENWIDTH 10

   END PAINTER

   // == Polygon ==================================//

   nDespX := mg_get( "d_window" , "fb_chord" , "col" )
   nDespY := mg_get( "d_window" , "fb_chord" , "rowBottom" )

   CREATE FRAMEBOX fb_polygon
      ROW nDespY + 10
      COL nDespX
      WIDTH 220
      HEIGHT 145
      CAPTION "Polygon"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_polygon
      ROW mg_get( "d_window" , "fb_polygon" , "row" ) + 20
      COL mg_get( "d_window" , "fb_polygon" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_polygon" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_polygon" , "height" ) - 30

      @ DRAW POLYGON { {60,10} , {10,20} , {20,80} , {60,90} } COLOR {255,220,120} PENWIDTH 3
      nPoint1 := { 70,100 }
      nPoint2 := { 10,120 }
      nPoint3 := { 30,150 }
      nPoint4 := { 70,145 }
      nPoint5 := { 50,130 }
      @ DRAW POLYGON { nPoint1 , nPoint2 , nPoint3 , nPoint4 , nPoint5 } COLOR {255,0,0} BACKCOLOR {255,255,255}
      @ DRAW POLYGON { { 110,10 } , { 70,35 } , { 110,60 } } COLOR {55,255,50} PENWIDTH 2
      nPoint1 := { 110,70 }
      nPoint2 := { 75,70 }
      nPoint3 := { 110,180 }
      nPoint4 := { 75,180 }
      @ DRAW POLYGON { nPoint1 , nPoint2 , nPoint3 , nPoint4 } COLOR {0,0,255} PENWIDTH 10

   END PAINTER

   // == PolyLine =================================//

   nDespX := mg_get( "d_window" , "fb_polygon" , "colRight" ) + 10
   nDespY := mg_get( "d_window" , "fb_polygon" , "row" ) - 10

   CREATE FRAMEBOX fb_polyLine
      ROW nDespY + 10
      COL nDespX
      WIDTH 220
      HEIGHT 145
      CAPTION "PolyLine"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_polyline
      ROW mg_get( "d_window" , "fb_polyline" , "row" ) + 20
      COL mg_get( "d_window" , "fb_polyline" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_polyline" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_polyline" , "height" ) - 30
      COLOR {255,0,0}
      BACKCOLOR {210,210,255}

      @ DRAW POLYLINE { {60,10} , {10,20} , {20,80} , {60,90} } COLOR {255,220,120} PENWIDTH 3
      nPoint1 := { 70,100 }
      nPoint2 := { 10,120 }
      nPoint3 := { 30,150 }
      nPoint4 := { 70,145 }
      nPoint5 := { 50,130 }
      @ DRAW POLYLINE { nPoint1 , nPoint2 , nPoint3 , nPoint4 , nPoint5 }
      @ DRAW POLYLINE { { 110,10 } , { 70,35 } , { 110,60 } } COLOR {55,255,50} PENWIDTH 2
      nPoint1 := { 110,70 }
      nPoint2 := { 75,70 }
      nPoint3 := { 110,180 }
      nPoint4 := { 75,180 }
      @ DRAW POLYLINE { nPoint1 , nPoint2 , nPoint3 , nPoint4 } COLOR {0,0,255} PENWIDTH 10

   END PAINTER

   // == Text and Points ==========================//

   nDespX := mg_get( "d_window" , "fb_polyLine" , "colRight" ) + 10
   nDespY := mg_get( "d_window" , "fb_polyLine" , "row" ) - 10

   CREATE FRAMEBOX fb_textAndPoints
      ROW nDespY + 10
      COL nDespX
      WIDTH 220
      HEIGHT 145
      CAPTION "Text and Points"
      FONTCOLOR {0,0,255}
   END FRAMEBOX

   CREATE PAINTER pt_textAndPoints
      ROW mg_get( "d_window" , "fb_textAndPoints" , "row" ) + 20
      COL mg_get( "d_window" , "fb_textAndPoints" , "col" ) + 10
      WIDTH mg_get( "d_window" , "fb_textAndPoints" , "width" ) - 20
      HEIGHT mg_get( "d_window" , "fb_textAndPoints" , "height" ) - 30
      COLOR {255,0,0}

      @ 10,10 DRAW TEXT "Marinas-GUI" WIDTH 250 HEIGHT 50 FONTCOLOR {255,0,0} FONTSIZE 15 FONTITALIC .T. PENWIDTH 2
      @ 50,130 DRAW POINT COLOR {255,220,120} PENWIDTH 20
      @ DRAW POINTS { {70,30} , {79,50} , {70,70} , {79,90} , {70,110} , {79,130} , {70,150} , {79,170} , {70,190} } COLOR {0,0,255} PENWIDTH 5
      @ DRAW POINT 100,110 COLOR {0,0,255} PENWIDTH 20

   END PAINTER

RETURN NIL



Example Circle:

File: d_painter2.prg


#include "marinas-gui.ch"

MEMVAR cPainter2Name
MEMVAR nNumber

Function main()

   PRIVATE cPainter2Name := "d_painter2"
   PRIVATE nNumber     := 33

   SET APPLSTYLE TO "MarinasLooks"

   CREATE WINDOW d_window
      ROW 0 ; COL 0
      WIDTH 820 ; HEIGHT 480
      CAPTION "Marinas-GUI Sample for Painter Control"
      ICON "../resource/d_test.ico"
      BACKCOLOR {223,242,253}
      MAIN .T.

      d_painter_def2()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

Return .T.


File: d_painter_def2.prg

#include "marinas-gui.ch"

FUNCTION d_painter_def2()

   CREATE PAINTER painterCircle
      PENWIDTH 1
      COL ( mg_get( "d_window" , "width" ) - 400 ) / 2
      ROW 0
      WIDTH 400
      HEIGHT 400
      COLOR {27,139,61}
   END PAINTER

   CREATE BUTTON painter2_b_clean
      ROW 420
      COL 100
      CAPTION "Clean painter"
      ONCLICK cleanPainter()
   END BUTTON

   CREATE BUTTON painter2_b1
      ROW 420
      COL 300
      CAPTION "DRAW circle"
      ONCLICK ( cleanPainter() , myCircle( , if( mg_get( "d_window" , "rg_multicolor" , "value" ) == 2 , .T. , .F. ) ) )
   END BUTTON

   CREATE BUTTON painter2_b2
      ROW 420
      COL 400
      CAPTION "DRAW circle slow"
      ONCLICK ( cleanPainter() , myCircle( 0.07 , if( mg_get( "d_window" , "rg_multicolor" , "value" ) == 2 , .T. , .F. ) ) )
   END BUTTON

   CREATE RADIOGROUP rg_multicolor
      ROW 420
      COL 600
      WIDTH 200
      ITEMS { "Green" , "Multicolor" }
      HORIZONTAL .T.
      VALUE 1
   END RADIOGROUP

   mg_do( "d_window" , "painter2_b1" , "onclick" )

RETURN NIL

FUNCTION cleanPainter()
   mg_do( "d_window" , "painterCircle" , "clear" )
RETURN NIL

#define DEF_PI     3.14159               /* Define a value for PI               */
#define DEF_MASPTS 16
#define COORDX     1
#define COORDY     2

FUNCTION myCircle( nDelay , lMulticolor )
   LOCAL nInx
   LOCAL nJnx
   LOCAL nHeight
   LOCAL nWidth
   LOCAL nCenterX
   LOCAL nCenterY
   LOCAL nRadius
   LOCAL nAngle
   LOCAL nStep
   LOCAL nRads
   LOCAL nCorrection
   LOCAL aPoints := {}
   DEFAULT nDelay TO 0
   DEFAULT lMulticolor TO .F.
   mg_set( "d_window" , "painter2_b_clean" , "enabled" , .F. )
   mg_set( "d_window" , "painter2_b1" , "enabled" , .F. )
   mg_set( "d_window" , "painter2_b2" , "enabled" , .F. )
   nHeight := mg_get( "d_window" , "painterCircle" , "height" )
   nWidth := mg_get( "d_window" , "painterCircle" , "height" )
   nCorrection := nWidth / nHeight
   nCenterX := nWidth / 2                /* Determine the center of circle      */
   nCenterY := nHeight / 2
   nRadius := (nHeight - 30) / (nCorrection * 2)
   nStep   := 360 / ( DEF_MASPTS - 1 )   /* Determine # of increments           */
   nAngle = 0                            /* Begin at zero degrees               */
   FOR nInx:=1 TO DEF_MASPTS             /* Determine circle intercepts         */
      nRads := nAngle * DEF_PI / 180.0   /* Convert nAngle to radians           */
      aAdd( aPoints , { nCenterX + int( cos(nRads) * nRadius ) , nCenterY - int( sin(nRads) * nRadius * nCorrection ) } )
      nAngle += nStep                    /* Move to next increment              */
   NEXT
   @ nCenterY-nRadius,nCenterX-nRadius DRAW ELLIPSE WINDOW "d_window" CONTROL "painterCircle" WIDTH nRadius*2 HEIGHT nRadius*2 /* Draw bounding circle */
   FOR nInx:=1 TO DEF_MASPTS
      FOR nJnx:=nInx TO DEF_MASPTS       /* For each remaining intersect        */
         @ aPoints[nInx][COORDX],aPoints[nInx][COORDY] TO aPoints[nJnx][COORDX],aPoints[nJnx][COORDY] DRAW LINE WINDOW "d_window" CONTROL "painterCircle" COLOR if( lMulticolor , { hb_random(0,255) , hb_random(0,255) , hb_random(0,255) } , mg_get( "d_window" , "painterCircle" , "color" ) )
         mg_wait( nDelay )
      NEXT
   NEXT
   mg_set( "d_window" , "painter2_b_clean" , "enabled" , .T. )
   mg_set( "d_window" , "painter2_b1" , "enabled" , .T. )
   mg_set( "d_window" , "painter2_b2" , "enabled" , .T. )
RETURN NIL




Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: March 09
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Jump to Donation Topic


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic