home *** CD-ROM | disk | FTP | other *** search
- /*
- ***********************************************************************
- *
- * Value Control
- * Slider with a window to show the current value
- * Behaves like a glorified integer
- *
- ***********************************************************************
- */
-
- #include "ValueControl.h"
- #include "mymenv.h"
-
-
- // Late binding constructor
- void ValueControl::bind(const ModelessDialog::ControlItem& control_item,
- const ModelessDialog::TextItem& value_item)
- {
- BasicControl::bind(control_item);
- show_val_item = new ModelessDialog::TextItem(value_item); // Have to make our own copy
- show_curr_value();
- }
-
- ValueControl::~ValueControl(void)
- {
- if( show_val_item != nil )
- delete show_val_item;
- }
-
- // Handle mouse-down event within a vlue control
- // Track the mouse and adjust the control values
- // Return FALSE if the control value was changed
- // (and therefore, more attention needed)
- Boolean ValueControl::handle_click(void)
- {
- return FALSE;
- #if 0
- ControlHandle ctl_handle = our_control();
- Point mouse_pt; // Get the mouse position in the control
- { // window local coordinates
- SetPort();
- GetMouse(&mouse_pt);
- }
- #endif
- }
-
-
- // Control Track action procedure
- // Figure out how the control value is to be changed
- // when the user clicked PgUp/PgDn/ArrowUp/ArrowDn areas
- // of the scrollbar
- // In all other cases, simply redisplay the current value
- // (in case the indicator was moved)
- void ValueControl::track_action(const int part_no)
- {
- ControlHandle ctl_handle = our_control();
- const int curr_value = GetControlValue(ctl_handle);
- int change = 0;
- switch(part_no)
- {
- case inUpButton:
- change = - small_increment;
- break;
- case inDownButton:
- change = small_increment;
- break;
- case inPageUp:
- change = - big_increment;
- break;
- case inPageDown:
- change = big_increment;
- break;
- }
- if( change != 0 )
- set_value(curr_value + change);
- show_curr_value();
- }
-
- // Show the current value of the control in a special
- // window
- void ValueControl::show_curr_value(void)
- {
- Str255 temp_str;
- NumToString((int)*this,temp_str);
- show_val_item->draw(temp_str);
- }
-