Qbasicnews.com

Full Version: FB v0.14b - may/21 - testing bug?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
this code compiled before on .13 and earlier versions of .14, now it breaks on duplicated definition of something or other.

Code:
'$include once: "wx-c/wx.bi"
#define wxCLOSE_BOX &h1000
#define FALSE 0
#define TRUE NOT(FALSE)
declare function fixstring(a as string) as string
declare sub updatedaemon(byval poos as integer)
declare sub buttonClick(byval event as long,byval iListener as long)

dim shared wx_app as wxapp ptr,wxfr as wxframe ptr,test as wxbutton ptr,thingy as integer=2
dim shared wxWindowIsShown as integer=TRUE,threads(100) as integer

function fixstring(a as string) as string
  
   dim b as byte ptr
   b=sadd(a)
   fixstring = *b
  
end function

sub ButtonClick(byval event as long, byval iListener as long)
   if thingy<26 then
      threads(thingy)=threadcreate( @updatedaemon, thingy )
      thingy+=1
   end if
end sub

sub onclose(byval event as wxEvent ptr,byval iListener as long)
   wxWindowIsShown=FALSE
   for i=1 to thingy-1
      threadwait(threads(i))
   next
   wxEvent_Skip(event,TRUE)
end sub

sub App_OnInit ()

    wxfr = wxFrame ()
    wxFrame_Create (wxfr, 0, 1, "Welcome to WX-C", wxSize ( -1, -1), wxSize ( -1, -1), wxDEFAULT_FRAME_STYLE or wxCLOSE_BOX, "frame" )
    wxWindow_SetAutoLayout(wxfr,TRUE)
    test=wxbutton()
    wxButton_Create(test,wxfr,2,"Load a file!",wxSize(-1,-1),wxSize(-1,-1),0,0,0)
    wxEvtHandler_proxy( test, @ButtonClick )
    wxEvtHandler_connect(test,wxEvent_EVT_COMMAND_BUTTON_CLICKED(),2,-1,0)
    wxEvtHandler_proxy( wxfr, @onclose )
    wxEvtHandler_connect(wxfr,wxEvent_EVT_CLOSE_WINDOW(),1,-1,0)
    wxWindow_CenterOnScreen(wxfr,wxBOTH)
    wxWindow_Show ( wxfr, 1)
    threads(1)=threadcreate( @updatedaemon, 1 )
    wxApp_OnInit(wx_app)

end sub

sub updatedaemon(byval poos as integer)
   do
      i+=1
      'locate poos,1:? i
      wxButton_SetLabel(test,str$(i))
      sleep 10
   loop while wxWindowIsShown=TRUE
   sleep poos*10
   '? "thread ";poos;" exited."
end sub

sub App_OnExit()

    ' here your code executed on exit
    dim wx_msgbox_size as wxSize ptr= wxSize ( 150, 50)
    wxMsgBox ( 0, "Bye Bye...", "Window Closed!", 0, wx_msgbox_size)
    end

end sub

' main code...

  wx_app = wxApp()
  wxApp_RegisterVirtual ( wx_app, @App_OnInit, @App_OnExit)
  wxApp_Run(0,0)

end

(ps how do i get it to hilight the stuffs?)
Actually the lastest version fixes a known bug (to me at least :P): enum's, typedef's and type's were allowed to have to same names..

Two typedef's must be removed from classes.bi: that bitmap one and wxFontEncoding - changes commited to CVS already.
ok, it works now. except on this file i tried to compile:

Code:
'$include: "wx-c/wx.bi"
#define FALSE 0
#define TRUE NOT(FALSE)
#define wxCLOSE_BOX &h1000
#define wxDefaultSize wxSize(-1,-1)
option escape

'enums at top or else they don't work

