goo

スプリットウィンドウ メモ (1/2)

スプリットウィンドウ メモ (1/2)
#include "Split.hsp"
newmod mod, Split, id, parent, wnd1, wnd2, x, y, w, h, posSplit, sizeSplit, typeSplit
id:スプリットバー用のウィンドウID
parent:親ウィンドウハンドル
wnd1,wnd2:分割用ウィンドウハンドル
x,y:スプリット表示領域の左上のクライアント座標
w,h:x,yからの幅(w)と高さ(h)
posSplit:x,yからのスプリットバーの表示位置
sizeSplit:スプリットバーの幅
typeSplit:0のとき横区切り、1のとき縦区切りで表示

SplitSize x, y, w, h, ps
x,y,w,h:上記と同様
ps:x,yからのスプリットバーの表示位置 但し、-1のときは現在の値を使用


Split.hsp
/***************************************************************************
 * module : Split                                                          *
 ***************************************************************************/
#module Split spData

#enum SP_HANDLE = 0
#enum SP_ID
#enum SP_HDC
#enum SP_PARENT
#enum SP_WND1
#enum SP_WND2
#enum SP_TYPE
#enum SP_MOVE
#enum SP_SIZE
#enum SP_POS
#enum SP_POSTMP
#enum SP_RECTX
#enum SP_RECTY
#enum SP_RECTW
#enum SP_RECTH
#enum SP_POINTX
#enum SP_POINTY

#define global SP_NUM	17
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
#define WM_LBUTTONUP 0x0202
#define PATINVERT 0x005A0049

#uselib "user32.dll"
#func  ReleaseCapture "ReleaseCapture"
#cfunc IsWindow "IsWindow" int
#cfunc GetDC "GetDC" int
#func  ReleaseDC "ReleaseDC" int,int
#cfunc GetParent "GetParent" int
#func  SetParent "SetParent" int,int
#func  SetProp "SetPropA" int,str,int
#func  GetProp "GetPropA" int,str
#func  RemoveProp "RemovePropA" int,str
#func  MoveWindow "MoveWindow" int,int,int,int,int,int
#func  LoadCursor "LoadCursorA" int,int
#func  SetCursor "SetCursor" int
#func  SetCapture "SetCapture" int
#func  GetCursorPos "GetCursorPos" var
#func  FillRect "FillRect" int,var,int
#func  ShowWindow "ShowWindow" int,int
#func  SetWindowLong "SetWindowLongA" int,int,int
#func  ClientToScreen "ClientToScreen" int,var
#func  InvalidateRect "InvalidateRect" int,int,int
#cfunc GetSysColorBrush "GetSysColorBrush" int
#func  CreateWindowEx "CreateWindowExA" int,str,int,int,int,int,¥
                                        int,int,int,int,int,int

#uselib "gdi32.dll"
#func  PatBlt "PatBlt" int,int,int,int,int,int
#cfunc CreateBitmap "CreateBitmap" int,int,int,int,var
#func  SelectObject "SelectObject" int,int
#func  DeleteObject "DeleteObject" int
#cfunc CreateSolidBrush "CreateSolidBrush" int
#cfunc CreatePatternBrush "CreatePatternBrush" int
#cfunc CreateDC "CreateDCA" str,int,int,int
#func  DeleteDC "DeleteDC" int

#deffunc SetSplitTmp_ var sp
	dim spt,SP_NUM
	dupptr spt,varptr(sp),SP_NUM*4
return

#deffunc GetSplitAry_
	dim spt,SP_NUM
	dupptr spt,arysp(cntsp),SP_NUM*4
return

#defcfunc SetSplitAry_ int wnd,int b
	if( b == 0 ) : dim arysp,1 : cntsp = 0
	GetProp wnd,"SPLIT" : tmp = stat
	if( tmp ){
		if( b ) : cntsp++
		arysp(cntsp) = tmp : GetSplitAry_ : return 1
	}
return 0

#deffunc DelSplitAry_
	if( cntsp ) : cntsp--
	GetSplitAry_
return

#modfunc SplitGetHandle
return spData(SP_HANDLE)

#deffunc ShowStatic_
	dim rect,4
	if( spt(SP_TYPE) ){
		rect(0) = spt(SP_RECTX)+spt(SP_POSTMP),spt(SP_RECTY)
		rect(2) = spt(SP_SIZE),spt(SP_RECTH)
		MoveWindow hStatic,rect(0),rect(1),rect(2),rect(3),1
	}
	else{
		rect(0) = spt(SP_RECTX),spt(SP_RECTY)+spt(SP_POSTMP)
		rect(2) = spt(SP_RECTW),spt(SP_SIZE)
		MoveWindow hStatic,rect(0),rect(1),rect(2),rect(3),1
	}
	if( GetParent(hStatic) != spt(SP_PARENT)) : SetParent hStatic,spt(SP_PARENT)
	ShowWindow hStatic,8
return

