# OpenVerse Fun Panel
# 
# this file initalizes the program and does any
# platform specific things/setup. It will then source 
# supporting modules.
#
# Module Name		- Fun Panel Setup
# Current Maintainter 	- Cruise <cruise@openverse.org>
# Sourced By		- InitMain.tcl
#
# Copyright (C) 1999 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.

#
# These frames must be defined as other functions need to know where they
# should add items.
#
set MV(plugin_frame) ".menu.main.r.b"
set MV(avatar_menu) ".menu.main.m.b.anims"
set MV(names_menu) ".menu.main.m.b.names.mb"
set MV(passageways_menu) ".menu.main.m.a.bookmarks"
set MV(chat_entry) ".menu.main.r.a.chat.chat"
set MV(connect_button) ".menu.main.r.b.connect"

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

frame .menu.main
frame .menu.main.r
frame .menu.main.r.a
frame .menu.main.r.b
frame .menu.main.r.a.chat -relief raised -borderwidth 2
frame .menu.main.m -relief raised -borderwidth 2
frame .menu.main.m.a -relief sunken -borderwidth 2
frame .menu.main.m.b -relief sunken -borderwidth 2

button .menu.main.r.b.connect -text [Trns connect] -command Connect
button .menu.main.r.a.chat.send -text [Trns send] -command SendText
entry .menu.main.r.a.chat.chat
button .menu.main.m.a.quit -text [Trns quit] -command {exit}
button .menu.main.m.a.chat -text [Trns text_chat] -command ToggleText
button .menu.main.m.a.help -text [Trns help] -command "source \"$MV(helpdir)/$MV(help.file.main)\""
button .menu.main.m.a.setup -text [Trns setup] -command Setup
menubutton .menu.main.m.a.bookmarks -text [Trns passageways] -menu \
	 .menu.main.m.a.bookmarks.m -relief raised -borderwidth 2 \
	-indicatoron 1
menu .menu.main.m.a.bookmarks.m
button .menu.main.m.b.avatars -text [Trns aved] -relief raised -borderwidth 2 \
	-command AvEd
checkbutton .menu.main.m.b.anim -text [Trns animate] -variable MV(anim.stop) -relief raised \
	-borderwidth 2 -offvalue 1 -onvalue 0 -command AnimateAvatar
menubutton .menu.main.m.b.anims -text [Trns avatars] -menu .menu.main.m.b.anims.m -relief \
	raised -borderwidth 2 -indicatoron 1
menu .menu.main.m.b.anims.m
checkbutton .menu.main.m.b.sound -text [Trns sound] -variable MV(bell) -relief raised \
	-borderwidth 2
frame .menu.main.m.b.names -relief raised -borderwidth 2
checkbutton .menu.main.m.b.names.cb -variable MV(names) -command ShowNames
menubutton .menu.main.m.b.names.mb -text [Trns names] -relief raised -borderwidth 2 \
	-menu .menu.main.m.b.names.mb.m -indicatoron 1
menu .menu.main.m.b.names.mb.m

pack .menu.main -side top -fill both -expand y 
pack .menu.main.m -side left
pack .menu.main.r -side left -fill both -expand y
pack .menu.main.r.a -side top -fill both -expand y
pack .menu.main.r.b -side top -fill both -expand y
pack .menu.main.m.a -side top -fill both -expand y
pack .menu.main.m.b -side bottom -fill both -expand y
pack .menu.main.m.a.quit .menu.main.m.a.chat .menu.main.m.a.help .menu.main.m.a.setup .menu.main.m.a.bookmarks -side left -fill both -expand y
pack .menu.main.m.b.avatars .menu.main.m.b.anim .menu.main.m.b.anims .menu.main.m.b.sound .menu.main.m.b.names -side left -fill both -expand y
pack .menu.main.m.b.names.cb .menu.main.m.b.names.mb -side left
pack .menu.main.r.a.chat -side left -fill x -expand y
pack .menu.main.r.a.chat.send -side left 
pack .menu.main.r.a.chat.chat -side left -fill x -expand y
pack .menu.main.r.b.connect -side left -fill both -expand y

bind .menu.main.r.a.chat.chat <Return> SendText
bind .menu.main.r.a.chat.chat <Up> "ShowPrev .menu.main.r.a.chat.chat"
bind .menu.main.r.a.chat.chat <Down> "ShowNext .menu.main.r.a.chat.chat"
bind .menu.main.r.a.chat.chat <Key> "CheckLen .menu.main.r.a.chat.chat"

focus .menu.main.r.a.chat.chat