enum some_ids
   ID_NOTEBOOK         = 1
   ID_LISTBOX
   ID_LISTBOX_SORTED
   ID_LISTBOX_SEL_NUM
   ID_LISTBOX_SEL_STR
   ID_LISTBOX_APPEND
   ID_LISTBOX_DELETE
   ID_LISTBOX_FONT
   ID_LISTBOX_ENABLE
   ID_LISTBOX_CLEAR
   ID_LISTBOX_COLOUR
  
   ID_CHOICE           = 20
   ID_CHOICE_SORTED
   ID_CHOICE_SEL_NUM
   ID_CHOICE_SEL_STR
   ID_CHOICE_APPEND
   ID_CHOICE_DELETE
   ID_CHOICE_FONT
   ID_CHOICE_ENABLE
   ID_CHOICE_CLEAR
  
   ID_COMBO            = 40
   ID_COMBO_SEL_NUM
   ID_COMBO_SEL_STR
   ID_COMBO_APPEND
   ID_COMBO_DELETE
   ID_COMBO_FONT
   ID_COMBO_ENABLE
   ID_COMBO_CLEAR
  
   ID_RADIO            = 60
   ID_RADIO_SEL_NUM
   ID_RADIO_SEL_STR
   ID_RADIO_FONT
   ID_RADIO_ENABLE
   ID_RADIO_BUTTON1
   ID_RADIO_BUTTON2
  
   ID_SLIDER           = 80
   ID_SPINCTRL
   ID_SPIN
   ID_BTNPROGRESS
   ID_BITMAP_BTN
   ID_BUTTON_LABEL
  
   ID_SIZER_CHECK1     = 90
   ID_SIZER_CHECK2
   ID_SIZER_CHECK3
   ID_SIZER_CHECK4
   ID_SIZER_CHECK14
   ID_SIZER_CHECKBIG
  
   ID_SETFONT          = 100
end enum

enum Images
   List = 0
   Choice
   Combo
   Text
   Radio
   Gauge
   Max
end enum

dim shared as any ptr wx_app,wx_frame,wx_StyledText,wx_panel,wx_file,wx_textctrl
dim shared filename as string ptr,fname$

sub ButtonClick(byval event as long, byval iListener as long)
end sub

