/* NIGHTFALL OpenGL Interface */
/* Copyright (C) 2001 Rainer Wichmann & Markus Kuster */
/* */
/* 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* ANSI C forbids an empty source file, so put this outside */
/* do nothing here if we don't have OpenGL */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Light.h"
#ifdef _WITH_OPENGL
#include "LightGLPrefs.h"
/* Preferences window */
GtkWidget *glPrefsWindow = NULL;
/* OpenGL preferences window opened */
int GLPrefWinOpened = FALSE;
/* Buttons in GL options */
GtkWidget *ButtonWire, *ButtonPoints, *ButtonOpaque;
/* Buttons in texturing options */
GtkWidget *ButtonTexture, *ButtonLabels, *ButtonAxes;
GtkWidget *ButtonPrimTxt, *ButtonSecTxt;
GtkWidget *PrimTxtLabel, *SecTxtLabel;
GtkWidget *ButtonIMAGE, *ButtonGRAV, *ButtonFLUX,
*ButtonTEMP, *ButtonVELOCITY;
#ifdef HAVE_DISK
GtkWidget *ButtonDiskTxt,*DiskTxtLabel;
#endif
/* Buttons in ok/cancel/save button bar */
GtkWidget *ButtonCancel, *ButtonOk, *ButtonApply;
typedef struct TempFlagsStruct {
int axes; /* want x-,y-, z-axis (ON/OFF) */
int texture; /* want textures (ON/OFF) */
int textype; /* type of texture */
int wireframe; /* want wire frame or solid rendering*/
int points; /* use POINTS instead of QUAD_STRIP */
int labels; /* want labels (ON/OFF) */
int TxtIsOn[3]; /* we want texturing (ON/OFF) */
char PTextFile[MAX_CFG_INLINE+1]; /* texture image file */
char STextFile[MAX_CFG_INLINE+1]; /* texture image file */
#ifdef HAVE_DISK
char DTextFile[MAX_CFG_INLINE+1]; /* texture image file */
#endif
} TempFlagsHandle;
TempFlagsHandle TempFlags; /* temporary variable to store flags */
/****************************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.1
@short Destroy the GL preferences window
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Widget to destroy
@return (void)
@heading Open GL Animation
****************************************************************************/
void GLOkPrefs (GtkWidget *widget, gpointer *data)
{
if (GLPrefWinOpened == FALSE)
return;
/* copy temporary values to global variables */
/* store actual setup in temporary variable */
Flags.axes = TempFlags.axes;
Flags.texture = TempFlags.texture;
Flags.textype = TempFlags.textype;
Flags.wireframe = TempFlags.wireframe;
Flags.points = TempFlags.points;
Flags.labels = TempFlags.labels;
Texture[Primary].IsOn = TempFlags.TxtIsOn[Primary];
Texture[Secondary].IsOn = TempFlags.TxtIsOn[Secondary];
strncpy(Texture[Primary].TextFile, TempFlags.PTextFile, MAX_CFG_INLINE+1);
Texture[Primary].TextFile[MAX_CFG_INLINE] = '\0';
strncpy(Texture[Secondary].TextFile,TempFlags.STextFile, MAX_CFG_INLINE+1);
Texture[Secondary].TextFile[MAX_CFG_INLINE] = '\0';
#ifdef HAVE_DISK
if (Flags.disk == ON) {
Texture[Disk].IsOn = TempFlags.TxtIsOn[Disk];
strncpy(Texture[Disk].TextFile, TempFlags.DTextFile, MAX_CFG_INLINE+1);
Texture[Disk].TextFile[MAX_CFG_INLINE] = '\0';
GLInitTexture(Disk,IMAGE);
}
#endif
GLInitTexture(Primary, TempFlags.textype);
GLInitTexture(Secondary, TempFlags.textype);
GLUpdateAll();
GLDisplayAll();
GLUpdateAll();
GLDisplayAll();
gtk_widget_destroy (GTK_WIDGET (glPrefsWindow));
GLPrefWinOpened = FALSE;
return;
}
/****************************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.1
@short Destroy the GL preferences window
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Widget to destroy
@return (void)
@heading Open GL Animation
****************************************************************************/
void GLApplyPrefs (GtkWidget *widget, gpointer *data)
{
if (GLPrefWinOpened == FALSE)
return;
/* set temporary values as new values */
Flags.axes = TempFlags.axes;
Flags.texture = TempFlags.texture;
Flags.textype = TempFlags.textype;
Flags.wireframe = TempFlags.wireframe;
Flags.points = TempFlags.points;
Flags.labels = TempFlags.labels;
Texture[Primary].IsOn = TempFlags.TxtIsOn[Primary];
Texture[Secondary].IsOn = TempFlags.TxtIsOn[Secondary];
strncpy(Texture[Primary].TextFile, TempFlags.PTextFile,MAX_CFG_INLINE+1);
Texture[Primary].TextFile[MAX_CFG_INLINE] = '\0';
strncpy(Texture[Secondary].TextFile, TempFlags.STextFile,MAX_CFG_INLINE+1);
Texture[Secondary].TextFile[MAX_CFG_INLINE] = '\0';
#ifdef HAVE_DISK
if (Flags.disk == ON) {
Texture[Disk].IsOn = TempFlags.TxtIsOn[Disk];
strncpy(Texture[Disk].TextFile, TempFlags.DTextFile, MAX_CFG_INLINE+1);
Texture[Disk].TextFile[MAX_CFG_INLINE] = '\0';
GLInitTexture(Disk,IMAGE);
}
#endif
GLInitTexture(Primary, TempFlags.textype);
GLInitTexture(Secondary, TempFlags.textype);
GLUpdateAll();
GLDisplayAll();
return;
}
/****************************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Destroy the GL preferences window
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Widget to destroy
@return (void)
@heading Open GL Animation
****************************************************************************/
void GLDeletePrefs (GtkWidget *widget, gpointer *data)
{
if (GLPrefWinOpened == FALSE)
return;
gtk_widget_destroy (GTK_WIDGET (glPrefsWindow));
GLPrefWinOpened = FALSE;
return;
}
/****************************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Destroy the GL preferences window
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Widget to destroy
@return (void)
@heading Open GL Animation
****************************************************************************/
void GLLabelsEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.labels = ON;
} else {
TempFlags.labels = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for 'axis on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLAxesEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.axes = ON;
} else {
TempFlags.axes = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for 'wire frame on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLFilledEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.wireframe = ON;
TempFlags.points = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.1
@short Callback function for 'texturing on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLTextureEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.texture = ON;
gtk_widget_set_sensitive(ButtonPrimTxt,TRUE);
gtk_widget_set_sensitive(ButtonSecTxt,TRUE);
gtk_widget_set_sensitive(PrimTxtLabel,TRUE);
gtk_widget_set_sensitive(SecTxtLabel,TRUE);
#ifdef HAVE_DISK
if (Flags.disk == ON) {
gtk_widget_set_sensitive(ButtonDiskTxt,TRUE);
gtk_widget_set_sensitive(DiskTxtLabel,TRUE);
}
#endif
} else {
TempFlags.texture = OFF;
gtk_widget_set_sensitive(ButtonPrimTxt,FALSE);
gtk_widget_set_sensitive(ButtonSecTxt,FALSE);
gtk_widget_set_sensitive(PrimTxtLabel,FALSE);
gtk_widget_set_sensitive(SecTxtLabel,FALSE);
#ifdef HAVE_DISK
if (Flags.disk == ON) {
gtk_widget_set_sensitive(ButtonDiskTxt,FALSE);
gtk_widget_set_sensitive(DiskTxtLabel,FALSE);
}
#endif
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for 'primary texture on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLPrimTextureEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
/*Texture[Primary].IsOn = ON;*/
TempFlags.TxtIsOn[Primary] = ON;
} else {
/*Texture[Primary].IsOn = OFF;*/
TempFlags.TxtIsOn[Primary] = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for input primary texture file
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLEnterPrimTxt (GtkWidget *widget, gpointer *entry)
{
const gchar *entry_text;
TempFlagsHandle *TexPtr=NULL;
TexPtr=&TempFlags;
entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
snprintf(TexPtr->PTextFile, MAX_CFG_INLINE+1, "%s", entry_text);
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for 'secondary texture on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLSecTextureEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
/*Texture[Secondary].IsOn = ON;*/
TempFlags.TxtIsOn[Secondary] = ON;
} else {
/*Texture[Secondary].IsOn = OFF;*/
TempFlags.TxtIsOn[Secondary] = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for inputsecondary texture file
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLEnterSecTxt (GtkWidget *widget, gpointer *entry)
{
const gchar *entry_text;
TempFlagsHandle *TexPtr=NULL;
TexPtr=&TempFlags;
entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
snprintf(TexPtr->STextFile, MAX_CFG_INLINE+1, "%s", entry_text);
return;
}
#ifdef HAVE_DISK
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for 'disk texture on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLDiskTextureEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
/*Texture[Disk].IsOn = ON;*/
TempFlags.TxtIsOn[Disk] = ON;
} else {
/*Texture[Disk].IsOn = OFF;*/
TempFlags.TxtIsOn[Disk] = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for input disk texture file
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLEnterDiskTxt (GtkWidget *widget, gpointer *entry)
{
const gchar *entry_text;
TempFlagsHandle *TexPtr=NULL;
TexPtr=&TempFlags;
entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
snprintf(TexPtr->DTextFile, MAX_CFG_INLINE+1, "%s", entry_text);
return;
}
#endif
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Callback function for 'GL_POINTS on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLPointsEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.points = ON;
TempFlags.wireframe = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Rainer Wichmann (rwichmann@lsw.uni-heidelberg.de)
@version 1.0
@short Callback function for 'textype setting'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data textype
@return (void)
@heading
*******************************************************************/
void GLTexTypeEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.textype = GPOINTER_TO_INT(data);
}
return;
}
/******************************************************************
@package nightfall
@author Rainer Wichmann (rwichmann@lsw.uni-heidelberg.de)
@version 1.0
@short Callback function for 'solid on/off'
@param (GtkWidget) *widget Discarded
@param (gpointer) *data Discarded
@return (void)
@heading
*******************************************************************/
void GLOpaqueEvent (GtkWidget *widget, gpointer *data)
{
if(GTK_TOGGLE_BUTTON (widget)->active) {
TempFlags.points = OFF;
TempFlags.wireframe = OFF;
}
return;
}
/******************************************************************
@package nightfall
@author Markus Kuster (kuster@astro.uni-tuebingen.de)
@version 1.0
@short Preferences window for OpenGL
@param (void)
@return (void)
@heading Open GL Animation
*******************************************************************/
void GLPrefs(void)
{
char InitString[4096]; /* init string for entry field */
GtkWidget *glBaseVBox; /* Vertical box for all frames */
GtkWidget *glOptHBox; /* Horizontal box for GL options */
GtkWidget *glTxtHBox; /* Horizontal box for texture options */
GtkWidget *glTypHBox; /* Horizontal box for textyp options */
GtkWidget *glDispOptHBox; /* Horizontal box for display options */
GtkWidget *glButtonHBox; /* Horizontal box for Close/Cancel buttons */
GtkWidget *OptFrame;
GtkWidget *TxtFrame;
GtkWidget *DispOptFrame;
GtkWidget *glOptTable;
GtkWidget *glTxtTable;
GtkWidget *glDispOptTable;
GSList *group;
GtkTooltips *tooltips;
/* store actual setup in temporary variable */
TempFlags.axes = Flags.axes;
TempFlags.texture = Flags.texture;
TempFlags.textype = Flags.textype;
TempFlags.wireframe = Flags.wireframe;
TempFlags.points = Flags.points;
TempFlags.labels = Flags.labels;
TempFlags.TxtIsOn[Primary] = Texture[Primary].IsOn;
TempFlags.TxtIsOn[Secondary] = Texture[Secondary].IsOn;
strncpy(TempFlags.PTextFile, Texture[Primary].TextFile, MAX_CFG_INLINE+1);
Texture[Primary].TextFile[MAX_CFG_INLINE] = '\0';
strncpy(TempFlags.STextFile, Texture[Secondary].TextFile, MAX_CFG_INLINE+1);
Texture[Secondary].TextFile[MAX_CFG_INLINE] = '\0';
#ifdef HAVE_DISK
if (Flags.disk == ON) {
TempFlags.TxtIsOn[Disk] = Texture[Disk].IsOn;
strncpy(TempFlags.DTextFile, Texture[Disk].TextFile, MAX_CFG_INLINE+1);
Texture[Disk].TextFile[MAX_CFG_INLINE] = '\0';
}
#endif
tooltips = gtk_tooltips_new ();
gtk_tooltips_set_delay (tooltips, 1800);
/* >>>>>>>>>>>>>>>>>>>>> MAKE WIDGET <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
glPrefsWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(glPrefsWindow), GTK_WIN_POS_MOUSE);
#ifdef USING_GTK2
gtk_window_set_resizable(GTK_WINDOW(glPrefsWindow), TRUE);
#else
gtk_window_set_policy (GTK_WINDOW(glPrefsWindow), FALSE, FALSE, TRUE);
#endif
gtk_signal_connect (GTK_OBJECT (glPrefsWindow), "delete_event",
GTK_SIGNAL_FUNC (GLDeletePrefs),
GTK_WIDGET (glPrefsWindow));
gtk_window_set_title (GTK_WINDOW (glPrefsWindow), _("Display Preferences") );
gtk_container_set_border_width (GTK_CONTAINER (glPrefsWindow), 0);
gtk_widget_show (glPrefsWindow);
/* Vertical Box containing all */
glBaseVBox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (glBaseVBox), 4);
gtk_container_add(GTK_CONTAINER (glPrefsWindow), GTK_WIDGET(glBaseVBox));
gtk_widget_show (glBaseVBox);
/* --------------------------------------------------------------------- */
/* Create GL Options frame */
OptFrame = gtk_frame_new (_("GL Options") );
gtk_container_add (GTK_CONTAINER (glBaseVBox), OptFrame);
gtk_container_set_border_width(GTK_CONTAINER(OptFrame), 2);
gtk_widget_show (OptFrame);
/* Start with GL Options frame */
glOptHBox = gtk_hbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (OptFrame), glOptHBox);
gtk_container_set_border_width (GTK_CONTAINER (glOptHBox), 4);
gtk_widget_show (glOptHBox);
glOptTable = gtk_table_new (1, 2, TRUE);
/* GLPoints button */
ButtonPoints = gtk_radio_button_new_with_label (NULL, _("Points") );
if (Flags.points == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonPoints), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonPoints,
_("Display visible surface elements using points"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonPoints), "toggled",
(GtkSignalFunc) GLPointsEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glOptTable),ButtonPoints, 0, 1, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonPoints);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonPoints));
/* Wire frame button */
ButtonWire = gtk_radio_button_new_with_label (group, _("Wire Frame") );
if (Flags.wireframe == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonWire), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonWire,
_("Display objects as wire frame"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonWire), "clicked",
(GtkSignalFunc) GLFilledEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glOptTable), ButtonWire, 1, 2, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonWire);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonWire));
/* Solid button */
ButtonOpaque = gtk_radio_button_new_with_label (group, _("Opaque") );
if (Flags.wireframe == OFF && Flags.points == OFF)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonOpaque), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonOpaque,
_("Display objects in opaque mode"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonOpaque), "toggled",
(GtkSignalFunc) GLOpaqueEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glOptTable), ButtonOpaque, 2, 3, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonOpaque);
/* show the table */
gtk_box_pack_start (GTK_BOX (glOptHBox), glOptTable, FALSE, FALSE, 0);
gtk_widget_show(glOptTable);
/* --------------------------------------------------------------------- */
/* Create Texture Options frame */
TxtFrame = gtk_frame_new (_("Texture Options") );
gtk_container_add (GTK_CONTAINER (glBaseVBox), TxtFrame);
gtk_container_set_border_width(GTK_CONTAINER(TxtFrame), 2);
gtk_widget_show (TxtFrame);
/* Start with Texture Options frame */
glTxtHBox = gtk_hbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (TxtFrame), glTxtHBox);
gtk_container_set_border_width (GTK_CONTAINER (glTxtHBox), 4);
gtk_widget_show (glTxtHBox);
glTxtTable = gtk_table_new (5, 2, TRUE);
/* show the table */
gtk_box_pack_start (GTK_BOX (glTxtHBox), glTxtTable, FALSE, FALSE, 0);
gtk_widget_show (glTxtTable);
/* texture ON/OFF button */
ButtonTexture = gtk_check_button_new_with_label (_("Textures") );
if (Flags.texture == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonTexture), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonTexture,
_("Switch texturing on"), NULL);
gtk_signal_connect (GTK_OBJECT (ButtonTexture), "clicked",
(GtkSignalFunc) GLTextureEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glTxtTable), ButtonTexture, 0, 1, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonTexture);
/* Primary texture button */
ButtonPrimTxt = gtk_check_button_new_with_label (_("Primary Texture On/Off") );
if (Texture[Primary].IsOn == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonPrimTxt), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonPrimTxt,
_("Toggle primary texture On/Off"), NULL);
gtk_signal_connect (GTK_OBJECT (ButtonPrimTxt), "clicked",
(GtkSignalFunc) GLPrimTextureEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glTxtTable), ButtonPrimTxt, 0, 1, 1, 2,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonPrimTxt);
if (Flags.texture == OFF)
gtk_widget_set_sensitive(ButtonPrimTxt,FALSE);
PrimTxtLabel = gtk_entry_new_with_max_length (256);
gtk_tooltips_set_tip (tooltips, PrimTxtLabel,
_("Image file used as texture for primary"), NULL);
gtk_signal_connect(GTK_OBJECT(PrimTxtLabel), "changed",
GTK_SIGNAL_FUNC(GLEnterPrimTxt),
PrimTxtLabel);
sprintf(InitString, "%s", Texture[Primary].TextFile);
gtk_entry_set_text (GTK_ENTRY (PrimTxtLabel), InitString);
gtk_entry_select_region (GTK_ENTRY (PrimTxtLabel),
0, GTK_ENTRY(PrimTxtLabel)->text_length);
gtk_table_attach (GTK_TABLE(glTxtTable), PrimTxtLabel, 1, 2, 1, 2,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (PrimTxtLabel);
if (Flags.texture == OFF)
gtk_widget_set_sensitive(PrimTxtLabel,FALSE);
/* Secondary texture button */
ButtonSecTxt = gtk_check_button_new_with_label (_("Secondary Texture On/Off") );
if (Texture[Secondary].IsOn == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonSecTxt), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonSecTxt,
_("Toggle secondary texture On/Off"), NULL);
gtk_signal_connect (GTK_OBJECT (ButtonSecTxt), "clicked",
(GtkSignalFunc) GLSecTextureEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glTxtTable), ButtonSecTxt, 0, 1, 2, 3,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonSecTxt);
if (Flags.texture == OFF)
gtk_widget_set_sensitive(ButtonSecTxt,FALSE);
SecTxtLabel = gtk_entry_new_with_max_length (256);
gtk_tooltips_set_tip (tooltips, SecTxtLabel,
_("Image file used as texture for secondary"), NULL);
gtk_signal_connect(GTK_OBJECT(SecTxtLabel), "changed",
GTK_SIGNAL_FUNC(GLEnterSecTxt),
SecTxtLabel);
sprintf(InitString, "%s", Texture[Secondary].TextFile);
gtk_entry_set_text (GTK_ENTRY (SecTxtLabel), InitString);
gtk_entry_select_region (GTK_ENTRY (SecTxtLabel),
0, GTK_ENTRY(SecTxtLabel)->text_length);
gtk_table_attach (GTK_TABLE(glTxtTable), SecTxtLabel, 1, 2, 2, 3,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (SecTxtLabel);
if (Flags.texture == OFF)
gtk_widget_set_sensitive(SecTxtLabel,FALSE);
#ifdef HAVE_DISK
if (Flags.disk == ON) {
/* Disk texture button */
ButtonDiskTxt = gtk_check_button_new_with_label (_("Disk Texture On/Off") );
if ( Texture[Disk].IsOn == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonDiskTxt), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonDiskTxt,
_("Toggle disk texture On/Off"), NULL);
gtk_signal_connect (GTK_OBJECT (ButtonDiskTxt), "clicked",
(GtkSignalFunc) GLDiskTextureEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glTxtTable), ButtonDiskTxt, 0, 1, 3, 4,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonDiskTxt);
if (Flags.texture == OFF)
gtk_widget_set_sensitive(ButtonDiskTxt,FALSE);
DiskTxtLabel = gtk_entry_new_with_max_length (256);
gtk_tooltips_set_tip (tooltips, DiskTxtLabel,
_("Image file used as texture for disk"), NULL);
gtk_signal_connect(GTK_OBJECT(DiskTxtLabel), "changed",
GTK_SIGNAL_FUNC(GLEnterDiskTxt),
DiskTxtLabel);
sprintf(InitString, "%s", Texture[Disk].TextFile);
gtk_entry_set_text (GTK_ENTRY (DiskTxtLabel), InitString);
gtk_entry_select_region (GTK_ENTRY (DiskTxtLabel),
0, GTK_ENTRY(DiskTxtLabel)->text_length);
gtk_table_attach (GTK_TABLE(glTxtTable), DiskTxtLabel, 1, 2, 3, 4,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (DiskTxtLabel);
if (Flags.texture == OFF)
gtk_widget_set_sensitive(DiskTxtLabel,FALSE);
}
#endif
/* --------------------------------------------------------------------- */
/* Start with Textyp Options */
glTypHBox = gtk_hbox_new (TRUE, 0);
gtk_table_attach (GTK_TABLE(glTxtTable), glTypHBox, 0, 2, 4, 5,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (glTypHBox);
/* GLPoints button */
ButtonIMAGE = gtk_radio_button_new_with_label (NULL, _("Image") );
if (Flags.textype == IMAGE)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonIMAGE), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonIMAGE,
_("Use image for texture"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonIMAGE), "clicked",
(GtkSignalFunc) GLTexTypeEvent,
GINT_TO_POINTER((gint) IMAGE));
gtk_box_pack_start (GTK_BOX (glTypHBox), ButtonIMAGE, FALSE, FALSE, 0);
gtk_widget_show (ButtonIMAGE);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonIMAGE));
/* Wire frame button */
ButtonFLUX = gtk_radio_button_new_with_label (group, _("Flux") );
if (Flags.textype == FLUX)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonFLUX), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonFLUX,
_("Use flux for texture"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonFLUX), "clicked",
(GtkSignalFunc) GLTexTypeEvent,
GINT_TO_POINTER((gint) FLUX));
gtk_box_pack_start (GTK_BOX (glTypHBox), ButtonFLUX, FALSE, FALSE, 0);
gtk_widget_show (ButtonFLUX);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonFLUX));
/* Wire frame button */
ButtonTEMP = gtk_radio_button_new_with_label (group, _("Temperature") );
if (Flags.textype == TEMP)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonTEMP), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonTEMP,
_("Use temperature for texture"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonTEMP), "clicked",
(GtkSignalFunc) GLTexTypeEvent,
GINT_TO_POINTER((gint) TEMP));
gtk_box_pack_start (GTK_BOX (glTypHBox), ButtonTEMP, FALSE, FALSE, 0);
gtk_widget_show (ButtonTEMP);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonTEMP));
/* Wire frame button */
ButtonGRAV = gtk_radio_button_new_with_label (group, _("Gravity") );
if (Flags.textype == GRAV)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonGRAV), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonGRAV,
_("Use surface gravity for texture"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonGRAV), "clicked",
(GtkSignalFunc) GLTexTypeEvent,
GINT_TO_POINTER((gint) GRAV));
gtk_box_pack_start (GTK_BOX (glTypHBox), ButtonGRAV, FALSE, FALSE, 0);
gtk_widget_show (ButtonGRAV);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonGRAV));
/* Wire frame button */
ButtonVELOCITY = gtk_radio_button_new_with_label (group, _("Velocity") );
if (Flags.textype == VELOCITY)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonVELOCITY), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonVELOCITY,
_("Use radial velocity for texture"),
NULL);
gtk_signal_connect (GTK_OBJECT (ButtonVELOCITY), "clicked",
(GtkSignalFunc) GLTexTypeEvent,
GINT_TO_POINTER((gint) VELOCITY));
gtk_box_pack_start (GTK_BOX (glTypHBox), ButtonVELOCITY, FALSE, FALSE, 0);
gtk_widget_show (ButtonVELOCITY);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ButtonVELOCITY));
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Display Options frame */
DispOptFrame = gtk_frame_new (_("Display Options") );
gtk_container_add (GTK_CONTAINER (glBaseVBox), DispOptFrame);
gtk_container_set_border_width(GTK_CONTAINER(DispOptFrame), 2);
gtk_widget_show (DispOptFrame);
glDispOptTable = gtk_table_new (1, 2, TRUE);
/* Start with display options frame */
glDispOptHBox = gtk_hbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (DispOptFrame), glDispOptHBox);
gtk_container_set_border_width (GTK_CONTAINER (glDispOptHBox), 4);
gtk_widget_show (glDispOptHBox);
/* Label button */
ButtonLabels = gtk_check_button_new_with_label (_("Show Labels") );
if (Flags.labels == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonLabels), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonLabels,
_("Show labels for the components"), NULL);
gtk_signal_connect (GTK_OBJECT (ButtonLabels), "clicked",
(GtkSignalFunc) GLLabelsEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glDispOptTable),ButtonLabels, 0, 1, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonLabels);
/* Axes button */
ButtonAxes = gtk_check_button_new_with_label (_("Show Axes") );
if (Flags.axes == ON)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ButtonAxes), TRUE);
gtk_tooltips_set_tip (tooltips, ButtonAxes,
_("Show x,y,z axes"), NULL);
gtk_signal_connect (GTK_OBJECT (ButtonAxes), "clicked",
(GtkSignalFunc) GLAxesEvent,
(gpointer) "0");
gtk_table_attach (GTK_TABLE(glDispOptTable),ButtonAxes, 1, 2, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 2, 2);
gtk_widget_show (ButtonAxes);
gtk_box_pack_start (GTK_BOX (glDispOptHBox), glDispOptTable, FALSE, FALSE, 0);
gtk_widget_show(glDispOptTable);
/* --------------------------------------------------------------------- */
/* Create button bar */
/* Start with GL Options frame */
glButtonHBox = gtk_hbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (glBaseVBox), glButtonHBox);
gtk_container_set_border_width (GTK_CONTAINER (glButtonHBox), 4);
gtk_widget_show (glButtonHBox);
/* Ok button */
ButtonOk = gtk_button_new_with_label (_("Ok") );
gtk_signal_connect (GTK_OBJECT (ButtonOk), "clicked",
GTK_SIGNAL_FUNC (GLOkPrefs),NULL);
gtk_box_pack_start (GTK_BOX (glButtonHBox), ButtonOk, TRUE, TRUE, 0);
(GTK_WIDGET_FLAGS (ButtonOk) |= (GTK_CAN_DEFAULT));
gtk_widget_grab_default (ButtonOk);
gtk_widget_show (ButtonOk);
/* Apply button */
ButtonApply = gtk_button_new_with_label (_("Apply") );
gtk_signal_connect (GTK_OBJECT (ButtonApply), "clicked",
GTK_SIGNAL_FUNC (GLApplyPrefs),NULL);
gtk_box_pack_start (GTK_BOX (glButtonHBox), ButtonApply, TRUE, TRUE, 0);
(GTK_WIDGET_FLAGS (ButtonApply) |= (GTK_CAN_DEFAULT));
gtk_widget_grab_default (ButtonApply);
gtk_widget_show (ButtonApply);
/* Cancel button */
ButtonCancel = gtk_button_new_with_label (_("Cancel") );
gtk_signal_connect (GTK_OBJECT (ButtonCancel), "clicked",
GTK_SIGNAL_FUNC (GLDeletePrefs),
GTK_WIDGET (glPrefsWindow));
gtk_box_pack_start (GTK_BOX (glButtonHBox), ButtonCancel, TRUE, TRUE, 0);
(GTK_WIDGET_FLAGS (ButtonCancel) |= (GTK_CAN_DEFAULT));
gtk_widget_grab_default (ButtonCancel);
gtk_widget_show (ButtonCancel);
return;
}
#endif /* OpenGL end */
syntax highlighted by Code2HTML, v. 0.9.1