brauche Euren beistand beim Programmieren unter Linux. Erstes Prob war, dass die Installationsroutine (aktuelles Kubuntu 64) nicht funzen wollte, checkinstall verlangt Komponenten, die das aktuelle Kubuntu scheinbar nicht hat.
Programmieren klappt scheinbar trotzdem (soweit ich das nach nur wenigen Schritten im Neuland beurteilen kann), allerdings nicht ohne - ... - nennen wir es mal "Erscheinungen".
Mein erster Test mit
Code: Alles auswählen
Enumeration
#parentwin
#parentstatusbar
#appfont
EndEnumeration
;- Variablen
Global wwevent.i, progend.i, but1.i, txt1.i, appfontid.i, windowcol.i
Define hFont.i
;- Canvasbutton
Structure buttondata
xpos.i
ypos.i
xpixel.i
ypixel.i
fgcol.i
fgcolhover.i
bgcol.i
bgcolhover.i
text.s
EndStructure
Global Dim cgbuttons.buttondata(10)
Global cgb0, cgb1, cgb2, cgb3, cgb4, cgb5, cgb6, cgb7, cgb8, cgb9
Procedure.i LoadPrivateFont(strFontFile.s, strFontFace.s, *pFontStart, *pFontEnd, iPointSize.i, iFlags.i = 0)
Protected hFont.i
Protected hFile.i
strFontFile = GetTemporaryDirectory() + strFontFile
If FileSize(strFontFile) = -1
hFile = CreateFile(#PB_Any, strFontFile)
If hFile
WriteData(hFile, *pFontStart, *pFontEnd - *pFontStart)
CloseFile(hFile)
EndIf
EndIf
RegisterFontFile(strFontFile)
hFont = LoadFont(#PB_Any, strFontFace, iPointSize, iFlags)
If Not IsFont(hFont)
hFont = GetGadgetFont(#PB_Default)
EndIf
ProcedureReturn hFont
EndProcedure
Procedure drawcgbutton(gadgetnum.i,cgb.i)
If StartDrawing(CanvasOutput(gadgetnum))
DrawingMode(#PB_2DDrawing_Transparent)
;RoundBox(0, 0, GadgetWidth(gadgetnum), GadgetHeight(gadgetnum), 3,3, cgbuttons.buttondata(cgb)\bgcol)
Box(0, 0, GadgetWidth(gadgetnum), GadgetHeight(gadgetnum), cgbuttons.buttondata(cgb)\bgcol)
DrawingFont(appfontid)
Breite = TextWidth(cgbuttons.buttondata(cgb)\text) : x = ((GadgetWidth(gadgetnum) - Breite) / 2)
Hoehe = TextHeight(cgbuttons.buttondata(cgb)\text) : y = ((GadgetHeight(gadgetnum) - Hoehe) / 2) -1
DrawText(x, y, cgbuttons.buttondata(cgb)\text , cgbuttons.buttondata(cgb)\fgcol)
StopDrawing()
ProcedureReturn 1
EndIf
EndProcedure
Procedure drawcgbuttonhover(gadgetnum.i,cgb.i)
If StartDrawing(CanvasOutput(gadgetnum))
DrawingMode(#PB_2DDrawing_Transparent)
;RoundBox(0, 0, GadgetWidth(gadgetnum), GadgetHeight(gadgetnum), 3,3, cgbuttons.buttondata(cgb)\bgcolhover)
Box(0, 0, GadgetWidth(gadgetnum), GadgetHeight(gadgetnum), cgbuttons.buttondata(cgb)\bgcolhover)
DrawingFont(appfontid)
Breite = TextWidth(cgbuttons.buttondata(cgb)\text) : x = ((GadgetWidth(gadgetnum) - Breite) / 2)
Hoehe = TextHeight(cgbuttons.buttondata(cgb)\text) : y = ((GadgetHeight(gadgetnum) - Hoehe) / 2) -1
DrawText(x, y, cgbuttons.buttondata(cgb)\text , cgbuttons.buttondata(cgb)\fgcolhover)
StopDrawing()
ProcedureReturn 1
EndIf
EndProcedure
Procedure createcgbutton(cgb.i)
gadgetnum.i = CanvasGadget(#PB_Any, cgbuttons.buttondata(cgb)\xpos, cgbuttons.buttondata(cgb)\ypos, cgbuttons.buttondata(cgb)\xpixel, cgbuttons.buttondata(cgb)\ypixel)
If gadgetnum
If StartDrawing(CanvasOutput(gadgetnum))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0, 0, GadgetWidth(gadgetnum), GadgetHeight(gadgetnum), windowcol)
StopDrawing()
If drawcgbutton(gadgetnum, cgb) = 1
ProcedureReturn gadgetnum
EndIf
Else
ProcedureReturn 0
EndIf
Else
ProcedureReturn 0
EndIf
EndProcedure
OpenWindow(#parentwin, 0, 0, 600, 600, "colbutton", #PB_Window_SystemMenu)
windowcol = RGB(255,255,255)
SetWindowColor(#parentwin,windowcol)
appfontid = FontID(LoadPrivateFont("YanoneKaffeesatz-Regular.ttf", "Yanone Kaffeesatz", ?start_myfont, ?end_myfont, 18))
SetGadgetFont(#PB_Default, appfontid)
cgbuttons.buttondata(0)\xpos = 10
cgbuttons.buttondata(0)\ypos = 10
cgbuttons.buttondata(0)\xpixel = 200
cgbuttons.buttondata(0)\ypixel = 30
cgbuttons.buttondata(0)\fgcol = RGB(255,255,255)
cgbuttons.buttondata(0)\fgcolhover = RGB(0,0,255)
cgbuttons.buttondata(0)\bgcol = RGB(255,0,0)
cgbuttons.buttondata(0)\bgcolhover = RGB(255,255,0)
cgbuttons.buttondata(0)\text = "Guggenheimer Ypsilon"
cgbuttons.buttondata(1)\xpos = 10
cgbuttons.buttondata(1)\ypos = 50
cgbuttons.buttondata(1)\xpixel = 200
cgbuttons.buttondata(1)\ypixel = 30
cgbuttons.buttondata(1)\fgcol = RGB(255,255,255)
cgbuttons.buttondata(1)\fgcolhover = RGB(0,0,0)
cgbuttons.buttondata(1)\bgcol = RGB(255,0,0)
cgbuttons.buttondata(1)\bgcolhover = RGB(255,0,255)
cgbuttons.buttondata(1)\text = "Lago Maggiore"
cgb0 = createcgbutton(0)
cgb1 = createcgbutton(1)
Repeat
wwevent= WaitWindowEvent()
Select wwevent
Case #PB_Event_CloseWindow
DeleteFile(GetTemporaryDirectory() + "YanoneKaffeesatz-Regular.ttf")
progend= #True
Case #PB_Event_Gadget
Select EventGadget()
Case cgb0
x_mouse = GetGadgetAttribute(cgb0, #PB_Canvas_MouseX)
y_mouse = GetGadgetAttribute(cgb0, #PB_Canvas_MouseY)
Select EventType()
Case #PB_EventType_LeftClick
If x_mouse <= GadgetWidth(cgb0) And y_mouse <= GadgetHeight(cgb0)
Debug "cgb0 links klick"
EndIf
Case #PB_EventType_RightClick
If x_mouse <= GadgetWidth(cgb0) And y_mouse <= GadgetHeight(cgb0)
Debug "cgb0 rechts klick"
EndIf
Case #PB_EventType_MouseEnter
drawcgbuttonhover(cgb0,0)
Debug "cgb0 maus drin"
Case #PB_EventType_MouseLeave
drawcgbutton(cgb0,0)
Debug "cgb0 maus raus"
EndSelect
Case cgb1
x_mouse = GetGadgetAttribute(cgb1, #PB_Canvas_MouseX)
y_mouse = GetGadgetAttribute(cgb1, #PB_Canvas_MouseY)
Select EventType()
Case #PB_EventType_LeftClick
If x_mouse <= GadgetWidth(cgb1) And y_mouse <= GadgetHeight(cgb1)
Debug "cgb1 links klick"
EndIf
Case #PB_EventType_RightClick
If x_mouse <= GadgetWidth(cgb1) And y_mouse <= GadgetHeight(cgb1)
Debug "cgb1 rechts klick"
EndIf
Case #PB_EventType_MouseEnter
drawcgbuttonhover(cgb1,1)
Debug "cgb1 maus drin"
Case #PB_EventType_MouseLeave
drawcgbutton(cgb1,1)
Debug "cgb1 maus raus"
EndSelect
EndSelect
EndSelect
Until progend
End
DataSection
start_myfont:
IncludeBinary "/home/chef/purebasic/examples/sources/yk/YanoneKaffeesatz-Regular.ttf"
end_myfont:
EndDataSection
funktioniert teilweise - beispielsweise nicht das SetWindowColor. Die Programmierumgebung folgende "Kommentare" ab:
[09:45:42] Warte auf den Start des Executable...
[09:45:42] Executable-Typ: Linux - x64 (64bit, Unicode)
[09:45:42] Executable gestartet.
[09:45:42] [WARNING] colbutton.pb (Zeile: 1)
[09:45:42] [WARNING] GLib-GIO (DEBUG): _g_io_module_get_default: Found default implementation local (GLocalVfs) for âgio-vfsâ
[09:46:24] Die Programmausführung ist abgeschlossen.
(in der vorletzten Zeile werden nach dem â noch jeweils 2 "sonderbare quadratische Schriftzeichen" gezeigt, die hier nicht wiedergegeben werden)
Was hat es mit den beiden "Warnings" auf sich?
Wie bekommt man das SetWindowColor in den Griff?