#deffunc FillRect_ int index
	dim rect,4
	if( spt(SP_TYPE) ){rect(0)=0,0,spt(SP_SIZE),spt(SP_RECTH)}
	else{rect(0)=0,0,spt(SP_RECTW),spt(SP_SIZE)}
	if( index != -1 ){
		hBrush = GetSysColorBrush(index)
		FillRect spt(SP_HDC),rect,hBrush
	}
	else{
		hBrush = CreateSolidBrush(0)
		FillRect spt(SP_HDC),rect,hBrush
		DeleteObject hBrush
	}
	InvalidateRect spt(SP_HANDLE),0,1
return

#deffunc PatBlt_
	FillRect_ -1
	hBitmap = CreateBitmap(8,8,1,1,grayPtn)
	hBrush = CreatePatternBrush(hBitmap)
	DeleteObject hBitmap
	SelectObject spt(SP_HDC), hBrush : hbrushOld = stat
	if( spt(SP_TYPE) ){PatBlt spt(SP_HDC),0,0,spt(SP_SIZE),spt(SP_RECTH),PATINVERT}
	else{PatBlt spt(SP_HDC),0,0,spt(SP_RECTW),spt(SP_SIZE),PATINVERT}
	SelectObject spt(SP_HDC),hbrushOld : DeleteObject hBrush
	InvalidateRect spt(SP_HANDLE),0,1
return

#deffunc SetCursor_
	if( spt(SP_TYPE) ){LoadCursor 0,32644}
	else{LoadCursor 0,32645}
	SetCursor stat
return

#deffunc SetSize_ int x,int y,int w,int h
	spt(SP_RECTX) = x,y,w,h
	if( spt(SP_RECTW) < 0 ) : spt(SP_RECTW) = 0
	if( spt(SP_RECTH) < 0 ) : spt(SP_RECTH) = 0
	if( spt(SP_POS) < 0 ) : spt(SP_POS) = 0
	tmp = spt(SP_POS) + spt(SP_SIZE)
	if( spt(SP_TYPE) ){
		if( tmp > spt(SP_RECTW) ) : spt(SP_POS) = spt(SP_RECTW) - spt(SP_SIZE)
	}
	else{
		if( tmp > spt(SP_RECTH) ) : spt(SP_POS) = spt(SP_RECTH) - spt(SP_SIZE)
	}
return

#deffunc Move_
	dim p,2 : dim rect,4
	if( spt(SP_MOVE) ){
		GetCursorPos p
		if( spt(SP_TYPE) ){
			spt(SP_POS) = p(0) - spt(SP_POINTX) + spt(SP_POSTMP)
			tmp = spt(SP_RECTW) - spt(SP_SIZE)
			if( spt(SP_POS) > tmp ) : spt(SP_POS) = tmp
		}
		else{
			spt(SP_POS) = p(1) - spt(SP_POINTY) + spt(SP_POSTMP)
			tmp = spt(SP_RECTH) - spt(SP_SIZE)
			if( spt(SP_POS) > tmp ) : spt(SP_POS) = tmp
		}
		if( spt(SP_POS) < 0 ) : spt(SP_POS) = 0
	}
	else{
		rect(0) = spt(SP_RECTX),spt(SP_RECTY)
		if( spt(SP_TYPE) ){rect(2) = spt(SP_POS),spt(SP_RECTH)}
		else{rect(2) = spt(SP_RECTW),spt(SP_POS)}
		if( SetSplitAry_(spt(SP_WND1),1) ){
			SetSize_ rect(0),rect(1),rect(2),rect(3)
			Move_ : DelSplitAry_
		}
		else{
			MoveWindow spt(SP_WND1),rect(0),rect(1),rect(2),rect(3),1
			InvalidateRect spt(SP_WND1),0,1
		}
		if( spt(SP_TYPE) ){
			rect(0) = spt(SP_RECTX)+spt(SP_POS)+spt(SP_SIZE)
			rect(1) = spt(SP_RECTY)
			rect(2) = spt(SP_RECTW)-spt(SP_POS)-spt(SP_SIZE)
			rect(3) = spt(SP_RECTH)
		}
		else{
			rect(0) = spt(SP_RECTX)
			rect(1) = spt(SP_RECTY)+spt(SP_POS)+spt(SP_SIZE)
			rect(2) = spt(SP_RECTW)
			rect(3) = spt(SP_RECTH)-spt(SP_POS)-spt(SP_SIZE)
		}
		if( SetSplitAry_(spt(SP_WND2),1) ){
			SetSize_ rect(0),rect(1),rect(2),rect(3)
			Move_ : DelSplitAry_
		}
		else{
			MoveWindow spt(SP_WND2),rect(0),rect(1),rect(2),rect(3),1
			InvalidateRect spt(SP_WND2),0,1
		}
		FillRect_ 15
	}
	ShowWindow spt(SP_HANDLE),8
	tmp = spt(SP_SIZE)
	if( spt(SP_TYPE) ){
		if( tmp > spt(SP_RECTW) ) : tmp = spt(SP_RECTW)
		rect(0) = spt(SP_RECTX)+spt(SP_POS),spt(SP_RECTY),tmp,spt(SP_RECTH)
	}
	else{
		if( tmp > spt(SP_RECTH) ) : tmp = spt(SP_RECTH)
		rect(0) = spt(SP_RECTX),spt(SP_RECTY)+spt(SP_POS),spt(SP_RECTW),tmp
	}
	MoveWindow spt(SP_HANDLE),rect(0),rect(1),rect(2),rect(3),1
