March 28, 2024, 04:10:00 PM

News:

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


Alpha update 12/28/2005

Started by Ionic Wind Support Team, December 27, 2005, 11:32:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ionic Wind Support Team

The latest alpha snapshot is ready for download.  Use the link provided after purchase and reinstall.

Changes/Additions:
-------------------------
- The menu editor was outputing the wrong style constants.  Fixed.
- A math bug dealing with subtracting doubles from floats was fixed.
- A bug causing member variables in derived classes to be duplicated was fixed.
- A few lingering parser lock up bugs were fixed.
- Many constants added to gui.inc.  Including constants used for SetRasterOp, SetFont, DrawMode, button controls, edit controls and static controls.

- SetSize added to the window class.
- EOF was added to the file I/O library.
- The raw printer functions OpenPrinter, WritePrinter, ClosePrinter and PrtDialog were added to the GUI library.

- The classes CButton, CEdit and CStatic are now part of the GUI library.  See 'editor.src' for an example on using the edit control class

No demos for the button or static control classes yet.  Here are a few example creation statments:

//create a button suitable for XP themes
btn.Create(40,40,80,20,AWS_VISIBLE|AWS_TABSTOP,10,"Close",w);

//create a button that can change it's colors
btn.Create(40,40,80,20,AWS_VISIBLE|AWS_TABSTOP|ABS_OWNERDRAW,10,"Close",w);
btn.SetColor(0,RGB(255,0,0));

Those are the major changes. 

Paul.
Ionic Wind Support Team

Parker

There are controls! Does the ownerdraw style make Aurora handle the drawing, or is it up to us? Or on second thought, maybe it's something that happens in the WndProc that we can handle if we override it.

Ionic Wind Support Team

The ownerdraw is handled by Aurora.  On Windows buttons don't natively support changing the background color so you have to roll your own button to do it.  That is the default behaviour in IBasic.

The problem is ownerdrawn buttons don't support XP themes so on Aurora I made the default a normal button.

You can override OnDrawItem if you want to experiment yourself.
Ionic Wind Support Team

Bruce Peaslee

The static controls work just fine. Here is a snip:


If Lots[i].isForSale = true
{
pTemp->DrawRect(30,5,10,10,BLACK,RED);
m_static = new(CStatic,1);
m_Static->Create(5,5,20,20,AWS_VISIBLE,1,"Hi",pTemp);
m_Static->SetColor(BLACK,GREEN);
}
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

The next update will have the dialog class functional. 

The design I finalized on was a mixture of the ideas presented in the "control" thread.  You can create controls using the classes directly, as shown in the editor.src demo.  However dialogs are normally based on templates that create all of the controls in one fell swoop when DoModal or ShowDialog is called.

So dialogs are templates like they were in IBasic and a single method adds controls to that template.  The method takes care of creating the control class internally.  Working with the control, to set its color or add items to a list view, involves getting a pointer to the internal class.  Something like this:

mydialog d1;
d1.Create(0,0,100,200,AWS_VISIBLE|AWS_CAPTION,0,"MyDialog",parent);
d1.AddControl(CTBUTTON,"Close",20,20,60,20,AWS_VISIBLE|ABS_OWNERDRAW,0,10);
d1.AddControl(CTBUTTON,"Save",20,90,60,20,AWS_VISIBLE|ABS_OWNERDRAW,0,11);
...
d1.DoModal();

mydialog::OnInitDialog()
{
CButton *btn
btn = GetControl(10);
btn->SetColor(0,RGB(255,255,0));
btn = GetControl(11);
btn->SetColor(0,RGB(255,0,0));
return true;
}

In linux most of this will be emulated since the dividing concept of a window/dialog doesn't apply.

Ionic Wind Support Team

Ionic Wind Support Team

And it works  ;D

Syntax is preliminary here.  Probably change before the update.


/*
Aurora example program
Compile as a WINDOWS target
*/

