Canvas

Windows specific questions.
albert
Posts: 4802
Joined: Sep 28, 2006 2:41
Location: California, USA

Canvas

Postby albert » Dec 22, 2010 3:27

How do you create a canvas object in FB???
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Re: Canvas

Postby AGS » Dec 27, 2010 11:18

albert wrote:How do you create a canvas object in FB???


A canvas object? Please elaborate. If you want win32 api kind of stuff then there are several examples in PATH_TO_FBC/examples/windows/

For example hello.bas

Code: Select all



#include once "windows.bi"

declare function        WinMain     ( byval hInstance as HINSTANCE, _
                                      byval hPrevInstance as HINSTANCE, _
                                      byval szCmdLine as string, _
                                      byval iCmdShow as integer ) as integer
                                 
                                 
   end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )

'':::::
function WndProc ( byval hWnd as HWND, _
                   byval wMsg as UINT, _
                   byval wParam as WPARAM, _
                   byval lParam as LPARAM ) as LRESULT
   
    function = 0
   
    select case( wMsg )
        case WM_CREATE           
            exit function

        case WM_PAINT
          dim rct as RECT
          dim pnt as PAINTSTRUCT
          dim hDC as HDC
         
            hDC = BeginPaint( hWnd, @pnt )
            GetClientRect( hWnd, @rct )
           
            DrawText( hDC, _
                    "Hello, World!", _
                    -1, _
                      @rct, _
                      DT_SINGLELINE or DT_CENTER or DT_VCENTER )
           
            EndPaint( hWnd, @pnt )
           
            exit function           
       
      case WM_KEYDOWN
         if( lobyte( wParam ) = 27 ) then
            PostMessage( hWnd, WM_CLOSE, 0, 0 )
         end if

       case WM_DESTROY
            PostQuitMessage( 0 )
            exit function
    end select
   
    function = DefWindowProc( hWnd, wMsg, wParam, lParam )   
   
end function

'':::::
function WinMain ( byval hInstance as HINSTANCE, _
                   byval hPrevInstance as HINSTANCE, _
                   byval szCmdLine as string, _
                   byval iCmdShow as integer ) as integer   
     
    dim wMsg as MSG
    dim wcls as WNDCLASS     
    dim hWnd as HWND
     
    function = 0
     
    with wcls
       .style         = CS_HREDRAW or CS_VREDRAW
       .lpfnWndProc   = @WndProc
       .cbClsExtra    = 0
       .cbWndExtra    = 0
       .hInstance     = hInstance
       .hIcon         = LoadIcon( NULL, IDI_APPLICATION )
       .hCursor       = LoadCursor( NULL, IDC_ARROW )
       .hbrBackground = GetStockObject( WHITE_BRUSH )
       .lpszMenuName  = NULL
       .lpszClassName = @"HelloWin"
    end with
         
    if( RegisterClass( @wcls ) = FALSE ) then
       MessageBox( null, "Failed to register wcls", "Error", MB_ICONERROR )
       exit function
    end if
   
    hWnd = CreateWindowEx( 0, _
                       @"HelloWin", _
                           "The Hello Program", _
                           WS_OVERLAPPEDWINDOW, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           NULL, _
                           NULL, _
                           hInstance, _
                           NULL )
                         

    ShowWindow( hWnd, iCmdShow )
    UpdateWindow( hWnd )
     
    while( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )   
        TranslateMessage( @wMsg )
        DispatchMessage( @wMsg )
    wend
   
    function = wMsg.wParam

end function


hDC is the Drawing Context (the canvas). The Cairo library http://cairographics.org/manual/ can be used to draw on the canvas.

You'd need to change the WM_PAINT code (it's in
function WndProc)

Code: Select all

case WM_PAINT

dim pnt as PAINTSTRUCT
dim hDC as HDC

hDC = BeginPaint( hWnd, @pnt )
'' Create the cairo surface and context.
dim surface as cairo_surface_t ptr = cairo_win32_surface_create (hdc)
dim cr as cairo_t ptr = cairo_create (surface)
/'
start drawing on the cairo context here using cairo functions
perhaps make this a call to a function where the actual drawing takes place
'/
'Cleanup.
cairo_destroy (cr)
cairo_surface_destroy (surface)
           
