⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 container-box.zc

📁 实现树形结构
💻 ZC
字号:
//[of]:description
//[c]Abstract class for all composites
//[c]
//[cf]
//[of]:license
//[c]Code Browser - a folding text editor for programmers
//[c]Copyright (C) 2003-07 Marc Kerbiquet
//[c]
//[c]This program is free software; you can redistribute it and/or modify
//[c]it under the terms of the GNU General Public License as published by
//[c]the Free Software Foundation; either version 2 of the License, or
//[c](at your option) any later version.
//[c]
//[c]This program is distributed in the hope that it will be useful,
//[c]but WITHOUT ANY WARRANTY; without even the implied warranty of
//[c]MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//[c]GNU General Public License for more details.
//[c]
//[c]You should have received a copy of the GNU General Public License
//[c]along with this program; if not, write to the Free Software
//[c]Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//[cf]
//[of]:imports
import "graphics/geometry"
import "graphics/graphics"
import "user/box"
//[c]
import "win32/windows"
import "private/sys-graphics"
//[cf]
//[c]
//[of]:container box
//[of]:type
public struct container box : local box
	// empty
end
//[cf]
//[c]
//[of]:restricted
//[of]:initialize (parent)
public func initialize (m: container box, parent: box)
	initialize (m, parent, false)
end
//[cf]
//[of]:initialize (parent, clip with children)
//[c]Initializes the container
//[c]
//[c]ARGUMENTS
//[c]	parent
//[c]		The parent box
//[c]	clip with children
//[c]		If set, all draw in the paint method will be clipped with children.
//[c]		With this option it is possible to draw something behind children
//[c]		without flicking.
//[c]
public func initialize (m: container box, parent: box, clip with children: bool)

	initialize (super (m), parent)
	class (m) = container box class
	parent proc (m) = ^DefWindowProcA(HWND, UINT, WPARAM, LPARAM)

	def style =  base style (m)
	if clip with children
		style |= WS_CLIPCHILDREN
	end

	create window ex(
		m,
		0,
		container class name,
		nil,
		style,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		parent handle (m),
		nil,
		hinstance,
		nil)
	
end
//[cf]
//[cf]
//[of]:private
//[of]:constants
//[c]
private def container class name := "zc-container"
//[cf]
//[of]:paint (m, msg, wParam, lParam)
private func paint (
		m: container box, 
		msg: UINT, 
		wParam: WPARAM,
		lParam: LPARAM)

	def hwnd = hwnd (m)
	def rect : RECT
	if GetUpdateRect (hwnd, rect, 0) <> 0

		def ps: PAINTSTRUCT
		def hdc = BeginPaint (hwnd, ps)
		
		def r := rectangle from boundaries (
			left (rect), 
			top (rect), 
			right (rect), 
			bottom (rect))
			
		def c: local canvas
		initialize(c, hdc)
		
		on paint (m, c, r)
		
		EndPaint(hwnd, ps)
		
		// Release the canvas after the EndPaint !
		release (c)
	end
	
	return 0

end
//[cf]
//[cf]
//[cf]
//[of]:container box class
//[of]:type
public struct container box class : local box class
	// empty
end
//[cf]
//[of]:container box class
public func container box class

	def c = the container box class
	if ~ initialized
		initialized = true
		c . copy (box class)
		c . mem size = sizeof local container box class
		c . wm paint = ^paint (container box, UINT, WPARAM, LPARAM)
		c . wm size = ^wm size (box, UINT, WPARAM, LPARAM)
		c . wm command = ^wm command (box, UINT, WPARAM, LPARAM)
		c . wm notify = ^wm notify (box, UINT, WPARAM, LPARAM)
	
		def wc: local WNDCLASSA
		style (wc) = CS_DBLCLKS
		lpfnWndProc (wc) = ^ route window proc (HWND, UINT, WPARAM, LPARAM)
		cbClsExtra (wc) = 0
		cbWndExtra (wc) = 0
		hInstance (wc) = hinstance
		hIcon (wc) = nil
		hCursor (wc) = LoadCursorA (nil, IDC_ARROW)
		hbrBackground (wc) = nil
		lpszMenuName (wc) = nil
		lpszClassName (wc) = container class name
		RegisterClassA (wc):int
	end
	
	return c

end
//[c]
private def initialized = false
private def the container box class : local container box class
//[cf]
//[cf]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -