C-Lite and wxWidgets

Posted By: TechMuc

C-Lite and wxWidgets - 07/15/08 01:05

Hey,

Is anyone interested in a tutorial about the binding of windows-style menues in an 3D-Gamestudio application?
If so I could write one.

Some examples how such an engine-implementation could look like:





If anybody is interested please write here. Sorry, that's no real contrib. but, I don't want to write a tutorial, no one asks for wink

Tech-Munich
Posted By: Xarthor

Re: C-Lite and wxWidgets - 07/15/08 06:26

Yes please! smile
I would like to see such a tutorial.

Thanks in advance!
Posted By: Helghast

Re: C-Lite and wxWidgets - 07/15/08 07:46

that would be superawesome!!!

That way you could like write your own editor with an ingame preview built in.
I'd be 100% interested laugh

regards,
Posted By: Michael_Schwarz

Re: C-Lite and wxWidgets - 07/15/08 08:40

Totally, that would be real helpful! smile
Posted By: Quad

Re: C-Lite and wxWidgets - 07/15/08 09:57

that would be awesome.

highly interested.
Posted By: Poison

Re: C-Lite and wxWidgets - 07/15/08 10:16

Same here I´m interested in such a tutorial smile .
Posted By: HeelX

Re: C-Lite and wxWidgets - 07/15/08 10:42

We would appreciate that! Do it! laugh
Posted By: oliver2s

Re: C-Lite and wxWidgets - 07/15/08 11:06

This would be very very nice. Maybe I can use it for an IceX 3 or so.
Posted By: TechMuc

Re: C-Lite and wxWidgets - 07/15/08 13:13

Okay I'll write one then in the next two days.

@oliver: your gladly invited to help me on my project :P
Posted By: Shadow969

Re: C-Lite and wxWidgets - 07/15/08 13:55

Looking forward to reading your tutorial smile
Posted By: Kasey_Dee

Re: C-Lite and wxWidgets - 07/16/08 23:55

Add another interested person to your list.
Posted By: gri

Re: C-Lite and wxWidgets - 07/17/08 08:36

hi,

me too.

,
gri
Posted By: Anonymous

Re: C-Lite and wxWidgets - 07/17/08 12:23

i am also interested
Posted By: TechMuc

Re: C-Lite and wxWidgets - 07/17/08 15:45

Okay, I'm very busy with my own project, therefore just a small introduction, the real tutorial will be released in ~1 week.
Sorry for the delay (if you want to be able to create a windows application with 3DGS the code below will allow it for you. Download the Documentation from http://docs.wxwidgets.org/stable/ - this is a very good reference - use it - and use your own brain. If you really want to develop with Windows-User Interface the hints given in the tutorial will be enough :P wink

If you have a question, just ask, I'll help.


Windows Interfaces and 3D-Gamestudio



PRENOTES: This Tutorial is NOT for absolute beginners. You must have knowledge in C++, you should have already a little bit experience with Visual Studio, or maybe even created a DLL. I'm German, therefore my English is not the best (Honestly this is my first english tutorial ever - honestly this is one of my first tutorials ever..-^^ i hope you understand everything). I use German software therefore also the screenshots are in German.


1) Programs / API

There are many available Windows-User-Interface API's outside. Many are used in famous Tools like for example wxWidgets which is used in Audacity or GDK+ which is used in GIMP. After searching through the web I decided to use wxWidgets because of very easy implementation, wonderful help tools and good documentation. Addionally it is platform independent and can therefore run on Mac and Linux (of course not very important for 3D-Gamestudio users).

1)For implementing wxWidget into your project you first have to download the wxWidgets API from http://www.wxwidgets.org . Install the WxWidgets API in a folder of your choice (in the following C:\wx2).
2)Even with wxWidgets the Design of Menus isn't that easy. Therefore there are many Programs in the web to design nice Graphical User-Interfaces with wxWidgets. I decided to use wxFormbuilder. It is free and easy to use. Additionally it supports many Addons and plugins for wxWidgets. You can download the Program from http://wxformbuilder.org.
3)There are many additions for wxWidgets. The most useful ones are collected on the site of wxformbuilder. If you want to develop profesional programs they might help you lots. Download them from http://wxformbuilder.org/?page_id=30
4)Of course you also need a c++ compiler. I work with Microsoft Visual Studio 2005 and will describe everything in this Tutorial for this compiler. You can get the express Version of Microsoft Visual Studio for free. Download it from http://www.microsoft.com/germany/Express . Or search Google for Microsoft Visual Studio 2008 Express Edition.


2) Setup Visual Studio

