wxGauge - Marquee implementation

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

wxGauge - Marquee implementation

Post by lowjoel »

Remember in XP you had that autoplay thingo that pops up when u insert removable media, and there was this blazing fast bar on it?

I've translated that to one that you all can use :)

For all of you normal developers, the patch is here, along with those for wxDev-C++ users, and if you have Borland Delphi, you can modify the wxDev-C++ source to allow you to use this style.

Code: Select all

===================================================================
Main wxWidgets Patch
===================================================================

Index: include/wx/msw/gauge95.h
===================================================================
RCS file: /pack/cvsroots/wxwindows/wxWindows/include/wx/msw/gauge95.h,v
retrieving revision 1.18
diff -u -r1.18 gauge95.h
--- include/wx/msw/gauge95.h	2005/01/21 18:11:12	1.18
+++ include/wx/msw/gauge95.h	2005/08/18 13:19:31
@@ -18,6 +18,8 @@
 
 #if wxUSE_GAUGE
 
+#define wxGA_MARQUEE 0x0030
+
 extern WXDLLEXPORT_DATA(const wxChar*) wxGaugeNameStr;
 
 // Group box
@@ -54,7 +56,11 @@
     // overriden base class virtuals
     virtual bool SetForegroundColour(const wxColour& col);
     virtual bool SetBackgroundColour(const wxColour& col);
-
+	
+	// start or stop a marquee
+	virtual void StartMarquee(int interval);
+	virtual void StopMarquee();
+	
 protected:
     virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
     virtual wxSize DoGetBestSize() const;

Index: src/msw/gauge95.cpp
===================================================================
RCS file: /pack/cvsroots/wxwindows/wxWindows/src/msw/gauge95.cpp,v
retrieving revision 1.47
diff -u -r1.47 gauge95.cpp
--- src/msw/gauge95.cpp	2004/08/26 08:46:18	1.47
+++ src/msw/gauge95.cpp	2005/08/18 13:19:59
@@ -159,6 +159,9 @@
 
     if ( style & wxGA_SMOOTH )
         msStyle |= PBS_SMOOTH;
+        
+    if ( style & wxGA_MARQUEE )
+    	msStyle |= PBS_MARQUEE;
 
     return msStyle;
 }
@@ -218,6 +221,16 @@
     ::SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col));
 
     return true;
+}
+
+void wxGauge95::StartMarquee(int interval)
+{
+	SendMessage((HWND)this->GetHWND(), PBM_SETMARQUEE, (WPARAM)true, (LPARAM)interval);
+}
+
+void wxGauge95::StopMarquee()
+{
+	SendMessage((HWND)this->GetHWND(), PBM_SETMARQUEE, (WPARAM)false, (LPARAM)0);
 }
 
 #endif // wxUSE_GAUGE

===================================================================
wxDev-C++ Patch
===================================================================

Index: source/components/wxgauge.pas
===================================================================
RCS file: /cvsroot/wxdsgn/wxdevcpp/source/components/wxgauge.pas,v
retrieving revision 1.12
diff -u -r1.12 wxgauge.pas
--- source/components/wxgauge.pas	14 Aug 2005 16:25:09 -0000	1.12
+++ source/components/wxgauge.pas	18 Aug 2005 13:07:22 -0000
@@ -268,6 +268,7 @@
 
   FWx_PropertyList.add('Wx_GaugeStyle : Gauge Styles');
   FWx_PropertyList.Add('wxGA_SMOOTH:wxGA_SMOOTH');
+  FWx_PropertyList.Add('wxGA_MARQUEE:wxGA_MARQUEE');
 
   FWx_PropertyList.add('Wx_GaugeOrientation : Orientation');

Index: source/components/wxUtils.pas
===================================================================
RCS file: /cvsroot/wxdsgn/wxdevcpp/source/components/wxUtils.pas,v
retrieving revision 1.19
diff -u -r1.19 wxUtils.pas
--- source/components/wxUtils.pas	14 Aug 2005 16:25:09 -0000	1.19
+++ source/components/wxUtils.pas	18 Aug 2005 13:14:12 -0000
@@ -228,7 +228,7 @@
 
   TWxGagOrientation = (wxGA_HORIZONTAL, wxGA_VERTICAL);
 
-  TWxgagStyleItem = (wxGA_SMOOTH);
+  TWxgagStyleItem = (wxGA_SMOOTH, wxGA_MARQUEE);
   TWxgagStyleSet  = set of TWxgagStyleItem;
 
   TWxsbtnOrientation = (wxSP_HORIZONTAL, wxSP_VERTICAL);
@@ -1155,6 +1155,9 @@
   if wxGA_SMOOTH in stdStyle then
     strLst.add('wxGA_SMOOTH');
 
+  if wxGA_MARQUEE in stdStyle then
+    strLst.add('wxGA_MARQUEE');
+
   if strLst.Count = 0 then
     Result := ''
   else
more or less there, just tweak it a tad over here and there and we should be fine.

Just a word of caution: my patch does *0* error checking meaning if you have called SetValue accidentally, prepare for a program crash...

I might have to find a way to fix that, though.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

Is there a pic of what you mean?

And hmm it is a bad thing to do no error checking, it might make wxWidgets base unstable, and not many ppl would like to apply your patch that way ;-)


- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

because the main wxGauge class does not allow for error checking, in short :P i will practically have to redo the class definition...
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

I too would like to see a screenshot of this control :)
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

its useless since its a moving marquee... u interested in a WMV? i have WME9 to capture it...

yep ill get it done ASAP
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

http://joelsplace.sg/studyroom/gaugedemo.wmv thats the link... including example usage
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Nice. Maybe contribute it to the "real" community (although it's only of use for Windows users, on other platforms it should have no meaning...).

BTW: Naomi is online :P
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

I do not really understand what does it do, as it doesn't run to the end.
Is it something to denote progress when the percentage can't be tracked in any reasonable accuracy? (e.g, once it reaches the end is starts moving back, or something)
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

It's a different kind of wxGauge display. Normally the gauge fills the bar based on the current step. Like

------------------------------------
|++++++++++++................|
------------------------------------

The marquee style doesn't fill it completely, but displays only the progress by moving part of the gauge. Like

Start
------------------------------------
|+++....................................|
------------------------------------

Step
------------------------------------
|.......+++.............................|
------------------------------------
Setp
------------------------------------
|...............+++.....................|
------------------------------------

etc...
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

SAWEEEET! Normally a lot of companies use those when they don't have a definite time - i.e. keeps on going from start to finish... its to mess with your mind!
[Mostly retired moderator, still check in to clean up some stuff]
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Yeah, just like a "bogus" process.. Something is happening, really, trust us, there still is something happing, we just don't know how much of the process is finished... Don't you move that mouse! I'm not dead yet, I'm actually busy. See the nice bar moving, see it?? No, no need to touch the mouse. :D
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

one of those times when wxBusyCursor doesnt work.... lol
yes i know naomis on...

but i just LOVE the wxDev-C++ integration that i manage to dig thru.... Find and Replace is a very nice ally :P

@upCASE what community?
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

And if the process lasts longer than it takes the bar to go to the end, it start moving back, I guess. And recall something.
Well, that exists on at least gtk+ too, and a feature request on sf.net trackers accompanied with a patch for wxMSW part, or even a patch to the patch tracker would be nice.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

oh yes it does go back to the beginning and starts all over again
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

@leio I know this is old, but you have any idea what code is for gtk? I'm a win32 person... If i have no choice :P
Post Reply