EndPaint( hWnd, @pnt )


For examples of cairo usage (how to draw lines etc...) you can have a look at PATH_TO_FBC/examples/libraries/cairo/clock.bas
albert
Posts: 4802
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Dec 28, 2010 0:06

With all the complexities of windowing in FB , all the function calls and callbacks and messaging, its about as complex as XBasic and PowerBasic.

I decided to use a RAD Interpreter called WXBasic. and WXWidgets.

After i'm done i might try to redo it in FB

The writers of FB should document the supported Windowing function calls in the bi files.

Its really hard to figure out by trial and rerror.
Simple
function (parameters) , lists would be nice.. and maybe som demo support code.
albert
Posts: 4802
Joined: Sep 28, 2006 2:41
Location: California, USA

WXBasic Picto-Font

Postby albert » Dec 28, 2010 0:17

Heres What I got so far in WXBasic

Code: Select all

'Picto-Font  V1.0
'Written in WXBasic
'Written by albert_redditt@yahoo.com
'
'I Adapted and modified the Demo "Scribble" program..
'

Option Explicit

Dim progName = "Picto-Font _ Version 1.0", bmpX  = 600,  bmpY = 600

' create the frame
Dim frame as wxFrame = New wxFrame( Nothing, -1, progName )
frame.SetSize(wxSize( bmpX, bmpY ))

'==============================================================
'==============================================================
'set event values
Const   ID_BLACK        = wxID_HIGHEST + 1,
        ID_BROWN        = wxID_HIGHEST + 2,
      ID_RED          = wxID_HIGHEST + 3,
        ID_ORANGE       = wxID_HIGHEST + 4,
        ID_YELLOW       = wxID_HIGHEST + 5,
        ID_GREEN        = wxID_HIGHEST + 6,
        ID_BLUE         = wxID_HIGHEST + 7,
        ID_PURPLE       = wxID_HIGHEST + 8,
        ID_WHITE        = wxID_HIGHEST + 9,
        ID_COLOR_DIALOG = wxID_HIGHEST + 10,
      ID_8x8          = wxID_HIGHEST + 11,
      ID_8x16         = wxID_HIGHEST + 12,
      ID_12x12        = wxID_HIGHEST + 13,
      ID_12x16        = wxID_HIGHEST + 14,
      ID_16x16        = wxID_HIGHEST + 15,
      ID_24x16        = wxID_HIGHEST + 16,
      ID_24x24        = wxID_HIGHEST + 17,
      ID_24x32        = wxID_HIGHEST + 18,
      ID_32x32        = wxID_HIGHEST + 19,
      ID_B1           = wxID_HIGHEST + 20,
      ID_B2           = wxID_HIGHEST + 21,
      ID_B3           = wxID_HIGHEST + 22,
      ID_B4           = wxID_HIGHEST + 23,
      ID_B5           = wxID_HIGHEST + 24,
      ID_B6           = wxID_HIGHEST + 25,
      ID_B7           = wxID_HIGHEST + 26,
      ID_B8           = wxID_HIGHEST + 27

'================================================================
' create a "File" menu
Dim mFile as wxMenu = New wxMenu()
mFile.Append( wxID_NEW, "&New", "Erase the current drawing")
mFile.AppendSeparator()
mfile.Append( wxID_SAVEAS,"&Save as"    ,"Save to current drawing.")
mfile.Append( wxID_SAVE  ,"&Save"       ,"Save to current drawing.")
mFile.Append( wxID_EXIT  ,"E&xit\tAlt-X", "Quit this program")

' create a "Colors" menu
Dim mColor As wxMenu = New wxMenu()
mColor.Append( ID_BLACK,  "Black",  "Make the brush black.", 1 )
mColor.Append( ID_BROWN,  "Brown",  "Make the brush brown.", 1 )
mColor.Append( ID_RED,    "Red",    "Make the brush red.", 1 )
mColor.Append( ID_ORANGE, "Orange", "Make the brush orange.", 1 )
mColor.Append( ID_YELLOW, "Yellow", "Make the brush yellow.", 1 )
mColor.Append( ID_GREEN,  "Green",  "Make the brush green.", 1 )
mColor.Append( ID_BLUE,   "Blue",   "Make the brush blue.", 1 )
mColor.Append( ID_PURPLE, "Purple", "Make the brush purple.", 1 )
mColor.Append( ID_WHITE,  "White",  "Make the brush white.", 1 )
mColor.AppendSeparator()
mColor.Append( ID_COLOR_DIALOG,  "Custom",  "Choose a color from the color dialog.", 1 )

