Category : C++ Source Code
Archive   : CPP_GRPH.ZIP
Filename : PAGESEL.CPP

 
Output of file : PAGESEL.CPP contained in archive : CPP_GRPH.ZIP
#include "pagesel.hpp"
#include "screen.hpp"

PageSelector::PageSelector() : Icon(-1, -1, -1, -1)
{
// assume all buttons are used, although the
// actual number should be determined at this
// time
total_buttons = MAX_PAGE_BUTTON;
button_selected = 0;

// stop if no buttons to be created
if (total_buttons == 0) return;

// compute the height of each button
int height = SCREEN_Y2 / total_buttons;

// create all the buttons required
for (int i = 0; i < total_buttons; i++) {
int x = PAGE_SELECTOR_X1;
int y = SCREEN_Y1 + height * i;
button [i] = new PageButton(this, x, y, height,
&Pages [i], i);
}
}

void PageSelector::Display()
{
// display all the page selector buttons
for (int i = 0; i < total_buttons; i++)
button [i]->Display();
}

void PageSelector::Select(int page)
{
// highlight the button for the new page
button [button_selected]->UnHighlight();
button_selected = page;
button [button_selected]->Highlight();

// load activation function
void (*activation_function)() =
button [button_selected]->activation_function;

// eliminate the old page displayed
CurrentScreen->ClearWorkArea();

// invoke the button's activation function
if (activation_function)
(*activation_function)();
}


PageSelector::~PageSelector()
{
// eliminate all the buttons
for (int i = 0; i < total_buttons; i++)
delete button [i];
}




PageButton::PageButton(PageSelector* parent_array,
int x, int y, int size,
PAGE_BUTTON_DEFINITION* pbp,
int page) :
Icon(x, y, x + PAGE_BUTTON_WIDTH, y + size)

{
parent = parent_array;
page_number = page;
strncpy(descriptor,
pbp->descriptor,
sizeof(descriptor) );
activation_function = pbp->activation_function;

border_color = RED;
inactive_color = CYAN;
active_color = BRIGHT_CYAN;
descriptor_color = BLACK;

box = new Box(x1, y1, x2 - x1, y2 - y1,
border_color, inactive_color);
}


void PageButton::Display()
{
box->Display();

BOX_TYPE title_box;
title_box.x1 = x1;
title_box.y1 = y1;
title_box.x2 = x2;
title_box.y2 = y2;
Legend t_legend;
t_legend.Center(&title_box,
descriptor_color,
descriptor);
}

void PageButton::LeftButtonPressed()
{
Highlight();
}

void PageButton::LeftButtonReleased()
{
parent->Select(page_number);
}

void PageButton::Highlight()
{
box->Color(active_color);
Display();
}

void PageButton::UnHighlight()
{
box->Color(inactive_color);
Display();
}

PageButton::~PageButton()
{
delete box;
}


  3 Responses to “Category : C++ Source Code
Archive   : CPP_GRPH.ZIP
Filename : PAGESEL.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/