I would like to be able to draw a file line using native Windows API (LineTo) like the one that TreeView uses to connect nodes to each other. But using RS_DOT to create the brush (::CreatePen(PS_DOT, 0, RGB(200, 200, 200))), produces a different kind of line. Does anyone know how I can draw such a line?
Creating a true dotted pen
LOGBRUSH LogBrush;
LogBrush.lbColor = c_colorGridLine;
LogBrush.lbStyle = PS_SOLID;
penDotted.CreatePen( PS_COSMETIC | PS_ALTERNATE , 1, &LogBrush, 0, NULL );
Related
I'm completely new at raphael and never have been especially good working with canvas elements. I found a useful piechart but need to tweak it a little more to fit my needs.
This is what I have now : http://jsfiddle.net/El4a/sbxjfafx/4/
And this is the figure I want to achieve
The white circle I'm trying to draw on top of the piechart, appears underneath it instead. I honestly have no idea how to fix this, although I'm sure the solution won't be that difficult.
I can achieve this figure using manual positioning (which is a crappy way) with the following code:
var paper = Raphael(10, 50, 500, 500);
var circle = paper.circle(280, 180, 175);
circle.attr("fill", "white");
circle.attr("stroke", "#fff");
But obviously this won't scale with the piechart, and is easily ruined by inconvenient things like changing the window size.
I have tried putting that code inside a function and create it the same way the piechart gets created.
Raphael.fn.circle = function(cx, cy, r){
var paper = this,
rad = Math.PI / 180,
chart = this.set();
var circle = paper.circle(280, 180, 175);
circle.attr("fill", "white");
circle.attr("stroke", "#fff");
return chart;
};
raphael("circle", 700, 700).circle(350, 350, 175, values, labels, "#fff");
But that leaves me with the result you can see in the fiddle.
Hope anyone can help!
Thanks in advance.
Make sure you don't create the canvas twice. So create it once, and then use that reference to create the new elements.
Also place the circle after the coloured one, so that it appears in front. This is all about the order of elements in the DOM.
eg jsfiddle
Relevant amended code.
var r = raphael("holder", 700, 700);
r.pieChart(350, 350, 200, values, labels, "#fff");
r.circle(350, 350, 175).attr({ fill: 'white' });
I created a custom button class CMyButton inherited from CButton, then I am using the DrawItem to customize the button.
Using the custtom button, I created 3button on dialog.
The issue is that the TAB key for the button is not working. If I remove drawitem then there is no issue. Can anyone please help on this?
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rect = lpDrawItemStruct->rcItem;
UINT state = lpDrawItemStruct->itemState;
pDC->DrawFrameControl(rect, DFC_BUTTON , DFCS_BUTTONPUSH | DFCS );
pDC->FillSolidRect(rect, RGB(24, 72, 76));
pDC->SetTextColor(RGB(255, 255, 255));
CString strText;
GetWindowText(strText);
pDC->DrawText(strText,rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
I doubt it. If you make a button owner draw, then you are responsible for drawing it all the time. This includes the focused state, etc. See the documentation for DRAWITEMSTRUCT.itemstate.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb775802%28v=vs.85%29.aspx
The focus rectangle is automatically rendered for standard controls on a dialog. If you subscribe to owner-drawing, responsibility to render visual cues is shifted to the custom implementation. While TABbing still works, keyboard focus remains invisible unless the implementation explicitly accounts for it.
You can use the DRAWITEMSTRUCT passed to your DrawItem method to query the item's state. If itemState contains the ODS_FOCUS flag, the control being rendered has the keyboard focus, and should produce the desired visual cue.
As a simple illustration, replace your call to FillSolidRect with the following code:
if ( state & ODS_FOCUS )
// Control has keyboard focus -> render it green
pDC->FillSolidRect( rect, RGB( 0, 255, 0 ) );
else
// Control doesn't have keyboard focus -> render it red
pDC->FillSolidRect( rect, RGB( 255, 0, 0 ) );
This allows you to see, that the TAB key does work as expected: The button control with keyboard focus is rendered green, whereas all other buttons are red.
If you are looking for a more standard appearance you can call CDC::DrawFocusRect (or DrawFocusRect) instead.
How change color default of text?
wxRitchTextCtrl
Here is my Source code
I change foreground color, Default color etc. always i get black color.
ed = new wxRichTextCtrl(panel, wxID_ANY, wxEmptyString, ..., wxVSCROLL);
ed->SetBackgroundColour(wxColour(0, 121, 122));
ed->SetForegroundColour(wxColour(255, 255, 255));
I would try this:
wxRichTextAttr attr = ed->GetBasicStyle();
attr.SetBackgroundColour(wxColour(0, 121, 122));
attr.SetTextColour(wxColour(255, 255, 255));
ed->SetBasicStyle(attr);
According to the docs, GetBasicStyle() and SetBasicStyle() refer to 'the style of the whole buffer before further styles are applied'. Constructing a copy of the current basic style as a baseline ensures we only change the attributes we want and don't inadvertently change any other defaults.
I wanted to create CMFCButton dynamically at runtime (Icon with Text on the button). The icon is created successfully but I wanted to display the icon above text.
I want to implement "Image on Top" property found in Resource Editor for the button.
My Code:
CMFCButton* appButton = new CMFCButton;
appButton->Create( _T("MfcButton1"), WS_CHILD | WS_VISIBLE, CRect(10, 10, 70, 50), this );
appButton->SetIcon( sfi.hIcon );
(according to the "NewControls" MFC sample).
To set an image in a CMFCButton use CMFCButton::SetImage.
To set the image above (or below) the text you can use the undocumented variable m_bTopImage
appButton->m_bTopImage = TRUE;
FYI: the complete samples can be downloaded from :
http://www.microsoft.com/en-us/download/details.aspx?id=5718
I am an amatuer with JOGL and SWT. I got a problem while try show some SWT Widgets over the GLCanvas using AbsoluteLayout.
composite = new Composite(parent, SWT.NONE);
composite.setLayout(null);
Button button = new Button(composite, SWT.NONE);
button.setText("New Button");
button.setBounds(172, 145, 94, 28);
glcanvas = GLCanvas.create(composite, SWT.NO_BACKGROUND, null, null, null);
I thought that the button should be on top of GLCanvas but it is always behind the GLCanvas. Am i doing something wrong ? Please help me, thank you very much.
Have you tried:
composite = new Composite(parent, SWT.NONE);
composite.setLayout(null);
glcanvas = GLCanvas.create(composite, SWT.NO_BACKGROUND, null, null, null);
Button button = new Button(composite, SWT.NONE);
button.setText("New Button");
button.setBounds(172, 145, 94, 28);
(Moving the glcanvas = GLCanvas... upwards to before creating the button)
Unless I'm missing something you're adding the button and then the canvas on top of it.
Currently, there is no solution for this problem. For more details, this problem only happens on MacOS , i have tested under Windows 8 x64 and it ok no thing is overlayed. Here is the link to the discusion on the official forum
http://forum.jogamp.org/How-to-overlay-SWT-Widgets-over-GLCanvas-td4029507.html