[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 981
Date       : Tue May  9 14:57:17 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/dialogop.cpp
   M /Trunk/XaraLX/Kernel/dialogop.h
   M /Trunk/XaraLX/Kernel/statline.cpp
   M /Trunk/XaraLX/Kernel/statline.h
   M /Trunk/XaraLX/wxOil/dlgmgr.cpp
   M /Trunk/XaraLX/wxOil/dlgmgr.h
   M /Trunk/XaraLX/wxOil/progress.cpp
   M /Trunk/XaraLX/wxOil/progress.h
   M /Trunk/XaraLX/wxOil/xrc/EN/statusbar.xrc
   M /Trunk/XaraLX/wxXtra/platform.cpp
   M /Trunk/XaraLX/wxXtra/platform.h

More status bar and progress bar work, and a workaround for a wxWidgets bug. Still not finished.


Diff:
Index: Trunk/XaraLX/Kernel/statline.h
===================================================================
--- Trunk/XaraLX/Kernel/statline.h	(revision 980)
+++ Trunk/XaraLX/Kernel/statline.h	(revision 981)
@@ -200,6 +200,18 @@
 public:
 	static StatusLine * Get() {return s_pStatusLine;}
 
+// Progress related functions
+public:
+	BOOL ShowProgress (BOOL Show=TRUE, String_64 *JobDescrip = NULL);
+
+	INT32 GetPercent(void) const {return CurrentPercent;}
+	BOOL SetPercent(INT32 Percent, BOOL RedrawBackground = FALSE, String_64 *JobDescrip = NULL);
+
+protected:
+	INT32 CurrentPercent;			// The currently displayed percentage value
+	String_64 *JobDescription;	// NULL, or pointer to description of current job
+	BOOL ProgressShown;
+
 	CC_DECLARE_DYNCREATE(StatusLine);              
 };
 
Index: Trunk/XaraLX/Kernel/statline.cpp
===================================================================
--- Trunk/XaraLX/Kernel/statline.cpp	(revision 980)
+++ Trunk/XaraLX/Kernel/statline.cpp	(revision 981)
@@ -174,6 +174,10 @@
 	// create a 'snapped' mouse pointer
 	pSnappedCursor = new Cursor(_R(IDCSR_SNAPPED));
 	SnappedCursorID = 0;
+
+	JobDescription=NULL;
+	CurrentPercent=-1;
+	ProgressShown=FALSE;
 }
 
 
@@ -1261,3 +1265,150 @@
 	return TRUE;
 }
 
