[Plib-cvs] plib/demos/p-guide/src LoadSave.cxx,1.7,1.8 WriteCode.cxx,1.9,1.10 pGuide.cxx,1.10,1.11
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2003-01-23 18:46:08
|
Update of /cvsroot/plib/plib/demos/p-guide/src In directory sc8-pr-cvs1:/tmp/cvs-serv3581 Modified Files: LoadSave.cxx WriteCode.cxx pGuide.cxx Log Message: Fixed symmetric resize issue where the corners were being calculated too big (resulting in corner resizes when you intended to do a single-border resize) - pGuide.cxx Fixed load problem with a file containing "widget0" not incrementing the widget_count variable - LoadSave.cxx Added trueOrFalse() to WriteCode.cxx and call it for all boolean values being written to the exported code. Now "TRUE" or "FALSE" are written instead of "1" or "0". - WriteCode.cxx ---------------------------------------------------------------------- Index: LoadSave.cxx =================================================================== RCS file: /cvsroot/plib/plib/demos/p-guide/src/LoadSave.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- LoadSave.cxx 31 Aug 2002 08:14:39 -0000 1.7 +++ LoadSave.cxx 23 Jan 2003 18:46:02 -0000 1.8 @@ -498,7 +498,7 @@ /* 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 (tmp_wid_num >= widget_number) widget_number = tmp_wid_num + 1; } if ( strstr(tag,"type") ) { Index: WriteCode.cxx =================================================================== RCS file: /cvsroot/plib/plib/demos/p-guide/src/WriteCode.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- WriteCode.cxx 18 Oct 2002 16:22:57 -0000 1.9 +++ WriteCode.cxx 23 Jan 2003 18:46:02 -0000 1.10 @@ -56,6 +56,12 @@ extern int status_window ; extern puFileSelector *file_selector ; +const char* trueOrFalse(bool tf) +{ + if (tf) return "TRUE"; + else return "FALSE"; +} + // The function itself void write_code ( puObject *ob ) @@ -406,10 +412,10 @@ if (wid->object_type == PUCLASS_LISTBOX) 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, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, wid->boolval1) ; + 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, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, wid->boolval1) ; + 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) @@ -441,12 +447,7 @@ (wid->object_type == PUCLASS_SCROLLBAR ) ) { /* Sliders */ - char orientation[10]; - if (wid->boolval2) - strcpy(orientation,"true"); /* Vertical */ - else - strcpy(orientation,"false"); /* Horizontal */ - 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, orientation, (wid->boolval2==1)?w:h) ; + 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) ; @@ -457,7 +458,7 @@ if (wid->object_type == PUCLASS_TRISLIDER ) { if (!wid->boolval3) - fprintf ( out, " %s->setFreezeEnds(false) ;\n", wid->object_name ) ; + 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?*/ @@ -466,11 +467,11 @@ } 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(%d) ;\n", wid->object_name, wid->boolval2) ; + 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, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->boolval2 ) ; + 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 ) ; } /* All puRange options */ Index: pGuide.cxx =================================================================== RCS file: /cvsroot/plib/plib/demos/p-guide/src/pGuide.cxx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pGuide.cxx 31 Aug 2002 08:14:39 -0000 1.10 +++ pGuide.cxx 23 Jan 2003 18:46:03 -0000 1.11 @@ -80,6 +80,14 @@ // 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 ) @@ -660,9 +668,6 @@ if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) && ( y >= box->min[1] ) && ( y <= box->max[1] ) ) { - #define RESIZING_BORDER_WIDTH 5 - #define RESIZING_CORNER_BORDER_WIDTH 8 - active_widget = wid ; active_object = wid->obj ; if ( abs ( x - box->min[0] ) < RESIZING_BORDER_WIDTH ) @@ -676,11 +681,10 @@ else activity_flag = 1 ; // Away from edges, we're moving it - // bottom left 6 - // top right 7 - // top left 8 - // bottom right 9 - + /* 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 ) @@ -702,8 +706,7 @@ activity_flag = 8; } - // TO DO: If the user clicks on a corner, let him resize in both directions at once - /* This basically will involve setting "resize_corner" to be 1 */ + /* If CTRL is held down, symmetric resize is forced. */ resize_symmetric = ctrl_key_down ? 2 : 1 ; |