Pen questions

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
Jasper
Earned a small fee
Earned a small fee
Posts: 18
Joined: Tue Sep 21, 2004 1:49 pm
Contact:

Pen questions

Post by Jasper » Tue Sep 21, 2004 2:09 pm

I'm using wxWidgets (or rather wxWindows 2.4.2) to print plans (not sure if that's the correct term, but it's meant to be something you cut out and fold). There are no problems on my printer (and as far as I know it also works on at least a few other printers), but it doesn't work on a Brother HL1250 (and probably also on a DeskJet connected to the same system, so it may have something to do with the system and not the printer). What goes wrong is that the lines are always drawn solid (some of them should be dotted or dashed). I've tried the following pen styles:
  • wxSOLID
  • wxDOT
  • wxLONG_DASH
  • wxSHORT_DASH
  • wxDOT_DASH
  • wxUSER_DASH
All of them show up solid (in wxSOLID's case that's to be expected, but the other ones should be dotted or dashed).
It's on a Windows system btw. (don't know the Windows version yet, but it's probably Windows XP).
Has anyone ever seen similar behaviour or has any clue where I could start looking for a solution.

On a side-note, I was wondering whether in the following section of code in pen.cpp (also in the current CVS version) the #ifndef should be replaced by #ifdef:

Code: Select all

#ifndef __WIN32__
  // In Windows, only a pen of width = 1 can be dotted or dashed!
  if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
      (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
      (Style == wxUSER_DASH))
    M_PENDATA->m_width = 1;
#else
/***
  DWORD vers = GetVersion() ;
  WORD  high = HIWORD(vers) ; // high bit=0 for NT, 1 for Win32s
  // Win32s doesn't support wide dashed pens

  if ((high&0x8000)!=0)
***/
  if (wxGetOsVersion()==wxWIN32S)
  {
    // In Windows, only a pen of width = 1 can be dotted or dashed!
    if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
        (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
        (Style == wxUSER_DASH))
      M_PENDATA->m_width = 1;
  }
#endif

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue Sep 21, 2004 2:19 pm

Have you tried that ? It seems you are right. If this indeed solves the issue report the bug through sourceforge:

http://sourceforge.net/tracker/?group_i ... tid=109863

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Jasper
Earned a small fee
Earned a small fee
Posts: 18
Joined: Tue Sep 21, 2004 1:49 pm
Contact:

Post by Jasper » Tue Sep 21, 2004 2:31 pm

I hadn't tried and it shouldn't solve the issue as the pen width is already set to 1 in my case. I just stumbled over it while browsing through pen.cpp and it struck me as odd.

I have looked into it a bit more now though, and I think it is indeed wrong and might be fixed in a better way by modifying the code wxPen::RealizeResource (still have to check what has changed in the latest CVS in this function). What I could find in the platform SDK documentation is that NT supports just about everything, CE only supports the CreatePen API call and only solid lines for widths >= 1 (what they call wide), 9x seems similar to CE, but with a few twists (not yet clear to me what exactly it does and does not support).
I'll have a better look at it and submit a bug report/patch to SF once I figured out what's correct.

Any ideas on the problem with dotted/dashed lines becoming solid?

Jasper
Earned a small fee
Earned a small fee
Posts: 18
Joined: Tue Sep 21, 2004 1:49 pm
Contact:

Post by Jasper » Sun Sep 26, 2004 10:34 am

I've modified the checks in pen.cpp a bit and I think it's more correct (and at least easier to understand) now, although there might still exist some cases that could be handled better. I submitted the patch to the patch manager at SF (request-id 1034942).

Any ideas on the issue of lines being drawn solid instead of dotted/dashed on some machines yet?

Post Reply