At first you have to create a new Project with Microsoft Visual Studio (File->New->Project). As type you have to choose Win32-Project. As we want to develop a DLL for you Engine Application you must choose "DLL" as application use (normally found in the tab application settings ("Anwendungseinstellungen"). Check the option "Create empty project" ("Zusätzliche Optionen"->"Leeres Projekt"). Click Finish and add a CPP file to your project (right click on "source files" in the right tab, add -> New element -> Cpp file).

Now you have to configure Microsoft Visual Studio C++ Project Settings. Open the Project Settings (Project->%Project name% Settings).
Click “configure settings”.
Important settings:
  • configuration type = DLL
  • font/character set = Not known / not defined


Next go to C/C++ --> General and setup the include paths:

  • C:\wx2\include
  • C:\wx2\lib\vc_lib\mswd
  • C:\wx2\additions\lib\vc_lib
  • C:\wx2\additions\include
  • C:\GStudio7\sdk_plugin


(of course you have to use your own paths).

No you have to setup the Library Paths. Goto “linker” (sorry don't know the english word. The tab below C/C++) --> general
These are the additional include folders:

  • C:\Programme\GStudio7\sdk_plugin
  • C:\wx2\additions\lib\vc_lib
  • C:\wx2\lib\vc_lib


At last you have to add the needed librarys. Go to “Linker” --> Commandline and add the following libraries in the text field:

user32.lib gdi32.lib comdlg32.lib comctl32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib rpcrt4.lib adll.lib wsock32.lib wxbase28d.lib wxmsw28d_core.lib wxmsw28d_propgrid.lib wmpio.lib


3) Write the Main.cpp


This is the “main” cpp file.

Code:
// Include the usual Windows headers
#define WIN32_LEAN_AND_MEAN		
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <process.h>

#define DLL_USE

#include "adll.h"

// for compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers
#ifndef WX_PRECOMP
    #include "wx/app.h"
    #include "wx/log.h"
    #include "wx/frame.h"
    #include "wx/menu.h"

    #include "wx/button.h"
    #include "wx/checkbox.h"
    #include "wx/listbox.h"
    #include "wx/statbox.h"
    #include "wx/stattext.h"
    #include "wx/textctrl.h"
    #include "wx/msgdlg.h"
#endif

#include "wx/sysopt.h"
#include "wx/bookctrl.h"
#include "wx/sizer.h"
#include "wx/colordlg.h"
#include "wx/fontdlg.h"
#include "wx/textdlg.h"

BOOL APIENTRY DllMain( 
  HANDLE hModule,
  DWORD ul_reason_for_call,
  LPVOID lpReserved)
{
  engine_bind();
  return TRUE;
}


This code includes all needed files for a 3D-Gamestudio DLL and wxWidgets.


4) Design a Menu with wxFormBuilder
(sorry still in German)


Bevor wir das Menü inkludieren können müssen wir es natürlich noch designen wink Also einfach wxFormbuilder mal öffnen.
Jedes Element eines Menüs muss natürlich einem Fenster untergeordnet werden. Das Haupt-Fenster kann entweder ein Frame / ein Dialog oder ein Panel sein. Alle haben ihre eigenen Eigenschaften, so hat zum Beispiel ein Panel per Default keine Titelleiste.
Normalerweise wählt man als Hauptfenster einen Frame! Dieser ist unter dem “Forms” Tab zu finden. Nach dem anklicken findet ihr Rechts immer alle Eigenschaften. Sollte alles selbsterklärend sein.
Wichtig ist nun wie man weitermacht. In wxwidgets wird ein Fenster über so genannte Sizers designt (diese findet ihr alle unter dem Tab “Layout”).

Diese Sizer solltet ihr unter dem Tab Layout finden. Jedes Element unterhalb des Hauptframes muss in einem Sizer gesetzt werden.
Ein Sizer ist eine Art Tabelle für alle Elemente (so wie so bei wxForumbuilder auch aufgezeichnet ist).

Beispiel Sizer 1: Das erste Objekt wird über dem zweiten gesetzt. Das zweite über den dritten usw.
Beispiel Sizer 3: Das erste Objekt ist links von den zweiten. Das Dritte Objekt ist unter dem ersten.



As it will last one week here are the most important parts of the code so that you can learn design with wxWidgets on your own.. wink As already said I'll release the tutorial in the next week

You will NOT be able to copy&paste the code but it'll help you.

Code:

//overwrite the default Application Class
class MyApp: public wxApp
{
	virtual bool OnInit(); //will be executed when wxWidgets is inited
	virtual int OnExit(); //will be executed when wxWidgets ends
};

int MyApp::OnExit()
{
	ShowWindow(ev->hWnd,SW_SHOWNORMAL);
	return 0;
}

bool MyApp::OnInit()
{
	frame = new wxFrame( (wxWindow*)0 ); //Main Frame, designed with wxFormBuilder
        ev->hWndTarget = (HWND)EnginePanel->GetHWND(); //The Panel where the Engine should be included
	frame->Show(TRUE);
	SetTopWindow(frame);
	ShowWindow((HWND)frame->GetHWND(),SW_SHOWNORMAL);
	ShowWindow(ev->hWnd,SW_MINIMIZE); //minimize old window

	return TRUE;
}

//inform wxWidget that the MyApp Class has to be created after wxEntry
IMPLEMENT_APP_NO_MAIN(MyApp) 

void wx_start_thread(void* i)
{
       //wxEntry starts wxWidgets
	wxEntry((HINSTANCE) ev->hInstance, (HINSTANCE)0, (wxCmdLineArgType)0, (int)0);
}


//call this function in Lite-C
DLLFUNC int Start()
{
        //wxwidgets has to be created in another thread...
	_beginthread(wx_start_thread,0,(void*)0);
	return 1;
}



So again sorry for the delay, I'll answer every upcoming question.

PS: surreptitious advertising wink


Posted By: oliver2s

Re: C-Lite and wxWidgets - 07/22/08 11:50

Thank you smile I think this will help many users including me. Very nice contribution.
Posted By: Quad

Re: C-Lite and wxWidgets - 07/22/08 13:07

Thank you, wasn't aware you posted it. waiting for the full tut wink

i guess i need to build wxwidget libraries now.
Posted By: Anonymous

Re: C-Lite and wxWidgets - 09/06/08 22:15

did you already finished the second part of the tutorial?
© 2024 lite-C Forums