home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
MAGNIFY
/
MAGNIFY.CPP
< prev
next >
Wrap
Text File
|
1995-05-01
|
3KB
|
86 lines
#ifndef _IBASE_ //Make sure ibase.hpp is included
#include <ibase.hpp> // since that is where IC_<environ>
#endif // is defined.
#include <iapp.hpp>
#include <iframe.hpp>
#include <icmdhdr.hpp>
#include <igbitmap.hpp>
#include <igrafctx.hpp>
#include <ibmpctl.hpp>
#include <itimer.hpp>
#include <isetcv.hpp>
#include <icustbut.hpp>
#include <ispinnum.hpp>
#include "magnify.hpp"
int main()
{
MagnifyWindow win;
IApplication::current().run();
return 0;
}
MagnifyWindow::MagnifyWindow ()
:IFrameWindow ("Magnify Sample", WND_MAIN),
bitmapControl(0,this,this),
canvas(100,this,this),
button(101,&canvas,&canvas),
xText(102,&canvas,&canvas),
xSpin(103,&canvas,&canvas),
yText(104,&canvas,&canvas),
ySpin(105,&canvas,&canvas),
bitmap(0)
{
setIcon( id() );
setClient(&bitmapControl);
handler.handleEventsFor(this);
button.enableLatching().setText("Magnify").enableTabStop();
xText.setText(" X:");
yText.setText(" Y:");
xSpin.setRange(IRange(1,desktopWindow()->size().width())).setLimit(4);
xSpin.setValue(32).enableTabStop();
ySpin.setRange(IRange(1,desktopWindow()->size().height())).setLimit(4);
ySpin.setValue(32).enableTabStop();
canvas.setMargin(ISize(2,2)).setAlignment(ISetCanvas::centerCenter);
addExtension(&canvas,aboveClient,(unsigned long) (canvas.minimumSize().height()));
moveSizeToClient(IRectangle(50,50,50+canvas.minimumSize().width(),
50+canvas.minimumSize().width()));
show();
button.setFocus();
}
void MagnifyWindow::timerFunction ()
{
IPoint mousePosition = IWindow::pointerPosition();
unsigned long xSize = xSpin.value();
unsigned long ySize = ySpin.value();
IRectangle rect(0,0,xSize,ySize);
ISize desktopSize = desktopWindow()->size();
rect.centerAt(mousePosition);
if (rect.left()<0)
rect.moveTo(IPoint(0,rect.bottom()));
if (rect.bottom()<0)
rect.moveTo(IPoint(rect.left(),0));
if (rect.right()>=desktopSize.width())
rect.moveTo(IPoint(desktopSize.width()-xSize,rect.bottom()));
if (rect.top()>= desktopSize.height())
rect.moveTo(IPoint(rect.left(),desktopSize.height()-ySize));
IGBitmap* newBitmap = new IGBitmap(IGraphicContext(desktopWindow()->handle()),rect);
bitmapControl.setBitmap(newBitmap->handle());
if (bitmap)
delete bitmap;
bitmap = newBitmap;
}
Boolean MagnifyHandler::command(ICommandEvent& event)
{
MagnifyWindow *win = (MagnifyWindow*) event.window();
if (win->button.isLatched())
win->timer.start(new ITimerMemberFn0<MagnifyWindow>(*win,MagnifyWindow::timerFunction),200);
else
win->timer.stop();
return true;
}