# OpenVerse "Pro" Panel
# 
# this file initalizes the program and does any
# platform specific things/setup. It will then source 
# supporting modules.
#
# Module Name		- Pro Panel Setup
# Current Maintainter 	- Cruise <cruise@openverse.org>
# Sourced By		- InitMain.tcl
# Requires		- OpenVerse 0.8-6 or higher!
#
# Copyright (C) 1999-2001 David Gale <cruise@openverse.org>
# For more information visit http://OpenVerse.org/
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
# USA.

set MV(plugin_frame) ".menu.main.plugins"
set MV(connect_button) ".menu.main.m.connect"
set MV(chat_entry) ".chat.bottom.chat"
set MV(names_menu) ".menu.main.m.names.m"
set MV(avatar_menu) ".menu.main.m.av.m"
set MV(passageways_menu) ".menu.main.m.ov.m"

if [winfo exists .menu.main] {destroy .menu.main}

frame .menu.main
frame .menu.main.m
frame .menu.main.chat -relief sunken -borderwidth 2
frame .menu.main.plugins

menubutton .menu.main.m.ov -text OpenVerse -menu .menu.main.m.ov.m \
	-underline 0
menu .menu.main.m.ov.m
.menu.main.m.ov.m add cascade -label [Trns passageways] -menu .menu.main.m.ov.m.m
menu .menu.main.m.ov.m.m
.menu.main.m.ov.m add command -label [Trns setup] -command Setup
.menu.main.m.ov.m add checkbutton -label [Trns sound] -variable MV(bell)
.menu.main.m.ov.m add separator
.menu.main.m.ov.m add command -label [Trns quit] -command exit

menubutton .menu.main.m.av -text [Trns avatars] -menu .menu.main.m.av.m \
	-underline 0
menu .menu.main.m.av.m
.menu.main.m.av.m add checkbutton -label [Trns animate] -variable MV(anim.stop) \
	-command AnimateAvatar -offvalue 1 -onvalue 0 
.menu.main.m.av.m add cascade -label [Trns avatars] -menu .menu.main.m.av.m.m
menu .menu.main.m.av.m.m
.menu.main.m.av.m add separator
.menu.main.m.av.m add command -label [Trns aved_long] -command AvEd

menubutton .menu.main.m.names -text Users -menu .menu.main.m.names.m \
	 -underline 0
menu .menu.main.m.names.m
.menu.main.m.names.m add checkbutton -label [Trns show_nametags] \
	 -variable MV(names) -command ShowNames
.menu.main.m.names.m add cascade -label [Trns names] -menu .menu.main.m.names.m.m
menu .menu.main.m.names.m.m

menubutton .menu.main.m.help -text [Trns help] -relief flat -underline 0 \
	-menu .menu.main.m.help.m
menu .menu.main.m.help.m

.menu.main.m.help.m add command -label [Trns about_openverse] \
	-command "source \"$MV(helpdir)/$MV(help.file.about)\""
.menu.main.m.help.m add command -label [Trns openverse_help] \
	-command "source \"$MV(helpdir)/$MV(help.file.main)\""
.menu.main.m.help.m add command -label [Trns technical_help] \
	-command "source \"$MV(helpdir)/$MV(help.file.technical)\""
.menu.main.m.help.m add command -label [Trns faq] \
	-command "source \"$MV(helpdir)/$MV(help.file.faq)\""

button .menu.main.m.connect -text [Trns connect] -command Connect \
	-borderwidth 1

pack .menu.main -side top -fill both -expand y 
pack .menu.main.m .menu.main.chat -side left -fill x -expand y
pack .menu.main.plugins -side right
pack .menu.main.m.ov .menu.main.m.av .menu.main.m.names \
	.menu.main.m.help .menu.main.m.connect -side left 


proc ColorMainButtons {} {
	global MV

	if $MV(use_windowmanager_colors) {return}
}

