wxFlatMenu & wxFlatMenuBar

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!
eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Sun Oct 22, 2006 6:18 pm

Infinity_77 wrote:In the initialization code of ShadowPopupWindow, you have:

wxwidgets:

long style = wxBORDER_NONE | wxWANTS_CHARS | wxPOPUP_WINDOW;
wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxT("flat_menu"));




So it does not inherit anymore from wx.PopupWindow, but from wx.Window (?!?!?).
Ok,

I change the code in the wxShadowPopupWindow, to be like this:

Code: Select all

wxShadowPopupWindow::wxShadowPopupWindow()
{
	wxWindow* parent = wxTheApp->GetTopWindow();
	wxASSERT_MSG(parent, wxT("Can't create menu without parent!"));

	// popup windows are created hidden by default
	//Hide();
	//long style = wxBORDER_NONE | wxWANTS_CHARS | wxPOPUP_WINDOW;
	wxPopupWindow::Create(parent);//, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxT("flat_menu"));
	//long style = wxBORDER_NONE | wxWANTS_CHARS | wxPOPUP_WINDOW;
	//wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxT("flat_menu"));

	// We need to override the creation of the window with our
	// so we provide other class to this window, with shadow style enabled
	CreateMSW();
}
It work the same as the old code, does this help you now?

If I understand Python correctly (I used python 2 years ago), writing this should work for you now:

Code: Select all

class ShadowPopupWindow(wx.PopupWindow):
def __init__(self, parent):
wx.PopupWindow.__init__(self, parent) 
HTH,
Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Post by NinjaNL » Sun Oct 22, 2006 6:45 pm

eranif wrote:Compiled demo with AUI:
http://www.eistware.com/flatmenu/22_oct ... th_AUI.zip
Demo doesn't seem to work with windows 2000
20:45:16: Can't create window of class wxMenu (error 1407: cannot find window class.)
20:45:16: Can't create window of class wxMenu (error 1407: cannot find window class.)
20:45:16: Can't create window of class wxMenu (error 1407: cannot find window class.)
20:45:16: Can't create window of class wxMenu (error 1407: cannot find window class.)
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/

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

Post by eranif » Sun Oct 22, 2006 7:27 pm

I am guessing you are running under win2k?

if this is the case, I am familiar of the problem still dont have a solution yet (except to remove the shadow from the menus)

EDIT:
Sorry, missed out that you mentioned that you are running under win 2k.

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

Infinity_77
Experienced Solver
Experienced Solver
Posts: 89
Joined: Tue Oct 03, 2006 6:30 pm
Location: London, UK
Contact:

Post by Infinity_77 » Sun Oct 22, 2006 8:03 pm

Hi Eran,

yes, your changes do help a lot. Anyway, I am still having troubles. The construction of the window seems to proceed without problems, but there are a couple of issues:

1) using:

Code: Select all

SetSize(wxSize(m_menuWidth, menuHeight+4));
At line 808 of flat_menu.cpp returns:

OverflowError: long int too large to convert to int

This is because the call to:

Code: Select all

wxClientDC dc(this);

wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
dc.SetFont(font);
int width, height, dummy, itemHeight, accelWidth = 0, accelHeight, filler;

wxString stam = wxT("Tp");
wxString accelFiller = wxT("XXXX"); // 4 spaces betweem text and accel column

// Calc text length/height
dc.GetMultiLineTextExtent(stam, &dummy, &itemHeight);
dc.GetMultiLineTextExtent(text, &width, &height);
return monstrous numbers for width, height and so on (something like 2083791885 2084020904) for the 2 numbers. So I guess there is some error in constructing the class in CreateMSW (in the Python implementation). For this, the only thing I am not able to translate is the following instruction:

Code: Select all

SetHWND( m_hWnd );
from line 143, in CreateMSW. I don't know how this can be done using the win32api, so I would be grateful if you have any insight about it...

Andrea.
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.alice.it/infinity77/

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

Post by eranif » Sun Oct 22, 2006 8:44 pm

hi,

try replacing GetMultiLineTextExtent() calls to GetTextExtent()

SetHWND is not a WINAPI function, but wxWindow functions which simply does:



wxWindow.m_hWnd = m_hWnd;

There is a member m_hWnd in wxWindow, it simply assigns it ...


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

Infinity_77
Experienced Solver
Experienced Solver
Posts: 89
Joined: Tue Oct 03, 2006 6:30 pm
Location: London, UK
Contact:

Post by Infinity_77 » Sun Oct 22, 2006 8:57 pm

Hi Eran,

thanks for your help (and patience!). It is going a little bit better with GetTextExtent, but not so much. I get:

Code: Select all

width, height = dc.GetTextExtent(text)
print width, height, itemHeight
it returns as a result of the "print":

32 26802740 29899732

Uhm, very tall as a popup menu :-D

The demo starts up, but I get a bunch of debug errors like:

Debug: ..\..\include\wx/msw/private.h(338): 'GetWindowRect' failed with error 0x00000578 (handle di finestra non valido.).
Debug: ..\..\include\wx/msw/private.h(338): 'GetWindowRect' failed with error 0x00000578 (handle di finestra non valido.).
Debug: ..\..\src\msw\window.cpp(1806): 'MoveWindow' failed with error 0x00000578 (handle di finestra non valido.).

That's because (I think) there is no _hWnd property in wxPython to assing to a window, so I can never call SetHWND or directly assing it a value. It is maybe a private property? No, probably it is not exposed in wxPython... so I am somewhat lost.

Thank you, as usual, for your suggestions.

Andrea.
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.alice.it/infinity77/

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

Post by eranif » Sun Oct 22, 2006 9:12 pm

Ok, lets try different approach :) :

From the mailing list, I found this email from Noel, try it:
Hi!

I realized that is is quite simple to add a shadow to a window on MSW
(XP):

try:
import win32gui, win32api
CS_DROPSHADOW= 0x00020000
GCL_STYLE= -26
cstyle= win32gui.GetClassLong(self.GetHandle(), GCL_STYLE)
if cstyle & CS_DROPSHADOW == 0:
win32api.SetClassLong(self.GetHandle(),
GCL_STYLE, cstyle | CS_DROPSHADOW)
except:
pass

Since you have already added CanSetTransparent() and SetTransparent()
to wxTopLevelWindow, would you accept a patch that adds CanAddShadow()
and SetShadow() to wxWindow? To the C++ library of course.

Maybe somebody who knows how we could achive a similar behaviour on GTK
or Mac reads this?
;o)

I have a HTMLPopup window to show context specific help. Together with
my ArtProviderFileSystem for images and this shadow functionality it
would make up an interesting help facility. Of course, if somebody is
interested I would donate the code.

Best regards,
Noel
Revert the code back to no-shadow.

Try Noel's suggestion as described above.

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

Infinity_77
Experienced Solver
Experienced Solver
Posts: 89
Joined: Tue Oct 03, 2006 6:30 pm
Location: London, UK
Contact:

Post by Infinity_77 » Sun Oct 22, 2006 9:24 pm

Hi Eran,

yes, I have seen the approach from Noel, and actually this is what I am doing in Symphony (the latest implementation, not the one of which you have seen the screenshots). However, I have also seen your comments following Noel's approach... this means every popup window that I may have in an app will have shadows just like the menus. Not very bad, but also not very clean. I'll see if Robin can share some thoughts on this issue.

Thank you so much for your help.

Andrea.
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.alice.it/infinity77/

Infinity_77
Experienced Solver
Experienced Solver
Posts: 89
Joined: Tue Oct 03, 2006 6:30 pm
Location: London, UK
Contact:

Post by Infinity_77 » Mon Oct 23, 2006 3:45 pm

Hi Eran and all,

if I may mention a couple of details about FlatMenu (these are really minor things):

1) In the "Customize" dialog, once you remove a menu and then you select it again, it is appended to the menu bar. So the "File" menu may be at the right end of the menubar after the "Customize" dialog. Is this an intended behavior? I felt more confortable in keeping the menu order, so I used Insert() instead of Append();

2) The nice hovering effect in the "Customize" dialog vanishes when you select "Options". Even if you hover on the "Menus" tab, no hovering effect is drawn. This is quite tricky, and I haven't found a solution yet...

Andrea.
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.alice.it/infinity77/

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

Post by eranif » Mon Oct 23, 2006 4:08 pm

Infinity_77 wrote: 1) In the "Customize" dialog, once you remove a menu and then you select it again, it is appended to the menu bar. So the "File" menu may be at the right end of the menubar after the "Customize" dialog. Is this an intended behavior?
At first it was the intended solution, but like you, I found it kinda funny that 'File' was placed last ... So it will be fixed.

The solution is to keep the initial layout of the menu at startup, and try to position the menu based on this layout afterwards.