proc ColorMainButtons {} {
	global MV

	if $MV(use_windowmanager_colors) {return}

	.menu.main configure -bg $MV(colors.frames.topbar.bg)
	.menu.main.r.b.connect configure -bg $MV(colors.buttons.connect.bg) \
		-fg $MV(colors.buttons.connect.fg) \
		-activebackground $MV(colors.buttons.connect.abg) \
		-activeforeground $MV(colors.buttons.connect.afg)
	.menu.main.r.a.chat configure -bg $MV(colors.frames.chat.bg)
	.menu.main.r.a.chat.send configure -bg $MV(colors.buttons.send.bg) \
		-fg $MV(colors.buttons.send.fg) \
		-activebackground $MV(colors.buttons.send.abg) \
		-activeforeground $MV(colors.buttons.send.afg)
	.menu.main.r.a.chat.chat configure -bg $MV(colors.buttons.entry.bg) -fg $MV(colors.buttons.entry.fg)
	.menu.main.m configure -bg $MV(colors.frames.menu.bord.bg) 
	.menu.main.m.a configure -bg $MV(colors.frames.menu.top.bg) 
	.menu.main.m.b configure -bg $MV(colors.frames.menu.bot.bg) 
	.menu.main.m.a.quit configure -bg $MV(colors.buttons.quit.bg) \
		-fg $MV(colors.buttons.quit.fg) \
		-activebackground $MV(colors.buttons.quit.abg) \
		-activeforeground $MV(colors.buttons.quit.afg)
	.menu.main.m.a.chat configure -bg $MV(colors.buttons.textchat.bg) \
		-fg $MV(colors.buttons.textchat.fg) \
		-activebackground $MV(colors.buttons.textchat.abg) \
		-activeforeground $MV(colors.buttons.textchat.afg)
	.menu.main.m.a.help configure -bg $MV(colors.buttons.help.bg) \
		-activebackground $MV(colors.buttons.help.abg) \
		-activeforeground $MV(colors.buttons.help.afg) \
		-fg $MV(colors.buttons.help.fg)
	.menu.main.m.a.setup configure -bg $MV(colors.buttons.setup.bg) \
		-fg $MV(colors.buttons.setup.fg) \
		-activebackground $MV(colors.buttons.setup.abg) \
		-activeforeground $MV(colors.buttons.setup.afg)
	.menu.main.m.a.bookmarks configure -bg $MV(colors.buttons.passageways.bg) \
		-fg $MV(colors.buttons.passageways.fg) \
		-activebackground $MV(colors.buttons.passageways.abg) \
		-activeforeground $MV(colors.buttons.passageways.afg)
	.menu.main.m.b.avatars configure -bg $MV(colors.buttons.aved.bg) \
		-fg $MV(colors.buttons.aved.fg) \
		-activebackground $MV(colors.buttons.aved.abg) \
		-activeforeground $MV(colors.buttons.aved.afg) 
	.menu.main.m.b.anim configure -bg $MV(colors.buttons.animate.bg) \
		-fg $MV(colors.buttons.animate.fg) \
		-activebackground $MV(colors.buttons.animate.abg) \
		-activeforeground $MV(colors.buttons.animate.afg)
	.menu.main.m.b.anims configure -bg $MV(colors.buttons.avatars.bg) \
		-fg $MV(colors.buttons.avatars.fg) \
		-activebackground $MV(colors.buttons.avatars.abg) \
		-activeforeground $MV(colors.buttons.avatars.afg)
	.menu.main.m.b.sound configure -bg $MV(colors.buttons.sound.bg) \
		-fg $MV(colors.buttons.sound.fg) \
		-activebackground $MV(colors.buttons.sound.abg) \
		-activeforeground $MV(colors.buttons.sound.afg)
	.menu.main.m.b.names configure -bg $MV(colors.frames.names.bg)
	.menu.main.m.b.names.cb configure -bg $MV(colors.buttons.names.chk.bg) \
		-fg $MV(colors.buttons.names.chk.fg) \
		-activebackground $MV(colors.buttons.names.chk.abg) \
		-activeforeground $MV(colors.buttons.names.chk.afg)
	.menu.main.m.b.names.mb configure -bg $MV(colors.buttons.names.bg) \
		-fg $MV(colors.buttons.names.fg) \
		-activebackground $MV(colors.buttons.names.abg) \
		-activeforeground $MV(colors.buttons.names.afg)
}

# Setup our Baloon Help!
if $MV(tooltips) {
	Bubble::initBubble .menu.main.m.b.names [Trns names_help]
	Bubble::initBubble .menu.main.m.a.chat [Trns textchat_help]
	Bubble::initBubble .menu.main.m.a.quit [Trns quit_help]
	Bubble::initBubble .menu.main.m.a.help [Trns help_help]
	Bubble::initBubble .menu.main.m.a.setup [Trns setup_help]
	Bubble::initBubble .menu.main.m.a.bookmarks [Trns passageways_help]
	Bubble::initBubble .menu.main.m.b.avatars [Trns aved_help]
	Bubble::initBubble .menu.main.m.b.anim [Trns animate_help]
	Bubble::initBubble .menu.main.m.b.sound [Trns sound_help]
	Bubble::initBubble .menu.main.r.b.connect [Trns panel_connect_help]
	Bubble::initBubble .menu.main.r.a.chat.send [Trns send_help]
	Bubble::initBubble .menu.main.m.b.anims [Trns avatars_help]
}

DoAvatars
DoBookmarks
DoNames
ColorMainButtons