'create "Glyph-Size" menu and append items.
dim m_Glyph_Size as wxMenu = New WxMenu()
m_Glyph_Size.Append( ID_8x8  , "8x8"   , "Change Glyph size.")
m_Glyph_Size.Append( ID_8x16 , "8x16"  , "Change Glyph size.")
m_Glyph_Size.Append( ID_12x12, "12x12" , "Change Glyph size.")
m_Glyph_Size.Append( ID_12x16, "12x16" , "Change Glyph size.")
m_Glyph_Size.Append( ID_16x16, "16x16" , "Change Glyph size.")
m_Glyph_Size.Append( ID_24x16, "24x16" , "Change Glyph size.")
m_Glyph_Size.Append( ID_24x24, "24x24" , "Change Glyph size.")
m_Glyph_Size.Append( ID_24x32, "24x32" , "Change Glyph size.")
m_Glyph_Size.Append( ID_32x32, "32x32" , "Change Glyph size.")

'create "Brush Size menu and append items
dim m_Brush_Size as wxMenu = New WxMenu()
m_Brush_Size.Append(ID_B1 , "1" , "Change Brush Size.")
m_Brush_Size.Append(ID_B2 , "2" , "Change Brush Size.")
m_Brush_Size.Append(ID_B3 , "3" , "Change Brush Size.")
m_Brush_Size.Append(ID_B4 , "4" , "Change Brush Size.")
m_Brush_Size.Append(ID_B5 , "5" , "Change Brush Size.")
m_Brush_Size.Append(ID_B6 , "6" , "Change Brush Size.")
m_Brush_Size.Append(ID_B7 , "7" , "Change Brush Size.")
m_Brush_Size.Append(ID_B8 , "8" , "Change Brush Size.")

' create an "About" menu and append an item
Dim mHelp As wxMenu = New wxMenu()
mHelp.Append( wxID_ABOUT, "&About...\tCtrl-A", "Show about dialog")

' create a menubar for the menus
Dim menuBar as wxMenuBar = New wxMenuBar()
menuBar.Append(mFile , "&File" )
menuBar.Append(m_Glyph_Size , "&Glyph-Size" )
menuBar.Append(mColor, "&Color")
menuBar.Append(m_Brush_Size , "&Brush-Size" )
menuBar.Append(mHelp , "&Help" )

' attach the menubar to the frame
frame.SetMenuBar(menuBar)

'==============================================================
'=============================================================
'set program variables

'create strings to hold vectors and properties.
dim x_glyph_size  as string ="0"
dim y_glyph_size  as string ="0"
dim x_positions as string   ="0"
dim y_positions as string   ="0"
dim brush_sizes as string   ="0"
dim colors      as string   ="0"
dim draw_to     as string   ="0"
dim brush as number = 1
dim d_color as number = 1

'set values for grid/glyph
bmpx=400
bmpy=400

Dim lastX as Number = 0
Dim lastY as Number = 0
Dim mouseDown as Number = 0

' create a bitmap for double buffering
dim Glyph as wxEmptyBitmap = wxEmptyBitmap( bmpx,bmpy )
' create a store for the graphic
Dim GlyphDC as wxMemoryDC = wxMemoryDC()
GlyphDC.SelectObject( Glyph )
GlyphDC.Clear()

'create a bitmap for the Glyph_Grid
dim Grids as wxEmptyBitmap = wxEmptyBitmap( bmpx,bmpy )
'create a store for the graphic
Dim GridDC as wxMemoryDC = wxMemoryDC()
GridDC.SelectObject( Grids )
GridDC.Clear()

'set initial brush size
dim brush_size=(bmpx/(bmpx*.06 ))

