Category : Files from Magazines
Archive   : DFPP01.ZIP
Filename : CHECKBOX.CPP

 
Output of file : CHECKBOX.CPP contained in archive : DFPP01.ZIP
// ------------- checkbox.cpp

#include "checkbox.h"
#include "desktop.h"

CheckBox::CheckBox(char *lbl, int lf, int tp, DFWindow *par)
: TextBox(lf, tp, 1, strlen(lbl)+5, par)
{
OpenWindow();
String lb("[ ] ");
lb += lbl;
lb += " ";
SetText(lb);
}

// ----------- common constructor code
void CheckBox::OpenWindow()
{
windowtype = CheckBoxWindow;
if (windowstate == CLOSED)
TextBox::OpenWindow();
SetColors();
setting = False;
}

void CheckBox::CloseWindow()
{
TextBox::CloseWindow();
}

// -------- set the fg/bg colors for the window
void CheckBox::SetColors()
{
colors.fg =
colors.sfg =
colors.ffg =
colors.hfg = Parent()->ClientFG();
colors.bg =
colors.sbg =
colors.fbg =
colors.hbg = Parent()->ClientBG();
shortcutfg = RED;
}

void CheckBox::Paint()
{
if (visible) {
if (isEnabled())
WriteShortcutLine(0, colors.fg, colors.bg);
else
WriteTextLine(0, colors.hfg, colors.hbg);
}
}

Bool CheckBox::SetFocus()
{
TextBox::SetFocus();
desktop.cursor().normalcursor();
desktop.cursor().SetPosition(Left()+1, Top());
desktop.cursor().Show();
return True;
}

void CheckBox::ResetFocus()
{
TextBox::ResetFocus();
desktop.cursor().Hide();
}

void CheckBox::Keyboard(int key)
{
if (key == ' ')
InvertCheckBox();
else
TextBox::Keyboard(key);
}

void CheckBox::LeftButton(int mx, int my)
{
if (ClientRect().Inside(mx,my))
InvertCheckBox();
}

void CheckBox::InvertCheckBox()
{
setting = setting ? False : True;
(*text)[1] = setting ? 'X' : ' ';
Paint();
}









  3 Responses to “Category : Files from Magazines
Archive   : DFPP01.ZIP
Filename : CHECKBOX.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/