This commit is contained in:
Alexander Deynichenko
2013-02-25 07:23:44 +04:00
parent 35ff18a6a1
commit 03b62f3315
809 changed files with 211135 additions and 0 deletions

View File

@@ -0,0 +1,756 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: LoadSave.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include <stdio.h>
#include "WidgetList.h"
#define TAG_SAVEFILE 0x00000001
#define TAG_WINDOW 0x00000002
#define TAG_OBJECT 0x00000004
#define TAG_WIDGET 0x00000008
#define TAG_SIZE 0x00000010
#define TAG_POSITION 0x00000020
#define TAG_COLOR 0x00000040
#define TAG_LEGEND 0x00000080
#define TAG_LABEL 0x00000100
#define TAG_DATA 0x00000120
#define CALLBACK_UP 0x00000001
#define CALLBACK_ACTIVE 0x00000002
#define CALLBACK_DOWN 0x00000004
#ifdef WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
// From the Main Window:
extern WidgetList *widgets ;
extern int max_layer ;
extern int main_window_width ;
extern int main_window_height ;
extern char main_window_name [ PUSTRING_MAX ] ;
extern int main_window_x ;
extern int main_window_y ;
extern int widget_number ;
extern bool main_window_changed ;
extern bool currently_loading ; /* Var for the Reshape function to not do its thing */
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern bool autolock ;
extern float main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ;
// From the Status Window
extern void setStatusWidgets ( WidgetList *wid );
extern int status_window ;
extern int main_window ;
extern puaFileSelector *file_selector ;
// Duplication checking
static void chk_dupname ( WidgetList *new_wid ) ;
static puInput *dup_newname = (puInput *)NULL ;
static puDialogBox *dup_dialog = (puDialogBox *)NULL ;
static WidgetList *nextwid ;
// Now our turn
void saveProject ( puObject *ob ) {
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
/* If they didn't give an extension, then tack ".xml" onto the end. */
if(!strstr(filename, "."))
sprintf(filename, "%s.xml", filename);
FILE *out = fopen ( filename, "wt" ) ;
if ( !out )
printf ( "ERROR opening file <%s> for writing\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !out ) return ;
/* Begin writing the XML */
const char *autolock_text;
if ( !autolock )
autolock_text="FALSE";
else
autolock_text="TRUE";
char projectname [] = "Test Project";
fprintf ( out, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE P-Guide>\n<savefile>\n\n" ) ;
fprintf ( out, "<version>VERSION</version>\n") ;
fprintf ( out, "<project>%s</project>\n", projectname) ;
fprintf ( out, "<autolock>%s</autolock>\n", autolock_text) ;
fprintf ( out, "<window>\n\t<name>%s</name>\n", main_window_name) ;
fprintf ( out, "\t<size>\n\t\t<width>%d</width>\n", main_window_width) ;
fprintf ( out, "\t\t<height>%d</height>\n\t</size>\n", main_window_height) ;
fprintf ( out, "\t<position>\n\t\t<x>%d</x>\n", main_window_x) ;
fprintf ( out, "\t\t<y>%d</y>\n\t</position>\n", main_window_y) ;
fprintf ( out, "\t<color>\n\t\t<r>%f</r>\n\t\t<g>%f</g>\n\t\t<b>%f</b>\n", main_window_color_r, main_window_color_g, main_window_color_b) ;
fprintf ( out, "\t\t<a>%f</a>\n\t</color>\n</window>\n\n", main_window_color_a) ;
fprintf ( out, "<objects>\n") ;
/* Now begin spitting out the actual widget data. */
WidgetList *wid = widgets ;
const char *place_name [] = { "PUPLACE_TOP_LEFT", "PUPLACE_TOP_CENTERED", "PUPLACE_TOP_RIGHT",
"PUPLACE_CENTERED_LEFT", "PUPLACE_CENTERED_RIGHT",
"PUPLACE_BOTTOM_LEFT", "PUPLACE_BOTTOM_CENTERED", "PUPLACE_BOTTOM_RIGHT",
"PUPLACE_CENTERED_CENTERED",
"PUPLACE_ABOVE_LEFT", "PUPLACE_ABOVE_RIGHT",
"PUPLACE_BELOW_LEFT", "PUPLACE_BELOW_RIGHT",
"PUPLACE_UPPER_LEFT", "PUPLACE_UPPER_RIGHT",
"PUPLACE_LOWER_LEFT", "PUPLACE_LOWER_RIGHT" } ;
while ( wid )
{
puObject *obj = wid->obj ;
int x, y, w, h ;
const char *hidden ;
const char *locked ;
const char *bool_one ;
const char *bool_two ;
const char *bool_three ;
obj->getPosition ( &x, &y ) ;
obj->getSize ( &w, &h ) ;
fprintf ( out, "\t<widget>\n\t\t<name>%s</name>\n", wid->object_name) ;
if (wid->legend_text != NULL)
fprintf ( out, "\t\t<legend>\n\t\t\t<text>%s</text>\n\t\t\t<pos>%s</pos>\n\t\t</legend>\n", wid->legend_text, place_name [ obj->getLegendPlace () ] ) ;
if (wid->label_text != NULL)
fprintf ( out, "\t\t<label>\n\t\t\t<text>%s</text>\n\t\t\t<pos>%s</pos>\n\t\t</label>\n", wid->label_text, place_name [ obj->getLabelPlace () ] ) ;
fprintf ( out, "\t\t<type>%s</type>\n", wid->object_type_name) ;
if ( !wid->visible )
hidden="FALSE";
else
hidden="TRUE";
if ( !wid->locked )
locked="FALSE";
else
locked="TRUE";
if ( wid->callbacks & CALLBACK_UP ) // Up-callback defined
fprintf ( out, "\t\t<callbacks>Up</callbacks>\n") ;
if ( wid->callbacks & CALLBACK_ACTIVE ) // Active callback defined
fprintf ( out, "\t\t<callbacks>Active</callbacks>\n") ;
if ( wid->callbacks & CALLBACK_DOWN ) // Down-callback defined
fprintf ( out, "\t\t<callbacks>Down</callbacks>\n") ;
if ( wid->callbacks == 0 )
fprintf ( out, "\t\t<callbacks></callbacks>\n") ;
fprintf ( out, "\t\t<layer>%d</layer>\n", wid->layer) ;
fprintf ( out, "\t\t<visible>%s</visible>\n", hidden) ;
fprintf ( out, "\t\t<locked>%s</locked>\n", locked) ;
fprintf ( out, "\t\t<size>\n\t\t\t<width>%d</width>\n\t\t\t<height>%d</height>\n\t\t</size>\n", w, h) ;
fprintf ( out, "\t\t<position>\n\t\t\t<x>%d</x>\n\t\t\t<y>%d</y>\n\t\t</position>\n", x, y) ;
fprintf ( out, "\t\t<data>\n\t\t\t<int1>%d</int1>\n\t\t\t<int2>%d</int2>\n", wid->intval1, wid->intval2) ;
if ( wid->boolval1 )
bool_one = "TRUE";
else
bool_one = "FALSE";
if ( wid->boolval2 )
bool_two = "TRUE";
else
bool_two = "FALSE";
if ( wid->boolval3 )
bool_three = "TRUE";
else
bool_three = "FALSE";
fprintf ( out, "\t\t\t<bool1>%s</bool1>\n\t\t\t<bool2>%s</bool2>\n\t\t\t<bool3>%s</bool3>\n", bool_one, bool_two, bool_three) ;
fprintf ( out, "\t\t\t<float1>%f</float1>\n\t\t\t<float2>%f</float2>\n", wid->floatval1, wid->floatval2) ;
fprintf ( out, "\t\t\t<float3>%f</float3>\n\t\t\t<float4>%f</float4>\n", wid->floatval3, wid->floatval4) ;
fprintf ( out, "\t\t\t<float5>%f</float5>\n\t\t\t<float6>%f</float6>\n", wid->floatval5, wid->floatval6) ;
if (wid->allowed)
fprintf ( out, "\t\t\t<allowed>%s</allowed>\n", wid->allowed) ;
/* Walk through the list of items, and make a seperate <items> entry for each line in the string */
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
while ( cr != '\0' )
{
*cr = '\0';
fprintf ( out, "\t\t\t<item>%s</item>\n", temp_items);
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
if (wid->object_type == PUCLASS_ARROW)
{
fprintf ( out, "\t\t\t<item>%s</item>\n", temp_items);
}
}
fprintf ( out, "\t\t</data>\n\t</widget>\n") ;
wid = wid->next ;
}
fprintf ( out, "</objects>\n</savefile>\n") ; /* XML output done */
fclose (out) ;
}
/*static void gotoNextLine( char* buffer )
{
while (buffer != "\n")
buffer++ ;
}*/
void loadProject ( puObject *ob ) {
extern puInput *window_name ;
extern puInput *window_size_x ;
extern puInput *window_size_y ;
extern puInput *window_position_x ;
extern puInput *window_position_y ;
extern puaSpinBox *window_color_r ;
extern puaSpinBox *window_color_g ;
extern puaSpinBox *window_color_b ;
extern puaSpinBox *window_color_a ;
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
FILE *in = fopen ( filename, "rt" ) ;
if ( !in )
printf ( "ERROR opening file <%s> for reading\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !in ) return ;
char rawbuffer[2048];
// Verify file is XML
float tver = 0.0f ;
char encversion[PUSTRING_MAX];
fgets( rawbuffer, sizeof(rawbuffer), in) ;
sscanf(rawbuffer,"<?xml version=\"%f\" encoding=\"%s\" ?>", &tver, encversion) ;
if (!tver) {
printf ("File does not contain proper XML headings.\n");
return ;
}
// Verify file is P-Guide
char tag[PUSTRING_MAX] ;
char tagvalue[PUSTRING_MAX] ;
fgets( rawbuffer, sizeof(rawbuffer), in) ;
if (!sscanf(rawbuffer,"<!DOCTYPE %s>", tag)) {
printf ("File, though XML, does not contain P-Guide information (or has damaged header information).\n");
return ;
}
// Start reading XML
main_window_changed = true ;
currently_loading = true ;
int groupid = 0 ;
puObject *new_obj = NULL;
WidgetList *new_wid = NULL ;
/* Dandy little variables */
int wid_val_y = 0, wid_val_x = 0, val_object_width = 20, val_object_height = 20, val_label_place = 4, val_legend_place = 8;
int intval1 = 0, intval2 = 0 ;
bool boolval1 = false, boolval2 = false, boolval3 = false ;
float floatval1 = 0.0f, floatval2 = 0.0f, floatval3 = 0.0f, floatval4 = 0.0f, floatval5 = 0.0f, floatval6 = 0.0f;
while(fgets( rawbuffer, sizeof(rawbuffer), in))
{
/**************************************************************/
/* Key for Groups in our XML file located at top of this file */
/**************************************************************/
*tag = '\0';
*tagvalue = '\0';
char *buffer = rawbuffer;
/* From here on we walk, line by line, through the XML and parse any tags we come to. */
while (*buffer == '\t' || *buffer == ' ') /* Ignore the tabs and spaces */
buffer++ ;
sscanf(buffer,"<%[^>]>", tag); /* Get the tag */
while (*buffer !='>') buffer++;
sscanf(buffer,">%[a-zA-Z_!@#$^&*0123456789-+/\\{}()=~`,. ]</", tagvalue) ; /* Get the tag's value. */
/* Classify the tag, so we know where the next will fit. */
if ( strstr(tag,"savefile") ) groupid |= TAG_SAVEFILE ;
if ( strstr(tag,"window") ) groupid |= TAG_WINDOW ;
if ( strstr(tag,"size") ) groupid |= TAG_SIZE ;
if ( strstr(tag,"position") ) groupid |= TAG_POSITION ;
if ( strstr(tag,"color") ) groupid |= TAG_COLOR ;
if ( strstr(tag,"object") ) groupid |= TAG_OBJECT ;
if ( strstr(tag,"widget") ) groupid |= TAG_WIDGET ;
if ( strstr(tag,"legend") ) groupid |= TAG_LEGEND ;
if ( strstr(tag,"label") ) groupid |= TAG_LABEL ;
if ( strstr(tag,"data") ) groupid |= TAG_DATA ;
/* Note: Order here matters, since the strstrs above WILL match closing tags. This */
/* doesn't hurt anything, as long as we remove the bitset when we realize they are */
/* close tags, not open ones. */
/* De-classify the tag, so we know where it doesn't fit. */
if ( strstr(tag,"/savefile") ) groupid ^= TAG_SAVEFILE ;
if ( strstr(tag,"/window") ) groupid ^= TAG_WINDOW ;
if ( strstr(tag,"/size") ) groupid ^= TAG_SIZE ;
if ( strstr(tag,"/position") ) groupid ^= TAG_POSITION ;
if ( strstr(tag,"/color") ) groupid ^= TAG_COLOR ;
if ( strstr(tag,"/object") ) groupid ^= TAG_OBJECT ;
if ( strstr(tag,"/widget") ) groupid ^= TAG_WIDGET ;
if ( strstr(tag,"/legend") ) groupid ^= TAG_LEGEND ;
if ( strstr(tag,"/label") ) groupid ^= TAG_LABEL ;
if ( strstr(tag,"/data") ) groupid ^= TAG_DATA ;
/* Now that the tag's classifcation has been determined, rip the data */
/* viciously from its' hold and throw it onto the memory stack. */
if (groupid & TAG_SAVEFILE )
{
/* NULLCHECK! */
if (tagvalue[0] == '\0') { sprintf(tagvalue, " "); }
if ( strstr(tag,"autolock") )
{
if (strstr(tagvalue, "TRUE"))
autolock = true ;
else
autolock = false ;
}
if (groupid & TAG_WINDOW)
{
if ( strstr(tag,"name") )
{
window_name->setValue(tagvalue) ;
strcpy(main_window_name, tagvalue);
}
if (groupid & TAG_SIZE)
{
if ( strstr(tag,"width") )
window_size_x->setValue(tagvalue) ;
if ( strstr(tag,"height") )
window_size_y->setValue(tagvalue) ;
}
if (groupid & TAG_POSITION)
{
if ( strstr(tag,"x") )
window_position_x->setValue(tagvalue) ;
if ( strstr(tag,"y") )
window_position_y->setValue(tagvalue) ;
}
if (groupid & TAG_COLOR)
{
if ( strstr(tag,"r") )
window_color_r->setValue(tagvalue) ;
if ( strstr(tag,"g") )
window_color_g->setValue(tagvalue) ;
if ( strstr(tag,"b") )
window_color_b->setValue(tagvalue) ;
if ( strstr(tag,"a") )
window_color_a->setValue(tagvalue) ;
}
}
if (groupid & TAG_OBJECT)
{
if ( strstr(tag,"/widget") )
{
extern WidgetList *widgets ;
/* Create a new frame in the viewing window (for manipulation). */
new_obj = new puFrame ( 0, 0, val_object_width, val_object_height ) ;
new_obj->setWindow( main_window ) ;
/* Set the representative widget's position */
new_obj->setPosition ( wid_val_x, wid_val_y ) ;
new_obj->setLegend ( new_wid->object_type_name ) ;
new_obj->setLegendPlace ( val_legend_place ) ;
if (new_wid->label_text)
{
new_obj->setLabel ( new_wid->label_text ) ;
new_obj->setLabelPlace ( val_label_place ) ; /**/
}
new_wid->boolval1 = boolval1;
new_wid->boolval2 = boolval2;
new_wid->boolval3 = boolval3;
new_wid->intval1 = intval1;
new_wid->intval2 = intval2;
new_wid->floatval1 = floatval1;
new_wid->floatval2 = floatval2;
new_wid->floatval3 = floatval3;
new_wid->floatval4 = floatval4;
new_wid->floatval5 = floatval5;
new_wid->floatval6 = floatval6;
intval1 = intval2 = 0 ;
boolval1 = boolval2 = boolval3 = false ;
floatval1 = floatval2 = floatval3 = floatval4 = floatval5 = floatval6 = 0.0f;
new_wid->obj = new_obj ;
new_wid->next = widgets ;
widgets = new_wid ;
} else if ( strstr(tag,"widget") ) {
/* Add the new object to the list of widgets (for the builder itself) */
new_wid = new WidgetList ;
/* Set those dandy variables */
wid_val_y = 0; wid_val_x = 0;
val_object_width = 20; val_object_height = 20;
val_label_place = 4; val_legend_place = 8;
new_wid->callbacks = 0;
new_wid->allowed = (char *)NULL ;
new_wid->items = (char *)NULL ;
new_wid->locked = false;
new_wid->legend_text = NULL ;
new_wid->label_text = NULL ;
}
if (groupid & TAG_WIDGET)
{
if ( strstr(tag,"name") )
{
strcpy(new_wid->object_name, tagvalue) ;
/* As names are copied, look for defaults (widget0..9999), */
/* and if it's higher than the current widget_number, set */
/* widget_number to it. */
int tmp_wid_num = 0;
sscanf(tagvalue, "widget%d", &tmp_wid_num) ;
if (tmp_wid_num >= widget_number) widget_number = tmp_wid_num + 1;
}
if ( strstr(tag,"type") )
{
new_wid->object_type = 0 ;
new_wid->object_type_name = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->object_type_name, tagvalue) ;
/* BEWARE: Popup[menu], BiSlider[WithEnds], and Button[box] want to be each other! Don't let them! */
if ( strstr(new_wid->object_type_name, "puaList")) new_wid->object_type |= PUCLASS_LIST ;
if ( strstr(new_wid->object_type_name, "puaChooser")) new_wid->object_type |= PUCLASS_CHOOSER ;
if ( strstr(new_wid->object_type_name, "puaSliderWithInput")) new_wid->object_type |= PUCLASS_SLIDERWITHINPUT ;
if ( strstr(new_wid->object_type_name, "puaBiSliderWithEnds")) new_wid->object_type |= PUCLASS_BISLIDERWITHENDS ;
else if ( strstr(new_wid->object_type_name, "puaBiSlider")) new_wid->object_type |= PUCLASS_BISLIDER ;
if ( strstr(new_wid->object_type_name, "puaScrollBar")) new_wid->object_type |= PUCLASS_SCROLLBAR ;
if ( strstr(new_wid->object_type_name, "puaSpinBox")) new_wid->object_type |= PUCLASS_SPINBOX ; /**/
if ( strstr(new_wid->object_type_name, "puaSelectBox")) new_wid->object_type |= PUCLASS_SELECTBOX ;
if ( strstr(new_wid->object_type_name, "puaComboBox")) new_wid->object_type |= PUCLASS_COMBOBOX ;
if ( strstr(new_wid->object_type_name, "puaLargeInput")) new_wid->object_type |= PUCLASS_LARGEINPUT ;
if ( strstr(new_wid->object_type_name, "puaVerticalMenu")) new_wid->object_type |= PUCLASS_VERTMENU ;
if ( strstr(new_wid->object_type_name, "puaTriSlider")) new_wid->object_type |= PUCLASS_TRISLIDER ;
if ( strstr(new_wid->object_type_name, "puaFileSelector")) new_wid->object_type |= PUCLASS_FILESELECTOR ;
if ( strstr(new_wid->object_type_name, "puDial")) new_wid->object_type |= PUCLASS_DIAL ;
if ( strstr(new_wid->object_type_name, "puListBox")) new_wid->object_type |= PUCLASS_LISTBOX ;
if ( strstr(new_wid->object_type_name, "puArrowButton")) new_wid->object_type |= PUCLASS_ARROW ;
if ( strstr(new_wid->object_type_name, "puDialogBox")) new_wid->object_type |= PUCLASS_DIALOGBOX ; /**/
if ( strstr(new_wid->object_type_name, "puSlider")) new_wid->object_type |= PUCLASS_SLIDER ;
if ( strstr(new_wid->object_type_name, "puButtonBox")) new_wid->object_type |= PUCLASS_BUTTONBOX ;
else if ( strstr(new_wid->object_type_name, "puButton")) new_wid->object_type |= PUCLASS_BUTTON ; /* See above for why the elses' */
if ( strstr(new_wid->object_type_name, "puInput")) new_wid->object_type |= PUCLASS_INPUT ;
if ( strstr(new_wid->object_type_name, "puMenuBar")) new_wid->object_type |= PUCLASS_MENUBAR ;
if ( strstr(new_wid->object_type_name, "puPopupMenu")) new_wid->object_type |= PUCLASS_POPUPMENU ; /**/
else if ( strstr(new_wid->object_type_name, "puPopup")) new_wid->object_type |= PUCLASS_POPUP ; /**/
if ( strstr(new_wid->object_type_name, "puOneShot")) new_wid->object_type |= PUCLASS_ONESHOT ;
if ( strstr(new_wid->object_type_name, "puText")) new_wid->object_type |= PUCLASS_TEXT ;
if ( strstr(new_wid->object_type_name, "puFrame")) new_wid->object_type |= PUCLASS_FRAME ;
}
if ( strstr(tag,"callbacks") )
{
/* Update callback's bit set */
if (strstr(tagvalue, "Up")) new_wid->callbacks |= CALLBACK_UP ;
if (strstr(tagvalue, "Down")) new_wid->callbacks |= CALLBACK_DOWN ;
if (strstr(tagvalue, "Active")) new_wid->callbacks |= CALLBACK_ACTIVE ;
}
if ( strstr(tag,"layer") )
{
new_wid->layer = atoi(tagvalue) ;
if ( max_layer <= new_wid->layer ) max_layer = new_wid->layer + 1 ;
}
if ( strstr(tag,"visible") )
{
if (strstr(tagvalue, "TRUE"))
new_wid->visible = true ;
else
new_wid->visible = false ;
}
if ( strstr(tag,"locked") )
{
if (strstr(tagvalue, "TRUE"))
new_wid->locked = true ;
else
new_wid->locked = false ;
}
if (groupid & TAG_LEGEND)
{
if ( strstr(tag,"text") )
{
delete new_wid->legend_text;
new_wid->legend_text = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->legend_text, tagvalue) ;
}
if ( strstr(tag,"pos") )
{
if (strstr(tagvalue, "PUPLACE_TOP_LEFT")) val_legend_place = PUPLACE_TOP_LEFT ;
if (strstr(tagvalue, "PUPLACE_TOP_CENTERED")) val_legend_place = PUPLACE_TOP_CENTERED ;
if (strstr(tagvalue, "PUPLACE_TOP_RIGHT")) val_legend_place = PUPLACE_TOP_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_LEFT")) val_legend_place = PUPLACE_CENTERED_LEFT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_RIGHT")) val_legend_place = PUPLACE_CENTERED_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_LEFT")) val_legend_place = PUPLACE_BOTTOM_LEFT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_CENTERED")) val_legend_place = PUPLACE_BOTTOM_CENTERED ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_RIGHT")) val_legend_place = PUPLACE_BOTTOM_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_CENTERED")) val_legend_place = PUPLACE_CENTERED_CENTERED ;
}
}
if (groupid & TAG_LABEL)
{
if ( strstr(tag,"text") )
{
delete new_wid->label_text;
new_wid->label_text = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->label_text, tagvalue) ;
}
if ( strstr(tag,"pos") )
{
if (strstr(tagvalue, "PUPLACE_TOP_LEFT")) val_label_place = PUPLACE_TOP_LEFT ;
if (strstr(tagvalue, "PUPLACE_TOP_CENTERED")) val_label_place = PUPLACE_TOP_CENTERED ;
if (strstr(tagvalue, "PUPLACE_TOP_RIGHT")) val_label_place = PUPLACE_TOP_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_LEFT")) val_label_place = PUPLACE_CENTERED_LEFT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_RIGHT")) val_label_place = PUPLACE_CENTERED_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_LEFT")) val_label_place = PUPLACE_BOTTOM_LEFT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_CENTERED")) val_label_place = PUPLACE_BOTTOM_CENTERED ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_RIGHT")) val_label_place = PUPLACE_BOTTOM_RIGHT ;
if (strstr(tagvalue, "PUPLACE_ABOVE_LEFT")) val_label_place = PUPLACE_ABOVE_LEFT ;
if (strstr(tagvalue, "PUPLACE_ABOVE_RIGHT")) val_label_place = PUPLACE_ABOVE_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BELOW_LEFT")) val_label_place = PUPLACE_BELOW_LEFT ;
if (strstr(tagvalue, "PUPLACE_BELOW_RIGHT")) val_label_place = PUPLACE_BELOW_RIGHT ;
if (strstr(tagvalue, "PUPLACE_UPPER_LEFT")) val_label_place = PUPLACE_UPPER_LEFT ;
if (strstr(tagvalue, "PUPLACE_UPPER_RIGHT")) val_label_place = PUPLACE_UPPER_RIGHT ;
if (strstr(tagvalue, "PUPLACE_LOWER_LEFT")) val_label_place = PUPLACE_LOWER_LEFT ;
if (strstr(tagvalue, "PUPLACE_LOWER_RIGHT")) val_label_place = PUPLACE_LOWER_RIGHT ;
}
}
if (groupid & TAG_SIZE)
{
if ( strstr(tag,"width") )
val_object_width = atoi(tagvalue) ;
if ( strstr(tag,"height") )
val_object_height = atoi(tagvalue) ;
}
if (groupid & TAG_POSITION)
{
if ( strstr(tag,"x") )
wid_val_x = atoi(tagvalue) ;
if ( strstr(tag,"y") )
wid_val_y = atoi(tagvalue) ;
}
if (groupid & TAG_DATA)
{
if ( strstr(tag,"int1") )
intval1 = atoi (tagvalue) ;
if ( strstr(tag,"int2") )
intval2 = atoi (tagvalue) ;
if ( strstr(tag,"bool1") )
{
if (strstr(tagvalue, "TRUE"))
boolval1 = true ;
else
boolval1 = false ;
}
if ( strstr(tag,"bool2") )
{
if (strstr(tagvalue, "TRUE"))
boolval2 = true ;
else
boolval2 = false ;
}
if ( strstr(tag,"bool3") )
{
if (strstr(tagvalue, "TRUE"))
boolval3 = true ;
else
boolval3 = false ;
}
if ( strstr(tag,"float1") )
floatval1 = (float)atof (tagvalue) ;
if ( strstr(tag,"float2") )
floatval2 = (float)atof (tagvalue) ;
if ( strstr(tag,"float3") )
floatval3 = (float)atof (tagvalue) ;
if ( strstr(tag,"float4") )
floatval4 = (float)atof (tagvalue) ;
if ( strstr(tag,"float5") )
floatval5 = (float)atof (tagvalue) ;
if ( strstr(tag,"float6") )
floatval6 = (float)atof (tagvalue) ;
if ( strstr(tag,"allowed") )
{
new_wid->allowed = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->allowed, tagvalue) ;
}
if ( strstr(tag,"item") )
{
strcat(tagvalue, "\n");
if (!new_wid->items)
{
new_wid->items = new char [1024] ;
strcpy(new_wid->items, tagvalue) ;
}
else
strcat(new_wid->items, tagvalue) ;
}
}
}
}
}
if (strstr(tag, "/savefile"))
{
static int mouse_x ;
static int mouse_y ;
setStatusWidgets( new_wid );
glutSetWindow ( main_window ) ;
glutSetWindowTitle ( window_name->getStringValue() ) ;
/* Fake out the Reshape parts that determine whether to move widgets around or not. */
mouse_x = 999 ;
mouse_y = 999 ;
glutReshapeWindow ( window_size_x->getValue(), window_size_y->getValue() ) ;
glutSetWindow ( status_window ) ;
}
buffer[0] = '\0';
}
fclose (in);
WidgetList *wid = widgets;
/* Check name for duplication */
nextwid = wid; /* Note: Yes, this is inelegant, but if we loop here, we end up making many copies of the same dialog box in the same memory space. This is a Bad Thing. */
chk_dupname(nextwid);
/* Done checking name for duplication */
}
static void chk_dupname_ok_cb ( puObject *ob )
{
/* The user's new name from the dialog has already been set to the object_name*/
/* Close dialogbox and update main window ...*/
puDeleteObject ( dup_dialog ) ;
dup_dialog = (puDialogBox *)NULL ;
dup_newname = (puInput *)NULL ;
/*but force a recheck afterwards to ensure it's an okay substitution. */
nextwid = nextwid->next ;
chk_dupname(nextwid);
}
static void chk_dupname ( WidgetList *new_wid )
{
if (!new_wid)
return;
WidgetList *wid = widgets ;
while ( wid )
{
if ( (strcmp(new_wid->object_name,wid->object_name) == 0) && (new_wid != wid) )
{
/* Popup a dialog telling user something's bad! */
dup_dialog = new puDialogBox ( 20, 20 ) ;
new puFrame ( 0, 0, 460, 120 ) ;
puText *text = new puText ( 80, 85 ) ;
text->setLabel ( "ERROR: Name already used." ) ;
text->setLabelFont(PUFONT_TIMES_ROMAN_24);
puText *directions = new puText ( 90, 65 ) ;
directions->setLabel ( "Please type in a new, unique name to continue." ) ;
directions->setLabelFont(PUFONT_HELVETICA_12);
dup_newname = new puInput (20,40,440,60) ;
dup_newname->setValuator(new_wid->object_name);
dup_newname->setValidData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_012345679");
puOneShot *ok = new puOneShot ( 200, 10, "Accept" ) ;
ok->setCallback ( chk_dupname_ok_cb ) ;
dup_dialog->close () ;
dup_dialog->reveal () ;
break ;
}
wid = wid->next ;
}
}