sub App_OnInit ()

    wx_Frame = wxFrame ()
    wxFrame_Create (wx_Frame, 0, 1, "Controls wxWidgets App", wxSize ( 50, 50), _
       wxSize ( 800, 430), wxDEFAULT_FRAME_STYLE or wxCLOSE_BOX, "frame" )
  
    wx_panel = wxPanel ()
    wxPanel_Create (wx_panel, wx_frame, 1, 0, 0, 0, 0)
  
    wx_textctrl=wxTextCtrl()
    wxTextCtrl_Create(wx_textctrl,wx_panel,-1,"This is the log window.\n", _
       wxSize(0,250),wxSize(792,123),wxTE_MULTILINE,0,0)
    wxTextCtrl_SetBackgroundColour(wx_textctrl,wxColour_ctorbyname("wheat"))
  
    wxLog_AddTraceMask("focus")
    wxLog_SetActiveTargetTextCtrl(wx_textctrl)
    
    dim wx_notebook as wxnotebook ptr
    wx_notebook=wxNotebook()
    wxNotebook_Create(wx_notebook,wx_panel,ID_NOTEBOOK,wxSize(1,0),wxSize(691,250),0,0)
  
    imagepath$="c:/fb/images/"
    dim imagelist as wximagelist ptr
    imagelist=wxImageList(16,16,FALSE,Max)
    dim as wxbitmap ptr listbmp,choicebmp,combobmp,textbmp,radiobmp,gaugebmp
    listbmp=wxBitmap()
    wxBitmap_LoadFile(listbmp,imagepath$+"list.bmp",wxBITMAP_TYPE_BMP)
    wxImageList_AddBitmap1(imagelist,listbmp,0)
    choicebmp=wxBitmap()
    wxBitmap_LoadFile(choicebmp,imagepath$+"choice.bmp",wxBITMAP_TYPE_BMP)
    wxImageList_AddBitmap1(imagelist,choicebmp,0)
    combobmp=wxBitmap()
    wxBitmap_LoadFile(combobmp,imagepath$+"combo.bmp",wxBITMAP_TYPE_BMP)
    wxImageList_AddBitmap1(imagelist,combobmp,0)
    textbmp=wxBitmap()
    wxBitmap_LoadFile(textbmp,imagepath$+"text.bmp",wxBITMAP_TYPE_BMP)
    wxImageList_AddBitmap1(imagelist,textbmp,0)
    radiobmp=wxBitmap()
    wxBitmap_LoadFile(radiobmp,imagepath$+"radio.bmp",wxBITMAP_TYPE_BMP)
    wxImageList_AddBitmap1(imagelist,radiobmp,0)
    gaugebmp=wxBitmap()
    wxBitmap_LoadFile(gaugebmp,imagepath$+"gauge.bmp",wxBITMAP_TYPE_BMP)
    wxImageList_AddBitmap1(imagelist,gaugebmp,0)
  
    wxNotebook_SetImageList(wx_notebook,imagelist)
    
    dim panel as wxpanel ptr
    panel=wxPanel_ctor2(wx_notebook,-1,0,0,0,0)
    wxNotebook_AddPage(wx_notebook,panel,"wxListBox",TRUE,List)
    dim choices(5) as byte ptr,choices2(2) as byte ptr
    choices(0)=callocate(6)
    *choices(0)="This"
    choices(1)=callocate(4)
    *choices(1)="is"
    choices(2)=callocate(11)
    *choices(2)="one of my"
    choices(3)=callocate(11)
    *choices(3)="wonderful"
    choices(4)=callocate(10)
    *choices(4)="examples"
    choices2(0)=callocate(7)
    *choices2(0)="First"
    choices2(1)=callocate(8)
    *choices2(1)="Second"
    dim as wxlistbox ptr listbox, listboxsorted
    listbox=wxListBox()
    wxListBox_Create(listbox,panel,ID_LISTBOX,wxSize(10,10),wxSize(120,70),5,@choices(0),wxLB_ALWAYS_SB,0,0)
    listboxSorted=wxListBox()
    wxListBox_Create(listboxSorted,panel,ID_LISTBOX,wxSize(10,90),wxSize(120,70),5,@choices(0),wxLB_SORT,0,0)
  
    dim as wxbutton ptr selectNum,selectStr,button
    selectNum=wxButton()
    wxButton_Create(selectNum,panel,-1,"Select #&2",wxSize(180,30),wxSize(150,-1),0,0,0)
  
    selectStr=wxButton()
    wxButton_Create(selectStr,panel,ID_LISTBOX_SEL_STR,"&Select 'This'",wxSize(340,30),wxSize(150,-1),0,0,0)
  
    wxButton_Create(wxButton(),panel,ID_LISTBOX_CLEAR,"&Clear",wxSize(180,80),wxSize(150, -1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_LISTBOX_APPEND,"&Append 'Hi!'",wxSize(340, 80),wxSize(150, -1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_LISTBOX_DELETE,"Delete selected item",wxSize(180,130),wxSize(150,-1),0,0,0)
    button=wxButton()
    wxButton_Create(button,panel,ID_LISTBOX_FONT,"Set &Italic font",wxSize(340,130),wxSize(150,-1),0,0,0)
    wxButton_SetDefault(button)
    
    dim checkbox as wxcheckbox ptr
    checkbox=wxCheckbox()
    wxCheckbox_Create(checkbox,panel,ID_LISTBOX_ENABLE,"&Disable",wxSize(20,170),wxSize(-1,-1),0,FALSE,0)
    wxCheckbox_Create(wxCheckbox(),panel,ID_LISTBOX_COLOUR,"&Toggle colour",wxSize(110, 170),wxSize(-1,-1),0,FALSE,0)
    'wxCursor_SetCursor(wxCursorById(wxCURSOR_HAND))
  
    panel=wxPanel_ctor2(wx_notebook,-1,0,0,0,0)
    wxNotebook_AddPage(wx_notebook,panel,"wxChoice",FALSE,Choice)
    
    dim as wxchoice ptr choicee,choiceSorted
    choicee=wxChoice()
    wxChoice_Create(choicee,panel,ID_CHOICE,wxSize(10,10),wxSize(120,-1),5,@choices(0),0,0,0)
    choiceSorted=wxChoice()
    wxChoice_Create(choiceSorted,panel,ID_CHOICE_SORTED,wxSize(10,70),wxSize(120,-1),5,@choices(0),wxCB_SORT,0,0)
  
    wxChoice_SetSelection(choicee,2)
  
    wxButton_Create(wxButton(),panel,ID_CHOICE_SEL_NUM,"Select #&2",wxSize(180,30),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_CHOICE_SEL_STR,"&Select 'This'",wxSize(340,30),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_CHOICE_CLEAR,"&Clear",wxSize(180,80),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_CHOICE_APPEND,"&Append 'Hi!'",wxSize(340, 80),wxSize(150, -1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_CHOICE_DELETE,"D&elete selected item",wxSize(180,130),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_CHOICE_FONT,"Set &Italic font",wxSize(340, 130),wxSize(150, -1),0,0,0)
    wxCheckbox_Create(wxCheckbox(),panel,ID_CHOICE_ENABLE,"&Disable",wxSize(20, 130),wxSize(-1,-1),0,FALSE,0)
  
    panel=wxPanel_ctor2(wx_notebook,-1,0,0,0,0)
    wxNotebook_Addpage(wx_notebook,panel,"wxComboBox",FALSE,Combo)
    wxStaticBox_Create(wxStaticBox(),panel,-1,"&Box around combobox",wxSize(5,5),wxSize(150,100),0,0)
    dim comboo as wxcombobox ptr
    comboo=wxComboBox()
    wxComboBox_Create(comboo,panel,ID_COMBO,"This",wxSize(20,25),wxSize(120,-1),5,@choices(0),0,0,0)
    wxButton_Create(wxButton(),panel,ID_COMBO_SEL_NUM,"Select #&2",wxSize(180,30),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_COMBO_SEL_STR,"&Select 'This'",wxSize(340,30),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_COMBO_CLEAR,"&Clear",wxSize(180,80),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_COMBO_APPEND,"&Append 'Hi!'",wxSize(340, 80),wxSize(150, -1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_COMBO_DELETE,"D&elete selected item",wxSize(180,130),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_COMBO_FONT,"Set &Italic font",wxSize(340, 130),wxSize(150, -1),0,0,0)
    wxCheckBox_Create(wxCheckBox(),panel,ID_COMBO_ENABLE,"&Disable",wxSize(20,130),wxSize(-1,-1),0,FALSE,0)
  
    panel=wxPanel_ctor2(wx_notebook,-1,0,0,0,0)
    wxNotebook_AddPage(wx_notebook,panel,"wxRadioBox",FALSE,Radio)

    wxRadioBox_Create(wxRadioBox(),panel,ID_RADIO,"&That",wxSize(10,160),wxSize(-1,-1),2,@choices2(0),1,wxRA_SPECIFY_ROWS,0,0)
    dim as wxradiobox ptr radiobox
    radiobox=wxRadioBox()
    wxRadioBox_Create(radiobox,panel,ID_RADIO,"T&his",wxSize(10,10),wxDefaultSize,5,@choices(0),1,wxRA_SPECIFY_COLS,0,0)
  
    wxButton_Create(wxButton,panel,ID_RADIO_SEL_NUM,"Select #&2",wxSize(180,30),wxSize(150,-1),0,0,0)
    dim as wxbutton ptr fontbutton
    fontButton=wxButton()
    wxButton_Create(fontButton,panel,ID_SETFONT,"Set &more Italic font",wxSize(340,30),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_RADIO_SEL_STR,"&Select 'This'",wxSize(180,80),wxSize(150,-1),0,0,0)
    wxButton_Create(wxButton(),panel,ID_RADIO_FONT,"Set &Italic Font",wxSize(340,80),wxSize(150,-1),0,0,0)
    wxCheckBox_Create(wxCheckBox(),panel,ID_RADIO_ENABLE,"&Disable",wxSize(340,130),wxSize(-1,-1),0,FALSE,0)
    wxRadioButton_Create(wxRadioButton(),panel,ID_RADIO_BUTTON1,"Radiobutton1",wxSize(210,170),wxDefaultSize,wxRB_GROUP,FALSE,0)
    wxRadioButton_Create(wxRadioButton(),panel,ID_RADIO_BUTTON2,"Radiobutton2",wxSize(340,170),wxSize(-1,-1),0,0,0)
  
  
    panel=wxPanel_ctor2(wx_notebook,-1,0,0,0,0)
    wxNotebook_AddPage(wx_notebook,panel,"wxGauge",FALSE,Gauge)
  
    wxStaticBox_Create(wxStaticBox(),panel,-1,"&wxGauge and wxSlider",wxSize(10,10),wxSize(222,130),0,0)
    dim as any ptr gauuge,gaugeVert,slider,spinctrl,spintext,spinbutton,btnprogress,grid1
    gauuge=wxGauge()
    wxGauge_Create(gauuge,panel,-1,200,wxSize(18,50),wxSize(155,30),wxGA_HORIZONTAL or wxNO_BORDER,0,0)
    gaugeVert=wxGauge()
    wxGauge_Create(gaugeVert,panel,-1,200,wxSize(195,35),wxSize(30,90),wxGA_VERTICAL or wxGA_SMOOTH or wxNO_BORDER,0,0)
    slider=wxSlider()
    wxSlider_Create(slider,panel,ID_SLIDER,0,0,200,wxSize(18,90),wxSize(155,-1),wxSL_AUTOTICKS or wxSL_LABELS,0,0)
    wxSlider_SetTickFreq(slider,40,0)
    wxStaticBox_Create(wxStaticBox(),panel,-1,"&Explanation",wxSize(230,10),wxSize(270,130),wxALIGN_CENTER,0)
    wxStaticText_Create(wxStaticText(),panel,-1, _
                           "In order to see the gauge (aka progress \n" + _
                           "bar) control do something, drag the \n" + _
                           "handle of the slider to the right\n" + _
                           "\n" + _
                           "This is also supposed to demonstrate\n" + _
                           "how to use static controls.", _
                           wxSize(250,25),wxSize(240,110),0,0)
    spinctrl=wxSpinCtrl()
    wxSpinCtrl_Create(spinctrl,panel,ID_SPINCTRL,"",wxSize(200,160),wxSize(80,-1),0,0,0,0,0)
    wxSpinCtrl_SetRange(spinctrl,10,30)
    wxSpinCtrl_SetValue(spinctrl,15)
    initialSpinValue = -5
    spintext=wxTextCtrl()
    wxTextCtrl_Create(spintext,panel,-1,"" + trim$(str$(initialSpinValue)),wxSize(20,160),wxSize(80,-1),0,0,0)
    spinbutton=wxSpinButton()
    wxSpinButton_Create(spinbutton,panel,ID_SPIN,wxSize(103,160),wxSize(80,-1),0,0)
    wxSpinButton_SetRange(spinbutton,-40,30)
    wxSpinButton_SetValue(spinbutton,initialSpinValue)
    btnProgress=wxButton()
    wxButton_Create(btnProgress,panel,ID_BTNPROGRESS,"&Show progress dialog",wxSize(300,160),wxSize(-1,-1),0,0,0)

   panel=wxPanel_ctor2(wx_notebook,-1,0,0,0,0)
   wxNotebook_AddPage(wx_notebook,panel,"wxGrid",FALSE,Grid)

grid1=wxGrid_ctorFull(panel,1000,wxSize(10,10),wxSize(400,400),1,"gridx")
grid1=wxGrid_CreateGrid(grid1,4,4,1)
    wxFrame_CreateStatusBar(wx_frame,2,0,3,"")
    wxFrame_SetStatusText(wx_frame,"Test",0)
    wxFrame_SetStatusText(wx_frame,"No file currently opened.",1)
  
    wxWindow_Show ( wx_frame, 1)

end sub


sub App_OnExit()

    ' here your code executed on exit
    wxMsgBox(wx_frame,"Bye Bye...","Window Closed!",0,wxSize(150,50))

end sub

' main code...

  wx_app = wxApp()
  wxApp_RegisterVirtual ( wx_app, @App_OnInit, @App_OnExit)
  wxApp_Run(0,0)

end

except the compiler decided to have a "Suspicious pointer assignment" warning (level 0)... how to get rid of that?
That's a new requested "feature", more to come when pointer type casting is added.

Checking the wx sources, CreateGrid returns a boolean, not a pointer:

Code:
public bool CreateGrid(int numRows, int numCols, wx.GridSelectionMode selmode);

Then, just remove the assignament.
k, thanks