ok ich habe nur kein plan wie ich sowas in blitzmax mache, ich kenne mich grundsätzlich gut mit assermbler aus, UND ich will keine tlist benutzen weil ich nicht ganau weiss was die macht.... aber ich hoffe ihr wisst was ich meine wenn ich den code poste, ich habe 2 probleme, erst mal 1:
wie muss ich die fenster sortieren? ok, ich habe den grundplan, habe es aber noch nicht wirklich umgesetzt.....gibt es erne einfachere möglichkeit:
magt sedin, dass es etwas lang ist, aber läuft....sry für alle comments. wie muss ich die sortframes function opimieren, bzw überhaupt programmieren, ich finde es echt hard sowas zu sortieren.....omg jetzt habe ich drei englische wörter verwendet
BlitzMax: [AUSKLAPPEN] [EINKLAPPEN] SuperStrict Framework brl.retro
Import brl.timer Import brl.Graphics Import brl.GLGraphics Import brl.max2d Import brl.glmax2d Import brl.d3d7max2d Import brl.maxgui Import brl.win32maxgui
AppTitle="New"
Global win:tgadget=createwindow("New",100,100,500,500,,15-window_menu-window_status+window_hidden) Global can:tgadget=createcanvas(0,0,500,500,win) SetGraphics canvasgraphics(can)
sethotkeyevent key_x ,modifier_alt,CreateEvent(event_windowclose,win) sethotkeyevent key_escape,0 ,CreateEvent(event_windowclose,win)
Global secmil%=MilliSecs(),oldmil% AddHook FlipHook,hookflip Function hookflip:Object(id%,data:Object,context:Object) Local a%=MilliSecs() oldmil=a-secmil secmil=a EndFunction
Function drawbox(x%,y%,w%,h%) w:+x-1 h:+y-1 DrawLine x,y,w,y,False DrawLine w,y,w,h,False DrawLine w,h,x,h,False DrawLine x,h,x,y,False EndFunction
Function drawcbox(x%,y%,w%,h%,rgbl%,rgbr%) w:+x-1 h:+y-1 SetColor rgbr Shr 16,rgbr Shr 8&$ff,rgbr&$ff DrawLine w,y,w,h,False DrawLine w,h,x,h,False SetColor rgbl Shr 16,rgbl Shr 8&$ff,rgbl&$ff DrawLine x,y,w,y,False DrawLine x,h,x,y,False EndFunction
Type tev Field x%,y% Field mx%,my%,mz% Field down%,up%,first%,last%
Method area%(x1%,y1%,w1%,h1%) Return (x>=x1) And (y>=y1) And (x<=x1+w1) And (y<=y1+h1) EndMethod
Method upd() mx=0 my=0 mz=0 up=0 first=0 last=0 Select CurrentEvent.id Case event_mousemove mx=x my=y x=CurrentEvent.x y=CurrentEvent.y mx=x-mx my=y-my Case event_mousewheel mz=CurrentEvent.data
Case event_mousedown Local a%=1 Shl (CurrentEvent.data-1) If Not down Then first=a down:|a Case event_mouseup Local a%=1 Shl (CurrentEvent.data-1) down:&~a If Not down Then last=a up=a EndSelect EndMethod EndType
Type tframe Field x%,y%,w%,h% Field prev:tframe Field lvl% Field opt%
Global gx%,gy%,gw%,gh% Global vx%,vy%,vw%,vh% Global active:tframe Global ox%,oy%
Method draw() Abstract
Method reset(xx%,yy%,ww%,hh%,p:tframe=Null) x=xx y=yy w=ww h=hh prev=p lvl=0 While p lvl:+1 p=p.prev Wend EndMethod Method posglobal(xx%,yy%) x=xx y=yy Local p:tframe=prev While p x:-p.x y:-p.y p=p.prev Wend EndMethod
Method get%() gx=x gy=y gw=w gh=h vx=x vy=y vw=w vh=h Local p:tframe=prev While p gx:+p.x gy:+p.y If (vx<0) Then vw:+vx vx=0 EndIf If (vy<0) Then vh:+vy vy=0 EndIf If (vx+vw>p.w) Then vw=p.w-vx If (vy+vh>p.h) Then vh=p.h-vy vx:+p.x vy:+p.y p=p.prev Wend Return (vw>0) And (vh>0) EndMethod
Method upd%(ev:tev) If active And (active<>Self) Then Return False If Not get() Then If ev.last Then opt:&~$3 active=Null EndIf Return False EndIf
If ev.area(vx,vy,vw,vh) Then opt:|$1 If ev.first Then active=Self opt:|$2 ox=gx-ev.x oy=gy-ev.y EndIf If (ev.last&$1) And (active=Self) Then opt:~$80 Else opt:&~$1 EndIf
If ev.last Then opt:&~$2 active=Null EndIf Return True EndMethod EndType
Type tframe_empty Extends tframe Method upd%(ev:tev)
Super.upd(ev) If opt&$2 Then posglobal ev.x+ox,ev.y+oy
EndMethod
Method draw() If Not get() Then Return SetViewport vx,vy,vw,vh If opt&$2 Then SetColor 255,255,255 Else SetColor 0,255,0
drawbox gx,gy,gw,gh SetViewport 0,0,canw,canh DrawText Bin(opt),gx,gy EndMethod EndType
Type tframe_but Extends tframe Field txt$,tx%,ty%
Method set(t$) txt=t tx=(w-TextWidth(txt))/2 ty=(h-TextHeight(txt))/2 EndMethod
Method upd%(ev:tev) Return Super.upd(ev) EndMethod
Method draw() If Not get() Then Return SetViewport vx,vy,vw,vh If (opt&$1) Then SetColor 0,96,96 Else SetColor 0,0,128 If (opt&$2) Then SetColor 0,128,128 DrawRect gx+1,gy+1,gw-1,gh-1
If (opt&$80) Then drawcbox gx,gy,gw,gh,$00008888,$0000ffff Else drawcbox gx,gy,gw,gh,$0000ffff,$00008888 SetColor 255,255,255 DrawText txt,gx+tx,gy+ty EndMethod EndType
Type tframe_win Extends tframe Field border%=12
Method upd%(ev:tev) Super.upd(ev) If (opt&$2) Then If (ev.down&$1) Then posglobal ev.x+ox,ev.y+oy
If (ev.down&$2) Then w:+ev.mx h:+ev.my EndIf EndIf EndMethod
Method draw() If Not get() Then Return SetViewport vx,vy,vw,vh SetColor 0,0,0 DrawRect gx+1,gy+1,gw-2,gh-2 SetColor 255,255,255 drawbox gx,gy,gw,gh DrawLine gx+1,gy+border,gx+gw-1,gy+border,False DrawLine gx+gw-border,gy+1,gx+gw-border,gy+gh-1,False DrawLine gx+gw-1,gy+gh-border,gx,gy+gh-border,False DrawLine gx+border,gy+gh-1,gx+border,gy,False EndMethod EndType
Function sorttframe(f:tframe[]) If Not f[0].active Or (f[0].active=f[0]) Then Return Local a%=f.length While a a:-1 If (f[a]=f[0].active) Then Exit Wend Local l%=a For Local b%=a Until f.length
If f[b].lvl<=f[l].lvl Then Local x:tframe=f[b] f[b]=f[l] f[l]=x l=b EndIf Next EndFunction
Global ev:tev=New tev Global canw%=clientwidth(can) Global canh%=clientheight(can)
Global tf:tframe[6] tf[0]=New tframe_empty tf[0].reset 50,50,canw-100,canh-100 tf[0].upd ev tf[1]=New tframe_empty tf[1].reset 50,30,canw-170,canh-170,tf[0] tf[2]=New tframe_but tf[2].reset 20,0,90,20,tf[1] tframe_but(tf[2]).set "Hello" tf[3]=New tframe_but tf[3].reset 20,30,90,20,tf[1] tframe_but(tf[3]).set "aha" tf[4]=New tframe_win tf[4].reset 60,5,130,80,tf[1] tf[5]=New tframe_but tf[5].reset 10,4,50,40,tf[4] tframe_but(tf[5]).set "win"
showgadget win
SetClsColor 64,64,64 Global timer:ttimer=CreateTimer(25) Repeat WaitEvent
Select CurrentEvent.id Case event_windowclose Exit Case event_gadgetpaint,event_timertick Cls For Local a%=0 Until tf.length
tf[a].draw Next SetViewport 0,0,canw,canh
Flip
Default ev.upd For Local a%=tf.length-1 To 0 Step-1
tf[a].upd ev Next sorttframe tf EndSelect Forever
~EDITIERT~ : code-tags
Xeres
|