Hypertreelist not firing when item selected - windows

I am on a Windows machine, I am using WxPython Phoenix. I have a hypertreelist that should fire a function when an item is selected (or focused/clicked)...
import wx.lib.agw.hypertreelist as htl
self.apps_tree = htl.HyperTreeList(self, -1,
size=wx.Size(width, height),
style=wx.TR_NO_BUTTONS | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_NO_LINES,
agwStyle=wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HAS_VARIABLE_ROW_HEIGHT | wx.TR_NO_BUTTONS | wx.TR_NO_LINES | wx.TR_HIDE_ROOT)
self.apps_tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnAppSelected)
I've tried to append the Bind on self (wx.Panel), I tried to use other events such as EVT_TREE_ITEM_HYPERLINK, EVT_TREE_ITEM_ACTIVATED but none worked. The code above works on Mac though...
The item not even gets colored... I have other elements on screen but as far as I can tell there is no overlaying...

For anyone having this issue...
I manage to make this work using self.Layout() after adding all elements on screen

Related

Make arbitrary widget appear as a top-level window in GTK on X

In Windows, it is possible to say
CreateWindow("myclass",...,WS_CHILD,...);
or
CreateWindow("myclass",...,WS_OVERLAPPEDWINDOW,...);
It is also possible to switch appearance at will:
SetWindowLongPtr((HWND)handle,GWL_STYLE,style_1);
SetWindowPos((HWND)handle,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowLongPtr((HWND)handle,GWL_EXSTYLE,style_0);
SetWindowPos((HWND)handle,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
if(style_1&WS_CHILD)
{
HWND owner=GetWindow((HWND)handle,GW_OWNER);
SetParent((HWND)handle,owner);
}
else
{SetParent((HWND)handle,NULL);}
It seems to me that most other GUI toolkits make a clear distinction between top-level windows and other widgets. The question is if and how it is possible to implement similar behavior in GTK on X
There is a GTK_WINDOW_TOPLEVEL and GTK_WINDOW_POPUP - unless you know what you do use the first. Also RTM https://developer.gnome.org/gtk3/stable/gtk3-Standard-Enumerations.html#GtkWindowType
You need to create a GtkWindow or GtkMainWindow and then add your desired widget x via gtk_container_add to the window you created.

Firefox Extension: Get page offset inside main Firefox window

Is it possible to get the offset of the page/window in the main Firefox window from inside an extension? To make things clear: It's not a DOM related question, I think it's an XPCOM question. I'll try to give an idea of what I need:
[Firefox]------------------------------------------------[ - # X ]
| Tab1 Title | Tab2 Title | |
------------------------------------------------------------------
| http://address.com/ | > |
------------------------------------------------------------------
* <- (X, Y) Offset of the page inside the main Firefox window |
| |
| |
| Page contents... |
| |
. .
. .
. .
Examples of basic bootstrap:
https://gist.github.com/Noitidart/9025999
This one has some extra stuff like the Services module imported, you need to import this module to use Services.wm; But to import Services you need the component Cu. see the top of the gist here:
https://gist.github.com/Noitidart/9026493
Now Services.wm.getMostRecentWindow('navigator:browser') gets only one window. If you want to iterate through all browser windows copy paste this. I include how to iterate over each each HTML window in the tabs in each browser as well.
const {interfaces: Ci, utils: Cu} = Components;
Cu.import('resource://gre/modules/Services.jsm');
//on this line can do Services.wm.getMostRecentBrowser('navigator:browser').gBrowser.contentDocument to get the currently focused tab document of the most recent browser window OR or continue to the loop below and it will do all windows and all tabs.
let XULWindows = Services.wm.getXULWindowEnumerator(null);
while (XULWindows.hasMoreElements()) {
let aXULWindow = XULWindows.getNext();
let aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
//aDOMWindow.gBrowser can be accesed here
//to go through all tabs in the gBrowser do this:
if (aDOMWindow.gBrowser && aDOMWindow.gBrowser.tabContainer) {
var tabs = aDOMWindow.gBrowser.tabContainer.childNodes;
for (var i = 0; i < tabs.length; i++) {
Cu.reportError('DOING tab: ' + i);
var tabBrowser = tabs[i].linkedBrowser;
var aHTMLWindow = tabBrowser.contentWindow;
var aHTMLDocument = aHTMLWindow.document;
}
}
}
yes run this code to get the offset, you mean page offset right?
gBrowser.contentDocument.getBoundingClientRect().left
you just access the dom of the main page and you can do anything there

How to add image in CTreeCtrl list in MFC

I am trying to add Image before the text in CTreeList control but it is not coming up, But what i observed is the the node name is started after some space , like it is leaving the space for bitmap , but image is not showing up.. here is the code snap:-
CImageList m_ImageList;
CBitmap m_Bitmap1;
m_ImageList.Create(16,16,ILC_COLOR32,1,1);
m_Bitmap1.LoadBitmap(IDB_BITMAP1);
m_ImageList.Add(&m_Bitmap1, RGB(0,0,0));
TreeSoft->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP |
TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT |
TVS_SINGLEEXPAND | TVS_SHOWSELALWAYS |
TVS_TRACKSELECT,
CRect(10, 10, 200, 240), this, 0x1221);
TreeSoft->SetImageList(&m_ImageList, TVSIL_NORMAL);
hTree = TreeSoft->InsertItem( L"Software Production",0,0, TVI_ROOT);
hCompany = TreeSoft->InsertItem(L"Microsoft",0,0, hTree);
Pls tell me what i am missing here...
Now you just need to set the image for the newly created branch:
TreeSoft->SetItemImage(hTree , 0, 0); // I think it starts from 0 (if it does not show try 1)
Just for testing purposes.
Create an icon with 16-bit color palette.
Instead of ILC_COLOR32 use ILC_COLOR.
And instead of RGB(0,0,0) use (COLORREF)0xFFFFFF
I have exact the same code except the smaller color palette and it works.
If this works you can try with the bigger palette.

Flex 4:Capturing mouse events with spark.primitive.path objects

I am trying to capture mouse events whenever the mouse does something over top of a spark.primitive.path (the 'L' shape below).
Everything I have read states that I need to put the path inside of a Group object and attach mouse handlers to that. So the code would look something like this..
<s:Group left="10" right="10" top="10" bottom="10" mouseOver="...">
<s:Path data="M 100 300 L 200 50 L 275 50 L 250 150 L 300 150 L 300 300 Z">
<s:stroke>
<s:SolidColorStroke color="0x888888"/>
</s:stroke>
</s:Path>
</s:Group>
...and produces something like this on screen (please forgive the ascii art)
_____________________________
| |
| _______ |
| / / |
| / / |
| / / |
| / /_____ |
| / | |
| / | |
| /______________| |
| |
-----------------------------
This does almost work. The problem is the mouse events are fired based on dimensions of the Group object, not the Path. So, if you mouse over to the left of the path that still fires mouse events, because the Group is a box starting at 0,0 and ending at the bottom right side of the 'L'.
Any thoughts on how I can resolve this (or an alternate solution) are greatly appreciated.
If you use a SkinnableContainer instead of a Group, you will get the behavior you are looking for.
Try encapsulating in a Graphic object (Flex4). See there: http://blog.flexexamples.com/2010/03/22/creating-a-simple-image-map-in-flex-4/

How do I use CMFCRebar to produce an acceptable look and feel?

I am trying to use some classes from the MFC Feature Pack to improve the look & feel of my MFC application.
In my application, I use one CReBar object to dock three different toolbars. I have updated the class of this object to use CMFCReBar, but it doesn´t look good when using some visual styles.
It seems there's a problem in the Feature Pack because it happens even with the RebarTest example deployed with package.
This is a screenshot of the example application just changing the visual style to Office 2007 (using the app. menu not by code):
Screenshot of RebarTest example application http://img105.imageshack.us/img105/1057/rebartestep5.png
Has anybody successfully used CMFCReBar? Is there any other way to achieve the same without using it?
Basically you don't need to use a rebar control anymore. By simply creating your CMFCToolbars and CMFCMenuBar, calling EnableDocking on them and then using DockPane on each, they will dock and take on the Office 2007 (or whatever other theme you use) look-and-feel. Check out the WordPad Feature Pack sample, or create a new project (one with all the default settings is fine) using AppWizard to see an example.
Ok from your comment: if you want to dock toolbars next to each other you can use DockPaneLeftOf after DockPane. It tends to act strangely with toolbar placement in my experience if you don't DockPane both toolbars first.
I haven't found a good simple solution to stopping the toolbars from being dragged yet while docking next to each other, you can remove the CBRS_GRIPPER style, however that doesn't stop the toolbars from being dragged.
You can also just not call EnableDocking on the menubar or toolbars. This will make them fixed place. However, DockPaneLeftOf does not seem to work in this case, so you lose docking toolbars next to each other.
So it seems like one or the other right now if you want to stop docking, or dock toolbars next to each other.
Paul DiLascia wrote a class to lock the CToolBar, I used it to create this class which will work on CMFCToolbar. And you can copy it to do exactly the same sort of thing for CMFCMenuBar - just change MFCToolBar to MFCMenuBar and you're done.
class CLockedMFCToolBar : public CMFCToolBar
{
public:
CLockedMFCToolBar() : CMFCToolBar() {}
protected:
LRESULT CLockedMFCToolBar::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
if ((msg==WM_LBUTTONDOWN || msg==WM_LBUTTONDBLCLK))
{
// Got click or double-click and toolbar is locked: if mouse in "dead
// zone" then ignore the message--don't pass to control bar
CPoint pt(lp);
if (OnToolHitTest(pt, NULL) == -1)
return 0; // return without handling: bypass control bar dragging!
}
// pass unhandled messages subclassed window--this is important!*/
return CMFCToolBar::WindowProc(msg, wp, lp);
}
};
//////////////////////////////
// in CMainFrame declaration
protected:
CLockedMFCMenuBar m_wndMenuBar;
CLockedMFCToolBar m_wndToolBar1;
CLockedMFCToolBar m_wndToolBar2;
////////////////////////////
// in CMainFrame::OnCreate
if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar1.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar2.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar2.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
EnableDocking(CBRS_ALIGN_ANY);
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar1.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar2);
DockPane(&m_wndToolBar1);
DockPaneLeftOf(&m_wndToolBar1, &m_wndToolBar2);
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_wndToolBar1.SetPaneStyle(m_wndToolBar1.GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_wndToolBar2.SetPaneStyle(m_wndToolBar2.GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
I've noticed a few visual problems when using the Office 2007 style too - it seems to be a little bit buggy. Can you use one of the others instead? XP Luna seems to be quite stable...

Resources