GTK+3 custom drawing area - c

I am new to GTK+3 and I want to create a custom drawing widget (maybe a grid). I need to be able to drag and drop logic objects on it for my logic gate simulator. How can this be done? The Drawing Area should be beside the menu containing logic objects.

I would probably recommend you use a GtkDrawingArea inside a GtkScrolledWindow. All drawing will have to be custom using Cairo. Draw a grid, then handle arranging your logic objects manually. You could use one of the GtkToolItem widgets for your top or side box of objects.
It's an ambitious project for the first time, but very similar to my first major project. It uses a very similar GtkDrawingArea idea. It's in Perl, and is here on GitHub. If you can decipher Perl, it might provide you some ideas for how a custom widget can be done.

In my opinion your requirements seem to be more tailored to a canvas. Project Ridley includes a selection of canvases candidate to be included in GTK+. Not sure this is still relevant now, but that selection is a good.

Related

dragable controls in runtime Similar to a toolbox in wpf

I want to create a project in WPF for designing a custom report.
For this, I need a library to add controls to a panel, canvas, etc. with drag and drop at runtime.
Controls should be resizable and moveable with the mouse. Finally I want to print this.
Telerik's WPF controls contain the Diagram Control which supports the features you mention out of the box. I use it for a very similar scenario as you describe and it works well. The might be a counterpart offered by Infragistics as well.
With .NET framework's built in features and/or free libraries you will able to cover the drag&drop part. You will have to implement the rest yourself which is possible but too much to ask for one question.
Late reply, but I came across this. Take a look at this
There are 4 parts that show how to do a toolbox with what you're looking for.

Coded UI Test - get my custom object (WinForms)?

I want to create an automated UI test that will test my syncfusion grid. My problem is that the recorder can't recognize this control (or any syncfusion control). I've searched a lot in the internet but I couldn't find any extension so the recorder will recognize my controls (I'm using WinForms, not WPF!), or at least a way to extend the recorder abilities so syncfusion's controls will be recognized somehow.
Is there any easy way to extend the recorder? Or is there any extension available?
Or maybe can I get the grid object from the WinClient that the recorder generates?
Thanks!
Start your program. Run the Spy++ utility. Type Ctrl+F to start the finder tool and drag the bulls-eye onto your form. Ok, Synchronize and have a look-see at the windows that are visible in the tree. If you see regular Windows Forms controls, like a Button or a Label, but not any of the SyncFusion controls then you've probably found the source of the problem.
Component vendors that try to improve .NET controls typically do so by creating 'window-less' controls. They are not really controls, they don't derive from the Control class and don't have a Handle property. They use the surface of the parent to draw themselves, making them look just like controls. The .NET ToolStripItem classes do this. And this is also the approach WPF uses.
The big advantage is that they render quickly and support all kinds of effects that regular controls can't support, like transparency, rotation and anti-aliased window edges. The big disadvantage is that the kind of tool that you are using suddenly gets noddy and can't find the control back. Because they work by finding the Windows window back on your form, there is no window for them.
This is a hard problem to solve, the 'control' exists only in memory and there's no good way for a tool to find it back. Using Accessibility is about the only other way for such a tool to find a control that I can think of. Which would have to be implemented by the control vendor first, a somewhat obscure feature that gets easily overlooked. You really do need the help of the vendor to find a workaround for this. Shouldn't be a problem, that's why you paid them the big money.
This is Rajadurai from Syncfusion. Thank you for your interest in Syncfusion Products. To make UI Test Automation recognize Syncfusion grids(WinForms), some internal support need to be provided in grid whose implementation is in progress and about to be completed. Please submit an incident through Direct-Trac for any further related inquiries in the following link.
http://www.syncfusion.com/Account/Logon?ReturnUrl=%2fsupport%2fdirecttrac
You can also contact us through support#syncfusion.com. We are happy to assist you.
Regards,
Rajadurai

