Jeder Arbeitsbereich ein Window?
Verfasst: 13.07.2012 03:16
Hallo.
Ich bin gerade dabei, mein Programm (18tausend Compilierte Zeilen)
neu zu strukturieren.
Nun ist mir die Idee gekommen:
Für jeden Aufgabenbereich im Prg- Fenster
ein eigenes Window zu benutzen.
Dadurch lässt sich auch manches leichter gestallten.
Z.B. Sidebars, oder angeklickte Gadgets bleiben Aktiv in der Anzeige, u.s.w.
Was haltet ihr von der Idee?
Gibt es da eventuell unvorhergesehende Probleme?
Hier mal mein Code:
Gruß: Bernd
Ich bin gerade dabei, mein Programm (18tausend Compilierte Zeilen)
neu zu strukturieren.
Nun ist mir die Idee gekommen:
Für jeden Aufgabenbereich im Prg- Fenster
ein eigenes Window zu benutzen.
Dadurch lässt sich auch manches leichter gestallten.
Z.B. Sidebars, oder angeklickte Gadgets bleiben Aktiv in der Anzeige, u.s.w.
Was haltet ihr von der Idee?
Gibt es da eventuell unvorhergesehende Probleme?
Hier mal mein Code:
Code: Alles auswählen
;- /// Constanten
;-{ Windows
Enumeration
#wndprg ; das Hauptfenster
#wndtoolb; Toolbar
#wndbuch
#wndtab
#wndeingabe
EndEnumeration
;}
;- { Menues
Enumeration
#menuprg
EndEnumeration
;}
;-{ Statusbars
Enumeration
#stbarprg
EndEnumeration
;}
;-{ Gadgets
Enumeration
#box_toolb
#box_buch
#box_eingabe
#box_tab
#liid1
#combo_buch1
#toolb_zeit
EndEnumeration
;}
;-{ Fonts
Enumeration
#fontid_eingabe
#fontid_toolb
EndEnumeration
;}
;- /// Global
;-{ boxen
Global boxx_wndprg
Global boxy_wndprg
Global boxw_wndprg
Global boxh_wndprg
Global boxx_toolb
Global boxy_toolb
Global boxw_toolb
Global boxh_toolb
Global boxx_buch
Global boxy_buch
Global boxw_buch
Global boxh_buch
Global boxx_eingabe
Global boxy_eingabe
Global boxw_eingabe
Global boxh_eingabe
Global boxx_tab
Global boxy_tab
Global boxw_tab
Global boxh_tab
;}
;-{ Fonts
Global txth_eingabe
Global txtw_eingabe
Global txth_toolb
Global txtw_toolb
;}
;- /// Fonts
LoadFont(#fontid_eingabe,"",12)
LoadFont(#fontid_toolb,"courier new",14,#PB_Font_Bold)
;-
;- ====================
Procedure box_berechnen()
boxw_wndprg = WindowWidth(#wndprg)
boxh_wndprg = WindowHeight(#wndprg)
boxw_toolb = boxw_wndprg
boxh_toolb = 32
boxy_buch = 0;MenuHeight()
boxy_buch + boxh_toolb
boxw_buch = 100
boxh_buch = boxh_wndprg
boxh_buch - MenuHeight()
boxh_buch - boxh_toolb
boxh_buch - StatusBarHeight(#stbarprg)
boxx_eingabe = 0
boxh_eingabe = txth_eingabe * 5
boxy_eingabe = boxh_wndprg
boxy_eingabe - boxh_eingabe
boxy_eingabe - StatusBarHeight(#stbarprg)
boxy_eingabe - MenuHeight()
boxw_eingabe = boxw_wndprg
boxx_tab = 0
boxy_tab = boxh_toolb
boxw_tab = boxw_wndprg
boxh_tab = boxh_buch
boxh_tab - boxh_eingabe
EndProcedure
;-
;- === Resize Fenster
Procedure Resize_WndBuch()
ResizeWindow(#wndbuch,0,boxy_buch,boxw_buch,boxh_buch)
ResizeGadget(#box_buch,0,0,WindowWidth(#wndbuch),WindowHeight(#wndbuch))
EndProcedure
Procedure Resize_WndEingabe()
ResizeWindow(#wndeingabe,0,boxy_eingabe,boxw_eingabe,boxh_eingabe)
ResizeGadget(#box_eingabe,0,0,WindowWidth(#wndeingabe),WindowHeight(#wndeingabe))
EndProcedure
Procedure Resize_WndTab()
ResizeWindow(#wndtab,0,boxy_tab,boxw_tab,boxh_tab)
ResizeGadget(#box_tab,0,0,WindowWidth(#wndtab),WindowHeight(#wndtab))
ResizeGadget(#liid1,0,0,GetGadgetAttribute(#box_tab,#PB_Panel_ItemWidth),GetGadgetAttribute(#box_tab,#PB_Panel_ItemHeight))
EndProcedure
Procedure Resize_WndToolb()
ResizeWindow(#wndtoolb,0,boxy_toolb,boxw_toolb,boxh_toolb)
ResizeGadget(#box_toolb,0,0,WindowWidth(#wndtoolb),WindowHeight(#wndtoolb))
x=GadgetWidth(#box_toolb) - GadgetWidth(#toolb_zeit)
ResizeGadget(#toolb_zeit,x,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndProcedure
Procedure Resize_Winprg()
Resize_WndToolb()
Resize_WndBuch()
Resize_WndEingabe()
Resize_Wndtab()
EndProcedure
;-
;- === Create Fenster
Procedure WindowOpen(hwnd,childwnd,x,y,w,h)
;fl =#PB_Window_SystemMenu
;fl |#PB_Window_Tool
fl |#PB_Window_BorderLess
fl |#PB_Window_Invisible
If Not OpenWindow(childwnd,x,y,w,h,"",fl,WindowID(hwnd))
End
EndIf
SetWindowColor(childwnd,RGB(0,255,0))
SetParent_(WindowID(childwnd),WindowID(hwnd))
HideWindow(childwnd,0)
oldStyle=GetWindowLongPtr_(WindowID(childwnd),#GWL_STYLE)
SetWindowLongPtr_(WindowID(childwnd),#GWL_STYLE,oldStyle|#WS_CHILD &(~#WS_POPUP))
SetWindowPos_(WindowID(childwnd), 0,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED)
SetActiveWindow(hwnd)
EndProcedure
Procedure Create_Toolbar()
WindowOpen(#wndprg,#wndtoolb,0,0,boxw_toolb,boxh_toolb)
ContainerGadget(#box_toolb,0,0,WindowWidth(#wndtoolb),WindowHeight(#wndtoolb),#PB_Container_Single)
w=txtw_toolb*9
h=txth_toolb
x=GadgetWidth(#box_toolb)-w
y=(GadgetHeight(#box_toolb)-txth_toolb)/2
TextGadget(#toolb_zeit,x,y,w,h,"")
SetGadgetFont(#toolb_zeit,FontID(#fontid_toolb))
CloseGadgetList()
EndProcedure
Procedure Create_Buchbox()
WindowOpen(#wndprg,#wndbuch,0,0,boxw_buch,boxh_buch)
ContainerGadget(#box_buch,0,0,WindowWidth(#wndbuch),WindowHeight(#wndbuch),#PB_Container_Double)
SetGadgetColor(#box_buch,#PB_Gadget_BackColor,RGB(0,0,255))
ComboBoxGadget(#combo_buch1,0,0,GadgetWidth(#box_buch)-4,24)
CloseGadgetList()
EndProcedure
Procedure Create_Eingabebox()
WindowOpen(#wndprg,#wndeingabe,0,boxy_eingabe,boxw_eingabe,boxh_eingabe)
ContainerGadget(#box_eingabe,0,0,WindowWidth(#wndeingabe),WindowHeight(#wndeingabe),#PB_Container_Double)
SetGadgetColor(#box_eingabe,#PB_Gadget_BackColor,RGB(255,0,0))
CloseGadgetList()
EndProcedure
Procedure Create_Tab()
WindowOpen(#wndprg,#wndtab,0,boxy_tab,boxw_tab,boxh_tab)
PanelGadget(#box_tab,0,0,WindowWidth(#wndtab),WindowHeight(#wndtab))
;SetGadgetColor(#box_tab,#PB_Gadget_BackColor,RGB(255,255,0))
AddGadgetItem(#box_tab,-1,"Panel 1")
ListIconGadget(#liid1,0,0,GetGadgetAttribute(#box_tab,#PB_Panel_ItemWidth),GetGadgetAttribute(#box_tab,#PB_Panel_ItemHeight),"Liste 1",80,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
AddGadgetColumn(#liid1,1,"Spalte 2",60)
AddGadgetColumn(#liid1,2,"Spalte 2",60)
AddGadgetColumn(#liid1,3,"Spalte 2",60)
AddGadgetItem(#liid1,-1,"Statz 1")
CloseGadgetList()
EndProcedure
Procedure Create_wndprg()
;- wndprg
fl=#PB_Window_SystemMenu
fl|#PB_Window_MaximizeGadget
fl|#PB_Window_MinimizeGadget
fl|#PB_Window_SizeGadget
fl|#PB_Window_ScreenCentered
If Not OpenWindow(#wndprg,0,0,800,400,"Haushalt",fl)
End
EndIf
CreateMenu(#menuprg,WindowID(#wndprg))
MenuTitle("Project")
MenuItem(1, "Open" +Chr(9)+"Ctrl+O")
CreateStatusBar(#stbarprg,WindowID(#wndprg))
AddStatusBarField(90)
StartDrawing(WindowOutput(#wndprg))
DrawingFont(FontID(#fontid_eingabe))
txtw_eingabe=TextWidth ("1234567890_-aeiouAEIOUQGX") /25
txth_eingabe=TextHeight("1234567890_-aeiouAEIOUQGX")
StopDrawing()
StartDrawing(WindowOutput(#wndprg))
DrawingFont(FontID(#fontid_toolb))
txtw_toolb=TextWidth ("1234567890_-aeiouAEIOUQGX") /25
txth_toolb=TextHeight("1234567890_-aeiouAEIOUQGX")
StopDrawing()
box_berechnen()
Create_Toolbar()
Create_Tab()
Create_Eingabebox()
Create_Buchbox()
EndProcedure
Create_wndprg()
;-
Procedure Set_Zeit()
Static Zeit1$
zeit2$=FormatDate("%hh.%ii.%ss",Date())
If Not zeit1$=zeit2$
SetGadgetText(#toolb_zeit,zeit2$)
zeit1$=zeit2$
EndIf
EndProcedure
;- ====================
Procedure Events_Winprg(ev)
Select ev
Case #WM_CLOSE
ende=1
Case #PB_Event_SizeWindow
;Debug "Window Size"
box_berechnen()
Resize_Winprg()
EndSelect
ProcedureReturn ende
EndProcedure
Procedure Events_WinToolb(ev)
If ev=#WM_LBUTTONDOWN
Debug "Click auf ToolBar"
EndIf
EndProcedure
Procedure Events_WinTab(ev)
If ev=#WM_LBUTTONDOWN
Debug "Click auf Tabbox"
EndIf
EndProcedure
Procedure Events_WinBuch(ev)
If ev=#WM_LBUTTONDOWN
Debug "Click auf Buch"
EndIf
EndProcedure
Procedure Events_WinEingabe(ev)
If ev=#WM_LBUTTONDOWN
Debug "Click auf Eingabe"
EndIf
EndProcedure
;-
;- === Event Schleife
Repeat
z+1
If z=14
z1+1
If z1=WindowWidth(#wndbuch)
z1=0
EndIf
;ResizeWindow(#winbuch,z1,#PB_Ignore,#PB_Ignore,#PB_Ignore)
;SetWindowPos_(WindowID(#winbuch), WindowID(#winbuch),z1,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
MoveWindow_(WindowID(#wndbuch),-boxw_buch+z1,boxy_buch,boxw_buch,boxh_buch,1)
StatusBarText(#stbarprg,0,Str(z1))
z=0
EndIf
Set_Zeit()
ev=WaitWindowEvent(10)
Select EventWindow()
Case #wndprg
ende=Events_Winprg(ev)
Case #wndbuch
Events_WinBuch(ev)
Case #wndeingabe
Events_WinEingabe(ev)
Case #wndtab
Events_WinTab(ev)
Case #wndtoolb
Events_WinToolb(ev)
EndSelect
Until Ende