Using 'Insert' instead of Append is bad idea, since user can remove menus in other ways then using the Customize dialog, (e.g. using Remove Menu from the 'Edit' menu provided in the sample) which can make your 'Insert' index invalid or out-of-bound
I suggest you keep the Append until I will apply the full solution.
Infinity_77 wrote: The nice hovering effect in the "Customize" dialog vanishes when you select "Options". Even if you hover on the "Menus" tab, no hovering effect is drawn. This is quite tricky, and I haven't found a solution yet...
The hover effect is not gone, this is intended behavior, since when you place your mouse over a non-selected tab, it is painted as raised tab (hard too see because of the colours are too similar, but it is there), so it hides the shadow of the selected tab

If you want to try something else, add this style to CustomizeDlg m_book member (of type wxLabelBook) inside the customize dialog:
style |= wxINB_WEB_HILITE;

I think this will satisfy you :wink:


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

Takeshi Miya
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Jan 22, 2006 11:43 pm

Post by Takeshi Miya » Tue Oct 24, 2006 10:41 pm

eranif wrote:
Jorg wrote:Good work Eran!
In fact, I am working on integrating wxFlatNotebook inside wxAUI (with bwilliams, wxAUI author), becuase I think wxFlatNotebook tabs, can offer alot to wxAUI.

Eran
One of the most wanted features! :D
I specially like how you can drag and drop windows to tabs in wxIFM or VS2005.

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

Post by eranif » Tue Oct 24, 2006 10:52 pm

Takeshi Miya wrote: One of the most wanted features! Very Happy
I specially like how you can drag and drop windows to tabs in wxIFM or VS2005.
Just for you Takeshi :wink:, here is my initial work which I sent to bwilliams (wxAUI author), a download link, if it will be accepted it will be integrated into CVS. (I think I will continue working on it even if it wont be accepted by the devs or kirix :D)

Another important fact:
All this was achieved without changing a single line in wxAUI, all changes were done to wxFlatNotebook.

http://www.eistware.com/fnb_aui/wxFlatNotebookTest.zip
Note that this is WIP, and not completed yet.

Usage:
- First you have to enable notebook dragging by Edit->Allow Drag and drop (2 flags, for the FOREIGN & the other flag)
- Pull one tab from the main notebook, and leave (left up) the mouse
- Position it anywhere
- pull another one
- you got the idea

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

Takeshi Miya
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Jan 22, 2006 11:43 pm

Post by Takeshi Miya » Tue Oct 24, 2006 11:24 pm

eranif wrote:
Takeshi Miya wrote: One of the most wanted features! Very Happy
I specially like how you can drag and drop windows to tabs in wxIFM or VS2005.
Just for you Takeshi :wink:, here is my initial work which I sent to bwilliams (wxAUI author), a download link, if it will be accepted it will be integrated into CVS. (I think I will continue working on it even if it wont be accepted by the devs or kirix :D)
That's amazing, really :D

Early things to note:
- You can't drag a tab outside the main frame directly (in wxIFM you can), the current workaround is to drag the tab first inside the window and then move the window
- Tabs and containers (panels) are being handled as a different concepts, unlike wxIFM where "tabs = panels", so when you close the last tab, the window closes. This is not bad either, but the approach chosen should be left to the developer or the user.
- This, instead of XOR rectangles (ok, purely wxAUI but maybe you know how to modify it accordingly :P):
Image

Infinity_77
Experienced Solver
Experienced Solver
Posts: 89
Joined: Tue Oct 03, 2006 6:30 pm
Location: London, UK
Contact:

Post by Infinity_77 » Wed Oct 25, 2006 12:19 pm

This, instead of XOR rectangles (ok, purely wxAUI but maybe you know how to modify it accordingly ):
Uhm, I may seem dumb, but in which respects the 4 pointing arrows are superior to XOR rectangles? If it is a purely aesthetic modification, I would vote to keep the rectangles. Otherwise, someone more skilled than me may explain the actual advantages...

Andrea.
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.alice.it/infinity77/

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

Post by T-Rex » Wed Oct 25, 2006 2:29 pm

Uhm, I may seem dumb, but in which respects the 4 pointing arrows are superior to XOR rectangles
I think some combination of this 2 ways could be a good solution.
Some color schemes under Windows and Linux (I tested only wxGTK) make XOR rectangles less visible and it would be very nice to enable other kind of indication for this case.

Post Reply