class mydialog:dialog
{
declare OnInitDialog(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
}

DECLARE IMPORT,GetSysColor(index as int),int;

global sub main()
{
def colordlg as mydialog;
colordlg.Create(0,0,317,255,0x80C80080,0,"Color Control Demo",0);
colordlg.AddControl(CTBUTTON,"Button1",38,31,70,20,0x50000000|AWS_TABSTOP,0,1);
colordlg.AddControl(CTBUTTON,"Button2",123,31,70,20,0x50000000|AWS_TABSTOP,0,2);
colordlg.AddControl(CTBUTTON,"Button3",208,31,70,20,0x50000000|AWS_TABSTOP,0,3);
colordlg.AddControl(CTBUTTON,"Button4",38,65,70,20,0x50000000|AWS_TABSTOP,0,4);
colordlg.AddControl(CTBUTTON,"Button5",123,65,70,20,0x50000000|AWS_TABSTOP,0,5);
colordlg.AddControl(CTBUTTON,"Flat",208,65,70,20,0x50008000|AWS_TABSTOP,0,6);
colordlg.AddControl(CTEDIT,"Edit1",37,101,231,19,0x50800000|AWS_TABSTOP,0,7);
colordlg.AddControl(CTCHECKBOX,"Check1",43,133,70,20,0x50000003,0,8);
colordlg.AddControl(CTLISTBOX,"ListBox1",121,135,70,60,0x50800140,0,9);
colordlg.AddControl(CTBUTTON,"Close",123,227,70,20,0x50000001|AWS_TABSTOP,0,10);
colordlg.AddControl(CTRADIOBUTTON,"Radio1",214,134,70,20,0x50000009,0,11);

colordlg.DoModal();
return 0;
}

mydialog::OnInitDialog(),int
{
CControl *pControl;
CenterWindow();
pControl = GetControl(1);pControl->SetColor(0,RGB(255,255,0));
pControl = GetControl(2);pControl->SetColor(RGB(0,0,255),0);
pControl = GetControl(3);pControl->SetColor(RGB(200,200,0),RGB(255,255,255));
pControl = GetControl(4);pControl->SetColor(RGB(255,255,255),RGB(0,0,255));
pControl = GetControl(5);pControl->SetColor(RGB(200,80,200),RGB(0,155,0));
pControl = GetControl(6);pControl->SetColor(0,RGB(0,255,255));
pControl = GetControl(7);pControl->SetColor(RGB(255,0,255),0);
pControl = GetControl(8);pControl->SetColor(RGB(0,0,255),RGB(255,255,255));
pControl = GetControl(9);pControl->SetColor(0,RGB(0,255,0));
//ADDSTRING colordlg,9,"Text"
pControl = GetControl(11);pControl->SetColor(RGB(128,7,43),GetSysColor(15));
return true;
}


mydialog::OnClose(),int
{
CloseDialog(1);
return true;
}

mydialog::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
IF(nID = 10) CloseDialog(1);
return true;
}
Ionic Wind Support Team

Parker

It seems a little odd to me to have a button class do a checkbox, option button, and normal button (like winapi) but then to have the control statement with different constants for each, is it possible to just use a button control with the button class' constants?

Ionic Wind Support Team

You can do either.  Entirely up to you as this works too:

//create a checkbox
colordlg.AddControl(CTBUTTON,"Check1",38,31,70,20,AWS_VISIBLE|ABS_CHECKBOX|AWS_TABSTOP,0,1);

A checkbox, radiobutton, button and groupbox are all button controls.  It's just the style that is different.  Using CTCHECKBOX just sets the style for you.

Ionic Wind Support Team

Parker