' create pens   
dim Custom_Color as wxColour
dim    Black   = wxPenFromColorName( "Black" , brush_size , wxSOLID ),
      Brown   = wxPenFromColorName( "Brown" , brush_size , wxSOLID ),
      Red     = wxPenFromColorName( "Red"   , brush_size , wxSOLID ),
        Orange  = wxPenFromColorName( "Orange", brush_size , wxSOLID ),
        Yellow  = wxPenFromColorName( "Yellow", brush_size , wxSOLID ),
        Green   = wxPenFromColorName( "Green" , brush_size , wxSOLID ),
        Blue    = wxPenFromColorName( "Blue"  , brush_size , wxSOLID ),
        Purple  = wxPenFromColorName( "Purple", brush_size , wxSOLID ),
        White   = wxPenFromColorName( "White" , brush_size , wxSOLID ),
      custom  = wxPenFromColorName( Custom_Color, brush_size , wxSOLID )

' set the pen
GlyphDC.SetPen( Black )
d_color = (GlyphDC.GetPen())
mColor.Check( ID_BLACK, 1 )
dim checkedColor as Number = ID_BLACK

'=================================================
'=================================================
sub onEvent( event ) Handles frame.leftDown, frame.leftUp, frame.rightDown, frame.motion
   
   dim g_x as string
   dim g_y as string
   dim p_x as string
   dim p_y as string
   dim b_s as string
   dim d_c as string
   
   ' get event information
    Dim x = event.GetX()
    Dim y = event.GetY()

   if x>bmpx or y>bmpy then return
   if x<0 or y<0 then return
   
    Dim type = event.GetEventType()

   Dim dc as wxClientDC = wxClientDC( frame )

    ' what type of event?
    Select Case type
   Case wxEVT_LEFT_DOWN
      if !mouseDown then
         mouseDown=1
      end if
      
   Case wxEVT_LEFT_UP
      if mouseDown=1 then
         mouseDown=0
         lastX=x
         lastY=y
      end if
      
   Case wxEVT_RIGHT_DOWN
      if mouseDown=0 then
         mouseDown=0
         lastX=x
         lastY=y
      end if

   Case wxEVT_MOTION
        If mouseDown=1 Then
         mouseDown=1
      end if
    End Select
   
   if mouseDown=1 then
      g_x = append("000" , str(bmpx)): g_x=right$(g_x,3)
      g_y = append("000" , str(bmpy)): g_y=right$(g_y,3)
      x_glyph_size = append( x_glyph_size , g_x)
      y_glyph_size = append( y_glyph_size , g_y)
      
      p_x = "000" : p_x = append( p_x , str$(int(100/((bmpx/(x+1)))))) : p_x=right$(p_x,3)
      p_y = "000" : p_y = append( p_y , str$(int(100/((bmpy/(y+1)))))) : p_y=right$(p_y,3)
      x_positions  = append( x_positions , p_x)
      y_positions  = append( y_positions , p_y)
      
      b_s = "000" : b_s = append( b_s , str$( int(100/((bmpx+bmpy)/(brush_size+brush_size)))) ) : b_s = right$(b_s,3)
      brush_sizes = append(brush_sizes , b_s)
      
      d_c = "00000000000000_" : d_c = append(d_c , str$(d_color)) : d_c = right$(d_c,14)
      colors = append( colors , d_c )
      
      if lastX<>x and lastY<>y then draw_to = append(str$(draw_to ) , str$(1) )
      if lastX =X and lastY =y then draw_to = append(str$(draw_to ) , str$(0) )
      
      print "x_glyph_size = " ;x_glyph_size
      print "y_glyph_size = " ;x_glyph_size
      print "x            = " ;x_positions
      print "y            = " ;y_positions
      print "brush size   = " ;brush_sizes
      print "Colors       = " ;colors
      print "Connected    = " ;draw_to
      
      dc = wxClientDC( frame )
      GlyphDC.DrawLine( lastX, lastY, x, y )
      dc.Blit( 0, 0, bmpX, bmpY, GlyphDC, 0, 5 )
      lastX=x
      lastY=y
      
   end if
   
   'mouseDown=0
   frame.releasemouse()

   Glyph_Grid()
   
End sub

'=================================================
'=================================================
Sub onPaint( event ) Handles frame.paint

    ' get the DC of the frame
    Dim dc as wxPaintDC = wxPaintDC( frame )
    ' blit the bitmap
    dc.Blit( 0, 0, bmpX, bmpY, GlyphDC, 0, 5  )
   
   Glyph_Grid()
   
