Split MainFrm with CDockablePane - visual-c++

I have two Cdockablepane and I want it to act like CSplitWnd.
I am not using splitwnd right now because I need docking feature..
Current UI
Green is MainFrame and Blue, Yellow is Dockablepane I created.
Red one is overlapped part I want to get rid of.
I have yellow.DockToWindow(&blue, CBRS_RIGHT); in my code
but I don't know what make that overlapping part..
and black part I want fill MainFrame just with blue and yellow pane.
Target UI So I want my code look like this.
I tried by changing yellow and blue's CRect() on create() but it seems like not the answer.
or changing the style.....
So please if anything comes in mind tell me..
My...I wanted to describe better..
Thank you.
===========================================================================
Following is the code in the CMainFrame MFC. It creates CDockablepane yellow&blue when MainFrame is created.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!blue.Create(_T("HORIZONTAL ROBOT PANE"), this, CRect(0, 0, 800, 500), TRUE, ID_DOCKABLE_LEFT,
dwViewStyle | CBRS_ALIGN_LEFT))
{
return FALSE;
}
blue.SetMinSize(CSize(800, 400));
blue.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&blue, AFX_IDW_DOCKBAR_LEFT);
if (!yellow.Create(_T("VERTICAL ROBOT PANE"), this, CRect(0, 0, 650, 500), TRUE, ID_DOCKABLE_RIGHT,
dwViewStyle | CBRS_ALIGN_RIGHT))
{
return FALSE;
}
yellow.SetMinSize(CSize(400, 400));
yellow.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&yellow, AFX_IDW_DOCKBAR_RIGHT);
yellow.DockToWindow(&blue, CBRS_RIGHT);
}

Related

How to identify colour of an icon of presence

I am new to espresso .My test scenario involves to check the colour of the icon during the presence.For example if person X in available there is small green icon next to his name, if he is busy icon change to red
I am not quit sure how I can test colour of the specific icon R.id.presence
I do understand I need to use drawable but not sure how
You can try something like this. Try to find the element(probably R.id.presence in your case) and then try to get the background color of the element. Now compare it with the expected color.
Sample code for a button where green as background color is being verified.
Button btn = (Button) findViewById(R.id.my_button);
Drawable buttonBackground = btn.getBackground();
ColorDrawable btn_color = (ColorDrawable) btn.getBackground();
int color = btn_color.getColor();
if (color == R.color.green) {
log("color is green");
}
Hope it helps :)

SWT Canvas fails to redraw on Windows but works on Linux

this.canvas = new Canvas(shell, SWT.NO_BACKGROUND);
I'm using a PaintListener:
this.canvas.addPaintListener(new PaintListener() {
#Override
public void paintControl(PaintEvent e) {
// Draw images
synchronized (imageMarks) {
for (ImageMark mark : Whiteboard.this.imageMarks)
{
Image image = Whiteboard.this.getImage(mark.id);
Point position = ScaledPoint.toSWTPoint(Whiteboard.this.getCanvasSize(), mark.getPosition());
Point bounds = mark.getUnscaledBoundaries(Whiteboard.this.getCanvasSize());
e.gc.drawImage(image, 0, 0, image.getBounds().width, image.getBounds().height, position.x, position.y,
bounds.x, bounds.y);
}
}
// Draw pencil marks
synchronized (pencilMarks) {
e.gc.setLineWidth(LINE_WIDTH);
for (double[] line : Whiteboard.this.pencilMarks)
{
Point lastPosPoint = ScaledPoint.toSWTPoint(Whiteboard.this.getCanvasSize(), new ScaledPoint(line[0], line[2]));
Point newPosPoint = ScaledPoint.toSWTPoint(Whiteboard.this.getCanvasSize(), new ScaledPoint(line[1], line[3]));
e.gc.drawLine(lastPosPoint.x, lastPosPoint.y, newPosPoint.x, newPosPoint.y);
}
}
// Draw pointer, assuming it's there
if (pointerMark != null)
{
synchronized (pointerMark) {
Point pos = ScaledPoint.toSWTPoint(Whiteboard.this.getCanvasSize(), pointerMark.getPosition());
if (pointerMark.isFlipped())
e.gc.drawImage(Whiteboard.pointerImageFlipped, pos.x, pos.y);
else
e.gc.drawImage(Whiteboard.pointerImage, pos.x, pos.y);
}
}
}
});
and redrawing the canvas via a canvas.redraw() call. On 64-bit Linux, this seems to be working without any issues, but strangely enough, on 64-bit Windows, nothing ever ends up being erased or redrawn. For example, if the screen is resized, the pencil markings do not resize as well, they just end up being cut out of the screen. When new marks are added (in other words, when the paint listener is called again), the repositioned markings are redrawn on top of the old ones which didn't scale with the window. In other words, I believe the canvas is not being cleared upon canvas.redraw(). Is there a workaround for this?
You are specifying SWT.NO_BACKGROUND which stops the Canvas being cleared before each paint.
If you use SWT.NO_BACKGROUND it is your paint method's responsibility to draw every pixel of the Canvas.
SWT.NO_BACKGROUND JavaDoc:
By default, before a widget paints, the client area is filled with the
current background. When this style is specified, the background is
not filled, and the application is responsible for filling every pixel
of the client area. This style might be used as an alternative to
"double-buffering" in order to reduce flicker. This style does not
mean "transparent" - widgets that are obscured will not draw through.

Is there any way to fill a drawing in C# GDI+, where the drawing involves multile Arcs,Lines?

