Reattaching pages to a Notebook in GTK# - gtk#

I'm using a Notebook widget to pull off a tabbed file view, and I've added code to allow detaching pages from an existing Notebook, which spawns a new window with a separate Notebook, containing just that page. However, I'd like the ability to move pages between multiple Notebooks as well.
The Notebook.WindowCreationHook delegate gives me the Notebook the page comes from, the page widget, and the x and y coordinates it's dropped at, but I don't know how I can tell what Notebook it's being dropped onto, if any. Is there a built-in mechanism for this reattachment, or do I have to go by the coordinates? If I have to use the coordinates, what's the best way to take them and get back a Notebook widget? I can store a list of the Notebooks I have floating around, if need be, but even then the code to figure out which one is which will be a bit tough (taking z-order and all that fun stuff into account).

I decided to go on my own advice (which you voted to -1, and I deleted since it doesn't really answer the question), so here I am risking my reputation again. With code:
http://uplink.kicks-ass.net/~radu/GTK_Sharp_Notebook/
At the above address you'll find two archives of the same thing (since I don't know which one you'll prefer). In the archives there's code I wrote today, and which does this:
The main window contains a Notebook with three tabs, each tab having a random UI element (a button, a calendar, and a checkbox). You can drag the tabs outside of the main window. When you drop them outside of the main window, a new window is created, itself containing a notebook. The tab you just dropped will appear in the new window. You got so far yourself.
Now, if you drag another tab from the main window to the new window, the tab is added to the notebook of the new window rather than create a new window.
Also, if you drag all the tabs away from the new window, back to the main window, the new window is destroyed (after the last tab has been dragged away).
Key to this thing? GroupId = 0 for all the notebooks. They handle the drags and drops themselves.
If you want to hide the tabs in the new windows (before you reattach them), you'd probably want to look into docking widgets rather than notebooks.
Note: I used MonoDevelop under Linux to make the linked application.

Related

Drag and Drop( ctrl+drag) Problems in Xcode

There are two places within Xcode (version 13.3) where I can't drag and drop anymore.
Trying to move a file to a Group. I have tried just clicking and dragging, control-click, option-click, command-click, none work. Instead of dragging the file, the cursor just moves without the selected/highlighted file and highlights whatever file or group it is hovering over.
Trying to drag a button to a View Controller to make a connection. Instead, a popup window appears with three rows, each with corresponding icon, two lines each (title and object type): View Controller, View, Button. (I can't figure out how to capture that screen since I am already holding the control key and mouse button (track pad) but here is a photo.
Update:. All works fine when using a mouse but these two problems always exist when using the trackpad. I did discover that by pressing the Escape key, I can perform the control-drag (but not move files). I have played with the trackpad settings but have not yet been able to figure out how to get rid of that window that appears.
This popup appears whether I am holding the control, option, or command key.
What xcode version are you using, just tried
#1 is working as expected on my xcode13.0
#2 seems to be working for me too..

Capture Hidden window with aero effects

I am trying to capture windows hidden behind my application. I am using windows 7 and VC++. I have tried printwindow() function which draws the both non-client and client area of hidden window, but captured window in the device context doesn't show desktop composition effects(aero effects). Instead it shows the captured window with windows 7 basic theme.
I have also tried with GetWindowDC() to retrive the DC of hidden window, and then Bitblt() it to memory DC but the captured window doesn't show non-client area (caption, close button, minimize button etc) correctly.
Anybody faced this issue?
Please help.
Click the link below. It leads to a MSDN site that lists all the existing Windows Functions ever of all history since Windows 95 up to Windows 8 (from period where Microsoft started Windows until present). It shows old windows functions of first Windows and new windows functions added for the new windows.
http://msdn.microsoft.com/en-us/library/windows/desktop/ff468919(v=vs.85).aspx
Anyway follow this site.
You will see the name of each function as a link.
Click any of them that you are interested.
Each link there leads to another MSDN site that explains all the basics knowledge that you must know about the function before using it, that you want to learn more. What that function does, its purpose, all its parameters and how to use each one, all their flags, all parameters types, return value and at last remarks section that shed more light and sometimes gives tips about the selected function.
Of course, you don't have to read all of them. Find in the list only the necessary functions to fit your needs. The functions that will solve your problem and answer your question that you posted.
By the way, I read your post, and I think that I found in the list the necessary functions that will do what you want to do, I will list them below, and say in one sentence what each does for what you need:
AnimateWindow - Enables you to produce special effects when showing or hiding windows. There are four types of animation: roll, slide, collapse or expand, and alpha-blended fade.
FlashWindow - Flashes the specified window one time. It does not change the active state of the window.
FlashWindowEx - Flashes the specified window specified number of times. It does not change the active state of the window.
Use these functions to achieve the aero effects that you want.
SetWindowPos - Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.
Use this function to show the hidden windows on the top side (above all other windows) and on the screen front of you. The operating system will automatically draw the both non-client and client area of these windows without using any gdi, draw and paint functions yourself.
If you want these windows to return back to their previous state (where they were hidden), then save their state with GetWindowPlacement function and later call SetWindowPlacement to bring them back to their hidden state. You can try GetWindowRect and SetWindowPos instead to achieve the same goal.
I also think that you will be interested in GetWindowTheme and SetWindowTheme functions and all the draw theme functions (BackgroundEx, Edge, Icon, Text, TextEx).
There are more theme functions. Find in msdn and in other sites on the web.

Keep part of a window always visible

It is possible to use the SetWindowPos API on Windows to keep a windows always on top of other windows, and there are many questions on StackOverflow dealing with this.
It is possible to keep only part of a Window always visible? I.e. specify a clipping region inside an existing window, and keep only that part visible?
A use case would be the following (on Windows):
User clicks on icon to run app.
User highlights a portion of the screen to focus on (similar to the Snipping Tool on Windows 7)
The highlighted part of the screen remains always visible, even when other windows/programs are moved over the selected region.
I know the issues that would spring up with having other applications that are also set to being topmost. Just curious if this is even possible?
Even if you change part of your window to be transparent to what's below (with a clipping region) it's still going to take all the mouse clicks, etc. that occur over the transparent part.
Your best bet is to create a new smaller window and make it top-most while hiding the main one.

Best practice to navigate between screens in a GUI program

I am studying GUI programming an am doing fine for very simple GUI scripts, but since the opportunities to prototype a bit larger, more complete "real world" programs, I'm having some doubts.
Specifically, I don't know how should I handle navigation between screens. For example:
I create a window
I create the window's content (a panel widget with lots of widgets)
One of the widgets, when clicked, "takes to another screen"
This "other screen" is supposedly something that replaces the current window content. But what should the program actually do?
- Destroy the panel widget?
- Hide/remove the panel widget, but let it "live" in memory, offscreen?
Destroying the whole window and creatin another one is most probably NOT the way to do it.
Some form of navigation (backtrack) is something I plan to achieve.
The core of the question is: how is it USUALLY done, on most programs - what is the "usual", or "current" or "obvious" way to do it?
Thanks for reading, and sorry if the question is confuse and/or vague.
(note: I use PyGTK, but I'd like to think que question is toolkit-agnostic)
The first window is the parent window and the window on a click or navigation can be your child window.. you can have a grand child window, grand grand child window, etc.
You need not delete the parent window. The child windows can be drawn on top of it.

mouse moved events are not detected by NSView

I am trying to make a simple application in which there is a empty red rectangle and whenever the mouse is moved over the upper half border of the rectangle the cursor will become closed hand.
I started with selecting the foundation command line project.Made a transparent NSWindow and embedded a NSView in it with the rectangle, made window to accept mouse moved events(by method: -setAcceptsMouseMovedEvents). I have overridden -canBecomeKeyWindow and -canBecomeMainWindow window to return YES. But somehow none of the -mouseMoved events are being received by NSView.
When I put the same code by making a cocoa application project and creating my window in -applicationDidFinishLaunching method , my view was able to receive -mouseMoved events.
why is it not receiving mouse moved events when I use foundation command line utility project ?
I have also observed that whenever I make a window(carbon or cocoa) through foundation cmd line utility project , the window doesn't become key even on clicking the title bar.On clicking the title bar color remains light grey instead of becoming dark grey. Why is this happening?
I have overridden -canBecomeKeyWindow and -canBecomeMainWindow of NSwindow to return YES.
I would agree with what Joshua has already said. Any application that is going to show a user interface, be it a faceless background process or one which shows up in the Dock, should be in the form of an application bundle, not a plain old Mach-O executable like the Foundation tool template will create.
Also, there are reasons why views do not respond to mouseMoved: events by default:
Mouse moved events can quickly flood the event queue
There is generally little reason to use mouseMoved:, as tracking areas are
far more effective and efficient.
A while back, I wrote a little test app that demonstrates the differences between these 2 approaches:
Moving your mouse around the upper view for roughly 20 seconds results in 1000 events, while in the lower view, which uses tracking areas, less than 50.
Sample GitHub project: https://github.com/NSGod/MouseMoved-vs-TrackingAreas
Again, as Joshua mentioned, it would be helpful if you could describe what you're trying to accomplish. If your app needs to be a background app (LSUIElement == 1), and present an interface without appearing in the Dock, then there are ways to do that (as Josh mentioned, a command-line, non-bundled app is not the way).
You have no event loop to detect events and pass them to your window because your program does not start an NSApplication. See the main.m file of a typical Cocoa application.
It might be helpful to describe what you're trying to accomplish by taking this approach. My guess is you're building a daemon but want a GUI interface to manage the otherwise "headless" daemon. That or you're building a new login management system. In either case, there are specific ways to do both and this isn't it. :-)

Resources