End Sub
'=================================================
'=================================================
sub Glyph_Grid()
   
   GridDC.SelectObject(Grids)
   GridDC.Clear()
   Grids= wxEmptyBitmap( bmpX,bmpY)
   GridDC.SelectObject(Glyph)
   GridDC.Clear()
   
   Dim dc as wxClientDC = wxClientDC( frame )
   dim a,b as number

   dim Xsteps as number
   dim Ysteps as number
   
   '8x8
   if bmpx=100 and bmpy=100 then
         Xsteps=100/8
         Ysteps=100/8
   end if
   '8x16
   if bmpx=100 and bmpy=200 then
         Xsteps=100/8
         Ysteps=200/16
   end if
   '12x12
   if bmpx=150 and bmpy=150 then
         Xsteps=150/12
         Ysteps=150/12
   end if
   '12x16
   if bmpx=150 and bmpy=200 then
         Xsteps=150/12
         Ysteps=200/16
   end if
   '16x16
   if bmpx=200 and bmpy=200 then
         Xsteps=200/16
         Ysteps=200/16
   end if
   '24x16
   if bmpx=300 and bmpy=200 then
         Xsteps=300/24
         Ysteps=200/16
   end if
   '24x24
   if bmpx=300 and bmpy=300 then
         Xsteps=300/24
         Ysteps=300/24
   end if
   '24x32
   if bmpx=300 and bmpy=400 then
         Xsteps=300/24
         Ysteps=400/32
   end if
   '32x32
   if bmpx=400 and bmpy=400 then
         Xsteps=400/32
         Ysteps=400/32
   end if
   
   for a = 0 to bmpx step Xsteps
      for b = 0 to bmpy step Ysteps
      dc = wxClientDC( frame )
         GridDC.Drawline(a,b ,            a , (bmpx/Xsteps) )
         GridDC.Drawline(a,b , (bmpy/Ysteps),            b  )
      next
   next
   
   GridDC.Drawline(  0   , bmpy-1 , bmpx-1,bmpy-1)
   GridDC.Drawline(bmpx-1,      0 , bmpx-1,bmpy-1)
   
   dc.Blit( 0, 0, a , b , GridDC ,0,0,6)

end sub
'=================================================
'=================================================
' callback for the New menu option
Sub OnNew( event ) Handles frame.menuSelected(wxID_NEW)
    GlyphDC.Clear()
    Dim dc as wxClientDC = wxClientDC( frame )
    dc.Blit( 0, 0, bmpX, bmpY, GlyphDC, 0, 0 )
End Sub
'=================================================
'=================================================
' callback for the Exit menu option
Sub OnQuit( event ) Handles frame.menuSelected(wxID_EXIT)
    frame.Close(True)
End Sub
'=================================================
'=================================================
' callback for the Colors menu option
Sub OnColor( event ) Handles    frame.MenuSelected(ID_BLACK),
                                frame.MenuSelected(ID_BROWN),
                        frame.MenuSelected(ID_RED),
                                frame.MenuSelected(ID_ORANGE),
                                frame.MenuSelected(ID_YELLOW),
                                frame.MenuSelected(ID_GREEN),
                                frame.MenuSelected(ID_BLUE),
                                frame.MenuSelected(ID_PURPLE),
                                frame.MenuSelected(ID_WHITE),
                                frame.MenuSelected(ID_COLOR_DIALOG)
   
   Dim id as Number = event.GetId()

    Select Case id
    Case ID_BLACK:     GlyphDC.SetPen( Black  ) : d_color = (GlyphDC.GetPen())
    Case ID_BROWN:    GlyphDC.SetPen( Brown  ) : d_color = (GlyphDC.GetPen())
    Case ID_RED:      GlyphDC.SetPen( Red    ) : d_color = (GlyphDC.GetPen())
   Case ID_ORANGE:   GlyphDC.SetPen( Orange ) : d_color = (GlyphDC.GetPen())
   Case ID_YELLOW:   GlyphDC.SetPen( Yellow ) : d_color = (GlyphDC.GetPen())
   Case ID_GREEN:    GlyphDC.SetPen( Green  ) : d_color = (GlyphDC.GetPen())
   Case ID_BLUE:     GlyphDC.SetPen( Blue   ) : d_color = (GlyphDC.GetPen())
   Case ID_PURPLE:   GlyphDC.SetPen( Purple ) : d_color = (GlyphDC.GetPen())
   Case ID_WHITE:    GlyphDC.SetPen( White  ) : d_color = (GlyphDC.GetPen())
   Case ID_COLOR_DIALOG
      ' bring up the dialog
      Dim dialog as wxColourDialog = New wxColourDialog( frame )
      If dialog.ShowModal() = wxID_OK Then
         Dim colorData as wxColourData = dialog.GetColorData()
         Custom_Color = colorData.GetColor()
         ' create the pen
         Dim CustomPen as wxPen = wxPenFromColor( Custom_Color , brush_size , wxSOLID )
         GlyphDC.SetPen( CustomPen)
         d_color = (CustomPen.GetColour())
         
      end if
    End Select
   
    ' check the menu
    mColor.Check( checkedColor, 0 )
    checkedColor = id
    mColor.Check( checkedColor, 1 )

