wxFlatNotebook

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply
eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Thu Jan 05, 2006 10:54 pm

I can confirm that, maybe the last minute fix that I inserted affected that ...
I will fix it asap

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Thu Jan 05, 2006 11:40 pm

Done - the bug is now fixed, please test it and let me know
You can do update from the CVS.

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio » Thu Jan 05, 2006 11:43 pm

Please keep in mind that anonymous access (on top of which the viewCVS web interface works too) is a bit out of sync from realtime on sourceforge STILL *mutters something*
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Fri Jan 06, 2006 6:33 am

Ceniza wrote:Linux: g++ 4.0.2
Windows: g++ 3.4.4

What's really weird is why 3.4.4 isn't "seeing" that function isn't there when tried to be used.
Did you try -wall ?
Under windows I had some Strange things to,
compiling methods without return value; until you use them :lol:

User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Fri Jan 06, 2006 3:45 pm

Hello.

Thanks for fixing the bug with scrolling. :)

I was thinking, maybe it will be good to add to wxPageContainer::OnTextDropTarget one more parameter wxPageContainer * oldParent and try to Reparent the page, then it may be possible to exchange the pages between different notebooks. I'll try to make some fixes tomorrow or a little bit later and we'll see what will happen :)

I'd like to hear your opinion about this idea before I start the work, maybe someone tried to implement this behaviour.

Regards,
T-Rex

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Fri Jan 06, 2006 8:41 pm

This will be great T-Rex - contact me in private message if you are intrested - so I cuold give you write access to the CVS - this way the merging can be skipped

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Sat Jan 07, 2006 1:29 am

Hello.

I created the small application using the existing source code from my older project... It uses wxCustomDataObject and wxDropTarget. But... it doesn't work and I don't know why.... It seems that I missed smth but I can't find it. Please, take a look at the source.

Code: Select all

#include <wx/wx.h>
#include <wx/dnd.h>
#include <math.h>

class wxFNBDragInfo
{
	wxWindow * m_Container;
	int m_PageIndex;	
public:		
	wxFNBDragInfo(wxWindow * container, int pageindex) : m_Container(container), m_PageIndex(pageindex){}
		wxWindow * GetContainer() {return m_Container;}
		int GetPageIndex() {return m_PageIndex;}
};

class wxFNBDropTarget : public wxDropTarget
{
private:	
	wxWindow * m_pParent;	
	wxCustomDataObject * m_DataObject;
public:
    wxFNBDropTarget(wxWindow * pParent)
		: m_pParent(pParent)		
		, m_DataObject(NULL)
	{
		m_DataObject = new wxCustomDataObject(wxDataFormat(wxT("wxFNB")));
		SetDataObject(m_DataObject);
	}
	virtual ~wxFNBDropTarget(void) {}
    virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
	{		
		wxFNBDragInfo * draginfo = (wxFNBDragInfo *)m_DataObject->GetData();
		if(draginfo == NULL) 
		{
                        // It seems that draginfo is allways NULL
			return wxDragNone;
		}
		((wxListBox *)m_pParent)->Insert(wxString::Format(_("Stored Number = %i"), draginfo->GetPageIndex()), 0);		
		return def; 	
	}
};

class DragSourcePanel : public wxPanel
{
public:
	DragSourcePanel(wxWindow * parent, wxWindowID id)
		: wxPanel(parent, id)
	{
	}
	DECLARE_EVENT_TABLE()
	void OnMouseDown(wxMouseEvent & event);
};

BEGIN_EVENT_TABLE(DragSourcePanel, wxPanel)
EVT_LEFT_DOWN(DragSourcePanel::OnMouseDown)
END_EVENT_TABLE()

void DragSourcePanel::OnMouseDown(wxMouseEvent & event)
{
	/* 
	This object should contain the information about page's owner [this] and page's index [rand()]
	*/
	wxFNBDragInfo draginfo(this, rand());
	wxCustomDataObject dataobject(wxDataFormat(wxT("wxFNB")));
	dataobject.SetData(sizeof(wxFNBDragInfo), &draginfo);
	wxDropSource dragSource(this);
	dragSource.SetData(dataobject);
	dragSource.DoDragDrop(wxDrag_DefaultMove);
}