#
# Overwrite the ToggleText function.
#
proc ToggleText {} {
	global MV

	set MV(TCCommand) 0
	if $MV(textwindow) {
		#
		# Add a catch here too!
		# 
		# destroy .chat
		# set MV(textwindow) 0
		# We never destroy it!
		return
	} else {
		set MV(textwindow) 1
		#
		# set the frame instead of a new window.. thats all we're doing.
		# I could put a catch here to allow plugins to trap this.
		# I will do that. Cruise - 10-21-2001
		#
		frame .chat -relief sunken -borderwidth 2
		pack .chat -side bottom -fill both -expand y
		#wm title .chat [Trns openverse_text_chat]
		#wm geometry .chat 646x149 

		frame .chat.chat
		frame .chat.bottom -relief sunken -borderwidth 2
		text .chat.chat.text -height 6 -width 0  -relief raised \
			-borderwidth 2 -yscrollcommand ".chat.chat.scrolly set" \
			-spacing1 1 -wrap word -state disabled
		scrollbar .chat.chat.scrolly -command ".chat.chat.text yview"

		# Added activeforeground red -JACK-
		button .chat.bottom.send -text [Trns send] -activeforeground red \
			-command {SendFromWindow}
		
		frame .chat.bottom.buttons
		label .chat.bottom.buttons.handle -image OpenVerse_Image_vhandle -relief \
			raised -bd 1
		update idletasks
		frame .chat.bottom.buttons.frame -relief raised -bd 1
                pack propagate .chat.bottom.buttons.frame 0
		pack .chat.bottom.buttons.handle -side left -fill y
		pack .chat.bottom.buttons.frame .chat.bottom.buttons -fill both -expand 1
		bind .chat.bottom.buttons.handle <ButtonRelease-1> "ChtButShowHide"
		set MV(ChtButState) show
		set bframe ".chat.bottom.buttons.frame"
		# "$bframe" is all over the place do a search to see where.
		#################################################################
		
		entry .chat.bottom.chat
                button .chat.bottom.rubber -image OpenVerse_Image_RUBBER -command EraseChat
                if $MV(log) {
                        button .chat.bottom.log -image OpenVerse_Image_LOG -command LogTog \
                                -bg red -activebackground pink
                } else {
                        button .chat.bottom.log -image OpenVerse_Image_LOG -command LogTog \
                                -bg $MV(defbg) -activebackground $MV(defhl)
                }
                if $MV(textwindow.lock) {
                        button .chat.bottom.scrlk -image OpenVerse_Image_SCRLK -command ToggleChatLock
                } else {
                        button .chat.bottom.scrlk -image OpenVerse_Image_SCRULK -command ToggleChatLock
                }

                ###############################################################
		# Added command buttons; moved bottom ones to $bframe. -JACK-
		#  ? Maybe could toggle, but too much code?
		label $bframe.label -text [Trns commands]
		
		# Depends upon text entered...
		# Order: wink, smile, frown, idea, love, sing, steam
		button $bframe.1 -image OpenVerse_Image_CHAT_wink \
		   	-command {SetSCHATcmd 1} -width 20 -height 20
		button $bframe.2 -image OpenVerse_Image_CHAT_smile \
			-command {SetSCHATcmd 2} -width 20 -height 20
		button $bframe.3 -image OpenVerse_Image_CHAT_frown \
			-command {SetSCHATcmd 3} -width 20 -height 20
		button $bframe.4 -image OpenVerse_Image_CHAT_idea \
			-command {SetSCHATcmd 4} -width 20 -height 20
		button $bframe.5 -image OpenVerse_Image_CHAT_love \
			-command {SetSCHATcmd 5} -width 20 -height 20
		button $bframe.6 -image OpenVerse_Image_CHAT_notes \
			-command {SetSCHATcmd 6} -width 20 -height 20
		button $bframe.7 -image OpenVerse_Image_CHAT_steam \
			-command {SetSCHATcmd 7} -width 20 -height 20
		# Called Directly
		# 11/05/2001 - Unununium Made the jump and shiver buttons the same size as the others
		button $bframe.jump -image OpenVerse_Image_CHAT_jump \
			-command { SendToServer "EFFECT jump"} -width 20 -height 20
		button $bframe.shiver -image OpenVerse_Image_CHAT_shiver \
			-command { SendToServer "EFFECT shiver"} -width 20 -height 20
		button $bframe.quit_ov -image OpenVerse_Image_CHAT_quit \
			-command { 
				if ![tk_dialog .chat.quitQuestion [Trns really_quit] \
				[Trns quit_question] \
				"" 1 [Trns quit] [Trns cancel]] {
					exit
				}
			}
		# 11/05/2001 -Unununium- Moved the quit button away from the others
		pack $bframe.label \
		 	$bframe.1 $bframe.2 $bframe.3 $bframe.4 $bframe.5 \
			$bframe.6 $bframe.7 $bframe.jump $bframe.shiver \
			-side left -fill both -padx 1
		pack $bframe.quit_ov -fill both -side right
		###############################################################
		# 2/25/2000 -JACK- 
		# Added Bubbles to the command buttons
		if $MV(tooltips) {
			Bubble::initBubble $bframe.jump [Trns cht_jump_bubble]
			Bubble::initBubble $bframe.shiver [Trns cht_shiver_bubble]
			Bubble::initBubble $bframe.quit_ov [Trns cht_quit_bubble]
			Bubble::initBubble $bframe.1 [Trns cht_wink_bubble]
			Bubble::initBubble $bframe.2 [Trns cht_smile_bubble]
			Bubble::initBubble $bframe.3 [Trns cht_frown_bubble]
			Bubble::initBubble $bframe.4 [Trns cht_idea_bubble]
			Bubble::initBubble $bframe.5 [Trns cht_love_bubble]
			Bubble::initBubble $bframe.6 [Trns cht_sing_bubble]
			Bubble::initBubble $bframe.7 [Trns cht_steam_bubble]
		}	
		pack .chat.chat -fill both -expand y
		pack .chat.chat.text -side left -fill both -expand y
		pack .chat.chat.scrolly -side left -fill y 
		pack .chat.bottom -fill x -expand n
		pack .chat.bottom.buttons -side top
		pack .chat.bottom.send -side left -expand n
		pack .chat.bottom.chat -side left -fill x -expand y
		pack .chat.bottom.log .chat.bottom.rubber \
			.chat.bottom.scrlk -side left

		focus .chat.bottom.chat
		# Hmnn.. should we be doing this?
		#QuickKeys ".chat"
		bind .chat.bottom.chat <Return> SendFromWindow
		#bind .chat <Destroy> "set MV(textwindow) 0"
		bind .chat.bottom.chat <Pause> "ToggleChatLock"
		bind .chat.bottom.chat <Up> "ShowPrev .chat.bottom.chat"
		bind .chat.bottom.chat <Down> "ShowNext .chat.bottom.chat"
		# These next binds enable cut and 
		# paste for Windows users. (BUG FIX, DG)
		bind .chat.bottom.chat <Control-c> {}
		bind .chat.bottom.chat <Control-v> {}
		bind .chat <KeyRelease> {focus .chat.bottom.chat}
		bind .chat.chat.text <ButtonPress> {.chat.chat.text configure -state normal}
		bind .chat.chat.text <ButtonRelease> {.chat.chat.text configure -state disabled}
		set hp [llength $MV(chats)]
		for {set c 0} {$c < $hp} {incr c} {
			InsertIntoChat 0 [lindex $MV(chats) $c]
		}
		# Colors (damn, why did I do this)
		#	1=Black
		#	2=Navy Blue
		#	3=Dark Green 
		#	4=Bright Red 
		#	5=Brown
		#	6=Magenta 
		#	7=Orange 
		#	8=Yellow 
		#	9=Bright Green
		#	10=Bluish-Green 
		#	11=Cyan 
		#	12=Blue
		#	13=Hot Pink 
		#	14=Dark Grey 
		#	15=Light Gray 
		#	0,16=White
		#	99=normal
		#
		set w .chat.chat.text
		$w tag configure B
		$w tag configure F
		$w tag configure B99
		$w tag configure F99
		$w tag configure F0 -foreground white
		$w tag configure F1 -foreground black
		$w tag configure F2 -foreground "navy blue"
		$w tag configure F3 -foreground "dark green"
		$w tag configure F4 -foreground "red"
		$w tag configure F5 -foreground "brown"
		$w tag configure F6 -foreground "magenta"
		$w tag configure F7 -foreground "orange"
		$w tag configure F8 -foreground "yellow"
		$w tag configure F9 -foreground "green"
		$w tag configure F00 -foreground white
		$w tag configure F01 -foreground black
		$w tag configure F02 -foreground "navy blue"
		$w tag configure F03 -foreground "dark green"
		$w tag configure F04 -foreground "red"
		$w tag configure F05 -foreground "brown"
		$w tag configure F06 -foreground "magenta"
		$w tag configure F07 -foreground "orange"
		$w tag configure F08 -foreground "yellow"
		$w tag configure F09 -foreground "green"
		$w tag configure F10 -foreground "#008080"
		$w tag configure F11 -foreground "cyan"
		$w tag configure F12 -foreground "blue"
		$w tag configure F13 -foreground "hot pink"
		$w tag configure F14 -foreground "dark grey"
		$w tag configure F15 -foreground "light grey"
		$w tag configure F16 -foreground "white"
		$w tag configure B0 -background white
		$w tag configure B1 -background black
		$w tag configure B2 -background "navy blue"
		$w tag configure B3 -background "dark green"
		$w tag configure B4 -background "red"
		$w tag configure B5 -background "brown"
		$w tag configure B6 -background "magenta"
		$w tag configure B7 -background "orange"
		$w tag configure B8 -background "yellow"
		$w tag configure B9 -background "green"
		$w tag configure B00 -background white
		$w tag configure B01 -background black
		$w tag configure B02 -background "navy blue"
		$w tag configure B03 -background "dark green"
		$w tag configure B04 -background "red"
		$w tag configure B05 -background "brown"
		$w tag configure B06 -background "magenta"
		$w tag configure B07 -background "orange"
		$w tag configure B08 -background "yellow"
		$w tag configure B09 -background "green"
		$w tag configure B10 -background "#008080"
		$w tag configure B11 -background "cyan"
		$w tag configure B12 -background "blue"
		$w tag configure B13 -background "hot pink"
		$w tag configure B14 -background "dark grey"
		$w tag configure B15 -background "light grey"
		$w tag configure B16 -background "white"
	}
}
DoAvatars
DoBookmarks
DoNames
ColorMainButtons
ToggleText
#
# Allow the window to be resized in the Y position!
#
wm resizable . 0 1