+/********************************************************************************************
+>	BOOL StatusLine::ShowProgress (BOOL Show=TRUE, String_64 *JobDescrip = NULL)
+
+	Author:		Alex Bligh
+	Created:	09/05/2006
+	Inputs:		BOOL Show : TRUE to show, else false
+				JobDescription - A BRIEF string describing the job currently being undertaken.
+						This will be displayed on the progress bar if possible
+	Outputs:	-
+	Returns:	TRUE if the initialisation of the progress bar was successful.
+	Purpose:	Creates a window and associates it with this CProgressBar object. The window
+				appears immediately over the status bar.
+	Notes:		This currently assumes that it'll only ever be opened at the bottom of the
+				Main Frame window.
+	SeeAlso:	StatusLine::SetPercent; StatusLine::GetPercent
+********************************************************************************************/
+
+BOOL StatusLine::ShowProgress (BOOL Show, String_64 *JobDescrip)
+{
+	BOOL Invalidate=(Show != ProgressShown);
+	BOOL FirstShow=(Show && !ProgressShown);
+	// Get rid of any old text
+	if (JobDescription)
+	{
+		delete JobDescription;
+		JobDescription=NULL;
+	}
+	
+	CurrentPercent = -1;
+	if (JobDescrip == NULL)
+		JobDescription = NULL;
+	else
+		JobDescription = new String_64(*JobDescrip);
+
+	if (JobDescription && Show)
+	{
+		SetStringGadgetValue(_R(IDC_SL_PROGRESSTEXT), *JobDescription);
+		Invalidate=TRUE;
+	}
+	else
+	{
+		SetStringGadgetValue(_R(IDC_SL_PROGRESSTEXT), String_64(_T("")));
+		Invalidate=TRUE;
+	}
+
+	if (0 && Invalidate)
+	{
+		EnableGadget(_R(IDC_SL_PROGRESSGAUGE), Show);
+		EnableGadget(_R(IDC_SL_PROGRESSTEXT), Show);
+		InvalidateGadget(_R(IDC_SL_PROGRESSTEXT));
+		InvalidateGadget(_R(IDC_SL_PROGRESSGAUGE));
+		PaintGadgetNow(_R(IDC_SL_PROGRESSTEXT));
+		PaintGadgetNow(_R(IDC_SL_PROGRESSGAUGE));
+		InvalidateGadget(0);
+		PaintGadgetNow(0); // repaint the whole bar
+		PaintGadgetNow(0); // repaint the whole bar
+	}
+
+//	InvalidateGadget(0);
+//	PaintGadgetNow(0);
+	InvalidateGadget(_R(IDC_SL_PROGRESSGAUGE), TRUE);
+	PaintGadgetNow(_R(IDC_SL_PROGRESSGAUGE));
+
+	ProgressShown=Show;
+
+	if (FirstShow)
+	{
+		CurrentPercent=-1;		// Force a redraw
+		SetPercent(0, TRUE);	// Force redraw of window _including background_
+	}
+
+	return TRUE;
+}
+
+
+/********************************************************************************************
+>	BOOL StatusLine::SetPercent(INT32 NewPercent,
+									BOOL ClearBackground = FALSE, String_64 *JobDescrip = NULL)
+
+	Author:		Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	15/02/94
+	Inputs:		NewPercent - the new percentage value to be displayed by the progress bar
+
+				ClearBackground - Clears the entire bar background and redraws everything, rather
+				than doing a (far more efficient) update of the bar/percentage alone. Use the default
+				of FALSE unless absolutely necessary!
+
+				JobDescrip - NULL, or a pointer to a new job description - pass NULL if this hasn't
+				changed, as it makes a copy of the new string every time it is changed.	If this is
+				non-NULL, then the ClearBackground flag will be forced to TRUE to draw the new text.
+
+	Outputs:	-
+	Returns:	TRUE if it successfully makes the change.
+	Purpose:	Sets the currently displayed percentage of the progress bar. The bar
+				will be immediately redrawn to reflect the new value. Values outside the
+				range 0..99 (inclusive) are clipped to 0 or 99. No redraw will be done if
+				NewPercent equals the currently displayed value.
+	SeeAlso:	CProgressBar::GetPercent; CProgressBar::Create
+********************************************************************************************/
+
+BOOL StatusLine::SetPercent(INT32 NewPercent, BOOL ClearBackground /* =FALSE */,
+								String_64 *JobDescrip /* =NULL */)
+// The extra argument ClearBackground is not mentioned in the help, because it
+// is used internally - When the window is first created, the background must be cleared,
+// but on normal updates this causes horrible flicker, so is to be avoided.
+{
+	if (NewPercent < 0) NewPercent = 0;
+	if (NewPercent > 99) NewPercent = 99;
+
+	// If there's no change, don't bother updating
+	if (JobDescrip == NULL && NewPercent == CurrentPercent)
+		return(TRUE);
+
+	CurrentPercent = NewPercent;
+
+	// If there is a new Job Description, change to use it
+	if (JobDescrip != NULL)
+	{
+		delete JobDescription;
+		JobDescription = new String_64(*JobDescrip);
+
+		if (JobDescription)
+		{
+			SetStringGadgetValue(_R(IDC_SL_PROGRESSTEXT), *JobDescription);
+		}
+		else
+		{
+			SetStringGadgetValue(_R(IDC_SL_PROGRESSTEXT), String_64(_T("")));
+		}
+
+//		InvalidateGadget(_R(IDC_SL_PROGRESSTEXT));
+//		PaintGadgetNow(_R(IDC_SL_PROGRESSTEXT));
+
+		ClearBackground = TRUE;		// Ensure that the new text is drawn
+	}
+
+	SetLongGadgetValue(_R(IDC_SL_PROGRESSGAUGE), CurrentPercent);
+//	InvalidateGadget(_R(IDC_SL_PROGRESSGAUGE), ClearBackground);
+//	PaintGadgetNow(_R(IDC_SL_PROGRESSGAUGE));
+//	InvalidateGadget(0, ClearBackground);
+//	PaintGadgetNow(0); // repaint the whole bar
+
+	InvalidateGadget(_R(IDC_SL_PROGRESSGAUGE), ClearBackground);
+	PaintGadgetNow(_R(IDC_SL_PROGRESSGAUGE));
+
+	return(TRUE);
+}
Index: Trunk/XaraLX/Kernel/dialogop.cpp
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.cpp	(revision 980)
+++ Trunk/XaraLX/Kernel/dialogop.cpp	(revision 981)
@@ -1946,11 +1946,12 @@
 
 /********************************************************************************************
 
->	void DialogOp::InvalidateGadget(CGadgetID Gadget)
+>	void DialogOp::InvalidateGadget(CGadgetID Gadget, BOOL EraseBackground=TRUE)
 
 	Author:		Rik_Heywood (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	20/10/94
 	Inputs:		Gadget - The ID of the gadget that you want to be redrawn
+				EraseBackground	TRUE if the background should be erased
 	Purpose:	Causes the Dialog Manager to tell the host os to get the gadget to be
 				redrawn. Calling this on a cc_DialogDraw gadget will cause you to receive
 				a DIM_REDRAW message in the not too distant future.
@@ -1959,10 +1960,10 @@
 
 ********************************************************************************************/
 