My application involves drawing of custom shapes, in which the details of the shapes are retrieved from the database. Shapes will be Lines, Arcs.
I will calling DrawArc and DrawLine function to draw the custom shapes.
My Problem is I need to fill this custom shape with a background color.
I am using the following namespaces.
using System.Drawing.Drawing2D;
using System.Drawing;
Things that I tried out:
Graphics.FillRegion Method
private void OnPaint(object sender, PaintEventArgs e)
{
Pen redPen = new Pen(Color.Red, 2);
// Create a graphics path
GraphicsPath path = new GraphicsPath();
// Add two lines, a rectangle and an ellipse
Graphics g = e.Graphics;
path.StartFigure();
path.AddLine(20, 400, 20, 20); // left
path.AddLine(20, 20, 400, 20); //top
path.AddLine(400, 20, 400, 400); // right
path.AddLine(400, 400, 20, 400); // bottom
path.CloseFigure();
g.DrawPath(redPen, path);
Region reg = new Region(path);
g.FillRegion(Brushes.Green, reg);
reg.Dispose();
g.Dispose();
}
Using this method it is easy to fill a simple shape, where the start and end points are clearly defined.
But my application involves complex shapes, which is difficult to track the points. If I use this method, filling of background color is not proper.
Pls suggest me some way of filling custom shapes.
thanks for your help.

Drawing strings with slick2d and TTF

I've been experimenting with String printing in LWJGL using slickutils. Generally when browsing the web I found two approaches to this. First being bitmaps where you have an entire alphabet and print each letter as a Texture, the other being using TrueTypeFonts and the truetypefont.drawString(20f,20f,"LWJGL String Test", Color.green) method.
However, most of the literature I found was a few years old. What is the right way to do this at the current time?
At the moment I'm using the TrueTypeFont method, however my result confuses me.
//It doesn't matter which Font I try to load, I get the same green bar.
//I think it has something to do with not finding the Fonts?
Font awtFont = new Font("Times New Roman", Font.BOLD, 24);
TrueTypeFont font = new TrueTypeFont(awtFont, true);
font.drawString(20f, 20f, "LWJGL TEST STRING",Color.green);
I've also copied an example from the internet and get the same result(just a bar).
Tried googling but couldn't find any fixes.
TrueTypeFont is deprecated. Use UnicodeFont instead.
Check this:
// Create a font with the size of 20, and not bold or italic.
Unicode font = new UnicodeFont("res/font.ttf", 20, false, false);
font.addAsciiGlyphs();
font.getEffects().add(new ColorEffect());
font.loadGlyphs();
g.setFont(font);
g.drawString("Shit example", 100, 100);

Draw a line in mfc with help of toolbar

I am trying to make a paint application in MFC using visul basic c++ 6.0 i have already created a window using Create function and also have created a toolbar with a tool line but i am stuck on how to code for the line because the function i know goes like d.lineTo(x,y) and d.Moveto(x2,y2) but it comes under the line function how do i use OnLButtonDown to Trap the co-ordiantes or is there any other way i can draw a line ..? any help will be useful
have a look at the MFC Scribble tutorial :
http://msdn.microsoft.com/en-us/library/aa716527%28v=vs.60%29.aspx)
It will get you started on how to handling mouse click and mouse move and drawing.
M.
Ok, you're going to have to override several member functions to do this. I've outlined an approach below. My example below deals with a single line-drawing operation (from mouse down, to mouse up). An exercise for you, is to make it so that once you've done one, you can then do another at a different place. It's easy, btw!
CWnd::OnLButtonDown(UINT _flags, CPoint _pt);
CWnd::OnLButtonUp(UINT _flags, CPoint _pt);
CWnd::OnMouseMove(UINT _flags, CPoint _pt);
CWnd::OnPaint()
Apologies if some of these function signatures are wrong! Add some members to your window class:
// at the top of your file
#include <vector>
// in your class
typedef std::vector<POINT> PointVector;
PointVector m_Points;
CYourWnd::OnLButtonDown(UINT _flags, CPoint _pt);
{
// NOTE: For more than one set of drawing, this will be different!
m_Points.clear();
m_Points.push_back(POINT(_pt.x, _pt.y));
}
CYourWnd::OnMouseMove(UINT _flags, CPoint _pt);
{
if(_flags & MK_LBUTTON)
{
const POINT& last(m_Points.back());
if(_pt.x != last.x || _pt.y != last.y)
{
m_Points.push_back(POINT(_pt.x, _pt.y));
Invalidate();
}
}
}
CYourWnd::OnPaint()
{
CPaintDC dc(this);
CRect rcClient; GetClientRect(&rc);
FillSolidRect(&rcClient, RGB(255, 255, 255));
if(m_Points.size())
{
dc.MoveTo(m_Points[0].x, m_Points[0].y);
for(PointsVector::size_type p(1);
p < m_Points.size();
++p)
dc.LineTo(m_Points[p].x, m_Points[p].y);
}
}
Obviously, this is crude and gives you a single drawing operation. Once you click the left button down again, it erases what you've done. So, once you have this working:
Make it so you can draw an unlimited amount of lines. You could accomplish this in several ways such as an additional container (to store vectors), or even drawing-operation classes that you can store in a single vector and then execute.
This solution may well flicker. How might you stop this? Perhaps OnEraseBkgnd holds the clue...
How about more colours?
All signs point towards creating some drawing-classes that encapsulate this for you, but I hope this has got you started.

Resources