End Sub
'=================================================
'=================================================
sub On_Brush_Size(event) handles   frame.menuSelected( ID_B1) ,
                     frame.menuSelected( ID_B2 ) ,
                     frame.menuSelected( ID_B3 ) ,
                     frame.menuSelected( ID_B4 ) ,
                     frame.menuSelected( ID_B5 ) ,
                     frame.menuSelected( ID_B6 ) ,
                     frame.menuSelected( ID_B7 ) ,
                     frame.menuSelected( ID_B8 )
   
   shared brush_size
   shared Black
    shared Brown
   shared Red   
   shared Orange
   shared Yellow
   shared Green 
   shared Blue   
   shared Purple
   shared White 
   shared Custom
   
   dim id as number = event.GetId()
   select case id
      case ID_B1
         brush_size=(bmpx/(bmpx*.06 ))
         brush=1
      case ID_B2
         brush_size=(bmpx/(bmpx*.04 ))
         brush=2
      case ID_B3
         brush_size=(bmpx/(bmpx*.025))
         brush=3
      case ID_B4
         brush_size=(bmpx/(bmpx*.02 ))
         brush=4
      case ID_B5
         brush_size=(bmpx/(bmpx*.015))
         brush=5
      case ID_B6
         brush_size=(bmpx/(bmpy*.013))
         brush=6
      case ID_B7
         brush_size=(bmpx/(bmpx*.011))
         brush=7
      case ID_B8
         brush_size=(bmpx/(bmpx*.01 ))
         brush=8
   end select
   
      Black   = wxPenFromColorName( "Black" , brush_size , wxSOLID )
      Brown   = wxPenFromColorName( "Brown" , brush_size , wxSOLID )
      Red     = wxPenFromColorName( "Red"   , brush_size , wxSOLID )
      Orange  = wxPenFromColorName( "Orange", brush_size , wxSOLID )
      Yellow  = wxPenFromColorName( "Yellow", brush_size , wxSOLID )
      Green   = wxPenFromColorName( "Green" , brush_size , wxSOLID )
      Blue    = wxPenFromColorName( "Blue"  , brush_size , wxSOLID )
      Purple  = wxPenFromColorName( "Purple", brush_size , wxSOLID )
      White   = wxPenFromColorName( "White" , brush_size , wxSOLID )
      Custom  = wxPenFromColorName( Custom_Color , brush_size , wxSOLID )
      
      if checkedColor=6000 then GlyphDC.SetPen( Black  )
      if checkedColor=6001 then GlyphDC.SetPen( Brown  )
      if checkedColor=6002 then GlyphDC.SetPen( Red    )
      if checkedColor=6003 then GlyphDC.SetPen( Orange )
      if checkedColor=6004 then GlyphDC.SetPen( Yellow )
      if checkedColor=6005 then GlyphDC.SetPen( Green  )
      if checkedColor=6006 then GlyphDC.SetPen( Blue   )
      if checkedColor=6007 then GlyphDC.SetPen( Purple )
      if checkedColor=6008 then GlyphDC.SetPen( White  )
      if checkedColor=6009 then
         Dim customPen as wxPen = wxPenFromColor( Custom_Color , brush_size , wxSOLID )
         GlyphDC.SetPen( CustomPen)
      end if