-void DialogOp::InvalidateGadget(CGadgetID Gadget)
+void DialogOp::InvalidateGadget(CGadgetID Gadget, BOOL EraseBackground/*=TRUE*/)
 {
 	// Call the Dialog Manager
-	DialogManager::InvalidateGadget(GetReadWriteWindowID(), Gadget);
+	DialogManager::InvalidateGadget(GetReadWriteWindowID(), Gadget, EraseBackground);
 }
 
 
Index: Trunk/XaraLX/Kernel/dialogop.h
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.h	(revision 980)
+++ Trunk/XaraLX/Kernel/dialogop.h	(revision 981)
@@ -387,8 +387,8 @@
 	
 	//--------------------------------------------------------------------------------------
 	
-	void PaintGadgetNow(CGadgetID gid);			// immediately updates gadget's appearance
-	void InvalidateGadget(CGadgetID Gadget);	// Force the gadget to be repainted
+	void PaintGadgetNow(CGadgetID gid);		// immediately updates gadget's appearance
+	void InvalidateGadget(CGadgetID Gadget, BOOL EraseBackground=TRUE);	// Force the gadget to be repainted
 
 	// Force *part* of a kernel-drawn gadget to repaint
 	void InvalidateGadget(CGadgetID Gadget,
Index: Trunk/XaraLX/wxXtra/platform.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/platform.cpp	(revision 980)
+++ Trunk/XaraLX/wxXtra/platform.cpp	(revision 981)
@@ -42,7 +42,33 @@
 
 // Platform dependent stuff starts here
 
+void wxPlatformDependent::FixUpdate(wxWindow * pwxWindow, bool flush /*=true*/)
+{
 #if defined( __WXGTK__ )
+    // On GTK, in 2.6.3 and predecessor, wxWindow::Update does not update the window
+    // where m_window is NULL, and thus misses native controls. We thus do it properly
+    // here - we assume the patch to fix this will be taken in 2.6.4
+    // This routine should be called after "update"
+#if !wxCHECK_VERSION(2,6,4)
+    // Update this one
+    if (pwxWindow && pwxWindow->m_widget && pwxWindow->m_widget->window)
+        gdk_window_process_updates( pwxWindow->m_widget->window, FALSE );
+    // now recurse through children
+    // Now process children if any
+    wxWindowList::Node * pNode = pwxWindow->GetChildren().GetFirst();
+    while (pNode)
+    {
+        FixUpdate(pNode->GetData(), false);
+        pNode = pNode->GetNext();
+    }
+    if (flush)
+        gdk_flush();
+#endif
+#endif
+    return;
+}
+
+#if defined( __WXGTK__ )
 void wxPlatformDependent::ParseGtkRcString(char * rcstring)
 {
     gtk_rc_parse_string(rcstring);
Index: Trunk/XaraLX/wxXtra/platform.h
===================================================================
--- Trunk/XaraLX/wxXtra/platform.h	(revision 980)
+++ Trunk/XaraLX/wxXtra/platform.h	(revision 981)
@@ -34,6 +34,8 @@
 public:
     virtual void InitWindow(wxWindow * pwxWindow) {} // To override
 
+    virtual void FixUpdate(wxWindow * pwxWindow, bool flush=true);
+
 #if defined( __WXGTK__ )
     virtual void ParseGtkRcString(char * rcstring);
     virtual void SetGtkWidgetName(wxWindow * pwxWindow, char * name);
Index: Trunk/XaraLX/wxOil/progress.cpp
===================================================================
--- Trunk/XaraLX/wxOil/progress.cpp	(revision 980)
+++ Trunk/XaraLX/wxOil/progress.cpp	(revision 981)
@@ -110,6 +110,7 @@
 //#include "oilprog.h"
 //#include "progbar.h"
 #include "node.h"
+#include "statline.h"
 
 #include "progress.h"
 
@@ -123,9 +124,9 @@
 
 BOOL Progress::AbortJob		= FALSE;		// TRUE if the we want to abort a job in ralph
 
-PORTNOTE("progress", "Removed progress system")
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
 
+#if !defined(EXCLUDE_FROM_RALPH)
+
 // --- Thread activation - set to 1 to enable the delayed-show thread
 // (NOTE: The start-delay thread is currently non-operational, so turning it on
 // has no effect. See below for details)
@@ -331,7 +332,7 @@
 
 MonotonicTime Progress::StartTime;				// Time the first call to Show() was made
 
-CProgressBar *Progress::ProgBar = NULL;			// The progress bar object (if used)
+//CProgressBar *Progress::ProgBar = NULL;			// The progress bar object (if used)
 
 
 /********************************************************************************************
@@ -426,7 +427,7 @@
 	if (bEnable)
 	{
 		ProgressCount = 0;
-		ERROR3IF(DescriptionID == NULL, "Progress constructor - Illegal NULL parameter");
+		ERROR3IF(!DescriptionID, "Progress constructor - Illegal NULL parameter");
 		Progress::Start(Delay, DescriptionID, FinalCount);
 	}
 }
@@ -530,7 +531,7 @@
 
 void Progress::Start(BOOL Delay, UINT32 DescriptionID, INT32 IntendedFinalCount)
 {
-	if (DescriptionID == NULL)
+	if (!DescriptionID)
 		Progress::Start(Delay, (StringBase *)NULL, IntendedFinalCount);
 	else
 	{
@@ -639,8 +640,10 @@
 
 			// And reset/redraw the progress bar display to make sure it starts from 0 again
 			// and shows the new job description (if any).
-			if (ProgBar != NULL)
-				ProgBar->SetPercent(0, TRUE, (HaveJobDescription) ? &JobDescription : NULL);
+			if (StatusLine::Get())
+			{
+				StatusLine::Get()->SetPercent(0, TRUE, (HaveJobDescription) ? &JobDescription : NULL);
+			}
 		}
 	}
 
@@ -796,24 +799,11 @@
 		// (Create if necessary) and update the progress bar, if it is needed
 		if (DisplayBar && FinalCount > 0)
 		{
-			if (ProgBar == NULL)
+			if (StatusLine::Get())
 			{
-				ProgBar = new CProgressBar;
-
-				if (ProgBar != NULL)
-				{
-					if (!ProgBar->Create((CFrameWnd *) (AfxGetApp()->m_pMainWnd), &JobDescription))
-					{
-						delete ProgBar;
-						ProgBar = NULL;
-					}
-					else
-						ProgBar->ShowWindow(SW_SHOW);
-				}
-
+				StatusLine::Get()->ShowProgress(TRUE, &JobDescription);
+				StatusLine::Get()->SetPercent(NewPercent);
 			}
-			else
-				ProgBar->SetPercent(NewPercent);
 		}
 
 		// Remember the last displayed percentage
@@ -859,13 +849,13 @@
 	if (ActiveDisplays > 0)
 		return;
 
-	if (ProgBar != NULL && CurrentPercent < 97)
+	if (StatusLine::Get() && CurrentPercent < 97)
 	{
 		// We are showing a progress bar, but have not shown "completion" of the job (99%)
 		// Briefly jump to 99% on the progress bar so the user can't see how bad our estimate
 		// of when we'd finish really was.
 
-		ProgBar->SetPercent(99);
+		StatusLine::Get()->SetPercent(99);
 
 		MonotonicTime Timer;
 		while (!Timer.Elapsed(150))
@@ -921,13 +911,9 @@
 		GetApplication()->UpdateStatusBarText(&Blank);
 
 		// --- Remove any active progress bar
-		if (ProgBar != NULL)
+		if (StatusLine::Get())
 		{
-			delete ProgBar;
-			ProgBar = NULL;
-
-			// Make sure it disappears immediately
-			((CFrameWnd *) (AfxGetApp()->m_pMainWnd))->RecalcLayout();
+			StatusLine::Get()->ShowProgress(FALSE);
 		}
 
 		// --- And reset all variables to suitable defaults
Index: Trunk/XaraLX/wxOil/dlgmgr.h
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.h	(revision 980)
+++ Trunk/XaraLX/wxOil/dlgmgr.h	(revision 981)
@@ -608,7 +608,7 @@
     // ------------------------------------------------------------------------------------- 
 	// Immediately updates gadget's appearance    
 	static void PaintGadgetNow(CWindowID WindowID, CGadgetID gid);
-	static void InvalidateGadget(CWindowID WindowID, CGadgetID Gadget);
+	static void InvalidateGadget(CWindowID WindowID, CGadgetID Gadget, BOOL EraseBackround=TRUE);
 
 				// Invalidates a specific portion of a cc_DialogDraw gadget
 	static void InvalidateGadget(CWindowID WindowID, CGadgetID Gadget,
Index: Trunk/XaraLX/wxOil/xrc/EN/statusbar.xrc
===================================================================
--- Trunk/XaraLX/wxOil/xrc/EN/statusbar.xrc	(revision 980)
+++ Trunk/XaraLX/wxOil/xrc/EN/statusbar.xrc	(revision 981)
@@ -46,8 +46,28 @@
             </object>
 
             <object class="sizeritem">
+                <flag>wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
+                <border>1</border>
+                <object class="wxStaticText" name="IDC_SL_PROGRESSTEXT">
+                    <font>
+                        <size>8</size>
+                    </font>
+                    <style>wxALIGN_LEFT</style>
+                    <label>Nothing selected</label>
+                    <tooltip>Status bar text</tooltip>
+                    <help>Displays the current status</help>
+                </object>
+            </object>
+
+            <object class="spacer">
                 <flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
                 <border>1</border>
+                <size>3,16</size>
+            </object>
+
+            <object class="sizeritem">
+                <flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
+                <border>1</border>
                <object class="wxCamArtControl" name="IDB_SL_SDRAG0">
                     <camartstyle>wxCACS_PUSHBUTTON|wxCACS_ALLOWHOVER|wxCACS_TOGGLEBUTTON</camartstyle>
                     <optoken>ToggleSolidDrag</optoken>
Index: Trunk/XaraLX/wxOil/dlgmgr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.cpp	(revision 980)
+++ Trunk/XaraLX/wxOil/dlgmgr.cpp	(revision 981)
@@ -4856,7 +4856,7 @@
 	Author:		Justin_Flude (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	1/9/94
 	Inputs:		WindowID			Window identifier
-				gid			Gadget (control) identifier
+				gid			Gadget (control) identifier,  or zero for the whole window
 	Outputs:	-
 	Returns:	-
 	Purpose:	Immediate paints any invalid areas of the given control (like the Windows
@@ -4867,18 +4867,25 @@
 
 void DialogManager::PaintGadgetNow(CWindowID WindowID, CGadgetID Gadget)
 {
+	if (!Gadget)
+	{
+		((wxWindow *)WindowID)->Update();
+		wxPlatformDependent::Get()->FixUpdate((wxWindow *)WindowID);
+		return;
+	}
 	// For the time being, we do this by Hide/Unhide
 	wxWindow * pGadget = GetGadget(WindowID, Gadget);
 	if (!pGadget) return;
 
 	pGadget->Update();
+	wxPlatformDependent::Get()->FixUpdate(pGadget);
 }
 
 
 
 /********************************************************************************************
 
->	static void DialogManager::InvalidateGadget(CWindowID WindowID, CGadgetID Gadget)
+>	static void DialogManager::InvalidateGadget(CWindowID WindowID, CGadgetID Gadget, BOOL EraseBackground)
 
 	Author:		Rik_Heywood (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	20/10/94
@@ -4888,14 +4895,18 @@
 
 ********************************************************************************************/
 
-void DialogManager::InvalidateGadget(CWindowID WindowID, CGadgetID Gadget)
+void DialogManager::InvalidateGadget(CWindowID WindowID, CGadgetID Gadget, BOOL EraseBackground /*=TRUE*/)
 {
+	if (!Gadget)
+	{
+		((wxWindow *)WindowID)->Refresh(EraseBackground);
+		return;
+	}
 	// For the time being, we do this by Hide/Unhide
 	wxWindow * pGadget = GetGadget(WindowID, Gadget);
 	if (!pGadget) return;
 
-	pGadget->Refresh();
-
+	pGadget->Refresh(EraseBackground);
 }
 
 
Index: Trunk/XaraLX/wxOil/progress.h
===================================================================
--- Trunk/XaraLX/wxOil/progress.h	(revision 980)
+++ Trunk/XaraLX/wxOil/progress.h	(revision 981)
@@ -132,8 +132,8 @@
 
 class String_64;
 class MonotonicTime;
-class CProgressBar;
 
+
 class Progress : public CC_CLASS_MEMDUMP
 {
 	CC_DECLARE_MEMDUMP(Progress)
@@ -207,7 +207,7 @@
 
 	static MonotonicTime StartTime;			// Time the first call to Show() was made
 
-	static CProgressBar *ProgBar;			// The progress bar object (if used)
+//	static CProgressBar *ProgBar;			// The progress bar object (if used)
 
 	static BOOL AbortJob;					// used to abort jobs in ralph - fake an escape condition
 protected:		// Preferences


Xara