Hello, Brains Trust
I cannot seem to make the font work.
Can you see where I am going astray?
The crunchpoint is at line 52 ...
Code: Select all
;==========
; BIG Calc
;==========
#Window_Main=0
#TimesFont =1
#Up =100
#Down =101
#Escape =257
#Tab =13100
maxg =48 ;0 to 48 gadget IDs
maxx =2 ;0 to 2 columns
maxy =15 ;0 to 15 rows
Dim pos(maxx+1,maxy+1)
If OpenWindow(#Window_Main,165,0,800,25*17,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"BIG Calc")
If CreateGadgetList(WindowID())
FontID.l = LoadFont(#TimesFont, "Times New Roman", 12,#PB_Font_Bold | #PB_Font_HighQuality)
id=0
For y=0 To maxy
xpos=1
ypos=y*25
StringGadget(id,xpos,ypos,100,24,"id="+Str(id)+": name")
pos(0,y)=GadgetID(id)
id+1
xpos=101
ypos=y*25
StringGadget(id,xpos,ypos,200,24,"id="+Str(id)+": result")
pos(1,y)=GadgetID(id)
id+1
xpos=302
ypos=y*25
StringGadget(id,xpos,ypos,497,24,"id="+Str(id)+": calculation")
pos(2,y)=GadgetID(id)
id+1
Next
xpos=1
ypos=25*16+4
TextGadget(id,xpos,ypos,797,24,"id="+Str(id)+": Displaying the calculation here as formatted For the parser, for input error detection",#PB_Text_Center)
pos(0,y)=GadgetID(id)
AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Up,#Up)
AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Down,#Down)
AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Tab,#Tab)
AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Escape,#Escape)
EndIf
For id=0 To maxg
SetGadgetFont(id,#TimesFont)
Next
xpos=2
ypos=0
EndIf
ActivateGadget(2)
Repeat
EventID=WaitWindowEvent()
SetGadgetText(48,Str(EventID))
;discover the string with the focus
If EventID=#PB_Event_Menu
For x=0 To maxx
For y=0 To maxy
If GetFocus_()=pos(x,y)
xpos=x
ypos=y
EndIf
Next
Next
;I would never have thought to lookup "MenuID"!
em=EventMenuID()
Select em
Case #Up
ypos-1
If yposmaxy:ypos=0:EndIf
Case #Tab
xpos+1
If xpos>maxx:xpos=0:EndIf
Case #Escape
End
EndSelect
SetFocus_(pos(xpos,ypos))
EndIf
Until EventID=#PB_Event_CloseWindow
End
Julian ^00^