end sub
'=================================================
'=================================================
sub On_Glyph_Size(event) Handles    frame.menuSelected( ID_8x8  ),
                     frame.menuSelected( ID_8x16 ),
                     frame.menuSelected( ID_12x12),
                     frame.menuSelected( ID_12x16),
                     frame.menuSelected( ID_16x16),
                     frame.menuSelected( ID_24x16),
                     frame.menuSelected( ID_24x24),
                     frame.menuSelected( ID_24x32),
                     frame.menuSelected( ID_32x32)
   
   shared bmpx,bmpy
   
   GlyphDC.SelectObject(Glyph)
   GlyphDC.Clear()
   OnNew(wxID_NEW)
   
   Dim id as number = event.GetId()
   
   select case id
      case ID_8x8
         bmpX=10*10 : bmpY=10*10
      case ID_8x16
         bmpX=10*10 : bmpY=10*20
      case ID_12x12
         bmpX=10*15 : bmpY=10*15
      case ID_12x16
         bmpX=10*15 : bmpY=10*20
      case ID_16x16
         bmpX=10*20 : bmpY=10*20
      case ID_24x16
         bmpX=10*30 : bmpY=10*20
      case ID_24x24
         bmpX=10*30 : bmpY=10*30
      case ID_24x32
         bmpX=10*30 : bmpY=10*40
      case ID_32x32
         bmpX=10*40 : bmpY=10*40
   
   end select

   GlyphDC.SelectObject(Glyph)
   GlyphDC.Clear()
   OnNew(wxID_NEW)
   Glyph= wxEmptyBitmap( bmpX,bmpY)
   GlyphDC.SelectObject(Glyph)
   GlyphDC.Clear()
   
   Glyph_Grid()
   
end sub
'=================================================
'=================================================
' callback for the About menu option
Sub OnAbout( event ) Handles frame.menuSelected(wxID_ABOUT)
    Dim msg as String = "Picto-Font Version 1.0\n" &
         "Simple Custom Font program.\n\n" &
         "Written in WXBasic By Albert Redditt Dec-Jan/2010.\n" &
         "Email: albert_redditt@yahoo.com \n" &
         "\n" &
            "Right Click on a position in the window to set the begining coordinates.\n\n" &
         "Click on a different position to make a line between the 2 positions.\n\n" &
         "Hold the left mouse button down while moving the mouse to do freestyle drawing.\n\n" &
         "Click on the right mouse button to set a new starting point for the next mouse click.\n" &
         "\n" &
         "FreeStyle Drawing should be kept to a minimum for smaller font sizes, as each pixel is recorded.\n"&
         "\n"
    wxMessageBox( msg, "About Picto-Font", wxOK + wxICON_INFORMATION, frame )
End Sub



frame.Show(True)

AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Postby AGS » Dec 29, 2010 6:11

FB does not come with built-in GUI commands.

What you get are a bunch of functions to draw lines, circles etc.... Other things like event handling are available at a 'low level'.

To create something like your example you'd need to use GTK, IUP or some other GUI toolkit. WxBasic uses wxwidgets for it's event handling/graphics etc...

Building a GUI is (at least to me) always about callbacks, messaging etc.... It's just the way GUI building works. And looking at your program that's the way wxbasic works as well.

The wxbasic developer has chosen to use wxwidgets for gui building. The freebasic developers have chosen to let you decide what you want to use to build your gui.

And win32 api is one of the more difficult (non cross platform) options to build one. When compared to win32 api gui toolkits like gtk and iup are very easy to use.
jdebord
Posts: 511
Joined: May 27, 2005 6:20
Location: Limoges, France
Contact:

Postby jdebord » Dec 29, 2010 8:31

albert
Posts: 4802
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Dec 29, 2010 21:28

I'm using versiom 2.0 of FB and cant load cairo lib
it responds cairo2.dll not found.

I had the same problem with GMP.lib not loading due to version differences.
wallyg
Posts: 88
Joined: May 08, 2009 7:08
Location: Tucson Arizona

Re: Links not working?

Postby wallyg » Feb 24, 2012 15:51



I was looking into using Panoramic and was interested in these links but when I click on them, I get an error message of not found? Any chance these articles are available elsewhere.

Thank you
Wally

Return to “Windows”

Who is online

Users browsing this forum: Josep Roca and 2 guests