View File

@@ -0,0 +1,9 @@
bin_PROGRAMS = pguide
pguide_SOURCES = pGuide.cxx StatusWindow.cxx WidgetList.h \
WidgetWindow.cxx WriteCode.cxx LoadSave.cxx PropertiesWindow.cxx
pguide_LDADD = -lplibpuaux
EXTRA_DIST = pGuide.dsp

View File

@@ -0,0 +1,610 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: PropertiesWindow.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Status Window
#include <plib/pu.h>
#include "WidgetList.h"
// From the Main Window:
extern int max_layer ;
extern WidgetList *active_widget ;
extern puObject *active_object ;
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern bool main_window_changed ;
// Status window parameters
int properties_window = 0 ; // Window handle
extern int main_window ;
// Status window widgets
puGroup *properties_group ;
// Function to set the widgets from the active object
// GLUT Status Window Callbacks
static void properties_window_specialfn ( int key, int, int )
{
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
glutPostRedisplay () ;
}
static void properties_window_keyfn ( unsigned char key, int, int )
{
puKeyboard ( key, PU_DOWN ) ;
glutPostRedisplay () ;
}
static void properties_window_motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
static void properties_window_mousefn ( int button, int updown, int x, int y )
{
puMouse ( button, updown, x, y ) ;
glutPostRedisplay () ;
}
static void properties_window_displayfn ( void )
{
glutSetWindow ( properties_window ) ;
/* Clear the screen */
glClearColor ( 0.1f, 0.1f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
puDisplay () ;
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
// PUI Callback Functions:
static void cb_properties_close (puObject *obj)
{
/* Save the changes ... Needed? */
if ( puActiveWidget() )
puActiveWidget() -> invokeDownCallback () ; /* Just make sure the last widget saves ... */
/* Delete the widgets */
puDeleteObject( properties_group );
/* Destroy the window */
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
// Data setting standard callbacks
static void cb_items (puObject *obj)
{
/*Set the Items*/
if (active_widget)
{
delete active_widget->items;
active_widget->items = new char [strlen(obj->getStringValue())+1] ;
strcpy(active_widget->items, obj->getStringValue());
}
}
static void cb_allowed (puObject *obj)
{
/*Set the Allowed string*/
if (active_widget)
{
delete active_widget->allowed;
active_widget->allowed = new char [strlen(obj->getStringValue())+1] ;
strcpy(active_widget->allowed, obj->getStringValue());
}
}
static void cb_int1 (puObject *obj)
{
/*Set the first integer storage value */
if (active_widget)
active_widget->intval1 = obj->getIntegerValue();
}
static void cb_int2 (puObject *obj)
{
/*Set the second integer storage value */
if (active_widget)
active_widget->intval2 = obj->getIntegerValue();
}
static void cb_bool1 (puObject *obj)
{
/*Set the first boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval1 = true ;
else
active_widget->boolval1 = false ;
}
}
static void cb_bool2 (puObject *obj)
{
/*Set the second boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval2 = true ;
else
active_widget->boolval2 = false ;
}
}
static void cb_bool3 (puObject *obj)
{
/*Set the second boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval3 = true ;
else
active_widget->boolval3 = false ;
}
}
static void cb_float1 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval1 = obj->getFloatValue();
}
static void cb_float2 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval2 = obj->getFloatValue();
}
static void cb_float3 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval3 = obj->getFloatValue();
}
static void cb_float4 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval4 = obj->getFloatValue();
}
static void cb_float5 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval5 = obj->getFloatValue();
}
static void cb_float6 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval6 = obj->getFloatValue();
}
// Function to define the window
int define_properties_window ()
{
properties_window = glutCreateWindow ( "Properties" ) ;
glutPositionWindow ( 400, 200 ) ;
glutReshapeWindow ( 500, 250 ) ;
glutDisplayFunc ( properties_window_displayfn ) ;
glutKeyboardFunc ( properties_window_keyfn ) ;
glutSpecialFunc ( properties_window_specialfn ) ;
glutMotionFunc ( properties_window_motionfn ) ;
glutMouseFunc ( properties_window_mousefn ) ;
// Set up the widgets
properties_group = new puGroup ( 0, 0 ) ;
new puFrame ( 0, 0, 500, 250 ) ;
puText *properties_instructions = new puText ( 250, 230 );
properties_instructions->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_instructions->setLabel("Here are the extended options for your");
puText *properties_typelabel = new puText ( 250, 215 );
properties_typelabel->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_typelabel->setLabel(active_widget->object_type_name);
puOneShot *properties_close = new puOneShot ( 370, 10, 490, 30 ) ;
properties_close->setLegend("Accept");
properties_close->setCallback(cb_properties_close);
/* puStyle stuff here*/
/* Now customize the display based on the widget currently selected */
if (active_widget->object_type == PUCLASS_FRAME)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for a puFrame.");
} if (active_widget->object_type == PUCLASS_TEXT)
{
/* Add in font properties? */
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puText.");
} if (active_widget->object_type == PUCLASS_BUTTON)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puButton.");
} if (active_widget->object_type == PUCLASS_ONESHOT)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puOneShot.");
} if ( (active_widget->object_type == PUCLASS_POPUPMENU) ||
(active_widget->object_type == PUCLASS_MENUBAR) ||
(active_widget->object_type == PUCLASS_VERTMENU) ||
(active_widget->object_type == PUCLASS_LISTBOX) ||
(active_widget->object_type == PUCLASS_COMBOBOX) ||
(active_widget->object_type == PUCLASS_SELECTBOX) ||
(active_widget->object_type == PUCLASS_BUTTONBOX) ||
(active_widget->object_type == PUCLASS_LIST) )
{
/* List */
puaLargeInput *properties_list_items = new puaLargeInput(10,10,300,195,0,5);
properties_list_items->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_items->setLabel("Enter items, each on a new line.");
properties_list_items->setValidData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_012345679 :;.,\n");
properties_list_items->setCallback(cb_items);
properties_list_items->setDownCallback(cb_items);
properties_list_items->setValue(active_widget->items);
puText *properties_list_note = new puText(400,190);
properties_list_note->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_note->setLabel("Each line will become");
puText *properties_list_note2 = new puText(400,175);
properties_list_note2->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_note2->setLabel("a selection option.");
} if (active_widget->object_type == PUCLASS_POPUPMENU)
{
/* Allow a list of menu items, and remember to point out these are hidden when created, and must be reveal()ed. */
/* NOT CURRENTLY IMPLEMENTED */
puText *properties_popupmenu_warning = new puText(400,150);
properties_popupmenu_warning->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_popupmenu_warning->setLabel("WARNING: Popup Menus are hidden by \
default when created. You must use \
reveal() to make them appear.");
} if (active_widget->object_type == PUCLASS_MENUBAR)
{
/* Allow a list of menu items */
} if (active_widget->object_type == PUCLASS_VERTMENU)
{
/* Allow a list of menu items */
} if (active_widget->object_type == PUCLASS_LISTBOX)
{
/* Allow a list of items */
} if (active_widget->object_type == PUCLASS_COMBOBOX)
{
/* List and a setCurrentItem, and if editable */
puaSpinBox *properties_combobox_currentitem = new puaSpinBox(320,135,480,155);
properties_combobox_currentitem->setLabel("Initial Selection:");
properties_combobox_currentitem->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_combobox_currentitem->setMinValue(0.0f);
properties_combobox_currentitem->setMaxValue(30.0f);
properties_combobox_currentitem->setCallback(cb_int1);
properties_combobox_currentitem->setValue(active_widget->intval1);
static char *properties_combobox_editable_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_combobox_editable = new puButtonBox(320, 50, 480, 120, properties_combobox_editable_callback_entries, TRUE);
properties_combobox_editable->setLabel("Editable?");
properties_combobox_editable->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_combobox_editable->setCallback(cb_bool1);
properties_combobox_editable->setValue(active_widget->boolval1);
} if (active_widget->object_type == PUCLASS_SELECTBOX)
{
/* List and a setCurrentItem */
puaSpinBox *properties_selectbox_currentitem = new puaSpinBox(320,135,480,155);
properties_selectbox_currentitem->setLabel("Initial Selection:");
properties_selectbox_currentitem->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_selectbox_currentitem->setMinValue(0.0f);
properties_selectbox_currentitem->setMaxValue(30.0f);
properties_selectbox_currentitem->setCallback(cb_int1);
properties_selectbox_currentitem->setValue(active_widget->intval1);
} if (active_widget->object_type == PUCLASS_BUTTONBOX)
{
/* Allow a list of menu items, and if multiple can be selected at once */
puText *properties_buttonbox_label = new puText(400,135);
properties_buttonbox_label->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_buttonbox_label->setLabel("Allow multiple");
static char *properties_buttonbox_multiselect_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_buttonbox_multiselect = new puButtonBox(320, 50, 480, 120, properties_buttonbox_multiselect_callback_entries, TRUE);
properties_buttonbox_multiselect->setLabel("selections?");
properties_buttonbox_multiselect->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_buttonbox_multiselect->setCallback(cb_bool1);
properties_buttonbox_multiselect->setValue(active_widget->boolval1);
} if ( (active_widget->object_type == PUCLASS_SLIDER ) ||
(active_widget->object_type == PUCLASS_BISLIDER ) ||
(active_widget->object_type == PUCLASS_TRISLIDER ) ||
(active_widget->object_type == PUCLASS_DIAL ) ||
(active_widget->object_type == PUCLASS_SPINBOX ) ||
(active_widget->object_type == PUCLASS_SCROLLBAR ) ||
(active_widget->object_type == PUCLASS_SLIDERWITHINPUT ) ||
(active_widget->object_type == PUCLASS_BISLIDERWITHENDS ))
{
/* int minx, int miny, int sz, {TRUE|FALSE}, int width */
puaSpinBox *properties_range_setmaxvalue = new puaSpinBox(30,150,110,170);
properties_range_setmaxvalue->setLabel("Maximum Value:");
properties_range_setmaxvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setmaxvalue->setMinValue(-5000.0f);
properties_range_setmaxvalue->setMaxValue(5000.0f);
properties_range_setmaxvalue->setCallback(cb_float1);
properties_range_setmaxvalue->setValue(active_widget->floatval1);
puaSpinBox *properties_range_setminvalue = new puaSpinBox(230,150,310,170);
properties_range_setminvalue->setLabel("Minimum Value:");
properties_range_setminvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setminvalue->setMinValue(-5000.0f);
properties_range_setminvalue->setMaxValue(5000.0f);
properties_range_setminvalue->setCallback(cb_float2);
properties_range_setminvalue->setValue(active_widget->floatval2);
puaSpinBox *properties_range_setstepvalue = new puaSpinBox(400,150,480,170);
properties_range_setstepvalue->setLabel("Step Size:");
properties_range_setstepvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setstepvalue->setMinValue(0.0f);
properties_range_setstepvalue->setMaxValue(5000.0f);
properties_range_setstepvalue->setCallback(cb_float3);
properties_range_setstepvalue->setValue(active_widget->floatval3);
static char *properties_range_cbmode_callback_entries [] = { "On Click", "Always", NULL } ;
puButtonBox *properties_range_cbmode = new puButtonBox(20, 80, 170, 130, properties_range_cbmode_callback_entries, TRUE);
properties_range_cbmode->setLabel("Callback Mode:");
properties_range_cbmode->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_cbmode->setCallback(cb_bool1);
properties_range_cbmode->setValue(active_widget->boolval1);
} if ( (active_widget->object_type == PUCLASS_SLIDER ) ||
(active_widget->object_type == PUCLASS_BISLIDER ) ||
(active_widget->object_type == PUCLASS_TRISLIDER ) ||
(active_widget->object_type == PUCLASS_SCROLLBAR ) )
{
static char *properties_range_vertical_callback_entries [] = { "Horizontal", "Vertical", NULL } ;
puButtonBox *properties_range_vertical = new puButtonBox(20, 10, 170, 60, properties_range_vertical_callback_entries, TRUE);
properties_range_vertical->setLabel("Orientation:");
properties_range_vertical->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_vertical->setValue(active_widget->boolval2);
properties_range_vertical->setCallback(cb_bool2);
} if (active_widget->object_type == PUCLASS_SLIDER)
{
puaSpinBox *properties_slider_value = new puaSpinBox(230,110,310,130);
properties_slider_value->setLabel("Starting Value:");
properties_slider_value->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_slider_value->setMinValue(-5000.0f);
properties_slider_value->setMaxValue(5000.0f);
properties_slider_value->setValue(active_widget->floatval4);
properties_slider_value->setStepSize(0.1f);
properties_slider_value->setCallback(cb_float4);
} if ((active_widget->object_type == PUCLASS_BISLIDER) ||
(active_widget->object_type == PUCLASS_BISLIDERWITHENDS))
{
puaSpinBox *properties_bislider_topvalue = new puaSpinBox(230,110,310,130);
properties_bislider_topvalue->setLabel("Top Slider Value:");
properties_bislider_topvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_bislider_topvalue->setMinValue(-5000.0f);
properties_bislider_topvalue->setMaxValue(5000.0f);
properties_bislider_topvalue->setValue(active_widget->floatval4);
properties_bislider_topvalue->setStepSize(0.1f);
properties_bislider_topvalue->setCallback(cb_float4);
puaSpinBox *properties_bislider_botvalue = new puaSpinBox(230,40,310,60);
properties_bislider_botvalue->setLabel("Bottom Slider Value:");
properties_bislider_botvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_bislider_botvalue->setMinValue(-5000.0f);
properties_bislider_botvalue->setMaxValue(5000.0f);
properties_bislider_botvalue->setValue(active_widget->floatval5);
properties_bislider_botvalue->setStepSize(0.1f);
properties_bislider_botvalue->setCallback(cb_float5);
} if (active_widget->object_type == PUCLASS_TRISLIDER)
{
puaSpinBox *properties_trislider_topvalue = new puaSpinBox(230,110,310,130);
properties_trislider_topvalue->setLabel("Top Slider Value:");
properties_trislider_topvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_topvalue->setMinValue(-5000.0f);
properties_trislider_topvalue->setMaxValue(5000.0f);
properties_trislider_topvalue->setValue(active_widget->floatval4);
properties_trislider_topvalue->setStepSize(0.1f);
properties_trislider_topvalue->setCallback(cb_float4);
puaSpinBox *properties_trislider_centvalue = new puaSpinBox(230,60,310,80);
properties_trislider_centvalue->setLabel("Center Slider Value:");
properties_trislider_centvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_centvalue->setMinValue(-5000.0f);
properties_trislider_centvalue->setMaxValue(5000.0f);
properties_trislider_centvalue->setValue(active_widget->floatval6);
properties_trislider_centvalue->setStepSize(0.1f);
properties_trislider_centvalue->setCallback(cb_float6);
puaSpinBox *properties_trislider_botvalue = new puaSpinBox(230,10,310,30);
properties_trislider_botvalue->setLabel("Bottom Slider Value:");
properties_trislider_botvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_botvalue->setMinValue(-5000.0f);
properties_trislider_botvalue->setMaxValue(5000.0f);
properties_trislider_botvalue->setValue(active_widget->floatval5);
properties_trislider_botvalue->setStepSize(0.1f);
properties_trislider_botvalue->setCallback(cb_float5);
static char *properties_trislider_lock_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_trislider_lock = new puButtonBox(380, 80, 480, 130, properties_trislider_lock_callback_entries, TRUE);
properties_trislider_lock->setLabel("Lock End Sliders:");
properties_trislider_lock->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_lock->setValue(active_widget->boolval3);
properties_trislider_lock->setCallback(cb_bool3);
} if (active_widget->object_type == PUCLASS_DIAL)
{
/* Wrap Mode */
static char *properties_dial_wrap_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_dial_wrap = new puButtonBox(20, 10, 170, 60, properties_dial_wrap_callback_entries, TRUE);
properties_dial_wrap->setLabel("Allow Dial Wrapping:");
properties_dial_wrap->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_dial_wrap->setValue(active_widget->boolval2);
properties_dial_wrap->setCallback(cb_bool2);
} if (active_widget->object_type == PUCLASS_SPINBOX)
{
/* Arrow position and height */
static char *properties_spinbox_arrow_callback_entries [] = { "Left", "Right", NULL } ;
puButtonBox *properties_spinbox_arrow = new puButtonBox(20, 10, 170, 60, properties_spinbox_arrow_callback_entries, TRUE);
properties_spinbox_arrow->setLabel("Arrow Position");
properties_spinbox_arrow->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrow->setValue(active_widget->boolval2);
properties_spinbox_arrow->setCallback(cb_bool2);
puaSpinBox *properties_spinbox_arrowheight = new puaSpinBox(230,110,310,130);
properties_spinbox_arrowheight->setLabel("Arrow Height:");
properties_spinbox_arrowheight->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrowheight->setMinValue(0.0f);
properties_spinbox_arrowheight->setMaxValue(20.0f);
properties_spinbox_arrowheight->setValue(active_widget->floatval4);
properties_spinbox_arrowheight->setStepSize(0.05f);
properties_spinbox_arrowheight->setCallback(cb_float4);
puText *properties_spinbox_arrowextra = new puText ( 310, 90 );
properties_spinbox_arrowextra->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrowextra->setLabel("(as porportion of spinbox height)");
} if (active_widget->object_type == PUCLASS_DIALOGBOX)
{
/* Not yet implemented as a class */
} if (active_widget->object_type == PUCLASS_ARROW)
{
static char *properties_arrow_arrowtype_options [] = { "Up", "Down", "Left", "Right",
"Double-Up", "Double-Down", "Double-Left",
"Double-Right", NULL } ;
puaComboBox *properties_arrow_arrowtype = new puaComboBox ( 120,10,310,30, properties_arrow_arrowtype_options, FALSE ) ;
properties_arrow_arrowtype->setLabel ( "Arrow Type:" ) ;
properties_arrow_arrowtype->setLabelPlace ( PUPLACE_LOWER_LEFT ) ;
properties_arrow_arrowtype->setCallback(cb_items);
int num = 0;
if (active_widget->items)
{
if (strstr(active_widget->items,"Double-Up"))
num = 4;
else if (strstr(active_widget->items,"Double-Down"))
num = 5;
else if (strstr(active_widget->items,"Double-Left"))
num = 6;
else if (strstr(active_widget->items,"Double-Right"))
num = 7;
else if (strstr(active_widget->items,"Up"))
num = 0;
else if (strstr(active_widget->items,"Down"))
num = 1;
else if (strstr(active_widget->items,"Left"))
num = 2;
else if (strstr(active_widget->items,"Right"))
num = 3;
}
properties_arrow_arrowtype->setCurrentItem(num);
} if ( (active_widget->object_type == PUCLASS_INPUT ) ||
(active_widget->object_type == PUCLASS_LARGEINPUT ) )
{
/*int minx, int miny, int maxx, int maxy */
/* Disabled, and Valid Data list */
puInput *properties_input_validdata = new puInput(20, 150, 260, 170);
properties_input_validdata->setLabel("Allowed Characters for Input:");
properties_input_validdata->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_input_validdata->setCallback(cb_allowed);
properties_input_validdata->setDownCallback(cb_allowed);
properties_input_validdata->setValue(active_widget->allowed);
static char *properties_input_enabled_callback_entries [] = { "Yes", NULL } ;
puButtonBox *properties_input_enabled = new puButtonBox(300, 140, 450, 170, properties_input_enabled_callback_entries, FALSE);
properties_input_enabled->setLabel("Input Allowed? (enabled)");
properties_input_enabled->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_input_enabled->setValue(active_widget->boolval1);
properties_input_enabled->setCallback(cb_bool1);
} if ((active_widget->object_type == PUCLASS_LARGEINPUT) ||
(active_widget->object_type == PUCLASS_SCROLLBAR) )
{
/*Arrows*/
static char *properties_largeinput_arrows_callback_entries [] = { "None", "Normal", "Normal and Fast", NULL } ;
puButtonBox *properties_largeinput_arrows = new puButtonBox(20, 10, 200, 130, properties_largeinput_arrows_callback_entries, TRUE);
properties_largeinput_arrows->setLabel("Which Arrow Buttons:");
properties_largeinput_arrows->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_largeinput_arrows->setValue(active_widget->intval1);
properties_largeinput_arrows->setCallback(cb_int1);
} if (active_widget->object_type == PUCLASS_LARGEINPUT)
{
/*Slider Size*/
puaSpinBox *properties_largeinput_sliderwidth = new puaSpinBox(300,90,400,110);
properties_largeinput_sliderwidth->setLabel("Slider Width:");
properties_largeinput_sliderwidth->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_largeinput_sliderwidth->setMinValue(0.0f);
properties_largeinput_sliderwidth->setMaxValue(150.0f);
properties_largeinput_sliderwidth->setValue(active_widget->intval2);
properties_largeinput_sliderwidth->setStepSize(1.0f);
properties_largeinput_sliderwidth->setCallback(cb_int2);
}
/* TODO:
* puaSliderWithInput: is input above or below slider?
* puaList: can we add the transparency field?
*/
properties_group->close () ;
return 0 ;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WidgetList.h 2083 2006-05-01 13:14:50Z bram $
*/
// Data Structure Definition
#ifndef WIDGET_LIST_H
#define WIDGET_LIST_H
#include <plib/pu.h>
#include <plib/puAux.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
// PUI Widget List for Main Window
struct WidgetList
{
puObject *obj ;
char *object_type_name ;
int object_type ;
char *label_text ;
char *legend_text ;
short callbacks ;
char object_name [ PUSTRING_MAX ] ;
bool visible ;
bool locked ;
int layer ; // GUI layer: 0 - in back, positive nubmers - greater in front of lesser
WidgetList *next ;
/* Additional data for the extended properties of widgets */
char *items ;
char *allowed ;
int intval1 ;
int intval2 ;
bool boolval1 ;
bool boolval2 ;
bool boolval3 ;
float floatval1 ;
float floatval2 ;
float floatval3 ;
float floatval4 ;
float floatval5 ;
float floatval6 ;
} ;
#endif // WIDGET_LIST_H

View File

@@ -0,0 +1,460 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WidgetWindow.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Widget Window
#include <stdio.h>
#include <plib/pu.h>
#include <plib/puAux.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
// Widget Window Data
bool selected_object_sticky = false ;
int selected_object_type ;
char *selected_type_string ;
puButton *active_button = (puButton *)NULL ;
// Widget window parameters
static int widget_window = 0 ; // Window handle
// GLUT Widget Window Callbacks
static void widget_window_specialfn ( int key, int, int )
{
glutPostRedisplay () ;
}
static void widget_window_keyfn ( unsigned char key, int, int )
{
if ( selected_object_type )
{
if ( key == 27 ) // Escape key, deactivate the selected button
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void widget_window_motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
static void widget_window_mousefn ( int button, int updown, int x, int y )
{
if ( ! puMouse ( button, updown, x, y ) )
{
// PUI didn't absorb the mouse click; deactivate the selected object type
if ( selected_object_type )
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void widget_window_displayfn ( void )
{
glutSetWindow ( widget_window ) ;
/* Clear the screen */
glClearColor ( 0.1f, 0.1f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
puDisplay () ;
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
// PUI Callback Functions:
static void frame_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_FRAME ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void text_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_TEXT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void menu_bar_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_MENUBAR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void vertical_menu_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_VERTMENU ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void spin_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SPINBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void list_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LIST ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_INPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void large_input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LARGEINPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void select_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SELECTBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void file_selector_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_FILESELECTOR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void list_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LISTBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void scroll_bar_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SCROLLBAR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void button_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BUTTON ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void one_shot_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_ONESHOT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void arrow_button_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_ARROW ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void button_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BUTTONBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void combo_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_COMBOBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void chooser_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_CHOOSER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void dial_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_DIAL ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void slider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void bislider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BISLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void trislider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_TRISLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void slider_with_input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SLIDERWITHINPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void bislider_with_ends_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BISLIDERWITHENDS ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
// Function to define the window
// The widgets are arranged in a rectangle:
// Frame Input Button Dial
// Text Large Input One Shot Slider
// Menu Bar Select Box Arrow Button Bi-Slider
// Vertical Menu File Selector Button Box Tri-Slider
// Spin Box List Box Combo Box Slider with Input
// List Scroll Bar Chooser Bi-Slider with Ends
//
// The following widgets are not offered:
// Group Interface Popup Popup Menu
// Dialog Box
int define_widget_window ()
{
widget_window = glutCreateWindow ( "Widget List" ) ;
int ln = 120 ; // Button length
int ht = 20 ; // Button height
int sp = 10 ; // Button spacing
int total_screen_width = glutGet( GLUT_SCREEN_WIDTH ) ;
glutReshapeWindow ( 4 * ln + 5 * sp, 6 * ht + 7 * sp ) ;
glutPositionWindow ( total_screen_width - (4 * ln + 5 * sp) - 20, 20 ) ;
glutDisplayFunc ( widget_window_displayfn ) ;
glutKeyboardFunc ( widget_window_keyfn ) ;
glutSpecialFunc ( widget_window_specialfn ) ;
glutMotionFunc ( widget_window_motionfn ) ;
glutMouseFunc ( widget_window_mousefn ) ;
// Global variable initialization (type string)
selected_type_string = new char [ PUSTRING_MAX ] ;
// Set up the widgets
puGroup *widget_group = new puGroup ( 0, 0 ) ;
new puFrame ( 0, 0, 4 * ln + 5 * sp, 6 * ht + 7 * sp ) ;
puButton *button = (puButton *)NULL ;
button = new puButton ( sp, 6*sp+5*ht, sp+ln, 6*sp+6*ht ) ;
button->setLegend ( "puFrame" ) ;
button->setCallback ( frame_cb ) ;
button = new puButton ( sp, 5*sp+4*ht, sp+ln, 5*sp+5*ht ) ;
button->setLegend ( "puText" ) ;
button->setCallback ( text_cb ) ;
button = new puButton ( sp, 4*sp+3*ht, sp+ln, 4*sp+4*ht ) ;
button->setLegend ( "puMenuBar" ) ;
button->setCallback ( menu_bar_cb ) ;
button = new puButton ( sp, 3*sp+2*ht, sp+ln, 3*sp+3*ht ) ;
button->setLegend ( "puaVerticalMenu" ) ;
button->setCallback ( vertical_menu_cb ) ;
button = new puButton ( sp, 2*sp+ht, sp+ln, 2*sp+2*ht ) ;
button->setLegend ( "puaSpinBox" ) ;
button->setCallback ( spin_box_cb ) ;
button = new puButton ( sp, sp, sp+ln, sp+ht ) ;
button->setLegend ( "puaList" ) ;
button->setCallback ( list_cb ) ;
button = new puButton ( 2*sp+ln, 6*sp+5*ht, 2*sp+2*ln, 6*sp+6*ht ) ;
button->setLegend ( "puInput" ) ;
button->setCallback ( input_cb ) ;
button = new puButton ( 2*sp+ln, 5*sp+4*ht, 2*sp+2*ln, 5*sp+5*ht ) ;
button->setLegend ( "puaLargeInput" ) ;
button->setCallback ( large_input_cb ) ;
button = new puButton ( 2*sp+ln, 4*sp+3*ht, 2*sp+2*ln, 4*sp+4*ht ) ;
button->setLegend ( "puaSelectBox" ) ;
button->setCallback ( select_box_cb ) ;
button = new puButton ( 2*sp+ln, 3*sp+2*ht, 2*sp+2*ln, 3*sp+3*ht ) ;
button->setLegend ( "puaFileSelector" ) ;
button->setCallback ( file_selector_cb ) ;
button = new puButton ( 2*sp+ln, 2*sp+ht, 2*sp+2*ln, 2*sp+2*ht ) ;
button->setLegend ( "puListBox" ) ;
button->setCallback ( list_box_cb ) ;
button = new puButton ( 2*sp+ln, sp, 2*sp+2*ln, sp+ht ) ;
button->setLegend ( "puaScrollBar" ) ;
button->setCallback ( scroll_bar_cb ) ;
button = new puButton ( 3*sp+2*ln, 6*sp+5*ht, 3*sp+3*ln, 6*sp+6*ht ) ;
button->setLegend ( "puButton" ) ;
button->setCallback ( button_cb ) ;
button = new puButton ( 3*sp+2*ln, 5*sp+4*ht, 3*sp+3*ln, 5*sp+5*ht ) ;
button->setLegend ( "puOneShot" ) ;
button->setCallback ( one_shot_cb ) ;
button = new puButton ( 3*sp+2*ln, 4*sp+3*ht, 3*sp+3*ln, 4*sp+4*ht ) ;
button->setLegend ( "puArrowButton" ) ;
button->setCallback ( arrow_button_cb ) ;
button = new puButton ( 3*sp+2*ln, 3*sp+2*ht, 3*sp+3*ln, 3*sp+3*ht ) ;
button->setLegend ( "puButtonBox" ) ;
button->setCallback ( button_box_cb ) ;
button = new puButton ( 3*sp+2*ln, 2*sp+ht, 3*sp+3*ln, 2*sp+2*ht ) ;
button->setLegend ( "puaComboBox" ) ;
button->setCallback ( combo_box_cb ) ;
button = new puButton ( 3*sp+2*ln, sp, 3*sp+3*ln, sp+ht ) ;
button->setLegend ( "puaChooser" ) ;
button->setCallback ( chooser_cb ) ;
// TODO: It appears that the "puaChooser" file is not in the puAux library yet.
button->hide ();
button = new puButton ( 4*sp+3*ln, 6*sp+5*ht, 4*sp+4*ln, 6*sp+6*ht ) ;
button->setLegend ( "puDial" ) ;
button->setCallback ( dial_cb ) ;
button = new puButton ( 4*sp+3*ln, 5*sp+4*ht, 4*sp+4*ln, 5*sp+5*ht ) ;
button->setLegend ( "puSlider" ) ;
button->setCallback ( slider_cb ) ;
button = new puButton ( 4*sp+3*ln, 4*sp+3*ht, 4*sp+4*ln, 4*sp+4*ht ) ;
button->setLegend ( "puaBiSlider" ) ;
button->setCallback ( bislider_cb ) ;
button = new puButton ( 4*sp+3*ln, 3*sp+2*ht, 4*sp+4*ln, 3*sp+3*ht ) ;
button->setLegend ( "puaTriSlider" ) ;
button->setCallback ( trislider_cb ) ;
button = new puButton ( 4*sp+3*ln, 2*sp+ht, 4*sp+4*ln, 2*sp+2*ht ) ;
button->setLegend ( "puaSliderWithInput" ) ;
button->setCallback ( slider_with_input_cb ) ;
button = new puButton ( 4*sp+3*ln, sp, 4*sp+4*ln, sp+ht ) ;
button->setLegend ( "puaBiSliderWithEnds" ) ;
button->setCallback ( bislider_with_ends_cb ) ;
widget_group->close () ;
return 0 ;
}

View File

@@ -0,0 +1,616 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WriteCode.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Function to write the actual code
#include <stdio.h>
#include "WidgetList.h"
#ifdef WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
// From the Main Window:
extern WidgetList *widgets ;
extern int max_layer ;
extern int main_window_width ;
extern int main_window_height ;
extern char main_window_name [ PUSTRING_MAX ] ;
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern int main_window_x ;
extern int main_window_y ;
extern bool main_window_changed ;
extern float main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ;
// From the Status Window
extern int status_window ;
extern puaFileSelector *file_selector ;
const char* trueOrFalse(bool tf)
{
if (tf) return "TRUE";
else return "FALSE";
}
// The function itself
void write_code ( puObject *ob )
{
// Get the file name and open the file
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
/* If they didn't give an extension, then tack ".cxx" onto the end. */
if(!strstr(filename, "."))
sprintf(filename, "%s.cxx", filename);
FILE *out = fopen ( filename, "wt" ) ;
if ( !out )
printf ( "ERROR opening file <%s> for writing\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !out ) return ;
// Start writing code:
fprintf ( out, "// TODO: Initial documentation\n" ) ;
fprintf ( out, "// TODO: Configuration Management system flags\n\n" ) ;
fprintf ( out, "// TODO: Any additional includes you may need\n\n" ) ;
fprintf ( out, "#include <GL/freeglut.h>\n\n" ) ;
fprintf ( out, "#include <plib/pu.h>\n\n" ) ;
fprintf ( out, "#include <plib/puAux.h> // TODO: Decide if you really need this\n\n" ) ;
fprintf ( out, "// GLUT Window Handle\n" ) ;
fprintf ( out, "int window_handle ;\n\n" ) ;
WidgetList *wid = widgets ;
fprintf ( out, "// PUI Widget Handles:\n" ) ;
while ( wid )
{
fprintf ( out, "%s *%s = (%s *)NULL ;\n", wid->object_type_name, wid->object_name,
wid->object_type_name ) ;
wid = wid->next ;
}
fprintf ( out, "\n" ) ;
// GLUT Callbacks:
fprintf ( out, "// GLUT Callbacks:\n" ) ;
fprintf ( out, "static void specialfn ( int key, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own special-key functionality in here\n" ) ;
fprintf ( out, " puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void keyfn ( unsigned char key, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own keyboard functionality in here\n" ) ;
fprintf ( out, " puKeyboard ( key, PU_DOWN ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void motionfn ( int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own mouse motion functionality in here\n" ) ;
fprintf ( out, " puMouse ( x, y ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void mousefn ( int button, int updown, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own mouse click functionality in here\n" ) ;
fprintf ( out, " puMouse ( button, updown, x, y ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void displayfn ( void )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // Clear the screen\n\n" ) ;
fprintf ( out, " glClearColor ( %f, %f, %f, %f ) ;\n", main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ) ;
fprintf ( out, " glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;\n\n" ) ;
fprintf ( out, " // TODO: Put any of your own window display in here\n\n" ) ;
fprintf ( out, " // Make PUI display\n" ) ;
fprintf ( out, " puDisplay () ;\n\n" ) ;
fprintf ( out, " glutSwapBuffers () ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "// TODO: Put any of your own additional GLUT callbacks in here\n\n" ) ;
// PUI Callbacks
fprintf ( out, "// PUI Callbacks:\n\n" ) ;
wid = widgets ;
while ( wid )
{
if ( wid->callbacks & 0x01 ) // Up-callback defined
{
fprintf ( out, "void %s_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your up-callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
if ( wid->callbacks & 0x02 ) // Active callback defined
{
fprintf ( out, "void %s_active_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your active callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
if ( wid->callbacks & 0x04 ) // Down-callback defined
{
fprintf ( out, "void %s_down_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your down-callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
wid = wid->next ;
}
fprintf ( out, "\n\n" ) ;
// The Main Program
fprintf ( out, "//**********************************************************\n" ) ;
fprintf ( out, "//* The Main Program *\n" ) ;
fprintf ( out, "//**********************************************************\n\n" ) ;
fprintf ( out, "int main ( int argc, char *argv[] )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Add any non-GLUT functionality you want to\n\n" ) ;
fprintf ( out, " // Create the GLUT window:\n" ) ;
fprintf ( out, " glutInitWindowPosition( %d, %d ) ;\n", main_window_x, main_window_y ) ;
fprintf ( out, " glutInitWindowSize ( %d, %d ) ;\n", main_window_width, main_window_height ) ;
fprintf ( out, " glutInit ( &argc, argv ) ;\n" ) ;
fprintf ( out, " glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;\n" ) ;
fprintf ( out, " window_handle = glutCreateWindow ( \"%s\" ) ;\n\n", main_window_name ) ;
fprintf ( out, " // GLUT Windowing Callbacks:\n" ) ;
fprintf ( out, " glutDisplayFunc ( displayfn ) ;\n" ) ;
fprintf ( out, " glutKeyboardFunc ( keyfn ) ;\n" ) ;
fprintf ( out, " glutSpecialFunc ( specialfn ) ;\n" ) ;
fprintf ( out, " glutMouseFunc ( mousefn ) ;\n" ) ;
fprintf ( out, " glutMotionFunc ( motionfn ) ;\n" ) ;
fprintf ( out, " glutPassiveMotionFunc ( motionfn ) ;\n" ) ;
fprintf ( out, " glutIdleFunc ( displayfn ) ;\n" ) ;
fprintf ( out, " // TODO: Add any additional GLUT callbacks that you defined earlier\n\n" ) ;
fprintf ( out, " // Initialize PUI:\n" ) ;
fprintf ( out, " puInit () ;\n\n" ) ;
// TO DO: Allow the user to select his own default fonts, style, and colour scheme
fprintf ( out, " // PUI Default Style, and Colors:\n" ) ;
fprintf ( out, " puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;\n" ) ;
fprintf ( out, " puSetDefaultColourScheme ( 0.3f, 0.4f, 0.6f, 1.0f ) ;\n" ) ;
fprintf ( out, " // TODO: Customize this as you like\n\n" ) ;
fprintf ( out, " // Define the widgets:\n\n" ) ;
fprintf ( out, " puGroup *window_group = new puGroup ( 0, 0 ) ;\n\n" ) ;
int layer ;
for ( layer = 0; layer < max_layer; layer++ )
{
wid = widgets ;
while ( wid )
{
if ( layer == wid->layer )
{
puObject *ob = wid->obj ;
int x, y, w, h ;
ob->getPosition ( &x, &y ) ;
ob->getSize ( &w, &h ) ;
/* Customize widget's constructor and extra details */
/* fprintf ( out, " %s = new %s ( %d, %d, %d, %d ) ;\n", wid->object_name,
wid->object_type_name, x, y, x+w, y+h ) ; */
/* General minx, miny, maxx, maxy constructor */
if ( (wid->object_type == PUCLASS_FRAME ) ||
(wid->object_type == PUCLASS_BUTTON ) ||
(wid->object_type == PUCLASS_INPUT ) ||
(wid->object_type == PUCLASS_BISLIDERWITHENDS))
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
/* General minx, miny constructor */
if (wid->object_type == PUCLASS_TEXT)
{
/* Add in font properties? */
fprintf ( out, " %s = new %s (%d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y) ;
}
if (wid->object_type == PUCLASS_ONESHOT)
{
/*
Add support for both constructors!
puButton::puButton ( int minx, int miny, const char *legend ) ;
puButton::puButton ( int minx, int miny, int maxx, int maxy ) ;
*/
fprintf ( out, " %s = new %s (%d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if ( (wid->object_type == PUCLASS_MENUBAR) ||
(wid->object_type == PUCLASS_VERTMENU) ) {
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
while ( cr != '\0' )
{
char *spc = strchr ( temp_items, ' ' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ' ' ) ;
}
spc = strchr ( temp_items, ':' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ':' ) ;
}
spc = strchr ( temp_items, ';' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ';' ) ;
}
spc = strchr ( temp_items, ',' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ',' ) ;
}
spc = strchr ( temp_items, '.' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, '.' ) ;
}
*cr = '\0';
fprintf ( out, " static char *%s_%s_submenu [] = { \"Filler\", NULL } ;\n", wid->object_name, temp_items) ;
fprintf ( out, " /* TODO: You need to create your own callbacks here, such as { \"exit_cb\",\"delete_cb\",NULL } */ \n") ;
fprintf ( out, " puCallback %s_%s_submenu_cb [] = { NULL, NULL } ;\n\n", wid->object_name, temp_items) ;
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
}
if (wid->object_type == PUCLASS_MENUBAR) {
/* TODO: add in "height" support */
fprintf ( out, " %s = new %s ( ) ;\n", wid->object_name, wid->object_type_name) ;
}
if (wid->object_type == PUCLASS_VERTMENU) {
/* TODO: add in "lock to corner" support */
fprintf ( out, " %s = new %s (%d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y) ;
}
if (wid->items)
{
char *temp_items = wid->items ;
char unspaced_items[PUSTRING_MAX];
char *cr = strchr(temp_items, '\n');
fprintf ( out, " {\n") ;
while ( cr != '\0' )
{
*cr = '\0';
strcpy(unspaced_items, temp_items);
/* Put back the space */
char *spc = strchr ( temp_items, '_' ) ;
while ( spc )
{
*spc = ' ' ;
spc = strchr ( temp_items, '_' ) ;
}
/* Now "unspaced_items" writes "I_have_no_spaces" while temp_items writes "I have no spaces" (AND LIES!) */
fprintf ( out, " %s->add_submenu (\"%s\", %s_%s_submenu, %s_%s_submenu_cb ) ;\n", wid->object_name, temp_items, wid->object_name, unspaced_items, wid->object_name, unspaced_items ) ;
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
fprintf ( out, " }\n") ;
}
fprintf ( out, " %s->close() ;\n", wid->object_name) ;
}
if ( (wid->object_type == PUCLASS_LISTBOX) ||
(wid->object_type == PUCLASS_COMBOBOX) ||
(wid->object_type == PUCLASS_SELECTBOX) ||
(wid->object_type == PUCLASS_BUTTONBOX) ||
(wid->object_type == PUCLASS_LIST))
{
char data[1024];
char onedata[PUSTRING_MAX];
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
sprintf ( data, " ");
while ( cr != '\0' )
{
*cr = '\0';
sprintf ( onedata, "\"%s\",", temp_items);
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
strcat(data, onedata);
}
}
fprintf ( out, " static char *%s_entries [] = { %s NULL } ;\n", wid->object_name, data) ;
if ( (wid->object_type == PUCLASS_LISTBOX) ||
(wid->object_type == PUCLASS_LIST) )
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name) ;
if (wid->object_type == PUCLASS_BUTTONBOX)
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, trueOrFalse(wid->boolval1)) ;
if (wid->object_type == PUCLASS_COMBOBOX)
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, trueOrFalse(wid->boolval1)) ;
fprintf ( out, " %s->setCurrentItem(%d) ;\n", wid->object_name, wid->intval1) ;
}
if (wid->object_type == PUCLASS_SELECTBOX)
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name) ;
fprintf ( out, " %s->setCurrentItem(%d) ;\n", wid->object_name, wid->intval1) ;
}
}
if (wid->object_type == PUCLASS_POPUPMENU)
{
/* Allow a list of menu items, and remember to point out these are hidden when created, and must be reveal()ed. */
/* NOT CURRENTLY IMPLEMENTED */
}
/* puRange */
if ( (wid->object_type == PUCLASS_SLIDER ) ||
(wid->object_type == PUCLASS_BISLIDER ) ||
(wid->object_type == PUCLASS_TRISLIDER ) ||
(wid->object_type == PUCLASS_DIAL ) ||
(wid->object_type == PUCLASS_SPINBOX ) ||
(wid->object_type == PUCLASS_SCROLLBAR ) )
{
/* Constructors */
if ( (wid->object_type == PUCLASS_SLIDER ) ||
(wid->object_type == PUCLASS_BISLIDER ) ||
(wid->object_type == PUCLASS_TRISLIDER ))
{
/* Sliders */
fprintf ( out, " %s = new %s (%d, %d, %d, %s, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, (wid->boolval2==1)?h:w, trueOrFalse(wid->boolval2), (wid->boolval2==1)?w:h) ;
/* Slider value options */
if (wid->object_type == PUCLASS_SLIDER )
fprintf ( out, " %s->setValue(%ff) ;\n", wid->object_name, wid->floatval4) ;
if ( (wid->object_type == PUCLASS_BISLIDER ) || (wid->object_type == PUCLASS_TRISLIDER ) )
{
fprintf ( out, " %s->setCurrentMax(%ff) ;\n", wid->object_name, wid->floatval4) ;
fprintf ( out, " %s->setCurrentMin(%ff) ;\n", wid->object_name, wid->floatval5) ;
if (wid->object_type == PUCLASS_TRISLIDER )
{
if (!wid->boolval3)
fprintf ( out, " %s->setFreezeEnds(FALSE) ;\n", wid->object_name ) ;
fprintf ( out, " %s->setValue(%ff) ;\n", wid->object_name, wid->floatval6) ;
fprintf ( out, " %s->setSliderFraction(0.1f) ;\n", wid->object_name) ;
/*Allow setting the slider fraction?*/
}
}
} else if (wid->object_type == PUCLASS_DIAL )
{
fprintf ( out, " %s = new %s (%d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, (h+w)/2) ;
fprintf ( out, " %s->setWrap(%s) ;\n", wid->object_name, trueOrFalse(wid->boolval2)) ;
} else if (wid->object_type == PUCLASS_SPINBOX )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, trueOrFalse(wid->boolval2) ) ;
fprintf ( out, " %s->setArrowHeight(%ff) ;\n", wid->object_name, wid->floatval4 ) ;
} else if (wid->object_type == PUCLASS_SCROLLBAR )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %d, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->intval1, trueOrFalse(wid->boolval2) ) ;
fprintf ( out, " %s->setArrowHeight(%ff) ;\n", wid->object_name, wid->floatval4 ) ;
}
/* All puRange options */
fprintf ( out, " %s->setMaxValue (%ff) ;\n", wid->object_name, wid->floatval1 ) ;
fprintf ( out, " %s->setMinValue (%ff) ;\n", wid->object_name, wid->floatval2 ) ;
fprintf ( out, " %s->setStepSize (%ff) ;\n", wid->object_name, wid->floatval3 ) ;
char cbmodetext[20] = "PUSLIDER_ALWAYS";
if (wid->boolval1)
strcpy(cbmodetext,"PUSLIDER_ALWAYS");
else
strcpy(cbmodetext,"PUSLIDER_CLICK");
fprintf ( out, " %s->setCBMode (%s) ;\n", wid->object_name, cbmodetext) ;
}
if (wid->object_type == PUCLASS_DIALOGBOX)
{
/* Not yet implemented as a class */
}
if (wid->object_type == PUCLASS_ARROW)
{
char arr_name[20] = "PUARROW_UP";
if (wid->items)
{
if (strstr(wid->items,"Double-Up"))
strcpy(arr_name, "PUARROW_FASTUP");
else if (strstr(wid->items,"Double-Down"))
strcpy(arr_name, "PUARROW_FASTDOWN");
else if (strstr(wid->items,"Double-Left"))
strcpy(arr_name, "PUARROW_FASTLEFT");
else if (strstr(wid->items,"Double-Right"))
strcpy(arr_name, "PUARROW_FASTRIGHT");
else if (strstr(wid->items,"Up"))
strcpy(arr_name, "PUARROW_UP");
else if (strstr(wid->items,"Down"))
strcpy(arr_name, "PUARROW_DOWN");
else if (strstr(wid->items,"Left"))
strcpy(arr_name, "PUARROW_LEFT");
else if (strstr(wid->items,"Right"))
strcpy(arr_name, "PUARROW_RIGHT");
}
fprintf ( out, " %s = new puArrowButton (%d, %d, %d, %d, %s ) ;\n", wid->object_name, x, y, x+w, y+h, arr_name) ;
}
if (wid->object_type == PUCLASS_CHOOSER)
{
// Just give it a dummy legend; set the legend later on
fprintf ( out, " %s = new %s (%d, %d, %d, %d, "" ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if (wid->object_type == PUCLASS_SLIDERWITHINPUT)
{
// Extra argument for input box being on the bottom of the slider
fprintf ( out, " %s = new %s (%d, %d, %d, %d, 0 ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if (wid->object_type == PUCLASS_INPUT )
{
/*Already had its constructor defined by the general -- look up*/
if (wid->boolval1 == false)
fprintf ( out, " %s->rejectInput() ;\n", wid->object_name ) ;
if ( wid->allowed)
fprintf ( out, " %s->setValidData(\"%s\") ;\n", wid->object_name, wid->allowed ) ;
}
if ( wid->object_type == PUCLASS_LARGEINPUT )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, w, h, wid->intval1, wid->intval2 ) ;
if (wid->boolval1 == false)
fprintf ( out, " %s->rejectInput() ;\n", wid->object_name ) ;
if ( wid->allowed)
fprintf ( out, " %s->setValidData(\"%s\") ;\n", wid->object_name, wid->allowed ) ;
}
/* Done custom constructor and extra details */
if ( wid->callbacks & 0x01 ) // Up-callback defined
fprintf ( out, " %s->setCallback ( %s_cb ) ;\n", wid->object_name, wid->object_name ) ;
if ( wid->callbacks & 0x02 ) // Active callback defined
fprintf ( out, " %s->setActiveCallback ( %s_active_cb ) ;\n", wid->object_name, wid->object_name ) ;
if ( wid->callbacks & 0x04 ) // Down-callback defined
fprintf ( out, " %s->setDownCallback ( %s_down_cb ) ;\n", wid->object_name, wid->object_name ) ;
// TO DO: Allow the user to customize colour and style
const char *place_name [] = { "PUPLACE_TOP_LEFT", "PUPLACE_TOP_CENTERED", "PUPLACE_TOP_RIGHT",
"PUPLACE_CENTERED_LEFT", "PUPLACE_CENTERED_RIGHT",
"PUPLACE_BOTTOM_LEFT", "PUPLACE_BOTTOM_CENTERED", "PUPLACE_BOTTOM_RIGHT",
"PUPLACE_CENTERED_CENTERED",
"PUPLACE_ABOVE_LEFT", "PUPLACE_ABOVE_RIGHT",
"PUPLACE_BELOW_LEFT", "PUPLACE_BELOW_RIGHT",
"PUPLACE_UPPER_LEFT", "PUPLACE_UPPER_RIGHT",
"PUPLACE_LOWER_LEFT", "PUPLACE_LOWER_RIGHT" } ;
if ( wid->label_text )
{
fprintf ( out, " %s->setLabel ( \"%s\" ) ;\n", wid->object_name, wid->label_text ) ;
fprintf ( out, " %s->setLabelPlace ( %s ) ;\n", wid->object_name, place_name [ ob->getLabelPlace () ] ) ;
// TO DO: Check for label font and print it
}
if ( wid->legend_text )
{
fprintf ( out, " %s->setLegend ( \"%s\" ) ;\n", wid->object_name, wid->legend_text ) ;
fprintf ( out, " %s->setLegendPlace ( %s ) ;\n", wid->object_name, place_name [ ob->getLegendPlace () ] ) ;
// TO DO: Check for legend font and print it
}
if( !wid->visible )
fprintf ( out, " %s->hide () ;\n", wid->object_name ) ;
fprintf ( out, " \n" ) ;
}
wid = wid->next ;
}
}
fprintf ( out, "\n\n" ) ;
fprintf ( out, " window_group->close () ;\n\n\n" ) ;
fprintf ( out, " // GLUT Main Loop\n" ) ;
fprintf ( out, " glutMainLoop () ;\n" ) ;
fprintf ( out, " return 0;\n" ) ;
fprintf ( out, "}\n\n" ) ;
// Close up shop
fclose ( out ) ;
main_window_changed = false ;
}

View File

@@ -0,0 +1,504 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE P-Guide>
<savefile>
<version>VERSION</version>
<project>Test Project</project>
<autolock>TRUE</autolock>
<window>
<name>Sample P-Guide File</name>
<size>
<width>600</width>
<height>400</height>
</size>
<position>
<x>0</x>
<y>0</y>
</position>
<color>
<r>0.750000</r>
<g>0.550000</g>
<b>0.650000</b>
<a>1.000000</a>
</color>
</window>
<objects>
<widget>
<name>left_arrow</name>
<type>puArrowButton</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>24</width>
<height>101</height>
</size>
<position>
<x>93</x>
<y>96</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Double-Left</item>
</data>
</widget>
<widget>
<name>right_arrow</name>
<type>puArrowButton</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>25</width>
<height>101</height>
</size>
<position>
<x>127</x>
<y>96</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Double-Right</item>
</data>
</widget>
<widget>
<name>combo</name>
<type>puComboBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>166</width>
<height>70</height>
</size>
<position>
<x>89</x>
<y>20</y>
</position>
<data>
<int1>2</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Option 1</item>
<item>Option 2</item>
<item>Option 3</item>
<item>Final</item>
</data>
</widget>
<widget>
<name>oneshot3</name>
<legend>
<text>Run Away</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>127</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>oneshot2</name>
<legend>
<text>Shoot</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>152</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>oneshot1</name>
<legend>
<text>Execute</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>177</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>dizzy</name>
<type>puSpinBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>166</width>
<height>40</height>
</size>
<position>
<x>89</x>
<y>205</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>20.000000</float1>
<float2>0.000000</float2>
<float3>1.000000</float3>
<float4>0.500000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>libris</name>
<label>
<text>Input</text>
<pos>PUPLACE_TOP_LEFT</pos>
</label>
<type>puLargeInput</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>334</width>
<height>232</height>
</size>
<position>
<x>258</x>
<y>13</y>
</position>
<data>
<int1>2</int1>
<int2>5</int2>
<bool1>TRUE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<allowed> </allowed>
</data>
</widget>
<widget>
<name>dial2</name>
<type>puDial</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>50</width>
<height>50</height>
</size>
<position>
<x>88</x>
<y>255</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>5.000000</float1>
<float2>0.000000</float2>
<float3>1.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>dial1</name>
<type>puDial</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>FALSE</locked>
<size>
<width>50</width>
<height>50</height>
</size>
<position>
<x>87</x>
<y>309</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>1.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>slider</name>
<type>puSlider</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>35</width>
<height>356</height>
</size>
<position>
<x>50</x>
<y>7</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>10.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.500000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>trislider</name>
<type>puTriSlider</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>FALSE</locked>
<size>
<width>47</width>
<height>356</height>
</size>
<position>
<x>1</x>
<y>7</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>17.000000</float1>
<float2>-5.000000</float2>
<float3>2.000000</float3>
<float4>16.000000</float4>
<float5>-0.500000</float5>
<float6>0.500000</float6>
</data>
</widget>
<widget>
<name>menu_bar</name>
<type>puMenuBar</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>120</width>
<height>30</height>
</size>
<position>
<x>0</x>
<y>367</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>File</item>
<item>Edit</item>
<item>View</item>
<item>Project</item>
<item>Build</item>
<item>Debug</item>
<item>Tools</item>
<item>Options</item>
<item>Window</item>
<item>Bookmarks</item>
<item>Help</item>
</data>
</widget>
<widget>
<name>buttonbox</name>
<type>puButtonBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>163</width>
<height>134</height>
</size>
<position>
<x>428</x>
<y>249</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>On</item>
<item>Off</item>
<item>Automatic</item>
</data>
</widget>
<widget>
<name>widget1</name>
<label>
<text>This is a test application</text>
<pos>PUPLACE_LOWER_RIGHT</pos>
</label>
<type>puText</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>5</width>
<height>20</height>
</size>
<position>
<x>173</x>
<y>360</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
</objects>
</savefile>

View File

@@ -0,0 +1,916 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: pGuide.cxx 2083 2006-05-01 13:14:50Z bram $
*/
#ifdef VERSION
#undef VERSION
#endif
#define VERSION = "0.1a"
// Program to allow the user to build a PUI Graphical User Interface
#include "WidgetList.h"
WidgetList *widgets = (WidgetList *)NULL ;
int max_layer = 1 ;
puObject *active_object = (puObject *)NULL ;
WidgetList *active_widget = (WidgetList *)NULL ;
static short activity_flag = 0 ; // 0 - inactive; 1 - moving; 2 - resizing xmin, 3 - resizing ymin, 4 - resizing xmax, 5 - resizing ymax
static int resize_symmetric = 1 ;
static int resize_corner = 0 ;
static int mouse_x_position_in_object = 0 ;
static int mouse_y_position_in_object = 0 ;
static int pguide_last_buttons = 0 ; // Because puMouse isn't called, we have to do our own last_buttons checking
// Main window parameters
int main_window = 0 ; // Main window handle
int main_window_width = 600 ;
int main_window_height = 600 ;
char main_window_name [ PUSTRING_MAX ] ;
int main_window_x = 0, main_window_y = 0 ;
float main_window_color_r = 1.0, main_window_color_g = 1.0,
main_window_color_b = 1.0, main_window_color_a = 1.0 ;
bool main_window_changed = false ;
static bool done_first_setup = false ;
bool currently_loading = false ;
static int ctrl_key_down = 0 ;
static int mouse_x = 0 ;
static int mouse_y = 0 ;
char pguide_current_directory [ PUSTRING_MAX ] ;
// Widget count
int widget_number = 0 ;
// Upon creation of new widgets, should they automatically be made "locked"?
bool autolock = false ;
// Properties popup
static puPopupMenu *context_menu;
// From the status window:
extern void setStatusWidgets ( WidgetList *wid ) ;
// From the properties window:
extern int properties_window;
// Definitions
#define RESIZING_BORDER_WIDTH 5
#define RESIZING_CORNER_BORDER_WIDTH 4
/** 4 seems to be the best number for this define... this makes sure *
* that the default widget size allows you to still resize along the *
* X axis without difficulty - 23 Jan 03 JCJ **/
// Properties Callback
static void cb_edit_properties ( puObject *ob )
{
if (properties_window)
{
extern puGroup *properties_group;
/* Delete the widgets */
puDeleteObject( properties_group );
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
extern int define_properties_window () ;
// Open the properties menu
define_properties_window();
}
static void cb_lock_toggle ( puObject *ob )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->obj == active_object )
{
if (wid->locked == false)
wid->locked = true ;
else
wid->locked = false ;
}
wid = wid->next ;
}
}
static void cb_popup_delete ( puObject *ob )
{
WidgetList *wid = widgets ;
WidgetList *prv = (WidgetList *)NULL ;
while ( wid )
{
if ( wid->obj == active_object )
{
if ( prv ) // Remove the widget from the linked list
prv->next = wid->next ;
else
widgets = wid->next ;
delete wid->object_type_name ; // Delete the widget
delete wid->legend_text ;
delete wid->label_text ;
delete wid->obj ;
delete wid->allowed ;
delete wid->items ;
delete wid ;
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
wid = (WidgetList *)NULL ;
if (properties_window)
{
extern puGroup *properties_group;
/* Delete the widgets */
puDeleteObject( properties_group );
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
}
else
{
prv = wid ;
wid = wid->next ;
}
}
}
// GLUT Main Window Callbacks
static void process_key ( int key )
{
extern int selected_object_type ;
extern puButton *active_button ;
ctrl_key_down = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ;
#define NUDGE_DISTANCE 1
#define LARGE_NUDGE_DISTANCE 10
if ( active_object ) // Active object; check the keys
{
main_window_changed = true ;
int xo, yo ;
active_object->getPosition ( &xo, &yo ) ;
int dist = ctrl_key_down ? LARGE_NUDGE_DISTANCE : NUDGE_DISTANCE ;
if ( key == GLUT_KEY_LEFT )
active_object->setPosition ( xo-dist, yo ) ;
else if ( key == GLUT_KEY_RIGHT )
active_object->setPosition ( xo+dist, yo ) ;
else if ( key == GLUT_KEY_UP )
active_object->setPosition ( xo, yo+dist ) ;
else if ( key == GLUT_KEY_DOWN )
active_object->setPosition ( xo, yo-dist ) ;
else if ( ( key == 127 ) || ( key == 8 ) ) // Delete or Backspace
{
WidgetList *wid = widgets ;
WidgetList *prv = (WidgetList *)NULL ;
while ( wid )
{
if ( wid->obj == active_object )
{
if ( prv ) // Remove the widget from the linked list
prv->next = wid->next ;
else
widgets = wid->next ;
delete wid->object_type_name ; // Delete the widget
delete wid->legend_text ;
delete wid->label_text ;
delete wid->obj ;
delete wid->allowed ;
delete wid->items ;
delete wid ;
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
wid = (WidgetList *)NULL ;
}
else
{
prv = wid ;
wid = wid->next ;
}
}
}
else if ( key == 27 ) // Escape key, deactivate the object
{
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
}
setStatusWidgets ( active_widget ) ;
}
if ( selected_object_type )
{
if ( key == 27 ) // Escape key, deactivate the selected button
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void main_window_specialfn ( int key, int, int )
{
process_key ( key ) ;
}
static void main_window_keyfn ( unsigned char key, int, int )
{
process_key ( key ) ;
}
static void main_window_motionfn ( int x, int yy )
{
int y = main_window_height - yy ;
mouse_x = x ;
mouse_y = y ;
// Dragging the mouse: If there is an active object, slide it around
if ( ( active_object ) && ( pguide_last_buttons != 4 ) )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->obj == active_object )
{
if (wid->locked == false)
{
extern puInput *object_position_x ;
extern puInput *object_position_y ;
extern puInput *object_size_x ;
extern puInput *object_size_y ;
main_window_changed = true ;
int dist ;
int xo, yo ;
active_object->getPosition ( &xo, &yo ) ;
int w, h ;
active_object->getSize ( &w, &h ) ;
if (resize_corner == 1)
{
switch ( activity_flag )
{
case 2 : // Resize top-right
case 3 :
activity_flag = 6;
break ;
case 4 : // Resize bottom_left
case 5 :
activity_flag = 7;
break ;
}
}
switch ( activity_flag )
{
case 1 : // Moving the object
active_object->setPosition ( x - mouse_x_position_in_object,
y - mouse_y_position_in_object ) ;
break ;
case 2 : // Resizing on x-min
dist = x - xo ;
if (w - dist < 5) break ;
if ( resize_symmetric * dist > w ) dist = w / resize_symmetric - 1 ;
active_object->setPosition ( x, yo ) ;
active_object->setSize ( w - resize_symmetric * dist, h ) ;
break ;
case 3 : // Resizing on y-min
dist = y - yo ;
if (h - dist < 5) break ;
if ( resize_symmetric * dist > h ) dist = h / resize_symmetric - 1 ;
active_object->setPosition ( xo, y ) ;
active_object->setSize ( w, h - resize_symmetric * dist ) ;
break ;
case 4 : // Resizing on x-max
dist = x - xo - w ;
if (w + dist < 5) break ;
if ( resize_symmetric * dist < -w ) dist = 1 - w / resize_symmetric ;
active_object->setSize ( w + resize_symmetric * dist, h ) ;
if ( resize_symmetric == 2 ) active_object->setPosition ( xo - dist, yo ) ;
break ;
case 5 : // Resizing on y-max
dist = y - yo - h ;
if (h + dist < 5) break ;
if ( resize_symmetric * dist < -h ) dist = 1 - h / resize_symmetric ;
active_object->setSize ( w, h + resize_symmetric * dist ) ;
if ( resize_symmetric == 2 ) active_object->setPosition ( xo, yo - dist ) ;
break ;
case 6 : // Resizing bottom-left
if ( yo - y > xo - x )
dist = yo - y;
else
dist = xo - x;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo - dist, yo - dist ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 7 : // Resizing top-right
if (y-yo-h>x-xo-w)
dist = y - yo - h ;
else
dist = x - xo - w ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 8 : // Resizing top-left
if (y-yo-h>x-xo-w)
dist = y - yo - h ;
else
dist = xo - x ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo - dist, yo ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 9 : // Resizing bottom-right
if (y-yo-h>x-xo-w)
dist = yo - y ;
else
dist = x - xo - w ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo , yo - dist ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
}
int a, b ;
active_object->getPosition ( &a, &b ) ;
object_position_x->setValue ( a ) ;
object_position_y->setValue ( b ) ;
active_object->getSize ( &a, &b ) ;
object_size_x->setValue ( a ) ;
object_size_y->setValue ( b ) ;
}
}
wid = wid->next ;
}
}
glutPostRedisplay () ;
}
static void main_window_passivefn ( int x, int yy )
{
int y = main_window_height - yy ;
// Dragging the mouse without a button down: save the mouse coordinates
mouse_x = x ;
mouse_y = y ;
/*if (context_menu->isVisible() == 1)
{
puBox *cont_box = context_menu->getABox();
if ( ( x >= cont_box->min[0] ) && ( x <= cont_box->max[0] ) &&
( y >= cont_box->min[1] ) && ( y <= cont_box->max[1] ) )
{
context_menu->checkHit(-1, 0, mouse_x, mouse_y);
}
}*/
}
static void main_window_mousefn ( int button, int updown, int x, int yy )
{
int y = main_window_height - yy ;
mouse_x = x ;
mouse_y = y ;
if ( updown == PU_DOWN )
pguide_last_buttons |= ( 1 << button ) ;
else
pguide_last_buttons &= ~( 1 << button ) ;
if ( button == PU_RIGHT_BUTTON )
{
/* Pressed the right mouse button -- popup the manipulation window. */
WidgetList *wid = widgets ;
while ( wid )
{
puBox *box = wid->obj->getABox () ;
if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
( y >= box->min[1] ) && ( y <= box->max[1] ) )
{
active_widget = wid ;
active_object = wid->obj ;
/* We can modify mouse_x and mouse_y, because theyre not used again if we're in the right mouse function */
/* If we're real close to the right of the screen, modify the X position ...*/
if (mouse_x > main_window_width - 110 ) mouse_x = main_window_width - 110 ;
/* If we're real close to the top of the screen, modify the Y position...*/
if (mouse_y > main_window_height - 140) mouse_y = main_window_height - 140 ;
context_menu->setPosition(mouse_x, mouse_y) ;
context_menu->reveal() ;
//puSetActiveWidget(context_menu, mouse_x, mouse_y) ;
break ;
}
wid = wid->next ;
}
} else {
if ( puActiveWidget() && ( active_object != puActiveWidget() ) )
{
puActiveWidget() -> invokeDownCallback () ;
puDeactivateWidget () ;
}
ctrl_key_down = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ;
if ( ( context_menu->isVisible() == 1) && ( active_widget ) )
{
puBox *cont_box = context_menu->getABox();
if ( ( x >= cont_box->min[0] ) && ( x <= cont_box->max[0] ) &&
( y >= cont_box->min[1] ) && ( y <= cont_box->max[1] ) )
{
context_menu->checkHit(button, updown, mouse_x, mouse_y);
} else {
context_menu->hide();
}
} else /*if ( context_menu->isVisible() == 1) { context_menu->hide(); } * The user did something funny, so hide the menu since they've been naughty */
{
// Downclick: Place a new widget, activate an existing widget, deactivate widget, or select from menu.
if ( updown == GLUT_DOWN )
{
// If there is a selected object, create a new one of that type.
// extern puObject *createWidget ( int type ) ;
extern int selected_object_type ;
if ( selected_object_type )
{
extern bool selected_object_sticky ;
extern char *selected_type_string ;
extern puButton *active_button ;
main_window_changed = true ;
// puObject *new_obj = createWidget ( selected_object->getType () ) ;
puObject *new_obj = new puFrame ( 0, 0, 90, 20 ) ;
char *object_type_name = new char [ PUSTRING_MAX ] ;
strcpy ( object_type_name, selected_type_string ) ;
new_obj->setLegend ( object_type_name ) ;
// Add the new object to the list of widgets
WidgetList *new_wid = new WidgetList ;
new_wid->obj = new_obj ;
new_wid->label_text = (char *)NULL ;
new_wid->legend_text = (char *)NULL ;
new_wid->allowed = (char *)NULL ;
new_wid->items = (char *)NULL ;
new_wid->object_type_name = object_type_name ;
new_wid->object_type = selected_object_type ;
new_wid->callbacks = 1 ; // Default: up callback enabled, others disabled
sprintf ( new_wid->object_name, "widget%d", widget_number++ ) ;
new_wid->visible = true ;
new_wid->locked = autolock ; /* Set it to the autolock var (true or false ) */
new_wid->layer = max_layer - 1 ;
new_wid->next = widgets ;
widgets = new_wid ;
// Set the new widget's position
new_obj->setPosition ( x, y ) ;
mouse_x_position_in_object = 0 ;
mouse_y_position_in_object = 0 ;
/* Set up the widget's default data values */
new_wid->intval1 = 0;
new_wid->intval2 = 0;
new_wid->boolval1 = false;
new_wid->boolval2 = false;
new_wid->boolval3 = false;
new_wid->floatval1 = 0.0f;
new_wid->floatval2 = 0.0f;
new_wid->floatval3 = 0.0f;
new_wid->floatval4 = 0.0f;
new_wid->floatval5 = 0.0f;
new_wid->floatval6 = 0.0f;
if (new_wid->object_type == PUCLASS_TEXT)
{
new_obj->setSize(5,20);
}
if (new_wid->object_type == PUCLASS_COMBOBOX)
{
new_wid->intval1 = 1;
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_SELECTBOX)
{
new_wid->intval1 = 1;
}
if (new_wid->object_type == PUCLASS_BUTTONBOX)
{
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_COMBOBOX)
{
new_wid->intval1 = 1;
new_wid->boolval1 = true;
}
if ( (new_wid->object_type == PUCLASS_SLIDER ) ||
(new_wid->object_type == PUCLASS_BISLIDER ) ||
(new_wid->object_type == PUCLASS_TRISLIDER ) ||
(new_wid->object_type == PUCLASS_DIAL ) ||
(new_wid->object_type == PUCLASS_SPINBOX ) ||
(new_wid->object_type == PUCLASS_SCROLLBAR ) )
{
new_wid->floatval1 = 1.0f;
new_wid->floatval2 = 0.0f;
new_wid->floatval3 = 0.0f;
new_wid->boolval1 = true;
}
if ( (new_wid->object_type == PUCLASS_SLIDER ) ||
(new_wid->object_type == PUCLASS_BISLIDER ) ||
(new_wid->object_type == PUCLASS_TRISLIDER ) )
{
new_wid->boolval2 = true;
}
if (new_wid->object_type == PUCLASS_SLIDER)
{
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_BISLIDER)
{
new_wid->floatval4 = 1.0f;
new_wid->floatval5 = 0.0f;
}
if (new_wid->object_type == PUCLASS_TRISLIDER)
{
new_wid->floatval4 = 1.0f;
new_wid->floatval5 = 0.0f;
new_wid->floatval6 = 0.5f;
new_wid->boolval3 = false;
}
if (new_wid->object_type == PUCLASS_DIAL)
{
new_obj->setSize(50,50);
new_wid->boolval2 = true;
}
if (new_wid->object_type == PUCLASS_SPINBOX)
{
new_wid->boolval2 = true;
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_SCROLLBAR)
{
/* Not Yet Implemented */
}
if (new_wid->object_type == PUCLASS_SPINBOX)
{
new_wid->boolval2 = true;
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_INPUT)
{
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_LARGEINPUT)
{
new_wid->boolval1 = true;
new_wid->intval1 = 1;
new_wid->intval2 = 5;
}
if (new_wid->object_type == PUCLASS_MENUBAR)
{
new_obj->setSize( 120, 30) ;
new_obj->setPosition( 0, puGetWindowHeight()-30) ;
new_wid->locked = true ;
}
if (new_wid->object_type == PUCLASS_VERTMENU)
{
new_obj->setSize( 45, 120) ;
new_obj->setPosition( 0, puGetWindowHeight()-120) ;
new_obj->setLegend("");
new_obj->setLabelPlace(PUPLACE_BOTTOM_LEFT);
new_obj->setLabel("puVerticalMenu");
new_wid->locked = true ;
}
// Make the new widget the active widget
active_object = new_obj ;
active_widget = new_wid ;
// If the "sticky" flag is not set, reset the selected object
if ( !selected_object_sticky )
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
else
{
// Clicking on a widget in the main widget list activates it
WidgetList *wid = widgets ;
while ( wid )
{
puBox *box = wid->obj->getABox () ;
if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
( y >= box->min[1] ) && ( y <= box->max[1] ) )
{
active_widget = wid ;
active_object = wid->obj ;
if ( abs ( x - box->min[0] ) < RESIZING_BORDER_WIDTH )
activity_flag = 2 ; // Resizing on x-min
else if ( abs ( x - box->max[0] ) < RESIZING_BORDER_WIDTH )
activity_flag = 4 ; // Resizing on x-max
else if ( abs ( y - box->min[1] ) < RESIZING_BORDER_WIDTH )
activity_flag = 3 ; // Resizing on y-min
else if ( abs ( y - box->max[1] ) < RESIZING_BORDER_WIDTH )
activity_flag = 5 ; // Resizing on y-max
else
activity_flag = 1 ; // Away from edges, we're moving it
/* Now we check and see if we're clicking on a corner - the sensitivity for
the determiniation of whether we're clicking a corner or not is held by the
definition of "RESIZING_CORNER_BORDER_WIDTH" which is at the top of this file */
int corner_resize_width = RESIZING_CORNER_BORDER_WIDTH + (((box->max[0] - box->min[0]) + (box->max[1] - box->min[1]) / 2 ) / 50 ) * 2 ;
if ( activity_flag != 1 )
{
// Bottom Right Corner
if ( ( abs( y - box->min[1] ) < corner_resize_width ) && (abs ( x - box->max[0] ) < corner_resize_width ) )
activity_flag = 9;
// Bottom Left Corner
if ( ( abs( y - box->min[1] ) < corner_resize_width ) && (abs ( x - box->min[0] ) < corner_resize_width ) )
activity_flag = 6;
// Top Right Corner
if ( ( abs( y - box->max[1] ) < corner_resize_width ) && (abs ( x - box->max[0] ) < corner_resize_width ) )
activity_flag = 7;
// Top Left Corner
if ( ( abs( y - box->max[1] ) < corner_resize_width ) && (abs ( x - box->min[0] ) < corner_resize_width ) )
activity_flag = 8;
}
/* If CTRL is held down, symmetric resize is forced. */
resize_symmetric = ctrl_key_down ? 2 : 1 ;
if (active_widget->object_type == PUCLASS_DIAL)
resize_corner = 1 ;
else
resize_corner = 0;
int object_x, object_y ;
active_object->getPosition ( &object_x, &object_y ) ;
mouse_x_position_in_object = x - object_x ;
mouse_y_position_in_object = y - object_y ;
break ;
}
wid = wid->next ;
}
if ( ( !wid ) && ( context_menu->isVisible()==0 ) ) // Ran through the entire list, deactivate any active widget
{
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
}
}
}
setStatusWidgets ( active_widget ) ;
}
}
glutPostRedisplay () ;
}
static void main_window_reshapefn ( int w, int h )
{
extern puInput *window_size_x ;
extern puInput *window_size_y ;
if (done_first_setup)
main_window_changed = true ;
else
done_first_setup = true ;
if ( ( !currently_loading ) && (
( mouse_x < main_window_width/2 ) || // Grabbed the left edge ...
( mouse_y < main_window_height/2 ) ) ) // or the bottom edge, move the widgets
{
WidgetList *wid = widgets ;
int deltax = 0 ;
int deltay = 0 ;
if ( mouse_x < main_window_width/2 ) deltax = w - main_window_width ;
if ( mouse_y < main_window_height/2 ) deltay = h - main_window_height ;
while ( wid )
{
int x, y ;
wid->obj->getPosition ( &x, &y ) ;
wid->obj->setPosition ( x + deltax, y + deltay ) ;
wid = wid->next ;
}
}
main_window_width = w ;
main_window_height = h ;
window_size_x->setValue ( w ) ;
window_size_y->setValue ( h ) ;
currently_loading = false ;
}
static void main_window_displayfn ( void )
{
/* Clear the screen */
glutSetWindow ( main_window ) ;
glClearColor ( main_window_color_r, main_window_color_g, main_window_color_b, main_window_color_a ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
// Set the OpenGL to draw PUI widgets
int w = puGetWindowWidth () ;
int h = puGetWindowHeight () ;
glPushAttrib ( GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
glDisable ( GL_LIGHTING ) ;
glDisable ( GL_FOG ) ;
glDisable ( GL_TEXTURE_2D ) ;
glDisable ( GL_DEPTH_TEST ) ;
glDisable ( GL_CULL_FACE ) ;
glViewport ( 0, 0, w, h ) ;
glMatrixMode ( GL_PROJECTION ) ;
glPushMatrix () ;
glLoadIdentity () ;
gluOrtho2D ( 0, w, 0, h ) ;
glMatrixMode ( GL_MODELVIEW ) ;
glPushMatrix () ;
glLoadIdentity () ;
// Draw the widgets
int layer ;
for ( layer = 0; layer < max_layer; layer++ )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->visible && ( wid->layer == layer ) ) wid->obj->draw ( 0, 0 ) ;
wid = wid->next ;
}
}
if ( active_object )
{
puBox *box = active_object->getBBox () ;
glColor4f ( 0.0f, 0.0f, 0.0f, 1.0f ) ;
glLineWidth ( 3.0f ) ;
glBegin ( GL_LINES ) ;
glVertex2i ( box->min[0]-1, box->min[1]-1 ) ;
glVertex2i ( box->max[0]+1, box->min[1]-1 ) ;
glVertex2i ( box->max[0]+1, box->max[1]+1 ) ;
glVertex2i ( box->min[0]-1, box->max[1]+1 ) ;
glVertex2i ( box->min[0]-1, box->min[1]-1 ) ;
glEnd () ;
}
context_menu->draw(0,0);
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
int main ( int argc, char **argv )
{
extern int define_widget_window () ;
extern int define_status_window () ;
int i = 0;
strcpy ( main_window_name, "PUI GUI Builder" ) ;
glutInitWindowPosition( 100, 0 ) ;
glutInitWindowSize ( main_window_width, main_window_height ) ;
glutInit ( &argc, argv ) ;
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
main_window = glutCreateWindow ( main_window_name ) ;
glutDisplayFunc ( main_window_displayfn ) ;
glutKeyboardFunc ( main_window_keyfn ) ;
glutSpecialFunc ( main_window_specialfn ) ;
glutMouseFunc ( main_window_mousefn ) ;
glutMotionFunc ( main_window_motionfn ) ;
glutPassiveMotionFunc ( main_window_passivefn ) ;
glutReshapeFunc ( main_window_reshapefn ) ;
glutIdleFunc ( main_window_displayfn ) ;
// If we're using windows, ignore the C: or whatnot
#ifdef WIN32
#define PATH_SEPARATOR '\\'
strcpy (pguide_current_directory, argv[0]+2);
#else
#define PATH_SEPARATOR '/'
strcpy (pguide_current_directory, argv[0]);
#endif
i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0';
puInit () ;
#ifdef VOODOO
puShowCursor () ;
#endif
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
puSetDefaultColourScheme ( 0.8f, 0.8f, 0.8f, 1.0f ) ;
// Add the properties context menu
context_menu = new puPopupMenu( 0, 0 ) ;
context_menu->add_item("Properties", cb_edit_properties) ;
context_menu->add_item("Lock/Unlock", cb_lock_toggle) ;
context_menu->add_item("Delete", cb_popup_delete) ;
context_menu->add_item("Cut", NULL) ;
context_menu->add_item("Copy", NULL) ;
context_menu->add_item("Change Class", NULL) ;
context_menu->close() ;
// Set up the other windows
define_widget_window () ;
define_status_window () ;
glutMainLoop () ;
return 0 ;
}

View File

@@ -0,0 +1,128 @@
# Microsoft Developer Studio Project File - Name="pGuide" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=pGuide - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "pGuide.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "pGuide.mak" CFG="pGuide - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "pGuide - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "pGuide - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
F90=df.exe
RSC=rc.exe
!IF "$(CFG)" == "pGuide - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 pui.lib puAux.lib sg.lib fnt.lib ul.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\plib"
!ELSEIF "$(CFG)" == "pGuide - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "pGuide___Win32_Debug"
# PROP BASE Intermediate_Dir "pGuide___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "pGuide___Win32_Debug"
# PROP Intermediate_Dir "pGuide___Win32_Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 pui_d.lib puAux_d.lib sg_d.lib fnt_d.lib ul_d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBCMTD" /pdbtype:sept /libpath:"..\..\..\..\plib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "pGuide - Win32 Release"
# Name "pGuide - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\LoadSave.cxx
# End Source File
# Begin Source File
SOURCE=.\pGuide.cxx
# End Source File
# Begin Source File
SOURCE=.\PropertiesWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\StatusWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\WidgetWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\WriteCode.cxx
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\WidgetList.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project