示例#1
0
void
MessagePanel ( panel_t  *panel )
{

    panel->box.row_length = 0;                  /* force resizing */
    panel->box.number_of_rows = 0;
    SetPanelSize ( panel );
    ShowPanel ( panel );

}
示例#2
0
void
MessageBarPanel ( panel_t  *panel )
{

    panel->box.row = Screen_rows - 1;
    panel->box.column = 0;
    panel->box.row_length = Screen_columns;
    panel->box.number_of_rows = 1;
    panel->control = 0;
    panel->control |= SHOW_ATTRIBUTES;
    panel->control |= SAVE_RESTORE;
    panel->control |= SHOW_TEXT;

    SetPanelSize ( panel );
    ShowPanel ( panel );
    ParkCursor();

}
示例#3
0
PUBLIC
void _System
DoHelpPanel ( register
              panel_t  *panel )
{
    uint    message_number,
            save_control;
    void    *memory;

    message_number = panel->help.default_message;

    if ( panel->help.array ) {
        if ( panel->choice < panel->help.array_size ) {
            message_number = panel->help.array [ panel->choice ];
        }
    }

    memory = get_help_message ( message_number );

    Help_panel.control |= NOT_SIZED;
    Help_panel.box.row_length = 0;
    SetPanelSize ( &Help_panel );
    Help_panel.box.column = SCREEN_WIDTH - min( Help_panel.box.row_length, SCREEN_WIDTH );

    save_control = Message_bar_panel.control;
    Message_bar_panel.control |= SAVE_RESTORE;

    MESSAGE_BAR_PANEL ( Help_message_line );
    ScrollingPanel ( &Help_panel );

    ErasePanel ( &Help_panel );
    ErasePanel ( &Message_bar_panel );
    Message_bar_panel.control = save_control;

    if ( memory ) {
        free ( memory );
    }

}
示例#4
0
uint
ScrollingPanel ( panel_t  *panel )
{
    int     key = ESCAPE;
    uint    row = panel->box.row,
            row_count,
            number_of_text_rows,
            save_control,
            column = panel->box.column;
    char    **original_text_line = panel->text_line,
            **top_line = panel->text_line,
            **bottom_line;
    bool    finished = FALSE;

    SetPanelSize ( panel );
    number_of_text_rows = panel->box.number_of_text_rows;
    if ( number_of_text_rows == 0 ) {
        return key;                                             /* early exit */
    }

    save_control = panel->control;

    if ( panel->control & HAS_BORDER ) {
        ++row;
        ++column;
    }
    if ( panel->control & IS_SCROLLABLE ) {
        panel->control |= SHOW_SCROLL_BAR;
    } else {
        panel->control &= ~SHOW_SCROLL_BAR;
    }

    panel->text_line = top_line;
    bottom_line = top_line;

    for ( row_count = 1;  row_count < number_of_text_rows;  ++row_count ) {
        if ( *(bottom_line + 1) ) {
            ++bottom_line;
        } else {
            break;
        }
    }

    ShowPanel ( panel );

    panel->control &= ~SHOW_NON_TEXT_ITEMS;           /* just need to show text */

    while ( ! finished ) {
        key = GetKeystroke ();
        switch ( key ) {
            case UP_CURSOR:
                if ( top_line > original_text_line ) {
                    --top_line;
                    --bottom_line;
                }
                break;
            case DOWN_CURSOR:
                if ( *(bottom_line + 1) ) {
                    ++top_line;
                    ++bottom_line;
                }
                break;
            case DOWNPAGE:
                row_count = 0;
                for ( ; *bottom_line; ++bottom_line, ++top_line ) {
                    if ( ++row_count >= number_of_text_rows ) {
                        break;                              /* last window line */
                    }
                    if ( ! *(bottom_line + 1) ) {           /* no more lines */
                        break;
                    }
                }
                break;
            case UPPAGE:
                row_count = 0;
                while ( top_line > original_text_line ) {
                    if ( ++row_count >= number_of_text_rows ) {
                        break;                              /* 1 page of lines */
                    }
                    --top_line;
                    --bottom_line;
                }
                break;
            case TOP_OF_FILE:
                while ( top_line > original_text_line ) {
                    --top_line;
                    --bottom_line;
                }
                break;
            case END_OF_FILE:
                while ( *(bottom_line + 1) ) {
                    ++top_line;
                    ++bottom_line;
                }
                break;
            case ESCAPE:
                finished = TRUE;
                break;
            case HELP:
                if ( panel->help.routine ) {
                    panel->help.routine ( panel );
                }
                break;
        }
        panel->text_line = top_line;
        ShowPanel ( panel );
    }

    panel->text_line = original_text_line;                  /* restore values */
    panel->control = save_control;

    return key;
}
示例#5
0
int
ScrollingMenuPanel ( register
                     panel_t  *panel )
{
    int     key = ESCAPE,
            direction;
    uint    row,
            row_count,
            max_string_length,
            number_of_text_rows,
            save_control,
            save_border_attribute = panel->box.border_attribute,
            column;
    char    **original_text_line = panel->text_line,
            **top_line,
            **current_line,
            **bottom_line;
    bool    finished = FALSE;
    uint    (* _System callback) (panel_t *panel) = panel->callback;

    if ( panel->control & INITIALIZE_PANEL ) {
        panel->control &= ~INITIALIZE_PANEL;
        top_line = original_text_line;
        while ( *top_line  &&  **top_line == NOT_SELECTABLE_CHAR ) {
            if ( *++top_line == NULL ) {
                --top_line;
                break;
            }
        }
        panel->top_line = top_line;
        panel->current_line = top_line;
    }

    SetPanelSize ( panel );
    number_of_text_rows = panel->box.number_of_text_rows;
    if ( number_of_text_rows == 0 ) {
        return key;                                             /* early exit */
    }

    if ( panel->control & HIGHLIGHT_BORDER_LINE ) {
        panel->box.border_attribute |= HIGHLIGHTED_FG;
    }

    save_control = panel->control;

    if ( panel->control & IS_SCROLLABLE ) {
        panel->control |= SHOW_SCROLL_BAR;
    } else {
        panel->control &= ~SHOW_SCROLL_BAR;
    }

    row = panel->box.row;
    column = panel->box.column;
    top_line = panel->top_line;
    current_line = panel->current_line;

    max_string_length = panel->box.row_length;
    if ( panel->control & HAS_BORDER ) {
        ++row;
        ++column;
        max_string_length -= 2;
    }

    panel->text_line = top_line;
    bottom_line = top_line;

    for ( row_count = 1;  row_count < number_of_text_rows;  ++row_count ) {
        if ( *(bottom_line + 1) ) {
            ++bottom_line;
        } else {
            break;
        }
    }

    ShowPanel ( panel );

    panel->control &= ~SHOW_NON_TEXT_ITEMS;           /* just need to show text */
    if ( panel->control & HAS_NON_SELECTABLE_LINE ) {
        panel->control |= SHOW_ATTRIBUTES;
    }

    if ( callback ) {
        panel->text_line = original_text_line;                 /* restore value */
        panel->choice = current_line - original_text_line;
        callback ( panel );
    }

    row += current_line - top_line;
    ReverseAttributes ( row, column, max_string_length, 1 );            /* on */

    while ( ! finished ) {
        key = GetKeystroke ();
        ReverseAttributes ( row, column, max_string_length, 1 );        /* off */
        switch ( key ) {
            case UP_CURSOR:
                if ( current_line > original_text_line ) {
                    if ( current_line == top_line ) {
                        --top_line;
                        --bottom_line;
                    } else {
                        --row;
                    }
                    --current_line;
                }
                direction = UP_CURSOR;
                break;
            case DOWN_CURSOR:
                if ( *(current_line + 1) ) {
                    if ( current_line == bottom_line ) {
                        ++top_line;
                        ++bottom_line;
                    } else {
                        ++row;
                    }
                    ++current_line;
                }
                direction = DOWN_CURSOR;
                break;
            case DOWNPAGE:
                row_count = 1;
                for ( ; row_count < number_of_text_rows; ++row_count ) {
                    if ( ! *(bottom_line + 1) ) {           /* no more lines */
                        break;
                    }
                    ++top_line;
                    ++bottom_line;
                    ++current_line;
                }
                direction = DOWN_CURSOR;
                break;
            case UPPAGE:
                row_count = 0;
                while ( top_line > original_text_line ) {
                    if ( ++row_count >= number_of_text_rows ) {
                        break;                              /* 1 page of lines */
                    }
                    --top_line;
                    --bottom_line;
                    --current_line;
                }
                direction = UP_CURSOR;
                break;
            case TOP_OF_FILE:
                while ( top_line > original_text_line ) {
                    --top_line;
                    --bottom_line;
                    --current_line;
                }
                while ( current_line > top_line ) {
                    --current_line;
                    --row;
                }
                direction = UP_CURSOR;
                break;
            case END_OF_FILE:
                while ( *(bottom_line + 1) ) {
                    ++top_line;
                    ++bottom_line;
                    ++current_line;
                }
                while ( current_line < bottom_line ) {
                    ++current_line;
                    ++row;
                }
                direction = DOWN_CURSOR;
                break;
            case HELP:
                if ( panel->help.routine ) {
                    panel->help.routine ( panel );
                }
                direction = 0;
                break;
            default:
                direction = 0;
                finished = TRUE;
        }

        switch ( direction ) {                /* skip over non-selectable lines */
            case UP_CURSOR:
                while ( **current_line == NOT_SELECTABLE_CHAR ) {
                    if ( current_line > original_text_line ) {
                        if ( current_line == top_line ) {
                            --top_line;
                            --bottom_line;
                        } else {
                            --row;
                        }
                        --current_line;
                    } else {
                        break;
                    }
                }
                while ( **current_line == NOT_SELECTABLE_CHAR ) {
                    if ( *(current_line + 1) ) {
                        if ( current_line == bottom_line ) {
                            ++top_line;
                            ++bottom_line;
                        } else {
                            ++row;
                        }
                        ++current_line;
                    } else {
                        break;
                    }
                }
                break;
            case DOWN_CURSOR:
                while ( **current_line == NOT_SELECTABLE_CHAR ) {
                    if ( *(current_line + 1) ) {
                        if ( current_line == bottom_line ) {
                            ++top_line;
                            ++bottom_line;
                        } else {
                            ++row;
                        }
                        ++current_line;
                    } else {
                        break;
                    }
                }
                while ( **current_line == NOT_SELECTABLE_CHAR ) {
                    if ( current_line > original_text_line ) {
                        if ( current_line == top_line ) {
                            --top_line;
                            --bottom_line;
                        } else {
                            --row;
                        }
                        --current_line;
                    } else {
                        break;
                    }
                }
                break;
            default:
                ;
        }
        if ( panel->top_line != top_line ) {
            panel->top_line = top_line;
            panel->text_line = top_line;
            ShowPanel ( panel );
        }

        ReverseAttributes ( row, column, max_string_length, 1 );      /* on */

        if ( ! finished ) {
            if ( callback ) {
                panel->text_line = original_text_line;      /* restore values */
                panel->top_line = top_line;                 /* update values */
                panel->current_line = current_line;
                panel->choice = current_line - original_text_line;
                callback ( panel );
            }
        }
    }

    panel->top_line = top_line;                             /* update values */
    panel->current_line = current_line;
    panel->choice = current_line - original_text_line;

    panel->control = save_control;                          /* restore values */
    panel->box.border_attribute = save_border_attribute;
    panel->text_line = original_text_line;

    if ( panel->control & TURN_OFF_LIGHT_BAR ) {
        ReverseAttributes ( row, column, max_string_length, 1 );      /* off */
    }
    if ( panel->control & HIGHLIGHT_BORDER_LINE ) {
        ShowOutline ( &panel->box );
    }

    return key;
}
/// HIFN Callback for the SLM pixels panel 
int CVICALLBACK SLMpixels_Callback (int panel, int event, void *callbackData,
		int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_PANEL_SIZE:
		{	
			// get the new panel size
			int xsize, ysize;
			GetPanelAttribute(panel, ATTR_WIDTH,  &xsize);
			GetPanelAttribute(panel, ATTR_HEIGHT, &ysize);
			
			// check if we are not dealing with an event fired after a programmatical resize
			if ((xsize != SLM_getXres()) || (ysize != SLM_getYres()))
			{
			
				// manually check for a maximize event, which sets the y size of the panel to 1061
				// so we use that value to detect a maximization (NOTE: This code is highly specific to 
				// the UCP lab computer and/or the Windows version running on that)
				if (ysize == 1061)
				{
					// yes, apparently we tried to maximize the panel
				
					// however, 1061 is not what we want, so we
					// set the size manually again to the desired SLM resolution
					SetPanelSize (panel, 1080, 1920);
				
					// set the upper left corner to the upper left corner of the screen,
					// and hope we have banned the titlebar
					SetPanelPos(panel, 0, 1920);
				}
			
				// adjust the canvas size accordingly
				SetCtrlAttribute(panel, SLMpixels_SLMcanvas, ATTR_WIDTH,  xsize);
				SetCtrlAttribute(panel, SLMpixels_SLMcanvas, ATTR_HEIGHT, ysize);
			
				// get the size of the simulation canvas
				int SimX, SimY;
				GetCtrlAttribute(pnlSimPanel, SimPanel_CANVAS, ATTR_WIDTH,  &SimX);
				GetCtrlAttribute(pnlSimPanel, SimPanel_CANVAS, ATTR_HEIGHT, &SimY);
				
				// get the subsampling factor
				int subsample;
				GetCtrlVal(TabPage_0, TABPANEL_SubSample, &subsample);

				// all data structures of the SLM need to be resized to acommodate the new 
				// number of pixels, so we just reintialise the SLM in its entirety			
				SLM_initialise(xsize, ysize, SimX, SimY, subsample);
			
				// update the SLM panel and the simulation Panel (if toggled)
				SLM_update(pnlSLMpixels, SLMpixels_SLMcanvas, pnlSimPanel, SimPanel_CANVAS, 1);
			
				// update the displayed information about the SLM 
				UpdateSLMinfo();
			}
				
			break;
		}
	}
	return 0;
}