Alright thanks, that's good to know, when I first tried to create a checkbox with the API I didn't know how, since they didn't have a "CHECKBOX" class. We'll need a ControlEx-type statement somehow, I think. ( Who doesn't want to use scintilla :) )

Ionic Wind Support Team

For a dialog there will be an AddControlEx.

For a window you can create your own scintilla class now.  Derive a class from CControl and override the Create method.  Use CreateWindowEx with the proper class name setting the return value to m_hWnd (all control classes derive from the window class).

m_hWnd = CreateWindowEx...

Ionic Wind Support Team

Parker

Thanks, for a window though, will there be a simpler way eventually, maybe a CCustomControl class that allows you to provide the window class name to it?

Ionic Wind Support Team

Not very difficult to roll your own custom control class.  I can't do everything for you ;)

Here is a very basic Create handler to get you started:


declare extern InitializeControl(CControl *control,int type);

MyControl::Create(int l,int t,int w,int h,int style,int nID,string title,window *parent),int
{
unsigned int hParent;hParent = null;
if(parent <> null)
{
if(GetDlgItem(parent->m_hwnd,nID)=0)
{
hParent = parent->m_hwnd;
m_hWnd = CreateWindowExA(WS_EX_CLIENTEDGE,"classname",title,style|WS_CHILD,l,t,w,h,hParent,nID,GetModuleHandle(0),0);
if(m_hWnd)
{
InitializeControl(this,1);
}
}
}

return m_hWnd;

}


As stated deriive the class from CControl.  InitializeControl is part of the GUI library and subclasses the control so that all of the OnXXX handlers work for your control class.  OnMouseMove, etc.  It also allows using SetColor with most control types.

If you want to provide the classname as part of the method then just call it CreateEx

Paul.
Ionic Wind Support Team

Parker

I was just asking if eventually, but thanks for this! I don't need anything else, but the InitializeControl is good to know about. Thanks again.

Ionic Wind Support Team

The dialog editor now generates Aurora skeleton code, complete with derived classes for the dialog.

This was generated a few minutes ago.  Should make it easy to get started on small projects.


#define BUTTON_1 1
#define BUTTON_2 2
#define RADIO_3 3
#define CHECK_4 4
#define EDIT_5 5
#define COMBO_6 6
class ColorDlg:dialog
{
declare OnInitDialog(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
}

global sub main()
{
ColorDlg d1;
d1.Create(0,0,300,202,0x80C80080,0,"Caption",0);
d1.AddControl(CTBUTTON,"Button1",14,15,70,20,0x5000000B,0x0,BUTTON_1);
d1.AddControl(CTBUTTON,"Button2",94,15,70,20,0x5000000B,0x0,BUTTON_2);
d1.AddControl(CTRADIOBUTTON,"Radio1",34,76,70,20,0x50000009,0x0,RADIO_3);
d1.AddControl(CTCHECKBOX,"Check1",119,76,70,20,0x50000003,0x0,CHECK_4);
d1.AddControl(CTEDIT,"Edit1",46,133,70,20,0x50800000,0x200,EDIT_5);
d1.AddControl(CTCOMBOBOX,"ComboBox1",167,122,70,80,0x50800603,0x0,COMBO_6);

d1.DoModal();
return 0;
}

ColorDlg::OnClose(),int
{
CloseDialog(1);
return true;
}

ColorDlg::OnInitDialog(),int
{
/* Initialize any controls here */
CenterWindow();
return true;
}

ColorDlg::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case BUTTON_1:
if(nNotifyCode = 0)
{
/*button clicked*/
}
case BUTTON_2:
if(nNotifyCode = 0)
{
/*button clicked*/
}
case RADIO_3:
case CHECK_4:
case EDIT_5:
/* respond to edit notifications here */
case COMBO_6:
/* respond to control notifications here */
}
return true;
}
Ionic Wind Support Team

Parker

Yay!! ;D This will be a nice thing to have

Ionic Wind Support Team

Besides the dialog editor I also have a class generator in the works.  Point and click overrides to automatically generate derived classes.  Kind of like Class Wizard from MSVC but less windows 3.1 looking ;)

The way it works is you pick your base class, such as window, and choose the message handlers you want the derived class to handle.  Click the button and go.  Which lets you concentrate on writing the implimentation instead of remembering which virtual function to override.

Ionic Wind Support Team

Zen

Wow this gets more exciting as the days goes by. Have you even stoped over xmas Paul?

Lewis

Steven Picard

Quote from: Ionic Wizard on December 29, 2005, 06:06:11 AM
Besides the dialog editor I also have a class generator in the works.  Point and click overrides to automatically generate derived classes.  Kind of like Class Wizard from MSVC but less windows 3.1 looking ;)

The way it works is you pick your base class, such as window, and choose the message handlers you want the derived class to handle.  Click the button and go.  Which lets you concentrate on writing the implimentation instead of remembering which virtual function to override.


Oh, that will be really handy.  ;D