return

#modfunc SplitSize int x,int y,int w,int h,int ps
	SetSplitTmp_ spData
	if( ps != -1 ) : spt(SP_POS) = ps
	if( SetSplitAry_(spt(SP_HANDLE),0) ){
		SetSize_ x,y,w,h : Move_
	}
return

#modfunc SplitGetPos
return spData(SP_POS)

#modfunc SplitSetPos int ps,int b
	SetSplitTmp_ spData
	spt(SP_POS) = ps : if( b ) : Move_
return spData(SP_POS)

#deffunc SetMove_ int bm
	dim p,2 : spt(SP_MOVE) = bm
	if( bm ){
		GetCursorPos p : spt(SP_POINTX) = p(0),p(1)
		spt(SP_POSTMP) = spt(SP_POS)
		SetCapture spt(SP_HANDLE) : ShowStatic_ : PatBlt_
	}
	else{
		ShowWindow hStatic,0 : ReleaseCapture
		if( SetSplitAry_(spt(SP_HANDLE),0) ) : Move_
	}
return

#modinit int id,int parent,int wnd1,int wnd2,¥
			int x,int y,int w,int h,¥
			int posSplit,int sizeSplit,int typeSplit

	dim rect,4 : dim spData,SP_NUM : tmpidx = ginfo(3)
	spData(SP_TYPE) = typeSplit : spData(SP_MOVE) = 0
	spData(SP_SIZE) = sizeSplit : spData(SP_RECTX) = x,y,w,h
	spData(SP_POS) = posSplit : spData(SP_ID) = id
	if( grayPtn == 0 ){
		dim grayPtn,4
		repeat 8:wpoke grayPtn,cnt*2,0x5555 << (cnt & 1):loop
	}
	spData(SP_PARENT) = parent : if( IsWindow(parent) == 0 ) : return
	spData(SP_WND1) = wnd1 : if( IsWindow(wnd1) == 0 ) : return 0
	spData(SP_WND2) = wnd2 : if( IsWindow(wnd2) == 0 ) : return 0
	if( GetParent(spData(SP_WND1)) != spData(SP_PARENT) ) : return 0
	if( GetParent(spData(SP_WND2)) != spData(SP_PARENT) ) : return 0
	if( hStatic == 0 ){
		CreateWindowEx 0,"STATIC",0,0x44000000,0,0,0,0,spData(SP_PARENT),0,0,0
		hStatic = stat
	}
	if( typeSplit ){bgscr id,sizeSplit,ginfo_dispy,2}
	else{bgscr id,ginfo_dispx,sizeSplit,2}
	spData(SP_HANDLE) = hwnd : spData(SP_HDC) = hdc
	SetWindowLong spData(SP_HANDLE),-16, 0x44000000
	SetParent spData(SP_HANDLE),spData(SP_PARENT)
	SetProp spData(SP_HANDLE),"SPLIT",varptr(spData)
	oncmd gosub *WMLBUTTONDOWN@Split, WM_LBUTTONDOWN
	oncmd gosub *WMLBUTTONUP@Split, WM_LBUTTONUP
	oncmd gosub *WMMOUSEMOVE@Split, WM_MOUSEMOVE
	gsel tmpidx
return spData(SP_HANDLE)

*WMLBUTTONDOWN@Split
	tmpid = ginfo(3) : gsel ginfo(24)
	if( SetSplitAry_(hwnd,0) ){
		SetCursor_ : SetMove_ 1
	}
	gsel tmpid
return

*WMLBUTTONUP@Split
	tmpid = ginfo(3) : gsel ginfo(24)
	if( SetSplitAry_(hwnd,0) ){
		SetMove_ 0
	}
	gsel tmpid
return

*WMMOUSEMOVE@Split
	tmpid = ginfo(3) : gsel ginfo(24)
	if( SetSplitAry_(hwnd,0) ){
		SetCursor_
		if( spt((SP_MOVE)) != 0 ) : Move_
	}
	gsel tmpid
return

#modterm
	RemoveProp spData(SP_HANDLE),"SPLIT"
return

#global
/***************************************************************************
 * End Of Split                                                            *
 ***************************************************************************/
コメント ( 0 ) | Trackback ( 0 )
« VS2008 ショー... スプリットウ... »
 
コメント
 
コメントはありません。
コメントを投稿する
 
名前
タイトル
URL
コメント
コメント利用規約に同意の上コメント投稿を行ってください。

数字4桁を入力し、投稿ボタンを押してください。