May 27, 2024, 09:22:34 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Been busy

Started by Ionic Wind Support Team, December 27, 2005, 08:28:12 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Ionic Wind Support Team

I've been quiet but have noted everything mentioned on the forums.  Getting the control classes 'just right' is taking time but there will be an update this evening.  Have the button and edit classes working nicely.  Solved quite a few bugs along the way and managed to add a few missing methods to the window class.

This editor example now compiles and runs


/*
a simple SDI editor (like notepad). Created by
using a multiline edit control sized to the window
version 1.2 for the Aurora compiler.
Compile with a WINDOWS target
*/
def hprinter,run as int;
def startpg,endpg,copies,collate as int;
def filename,ln,printer as string;
def file1 as unsigned int;
def buffer[32766] as DSTRING;

class editorwindow:window
{
declare virtual OnClose(),int;
declare virtual OnSize(int nType,int cx,int cy),int;
declare virtual OnMenuPick(int nID),int;
CEdit *m_ed;
}

global sub main()
{
editorwindow win;
win.m_ed = new(CEdit,1);
menu m;
//Open our main window, get its client size and create the control
win.Create(0,0,640,400,AWS_SIZE|AWS_MINIMIZEBOX|AWS_MAXIMIZEBOX|AWS_MAXIMIZE|AWS_CAPTION|AWS_SYSMENU,0,"EDITOR V1.2",0);
rc = win.GetClientRect();
win.m_ed->Create(rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,AES_MULTILINE|AWS_HSCROLL|AWS_VSCROLL,1,"",win);
m.BeginMenu();
m.MenuTitle( "&File");
m.MenuItem( "&Load File\tCtrl+L",0,1);
m.MenuItem( "&Save\tCtrl+S",0,2);
m.MenuItem( "&Print\tAlt+P",0,4);
m.MenuItem( "&Quit\tCtrl+C",0,3);
m.MenuTitle( "&Options");
m.MenuItem( "Change Font\tF4",0,5);
m.EndMenu();
win.SetMenu(m.Detach());

//add our keyboard accelerators
win.AddAccelerator(FCONTROL|FVIRTKEY,ASC("L"),1);
win.AddAccelerator(FCONTROL|FVIRTKEY,ASC("S"),2);
win.AddAccelerator(FCONTROL|FVIRTKEY,ASC("C"),3);
win.AddAccelerator(FALT|FVIRTKEY,ASC("P"),4);
win.AddAccelerator(FVIRTKEY,0x73,5);//F4 key changes font

win.m_ed->SetColor(0,RGB(255,255,255));
//process messages until somebody closes us
run = 1;
do{wait();}until run=0;
win.Destroy();
delete win.m_ed;
return;
}

//handler subroutines
//process OnSize to size the edit control
//process OnMenuPick for the menus
//process OnClose to quit the program
editorwindow::OnClose(),int
{
run = 0;
return true;
}

editorwindow::OnSize(int nType,int cx,int cy),int
{
//size the edit control to match the client size of the window
//we use m_ed->m_hwnd to verify the existance of the edit control
//because the first OnSize message is sent while the window is being created
//but before we have a chance to add the edit control.
if m_ed->m_hwnd
m_ed->SetSize(0,0,cx,cy);
return true;
}

editorwindow::OnMenuPick(int nID),int
{
select nID
{
case 5:
ChangeFont(this);
case 4:
//dump the edit control to the printer
DoPrint(this);
case 3:
//quit the program
run = 0;
case 2:
//save the file
DoSave(this);
case 1:
DoOpen(this);
}

return true;
}

//------------- DOOPEN ----------------
SUB DoOpen(editorwindow *win)
{
filename = filerequest("Load File",win,1);
if(len(filename) > 0)
{
buffer = "";
file1 = OpenFile(filename,MODE_READ);
if(file1)
{
do
{
if(ReadString(file1,ln,255)<>0)
{
if len(buffer) < (32766-257)
{
buffer = buffer + ln + chr$(13) + chr$(10);
}
}
} until Eof(file1);
CloseFile(file1);
win->m_ed->SetText(buffer);
}
}
RETURN;
}

//------------- DOSAVE -----------------
SUB DoSave(editorwindow *win)
{
filename = filerequest("Save File",win,0);
if(len(filename) > 0)
{
file1 = OpenFile(filename,MODE_WRITE|MODE_CREATE);
if(file1)
{
buffer = win->m_ed->GetText();
Write(file1,buffer,len(buffer));
CloseFile(file1);
}
}
RETURN;
}
//------------- DOPRINT ----------------
//prints the contents of the edit control
//using straight text printing.
//This method won't work for GDI only printers
//--------------------------------------
SUB DoPrint(editorwindow *win)
{
startpg = 1;
endpg = 1;
copies = 1;
collate = 1;
printer = PrtDialog(win,startpg,endpg,copies,collate);
hprinter = OpenPrinter(printer,"Document","TEXT");
if(hprinter)
{
buffer = win->m_ed->GetText();
WritePrinter(hprinter, buffer);
ClosePrinter(hprinter);
}
return;
}
//------------- CHANGEFONT -------------
SUB changefont(editorwindow *win)
{
DEF size,weight,flags,col as int;
DEF fontname as string;
size = 12;
weight = 400;
flags = 0;
col = 0;
fontname = FontRequest(*win,size,weight,flags,col);
if(fontname <> "")
win->SetFont(fontname,size,weight,flags,1);
win->m_ed->SetColor(col,RGB(255,255,255));
return;
}
Ionic Wind Support Team

Bruce Peaslee

December 27, 2005, 10:48:31 PM #1 Last Edit: December 27, 2005, 10:50:37 PM by peaslee
Quote from: Ionic Wizard on December 27, 2005, 08:28:12 PM
...ÂÃ,  but there will be an update this evening.ÂÃ, 
Not by the time I have to get some sleep (yawn...)ÂÃ,  ;)

Edit: Paul, anybody who thinks you don't put it all into this project is an idiot.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

Ionic Wind Support Team

Parker

Paul,
It really is amazing what you've done so far. Aurora is becoming much better than IBasic in much less time, counting you have another job to tend to. And I like the idea of having all this open to the public much better than the closed beta idea, I still don't like the prereg forums since they're a mystery to me.

Ionic Wind Support Team

The whole prereg thing wasn't my idea.  It was a compromise with Idigicon.

But lets leave the past where it belongs ;)
Ionic Wind Support Team