Buchempfehlung
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Umfassend, aber leicht verständlich führt dieses Buch in die Programmierung von ATMEL AVR Mikrocontrollern ein. [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

Button.bi

Uploader:MitgliedOneCypher
Datum/Zeit:20.09.2009 17:17:13
Hinweis: Dieser Quelltext ist Bestandteil des Projekts GuiPtr, zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
Warnung: Es steht bereits eine neuere Version des Quelltexts zur Verfügung. Die hier vorliegende alte Version könnte Fehler enthalten, die in der neuen Version vielleicht ausgebessert wurden.

#include once "GuiPtr.bi"

type Button
    Object as GuiObject ptr
    Caption as string
    Pressed as ubyte
    declare constructor(left as integer, top as integer, w as integer, h as integer, GWindowtitle as string)
end type

sub DrawButton(ButtonPTR as any ptr)
    dim b as Button ptr = ButtonPTR
    with *b
        select case .pressed
        case 0
            with *.object
                line .buffer, (.left, .top)-(.left + .width, .top + .height),RGB(212,208,200),BF
                line .buffer, (.left, .top)-(.left + .width, .top + .height),RGB(64,64,64),B
                line .buffer, (.left, .top)-(.left, .top + .height),RGB(255,255,255)
                line .buffer, (.left, .top)-(.left + .width, .top),RGB(255,255,255)
                Draw string .buffer, (.left + ((.width /2) - ((len(b->caption)*8)/2)), .top + ((.height / 2) - 7)),b->caption, RGB(0,0,0)
            end with
        case 1
            with *.object
                line .buffer, (.left, .top)-(.left + .width, .top + .height),RGB(212,208,200),BF
                line .buffer, (.left, .top)-(.left + .width, .top + .height),RGB(255,255,255),B
                line .buffer, (.left, .top)-(.left, .top + .height),RGB(64,64,64)
                line .buffer, (.left, .top)-(.left + .width, .top),RGB(64,64,64)
                Draw string .buffer, (1+.left + ((.width /2) - ((len(b->caption)*8)/2)), 1+.top + ((.height / 2) - 7)),b->caption, RGB(0,0,0)
            end with
        end select
    end with
end sub

sub DrawButtonPressed(ButtonPTR as any ptr,e as EventParameter)
    dim b as Button ptr = ButtonPTR
    b->pressed = 1
    b->object->root->redraw
end sub

sub DrawButtonReleased(ButtonPTR as any ptr,e as EventParameter)
    dim b as Button ptr = ButtonPTR
    b->pressed = 0
    b->object->root->redraw
end sub

constructor Button(left as integer, top as integer, w as integer, h as integer, ButtonCaption as string)
    'Objectconstruction
    Object = new GuiObject(@This)
    with *Object
        .ClassName = "Button"
        .left = left
        .top = top
        .width = w
        .height = h
        .PrivateEvents = new Events
        with *.PrivateEvents
            .OnDraw = @DrawButton
            .OnMouseDown = @DrawButtonPressed
            .OnMouseUp = @DrawButtonReleased
        end with
    end with
    'Controlelements
    Caption = ButtonCaption
end constructor