Buchempfehlung
Visual Basic 6 Kochbuch
Visual Basic 6 Kochbuch
Viele praktische Tipps zum Programmieren mit Visual Basic 6, die sich oft auch auf FB übertragen lassen. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

CustomFbTk.bi 'Eine einfache Erweiterungsdemo für FbTk

Uploader:MitgliedOneCypher
Datum/Zeit:22.10.2008 01:10:05

'CustomFbTk.bi
'Copyright Christian H. 2008
'Dieser Quelltext darf frei weitergegeben oder verändert werden.

#include once "fbtk.bi"


'Mit dem folgenden Quelltext möchte ich demonstrieren wie einfach es sein kann,
'ein neues Steuerelement für eine GFX-Gui-Engine zu programmieren.
'Weitere Steuerelemente wie Schieberegler oder ListBoxen können auf gleichen weg programmiert werden.

namespace CustomFbTk
    'Button
    type _Button
        tko as fbtk._tko                        'Es ist ein Toolkit-Objekt
        caption as string                       'Button text
    end type

    Sub ButtonRepaint(button as _button ptr)    'Übernimmt das neuzeichnen des Labels
        dim x as integer = button->tko.x
        dim y as integer = button->tko.y
        dim w as integer = button->tko.w
        dim h as integer = button->tko.h
        dim x2 as integer = button->tko.x + w
        dim y2 as integer = button->tko.y + h
        dim t as string = button->caption
        line (X,Y)-(X2,Y),RGB(255,255,255)
        line (X,Y)-(X,Y2),RGB(255,255,255)
        line (X2-1,Y+1)-(X2-1,Y2-1),RGB(128,128,128)
        line (X+1,Y2-1)-(X2-1,Y2-1),RGB(128,128,128)
        line (X2,Y)-(X2,Y2),RGB(0,0,0)
        line (X,Y2)-(X2,Y2),RGB(0,0,0)
        line (X+1,Y+1)-(X2-2,Y2-2),RGB(200,200,200),BF
        draw string (X +((X2-X)/2-(LEN(t)*4)),Y+((Y2-Y)/2)-8),t,RGB(0,0,0)
        'line (x,y)-(x2,y2),RGB(32,32,32),BF
        'draw string (x +((w/2)-(len(t)* 8/2)),y+(h/2) -8),t,RGB(255,255,255)
    end sub

    sub PressedButton(button as _button ptr)    'Wenn ein Button gedrückt wurde soll er anders gezeichnet werden
        dim x as integer = button->tko.x
        dim y as integer = button->tko.y
        dim w as integer = button->tko.w
        dim h as integer = button->tko.h
        dim x2 as integer = button->tko.x + w
        dim y2 as integer = button->tko.y + h
        dim t as string = button->caption
        line (X,Y)-(X2,Y2),RGB(0,0,0),B
        line (X+1,Y+1)-(X2-1,Y2-1),RGB(128,128,128),B
        line (X+2,Y+2)-(X2-2,Y2-2),RGB(200,200,200),BF
        draw string (X +((X2-X)/2-(LEN(t)*4))+1,Y+((Y2-Y)/2)-8+1),t,RGB(0,0,0)
    end sub

    'Folgende Funktion liefert die Addresse des neuen Buttons zurück
    function AddButton(x as integer,y as integer, w as integer, h as integer, caption as string) as _button ptr
        dim tmp_button as _button ptr = fbtk.NewTko(new _button)
        tmp_button->tko.x = x
        tmp_button->tko.y = y
        tmp_button->tko.w = w
        tmp_button->tko.h = h
        tmp_button->tko.RePaint = @ButtonRepaint
        tmp_button->tko.PreClick = @PressedButton
        tmp_button->caption = caption
        return tmp_button
    end function

end namespace