Category : Files from Magazines
Archive   : DDJ9405F.ZIP
Filename : BUTTON.CPP

 
Output of file : BUTTON.CPP contained in archive : DDJ9405F.ZIP
// ------------- button.cpp

#include "button.h"
#include "desktop.h"

Button::Button(const String& lbl, int lf, int tp, DFWindow *par)
: TextBox(lf, tp, 1, lbl.Strlen()+5, par)
{
String lb("( ) ");
lb += lbl;
lb += " ";
SetText(lb);
setting = False;
setchar = ' ';

Color clr = Colors();
clr.fg =
clr.sfg =
clr.ffg =
clr.hfg = par ? par->ClientFG() : 0;
clr.bg =
clr.sbg =
clr.fbg =
clr.hbg = par ? par->ClientBG() : 0;
SetColor(clr);
shortcutfg = RED;
}

void Button::Paint()
{
if (isVisible()) {
(*text)[1] = setting ? setchar : ' ';
if (isEnabled())
WriteShortcutLine(0, ClientFG(), ClientBG());
else
WriteTextLine(0, HighlightFG(), HighlightBG());
}
}

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

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

void Button::Keyboard(int key)
{
if (key == ' ')
InvertButton();
else
TextBox::Keyboard(key);
}

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

void Button::InvertButton()
{
if (setting)
ReleaseButton();
else
PushButton();
}

void Button::PushButton()
{
setting = True;
Paint();
}

void Button::ReleaseButton()
{
setting = False;
Paint();
}








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