Re: Try to implement Pulsing progress bar in windows_chenxiajian

From: Martin Sevior <msevior_at_gmail.com>
Date: Fri Apr 15 2011 - 04:21:57 CEST

Hi Chen,

That is exactly the right place to implement the pulse part of the
progress bar. Thanks also for your UML diagram. I knew the statusbar
code was complex but it was still amazing to see all those lines
showing the dependencies.

Cheers

Martin

2011/4/15 chenxiajian1985 <chenxiajian1985@gmail.com>:
> Hi, Thanks Martin. I learned a lot from your code.
> I have shared my understanding about the source code in the mail-list. If some mistakes, pls tell me. Thanks
>
> Today I will try to implement the Pulsing progress bar in Windows
> in the notify function of ap_usb_ProgressListener and i find Where to add pulse process bar
> void ap_usb_ProgressListener::notify()
> {
> if(pProgress->isDefinate())
> {
> double fraction = pProgress->getFraction();
> SendMessage(m_ProgressWND,PBM_SETPOS,fraction*100,0);
> }
> else
> { //here pulse process bar <--------------pulse process bar
> }
> }
>
> Regards
> Chen Xiajian
>
>
> 发件人: Martin Sevior
> 发送时间: 2011-04-15 08:41:58
> 收件人: chenxiajian1985
> 抄送: abiword-dev
> 主题: Committed! Re: [modified]patch file_Implement progress bar in windows_chenxiajian
>
> Committed!
> Author: msevior
> Date: 2011-04-15 02:39:46 +0200 (Fri, 15 Apr 2011) New Revision: 29715
> Modified:
> abiword/trunk/src/wp/ap/win/ap_Win32StatusBar.cpp
> abiword/trunk/src/wp/ap/win/ap_Win32StatusBar.h
> abiword/trunk/src/wp/ap/xp/ap_StatusBar.h
> Log:
> Patch from Chen Xiajian to implement progress bar for windows.
> Thanks very much Chen!
> Cheers
> Martin
> 2011/4/14 chenxiajian1985 <chenxiajian1985@gmail.com>:
>> Hi, Martin. Sorry to bother you again.
>> Thanks for your suggestion. That is due to my carelessness. Sorry Now I have make a big modify
>> The patch file I have modified in the following spaces, to keep same with the source code:
>> ==================1 ap_usb_ProgressListener======
>> create a class to deal with ProgressListener(the same as the gtk code). seperate from the statusBarListener
>> class ap_usb_ProgressListener : public AP_StatusBarFieldListener
>> {
>> public:
>> .............
>> virtual void notify(); //deal with progressbar update
>> protected:
>> HWND m_ProgressWND;
>> };
>> ==================2======
>> and in the notify function deal with the update: and i find the place to add pulse process bar
>> void ap_usb_ProgressListener::notify()
>> {
>> if(pProgress->isDefinate())
>> {
>> double fraction = pProgress->getFraction();
>> SendMessage(m_ProgressWND,PBM_SETPOS,fraction*100,0);
>> }
>> else
>> { //here pulse process bar <--------------pulse process bar
>> }
>> }
>> ===========================3============
>> In this situation, I need to build the connection between ap_usb_ProgressListener and ProcessBar in the createWindow() in this place, your code have one error(the elseif is in the wrong place)
>> else if(pf->getFillMethod() == PROGRESS_BAR)
>> {
>> pf->setListener((AP_StatusBarFieldListener *)(new ap_usb_ProgressListener(pf, m_hwndProgressBar)));
>> }
>> ===========================4============
>> Remove unused function and variables
>>
>> I learned a lot from your code. Thanks
>>
>> chenxiajian1985
>> -------------------------------------------------------------
>> 发件人:Martin Sevior
>> 发送日期:2011-04-14 12:53:04
>> 收件人:chenxiajian1985; abiword-dev
>> 抄送:
>> 主题:Re: Re: [modified]patch file_Implement progress bar in windows_chenxiajian
>>
>> Hi Chen,
>>
>> Thankyou for your contributions. I really appreciate how quickly you
>> are picking everything up.
>>
>> I have a few more comments.
>>
>> Firstly, when we define class member variables, we prepend an "m_" to
>> their names. So if you create a new member variable "percentLoad" call
>> is "m_percentLoad" instead.
>>
>> HOWEVER in this case you need percentLoad or the call:
>>
>> m_pStatusBar->setPercent(percentFilled);
>>
>> in the fl_DocListener class.
>>
>> Simply use the the existing method:
>>
>> double AP_StatusBarField_ProgressBar::getFraction(void)
>>
>> Which returns a double between 0.0 and 1.0 of the fraction of the
>> progress completed.
>>
>> The code I wrote in fl_DocListedner already does what is needed to
>> make sure getFraction returns a valid number.
>>
>> So your code in the ap_Win32StatusBar::notify method would be:
>>
>> int percent = textInfo->getApStatusBar()->getFraction()*100;
>> SendMessage(m_pSB->getProgressBar(),PBM_SETPOS,percent,0)
>>
>> So please remove the getPercent, setPercent methods from the code and
>> just use the getFraction method.
>>
>> Cheers
>>
>> Martin
>> On Thu, Apr 14, 2011 at 2:13 PM, chenxiajian1985
>> <chenxiajian1985@gmail.com> wrote:
>>> Hi, Martin
>>> the attachment is the modified patch file follows your instruction. I have tested in my computer, it works well.
>>> I have modified as following:
>>> 1 the implementation of the virtual function
>>> void AP_Win32StatusBar::showProgressBar(void)
>>> {
>>> ShowWindow(m_hwndProgressBar,SW_SHOW);
>>> }
>>> void AP_Win32StatusBar::hideProgressBar(void)
>>> {
>>> ShowWindow(m_hwndProgressBar,SW_HIDE);
>>> SendMessage(m_hwndProgressBar,PBM_SETPOS,0,0); //hide and set to zero
>>> }
>>>
>>> 2 modify some member variable(no need pass by the paramter and just get from the "this" pointer)
>>>
>>>
>>> We can use the progress bar: set the "percent" variable when set the status Bar text (m_sBuf)
>>>
>>> If have some problem about the patch, and some other bug in Windows, pls tell me. I would like to fix it
>>>
>>> Thanks
>>> Chen Xiajian
>>>
>>>
>>> 发件人: Martin Sevior
>>> 发送时间: 2011-04-14 08:34:49
>>> 收件人: chenxiajian1985
>>> 抄送: abiword-dev
>>> 主题: Re: patch file_Implement progress bar in windows_chenxiajian
>>>
>>> Hi Chen,
>>> Thanks very much for this! Looking at your code, it appears that you
>>> automatically hide the progress bar after it has reached either 50% or
>>> 100%.
>>> Instead of that please implement the following virtual methods for
>>> AP_Win32StatusBar.
>>> virtual void showProgressBar(void) {}
>>> virtual void hideProgressBar(void) {}
>>> The implementation in the gtk build is really simple.
>>> void AP_UnixStatusBar::showProgressBar(void)
>>> {
>>> gtk_widget_show(m_wProgressFrame);
>>> }
>>> void AP_UnixStatusBar::hideProgressBar(void)
>>> {
>>> gtk_widget_hide(m_wProgressFrame);
>>> }
>>> Where m_wProgressFrame is the container that holds the progress bar. I
>>> imagine Win32 has similar functionality?
>>> (I'm not a windows developer!)
>>> The cross platform code will show and and hide the progress bars as
>>> needed and has already been written.
>>> Finally, we can indeed use these for other situations in abiword later :-)
>>> Cheers
>>> Martin
>>> 2011/4/14 chenxiajian1985 <chenxiajian1985@gmail.com>:
>>>> Hi, all
>>>> the attachment is the patch file that I implemant progress bar in windows. I have checked in my computer it works well.
>>>> the image shows the progress bar in windows:
>>>> http://hi.csdn.net/attachment/201104/13/65043_1302717024x1D4.png
>>>>
>>>> I care about some factors when coding:
>>>> 1. when resize the status bar, the progress bar must resize too
>>>> 2. the basic function
>>>> 3. use the win32 common ctrls, the same as the source code
>>>> 4. the position of the progress bar
>>>> 5. the show and hide when operation finish
>>>> ....
>>>>
>>>> Anyone who some suggestion, pls tell me. I will make the function more excellent.
>>>>
>>>>
>>>> Thanks
>>>> chen xiajian
>>>
>>
> .
>
Received on Fri Apr 15 04:22:15 2011

This archive was generated by hypermail 2.1.8 : Fri Apr 15 2011 - 04:22:15 CEST