2011年4月27日星期三

Share of some understanding about Source code

Recently I try to implement the process bar in windows. and I read a lot of source code, I make a summary of that. I want to share with you all, I hope that is helpfull to you all. 
Anyone interested in that pls disscus with me, Thank you.
 
the attachment is the class diagram in UML format. we can see that:
 
1. the AP_StatusBar is an abstract class represent the status bar.
 And the Windows AP_Win32StatusBar inherited from AP_StatusBar
And in the AP_StatusBar contain the interface elements——m_vecFields(vector of StatusBarField) and processField(processBar). 
But they are all the abstract class AP_StatusBarField. And the concreate class is AP_StatusBarFidld_ProcessBar / ap_sbf_pageInfo /ap_sbf_StatusMessage/ ap_sbf_InputMode / ap_sbf_Language.
 
AP_StatusBarField_ProcessBar: present the processBar
ap_sbf_pageInfo: present pageInfo
ap_sbf_StatusMessage:present StatusMessage
ap_sbf_InputMode: present InputMode
ap_sbf_Language: present Language
 
2. And the event-handler of the interface elements are all in the following format:
  firstly, creating the event-handler Listener 
  then build the connection between them
  override the notify function in the Listener to handler the event
 
  every interface element has Listener class:
AP_StatusBarFidld_ProcessBar: ap_usb_processListener
ap_sbf_pageInfo: ap_usb_TextListener
ap_sbf_StatusMessage: ap_usb_TextListener
ap_sbf_InputMode: ap_usb_TextListener
ap_sbf_Language: ap_usb_TextListener
 
all the listener are all inherit from the Ap_StatusBarFieldListener.  
and the event are all handled in the notify function.
 
3. in the AP_Win32StatusBar.
   the createWindow function create the HWNDs and make connection with their listener
AP_Win32StatusBar::createWindow:
for (UT_sint32 k = 0; k <  getFields()-> getItemCount(); k++) 
{  
    pf-> setListener(...));
}

没有评论:

发表评论