Making input form rotate in 3d using WPF (like silverlight planeprojection)

I am looking at updating the UI of one of my projects that currently uses Winforms and i was hoping to use WPF. I have used silverlight for a while and wanted to use the same PlaneProjection effects to basically rotate my form (by form i mean a group of input controls) along the Y axis.
After looking over the interwebs it looks like for some reason WPF doesnt support this kind of usage with 2d controls like silverlight does, however after scouring i managed to find Thriple, which looked like it was what i wanted, however i find trying to create my UI in the XAML editor a nightmare with it as it seems to stretch and skew everything and ignores the width/heights as if it is automatically scaling everything.
I was wondering if there was anything else that would allow me to do what i want, ideally i would also like it to support WindowsFormHost controls as i have some winform controls that i would like to continue using. It seems a bit silly that silverlight does EXACTLY what i want, but the main technology it is based upon doesnt...
Any alternatives would be great, i just want something that will let me rotate and translate my controls in 3d space and still allow the user to interact with the control.
I don't think it's as easy to do in WPF, but its definitely possible. You'd have to use the Viewport2DVisual3D class inside a Viewport3d.

What are the advantages of the WPF ToolBar?

I'm trying to decide whether I should create a simple StackPanel with Buttons on it, or whether I should use the WPF ToolBar class to contain these buttons (I am creating a simple toolbar).
What are the pros and cons to using WPF's built-in ToolBar control?
So far, these are the only advantages I have seen:
The ToolBars can collapse when necessary; additional items are available from a context drop down.
If the ToolBar is contained within a ToolBarTray, multiple ToolBars can be repositioned relative to each other.
Are the any other benefits to the WPF ToolBar? Neither of these apply to my simple toolbar.
Accessibility might be better with the WPF Toolbar, because it shows itself to Windows UI Automation as a toolbar with toolbar buttons, rather than some random controls. You never know who'll use your software.
Another very small advantage is that buttons in the ToolBar will be styled correctly, whereas the buttons in the StackPanel will take on their default look. Not insurmountable by any means, but a little annoyance none-the-less.
I would say use the Toolbar, because you never know when the next project will come along and need it. You also never know when this project may need it. I don't think there is any real drawback to using it over a StackPanel and the advantage you didn't mention is you'll have more experiance with a built in control for the next project.
On the other hand, I don't see any harm in doing it with the StackPanel, only that if you need to extend functionallity in the future, you'll have to do some rework.

WPF Layer Control

I'm in need of a WPF layer control that does the following
1) Have multiple layers of content on top of each other.
2) Ability to turn layers on/off at design and runtime, ie we need a UI maybe something like a tabbed control
3) Move layers up/down the stack
4) Change opacity for layers
Now I know all of the above is possible in Xaml/WPF. I've coded up a simple version using a grid, that has mutiple cells at design time, 1 cell = 1 layer, and only a single cell at runtime, all the cells are merged into one. Thing is that was a kludge, didn't give me the design time control that I needed, all controls end up with a single parent, ugly. Anyone got an off the shelf, or part working example - if not I'll code up a proper one and share it on CodePlex.
I'm sure I'm not the only person out there who needs this functionality, am I?
With my previous client we accomplished this using Canvases. The application was a 'CAD' like in nature so our layers were responsible for graphical representations of the domain.
I do not know of any 3rd party tools that accomplish this at the moment.
I think the reasoning for this is that when you are looking for this functionality it is very specific to the domain & application.
If you were going to build your own control I would encourage building a custom control for managing the logic, then allow others to style the look and feel. It would be more of the Wpf way of approaching the problem.
In that way if 1 consumer wants to use canvases they could. If you wanted to use a grid, then you could as well.
If you have any psuedo code of what you would like to do, I can see if any of my old POCs can be modified to meet your needs. Or if you want to start a CodePlex project I wouldn't mind contributing.
That's just my 2 cents.

Resources