class MyFrame : public wxFrame
{		
	wxListBox * m_ListBox;
public:
	MyFrame(wxWindow * parent);	
	DECLARE_EVENT_TABLE()	
	void OnExit(wxCommandEvent & event);
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
END_EVENT_TABLE()

MyFrame::MyFrame(wxWindow * parent)
: wxFrame(parent, -1, _("Test"), wxDefaultPosition, wxDefaultSize, wxSYSTEM_MENU | wxCLOSE_BOX | wxCAPTION)
{		
	wxMenuBar * menuBar = new wxMenuBar();
	SetMenuBar(menuBar);
	wxMenu * fileMenu = new wxMenu();
	fileMenu->Append(wxID_EXIT, _("Exit\tAlt+F4"));
	menuBar->Append(fileMenu, _("File"));
	wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
	SetSizer(sizer);	

	wxPanel * panel1 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER);
	wxBoxSizer * panelsizer = new wxBoxSizer(wxVERTICAL);
	panel1->SetSizer(panelsizer);
	m_ListBox = new wxListBox(panel1, 10001);
	m_ListBox->SetDropTarget(new wxFNBDropTarget(m_ListBox));
	panelsizer->Add(m_ListBox, 1, wxEXPAND|wxALL, 5);

	DragSourcePanel * panel2 = new DragSourcePanel(this, -1);

	sizer->Add(panel1, 1, wxEXPAND|wxALL, 5);
	sizer->Add(panel2, 1, wxGROW);

	CreateStatusBar();
		
	Centre();
}

void MyFrame::OnExit(wxCommandEvent & event)
{
	Close();
}

class MyApp : public wxApp
{
public:
	virtual bool OnInit();
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
	MyFrame * frame = new MyFrame(NULL);	
	frame->Show();	
	SetTopWindow(frame);
	return true;
}
Also I mostly prepared the source code of wxFlatNotebook for tab exchange but I have the same problem there (since I used the same source code).

Regards,
T-Rex

User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Sat Jan 07, 2006 3:29 pm

At last!!! I managed how to make it work. Now it is possible to exchange the pages between notebooks :)
I'm going to update the documentation and will upload the source code to my site a little bit later.

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Sat Jan 07, 2006 4:11 pm

Great Job, Looking eagerly to see it !

Before you update the files, can you please do update from the CVS - so you make sure you are working on the latest files?

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Sat Jan 07, 2006 6:16 pm

I uploaded the updated source code to
http://www.ttanalytics.nm.ru/wxFlatNotebook.rar
And here is the sample executable for MSW which I created using wxAUI, wxToolBox and wxFlatNotebook (it illustrates the page exchange):
http://www.ttanalytics.nm.ru/wxToolBoxSampleIDE_bin.rar

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Sat Jan 07, 2006 6:28 pm

I guess the fight for wxWidgets IDE will soon get finished :D

User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Sat Jan 07, 2006 6:34 pm

That was the skeleton of my current project, not wx IDE ;)

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Sat Jan 07, 2006 6:38 pm

Very nice indeed

I will merge the changes to the CVS.

Btw, is it going to be commrecial IDE?

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Sat Jan 07, 2006 6:43 pm

Yes.

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Sat Jan 07, 2006 8:36 pm

T-Rex,
For now I am not merging your changes, since I found several bugs in it:

1. When dragging a page a selection event is fired - with erronous indexs (sucn as 26380 etc)
2. When dragging a tab to a new notebook and there IS more room for the tab - still the whole tabs are scrolled left and the new tab is placed single on the row

3. In some cases - cant tell when exactly, the tab causes the book to display two windows at the same time (like a splitter window)!

4. And last after getting error number 3, when I tried to drag a tab the demo application crashed.

I dont have time to look at it now, If you have the time please have a look at what I described.

Should be easy to simulate:

Add a second notebook to the demo application with some pages init.

Compile the demo with the DEVELOPMENT define set, (this will enable to the log window) - and just follow the log messages.

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

Post Reply