OpenSero
;
;  OpenSero
;  (動作OS NT系OS)
screen 0,,,2
#packopt name "sero"
#define navigate "Navigate"
#include "kernel32.as"
#include "user32.as"
#define WS_EX_LAYERED $80000
#define LWA_COLORKEY 1
#define ULW_ALPHA 2
#include "mod_stbar.as"
#include "hspext.as"
onerror *errmes
ver="0.0.0.1"
dim OSVERSIONINFO, 37
OSVERSIONINFO = $94
GetVersionEx varptr(OSVERSIONINFO)
bgscr 1 , 320 , 540 , 9 , ginfo(20)/2-160 , ginfo(21)/2-270 , 320 , 540
color 223,223,223
boxf 0 , 0 , 320 , 540
color 32,32,32
font "メイリオ" , 32
pos 128,424:mes "Sero"
font "MS Gothic" , 16
pos 16,540-32:mes "Please wait"
title "起動中..."
daig=0
if OSVERSIONINFO.4 = 1 {
	dialog "Seroをダウンロードして頂きありがとうございます。\nこのエディターは、Windows9xではご利用いただくことができません。\nNT系OSでご利用ください。",1,"互換性のないアプリケーション"
	end
}
notesel ver
notesave "sero.ini"
onexit *endbtn
*start
	screen 1 , 640 , 480 , 2 , -1 , -1 , 640 , 480
	color 191,191,191
	boxf 0 , 0 , 640 , 480
	color 223 , 223 , 223
	boxf 64 , 0 , 112 , 32
	color 223,32,32
	boxf 112 , 0 , 176 , 32
	bgscr 0 , ginfo(20) , ginfo(21) , 0 , (ginfo(20)-1280)/2 , (ginfo(21)-768)/2
	gsel ,2
	mci "stop A"
	stbar_ini
	oncmd gosub *event_WM_SIZE, 0x0005
	stbar_text "起動中"
	title "Sero"
	width 1280 , 768
	color 0 , 128 , 255
	boxf 0 , 0 ,1280 , 768
	color 223 , 223 , 223
	boxf 1 , 1 , 1278 , 766
	font "MS ゴシック",16,0
	cr=223
	cg=223
	cb=223
	color 32,32,32
	pos 4 , 4:mes "Sero"
	sysfont 0
	GetWindowLong hwnd, -20
	SetWindowLong hwnd, -20, stat | WS_EX_LAYERED
	SetLayeredWindowAttributes hwnd, 0,243, ULW_ALPHA
	objmode 1
	sdim buf,12800000			; テキストのバッファを確保
	buf=""				; バッファをクリア
	name=""
	buf={"<!DOCTYPE>\n<HTML>\n<HEAD>\n<title>Hello.world</title>\n</HEAD>\n<BODY>\n<h1>Hello.world</h1>\nHello.world\n</BODY>\n</HTML>"}
	sample={"<!DOCTYPE>\n<HTML>\n<HEAD>\n<title></title>\n</HEAD>\n<BODY bgcolor="#dfdfdf" text="#323232" link="#0080ff" alink="#0080ff" vlink="#0080ff">\n<script>\nalert("OpenSeroをご利用いただきありがとうございます。")\n</script>\n<h1>OpenSeroをご利用いただきありがとうございます。</h1>\n<p>\n本アプリケーションは、HTMLを簡単に書くために作成されました。<p>\n<p>\n<p>\ncreate by 太郎ちゃんチャンネル\n</BODY>\n</HTML>"}
	flg=1				; 0=編集不可/1=編集可能
	pos 2 , 66:mesbox buf,1276/2,675,flg+4,0	; 最大サイズ編集許可
	objsize 64,32
	objimage 1, 0, 0
	pos 2,32:button "読み込み",*file_load
	pos 68,32:button "保存",*file_save
	pos 1280/2+2,32:button "更新",*reie
	objsize 48,32
	objimage 1, 64, 0 , 112 , 0 , 112 , 0
	pos 1230,2:button "×",*endbtn
	objimage 1, 64, 0 , 64 , 32 , 64 , 32
	pos 1182,2:button "□",*dai
	pos 1134,2:button "─",*syo
	pos 1086,2:button "C",*col
	pos 1280/2+2,64
	axobj ie, "Shell.Explorer.2", 1280/2-4, 675
	if stat == -1 {
		dialog "プレビュー表示を準備出来ませんでした。", 1
		goto *start
	}
	ie -> "Navigate" "about:blank"
	await 70
	doc = ie("Document")
	doc -> "write" sample
	name = ie("LocationURL")
	pDoc = ie("Document")
	name = pDoc("Title")
	color cr , cg , cb
	boxf 1 , 1 , 1278 , 32
	font "MS ゴシック",16,0
	cc=cr+cg+cb
	if cc > 384 {
		color 0,0,0
		pos 4,4:mes "Sero  "+name
	}
	if cc <= 384 {
		color 255,255,255
		pos 4,4:mes "Sero  "+name
	}
	title "Sero  "+name
	sysfont 0
	onclick gosub *click
	onkey gosub *keychk
	stbar_text "起動完了"
*main
	stop
*keychk
	if buf = "err" {
		errerr="err"*3
	}
	stbar_text "編集中..."
	goto *main
*file_save
	stbar_text "保存作業中"
	buf=buf+"\n\n<!-- OpenSeroで作成 -->\n<!-- by太郎ちゃんチャンネル うp主 -->"
	dialog "html",17
	if stat=0 : goto *dlcan
	fname = refstr
	exname=getpath(fname,2)		; ファイル名の拡張子を取得
	if exname="" : fname+=".html"	; 拡張子がなければ.txtを追加
	notesel buf
	notesave fname			; テキストファイルをセーブ
	stbar_text "保存完了"
*dlcan
	stop
*file_load
	stbar_text "読み込み作業中"
	dialog "html",16
	if stat=0 : goto *dlcan2
	notesel buf
	noteload refstr			; テキストファイル読み込み
	objprm 1,buf
	goto *keychk
	stbar_text "読み込み完了"
*dlcan2
	stop
*endbtn
	dialog "編集中のページが破棄されます。\nよろしいですか?" , 3 , "選択"
	if stat = 7 {
		stop
	}
	end
*dai
	if daig = 0 {
		bgscr 0 , ginfo(20) , ginfo(21) , 0 , 0 , 0 , ginfo(20) , ginfo(21)
		title "Sero"
		GetWindowLong hwnd, -20
		SetWindowLong hwnd, -20, stat | WS_EX_LAYERED
		SetLayeredWindowAttributes hwnd, 0,243, ULW_ALPHA
		color 0 , 128 , 255
		boxf 0 , 0 ,ginfo(20) , ginfo(21)
		color 223 , 223 , 223
		boxf 1 , 1 , ginfo(20)-2 , ginfo(21)-2
		font "MS ゴシック",16,0
		cr=223
		cg=223
		cb=223
		color 32,32,32
		pos 4 , 4:mes "Sero"
		sysfont 0
		flg=1				; 0=編集不可/1=編集可能
		pos 2 , 66:mesbox buf,(ginfo(20)-4)/2,ginfo(21)-93,flg+4,0	; 最大サイズ編集許可
		objsize 64,32
		objimage 1, 0, 0
		pos 2,32:button "読み込み",*file_load
		pos 68,32:button "保存",*file_save
		pos ginfo(20)/2+2,32:button "更新",*reie
		objsize 48,32
		objimage 1, 64, 0 , 112 , 0 , 112 , 0
		pos ginfo(20)-50,2:button "×",*endbtn
		objimage 1, 64, 0 , 64 , 32 , 64 , 32
		pos ginfo(20)-98,2:button "■",*dai
		pos ginfo(20)-146,2:button "─",*syo
		pos ginfo(20)-194,2:button "C",*col
		pos ginfo(20)/2+2,64
		axobj ie, "Shell.Explorer.2", ginfo(20)/2-4, ginfo(21)-93
		if stat == -1 {
			dialog "プレビュー表示を準備出来ませんでした。", 1
			goto *start
		}
		ie -> "Navigate" "about:blank"
		await 70
		doc = ie("Document")
		doc -> "write" buf
		name = ie("LocationURL")
		pDoc = ie("Document")
		name = pDoc("Title")
		color cr , cg , cb
		boxf 1 , 1 , ginfo(20)-2 , 32
		font "MS ゴシック",16,0
		cc=cr+cg+cb
		if cc > 384 {
			color 0,0,0
			pos 4,4:mes "Sero  "+name
		}
		if cc <= 384 {
			color 255,255,255
			pos 4,4:mes "Sero  "+name
		}
		title "Sero  "+name
		sysfont 0
		stbar_ini
		daig=1
		stop
	}
	if daig = 1 {
		bgscr 0 , ginfo(20) , ginfo(21) , 0 , (ginfo(20)-1280)/2 , (ginfo(21)-768)/2
		stbar_ini
		oncmd gosub *event_WM_SIZE, 0x0005
		title "Sero"
		width 1280 , 768
		color 0 , 128 , 255
		boxf 0 , 0 ,1280 , 768
		color 223 , 223 , 223
		boxf 1 , 1 , 1278 , 766
		font "MS ゴシック",16,0
		cr=223
		cg=223
		cb=223
		color 32,32,32
		pos 4 , 4:mes "Sero"
		sysfont 0
		GetWindowLong hwnd, -20
		SetWindowLong hwnd, -20, stat | WS_EX_LAYERED
		SetLayeredWindowAttributes hwnd, 0,243, ULW_ALPHA
		objmode 1
		flg=1				; 0=編集不可/1=編集可能
		pos 2 , 66:mesbox buf,1276/2,675,flg+4,0	; 最大サイズ編集許可
		objsize 64,32
		objimage 1, 0, 0
		pos 2,32:button "読み込み",*file_load
		pos 68,32:button "保存",*file_save
		pos 1280/2+2,32:button "更新",*reie
		objsize 48,32
		objimage 1, 64, 0 , 112 , 0 , 112 , 0
		pos 1230,2:button "×",*endbtn
		objimage 1, 64, 0 , 64 , 32 , 64 , 32
		pos 1182,2:button "□",*dai
		pos 1134,2:button "─",*syo
		pos 1086,2:button "C",*col
		pos 1280/2+2,64
		axobj ie, "Shell.Explorer.2", 1280/2-4, 675
		if stat == -1 {
			dialog "プレビュー表示を準備出来ませんでした。", 1
			goto *start
		}
		ie -> "Navigate" "about:blank"
		await 70
		doc = ie("Document")
		doc -> "write" buf
		name = ie("LocationURL")
		pDoc = ie("Document")
		name = pDoc("Title")
		color cr , cg , cb
		boxf 1 , 1 , 1278 , 32
		font "MS ゴシック",16,0
		cc=cr+cg+cb
		if cc > 384 {
			color 0,0,0
			pos 4,4:mes "Sero  "+name
		}
		if cc <= 384 {
			color 255,255,255
			pos 4,4:mes "Sero  "+name
		}
		title "Sero  "+name
		sysfont 0
		daig=0
	}
	stop
*syo
	sendmsg hwnd, $112, $F020
	stop
*col
	dialog "背景色を選択",32,"背景色色を選択"
	if stat=1 {
		cr=ginfo_r
		cg=ginfo_g
		cb=ginfo_b
		dr=cr-32
		dg=cg-32
		db=cb-32
		color cr , cg , cb
		boxf 1 , 1 , 1278 , 766
		gsel 1
		color dr , dg , db 
		boxf 0 , 0 , 640 , 480
		color cr , cg , cb
		boxf 64 , 0 , 112 , 32
		color 223,32,32
		boxf 112 , 0 , 176 , 32
		gsel 0
	}
	color cr , cg , cb
	boxf
	font "MS ゴシック",16,0
	cc=cr+cg+cb
	if cc > 384 {
		color 0,0,0
		pos 4,4:mes "Sero  "+name
	}
	if cc <= 384 {
		color 255,255,255
		pos 4,4:mes "Sero  "+name
	}
	sysfont 0
	stop
*errmes
	dialog "例外が発生しました。\nご迷惑をお掛けしております。\n\nエラー内容="+wparam+"\nコード="+lparam+"\n\n[OK]を押すと診断情報を保存します。",1,"例外が発生しました"
	er="Sero"+ver+"\nエラー内容="+wparam+"\nコード="+lparam
	notesel er
	notesave "error.log"			; テキストファイルをセーブ
	dialog dir_exe+"\\error.logに保存されました。" , 0 , "保存完了"
	end
*reie
	ie -> "Navigate" "about:blank"
	await 70
	doc = ie("Document")
	doc -> "write" buf
	name = ie("LocationURL")
	pDoc = ie("Document")
	name = pDoc("Title")
	title name
	delcom pDoc
	color cr , cg , cb
	boxf 1 , 1 , 1278 , 32
	font "MS ゴシック",16,0
	cc=cr+cg+cb
	if cc > 384 {
		color 0,0,0
		pos 4,4:mes "Sero  "+name
	}
	if cc <= 384 {
		color 255,255,255
		pos 4,4:mes "Sero  "+name
	}
	title "Sero  "+name
	sysfont 0
	goto *main
*gogo
	aplobj "EDIT"
	wait 150
	aplstr buf
	wait 150
	stop
//最後にするやーつ
*click
	if daig = 0 {
	if wparam=1 : sendmsg hwnd,$00A1,2,0
	return
	stop
	}
*event_WM_SIZE
	stbar_resize		; ステータスバーのリサイズ
	return
	stop