home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
yacl-012.zip
/
uidemo
/
graphic1
/
appwin.old
< prev
next >
Wrap
Text File
|
1994-10-14
|
2KB
|
89 lines
#include "ui/ui.h"
#include "appwin.h"
#define ID_MESSAGE 10
#define MESSAGE "Click and hold mouse to begin drawing"
AppWindow::AppWindow()
: UI_CompositeVObject (NULL, NULL, FALSE, UI_Rectangle (50, 50, 500, 300))
{
_status = new UI_Label (this, UI_Rectangle (50, 50, 400, 30));
*(_status->Model()) = CL_String (MESSAGE);
_inDrag = FALSE;
}
AppWindow::~AppWindow()
{
DestroyDisplaySurface ();
}
void AppWindow::Initialize ()
{
UI_CompositeVObject::Initialize();
CreateDisplaySurface ();
}
bool AppWindow::ButtonDown (const UI_Point& p, UI_MouseButton m,
bool, bool)
{
if (m != UIM_Left)
return FALSE;
_inDrag = TRUE;
_Controller->GiveMouseTo (*this);
_startPt = p;
_oldRect.Origin (p);
_displaySurface->Pen().Pattern (UIPen_DashDot);
_displaySurface->Mode (UI_DisplaySurface::GMode_Xor);
return TRUE;
}
bool AppWindow::MouseMove (const UI_Point& p)
{
if (!_inDrag)
return TRUE;
long wd = p.XCoord() - _startPt.XCoord();
long ht = p.YCoord() - _startPt.YCoord();
_displaySurface->DrawRectangle (_oldRect); // Erase the old rectangle
UI_Rectangle r (_startPt, wd, ht);
_displaySurface->DrawRectangle (r); // Draw the new rectangle
_oldRect = r;
*(_status->Model()) = CL_String (wd) + " x " + CL_String(ht);
return TRUE;
}
bool AppWindow::ButtonUp (const UI_Point& p, UI_MouseButton m)
{
if (m != UIM_Left)
return FALSE;
_inDrag = FALSE;
_Controller->ReleaseMouse();
_displaySurface->Pen().Pattern (UIPen_Solid);
_displaySurface->Mode (UI_DisplaySurface::GMode_Copy);
UI_Rectangle s (_startPt, p.XCoord() - _startPt.XCoord(),
p.YCoord() - _startPt.YCoord());
_displaySurface->DrawRectangle (s);
_oldRect = UI_Rectangle (0, 0, 0, 0);
*(_status->Model()) = CL_String (MESSAGE);
return TRUE;
}
bool AppWindow::DoubleClick (const UI_Point& p, UI_MouseButton m)
{
UI_SimpleDialog ("Double click button " + CL_String ((long) m) +
" at " + CL_String (p.XCoord ())
+ " x " + CL_String (p.YCoord ()));
return TRUE;
}