$PBExportHeader$u_dwtoolbar.sru $PBExportComments$Datawindow based Toolbar forward global type u_dwtoolbar from u_base_container end type type label from u_st within u_dwtoolbar end type type dw_1 from u_dw within u_dwtoolbar end type type ids_buttons from n_ds within u_dwtoolbar end type end forward global type u_dwtoolbar from u_base_container integer width = 937 integer height = 164 boolean border = true boolean #tooltips = true event ke_buttonclicked ( readonly string buttonid, readonly string buttontext, readonly string buttondata ) event ke_dropdown ( readonly string buttonid, readonly string buttontext, readonly string buttondata, readonly integer popx, readonly integer popy ) event ke_dropdowncoordinate ( readonly integer buttonindex, readonly integer popx, readonly integer popy ) event ke_menuitemclicked ( readonly string buttonid ) event ke_routemenu ( ) event ke_itemchanged ( readonly long row, readonly dwobject dwo, readonly string data ) label label dw_1 dw_1 ids_buttons ids_buttons end type global u_dwtoolbar u_dwtoolbar type prototypes Function Boolean TrackMouseEvent ( ref trackmouseevent lpTrackMouseEvent ) Library 'user32.dll' alias for "TrackMouseEvent;Ansi" Function ulong SetCapture(ulong hWnd) Library "USER32.DLL" Function BOOLEAN ReleaseCapture() Library "USER32.DLL" end prototypes type variables Public: string #ToolbarDataObject string #DataObject = "dynamic" boolean #CacheToolbarDefinition = TRUE boolean #StandardImages = TRUE string #ImageList boolean #LargeIcons boolean #Gripper = TRUE boolean #FixedWidth boolean #NewLine = TRUE Protected: str_dwtoolbarbutton istr_buttons[] str_theme istr_theme ulong iul_himl Private: CONSTANT string DWTB_SVC = "n_svc_dwtoolbar" n_svc_dwtoolbar inv_tb Boolean MouseDown, MouseCaptured string ANCHOR_BUTTON string HOT_BUTTON integer ii_width, ii_height boolean ib_suspenddraw, ib_suspendsize CONSTANT string DEFAULT_TIP = "||DW TIP||" long ToolTipID, BaloonToolTipID String dwTooltip, LastDWO Boolean HitTest, IsBalloon integer ii_lastx, ii_lasty end variables forward prototypes public subroutine of_setdataobject (readonly string as_dataobject) public function long of_getbuttons (ref str_dwtoolbarbutton astr[]) public subroutine of_settoolbarbuttons (datastore ads) public subroutine of_settoolbarbuttons (string as_dataobject) public subroutine of_init () public subroutine of_setimagelist (readonly unsignedlong al_himl) public function unsignedlong of_getimagelist () public subroutine of_largeicons () public subroutine of_smallicons () public subroutine of_buttonenable (readonly string as_buttonid, readonly boolean ab_enable) public subroutine of_buttoncheck (readonly string as_buttonid, readonly boolean ab_check) public function boolean of_isbuttonchecked (readonly string as_buttonid) public function boolean of_isbuttonenabled (readonly string as_buttonid) public subroutine of_settheme (readonly integer ai_theme) public subroutine of_buildtoolbar () public subroutine of_addtoolbarbuttons (datastore ads) public subroutine of_setdimensions (readonly integer ai_width, readonly integer ai_height) public subroutine of_refresh () public subroutine of_suspenddraw () public subroutine of_resumedraw () public subroutine of_suspendresize () public subroutine of_resumeresize () public function long of_getindexfromid (readonly string as_buttonid) public function long of_makemenuitems (ref str_menuitem astr_items[]) public subroutine of_popmenu (readonly str_menuitem astr[], readonly integer ai_x, readonly integer ai_y) public subroutine of_popmenu (readonly integer ai_x, readonly integer ai_y) public function str_theme of_gettheme () public subroutine of_tooltips (readonly boolean ab_tooltips) end prototypes event ke_buttonclicked(readonly string buttonid, readonly string buttontext, readonly string buttondata);//=========================================================================== // Event : Ke_buttonclicked (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String buttonid // readonly String buttontext // readonly String buttondata //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== //triggered on toolbar button click end event event ke_dropdown(readonly string buttonid, readonly string buttontext, readonly string buttondata, readonly integer popx, readonly integer popy);//=========================================================================== // Event : Ke_dropdown (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String buttonid // readonly String buttontext // readonly String buttondata // readonly Integer popx // readonly Integer popy //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== //triggered when dropdown toolbar button is clicked //use the popx and popy variables for display end event event ke_dropdowncoordinate(readonly integer buttonindex, readonly integer popx, readonly integer popy);//=========================================================================== // Event : Ke_dropdowncoordinate (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly Integer buttonindex // readonly Integer popx // readonly Integer popy //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== EVENT ke_dropdown(istr_buttons[buttonindex].id, & istr_buttons[buttonindex].text, & istr_buttons[buttonindex].data, & popx, & popy) end event event ke_menuitemclicked(readonly string buttonid);//=========================================================================== // Event : Ke_menuitemclicked (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String buttonid //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== //fired from dynamic menu long ll_index ll_index = of_getindexfromid(buttonid) EVENT ke_buttonclicked(buttonid, istr_buttons[ll_index].text, istr_buttons[ll_index].data) end event event ke_routemenu();//=========================================================================== // Event : Ke_routemenu (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== //fired from dynamic menu EVENT ke_menuitemclicked(STRING(Message.LongParm, "address")) end event event ke_itemchanged(readonly long row, readonly dwobject dwo, readonly string data);//=========================================================================== // Event : Ke_itemchanged (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly Long row // readonly DWObject dwo // readonly String data //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== //firew when toolbar itemchanged end event public subroutine of_setdataobject (readonly string as_dataobject);//=========================================================================== // Function: of_Setdataobject (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String as_dataobject //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== this.#DataObject = as_dataobject n_svc_mgr lnv_svc IF #DataObject = "dynamic" THEN n_svc_dwmaker lnv_dyn string ls_syntax, ls_err lnv_svc.of_LoadSvc(lnv_dyn, "n_svc_dwmaker") ls_syntax = lnv_dyn.of_makedw(lnv_svc, {"dummy"}, {"number"}) IF dw_1.Create(ls_syntax, ls_err) = CRet.FAILURE THEN Messagebox("Error on Create DW", ls_err, StopSign!) RETURN END IF ELSE dw_1.Dataobject = as_dataobject END IF //reset vars str_dwtoolbarbutton lstr[] istr_buttons = lstr IF dw_1.RowCount() <= 0 THEN dw_1.InsertRow(0) end subroutine public function long of_getbuttons (ref str_dwtoolbarbutton astr[]);//=========================================================================== // Function: of_Getbuttons (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // reference str_dwtoolbarbutton astr[] //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== astr = istr_buttons RETURN UPPERBOUND(istr_buttons) end function public subroutine of_settoolbarbuttons (datastore ads);//=========================================================================== // Function: of_Settoolbarbuttons (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value DataStore ads //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc blob lb IF NOT ISVALID(ads) THEN RETURN ads.GetFullState(lb) ids_buttons.SetFullState(lb) IF #CacheToolbarDefinition THEN IF inv_tb.of_Buildfromcache(this, istr_buttons) THEN RETURN END IF inv_tb.of_AddButtons(lnv_svc, & this, & istr_buttons) of_Buildtoolbar() end subroutine public subroutine of_settoolbarbuttons (string as_dataobject);//=========================================================================== // Function: of_Settoolbarbuttons (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value String as_dataobject //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_ds lds lds = CREATE n_ds IF lds.of_SetDataobject(as_dataobject) = CRet.SUCCESS THEN of_SetToolbarButtons(lds) END IF DESTROY lds end subroutine public subroutine of_init ();//=========================================================================== // Function: of_Init (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc n_svc_theme lnv_t lnv_svc.of_LoadSvc(lnv_t, CSvc.THEME) istr_theme = lnv_t.of_GetTheme() end subroutine public subroutine of_setimagelist (readonly unsignedlong al_himl);//=========================================================================== // Function: of_Setimagelist (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly UnsignedLong al_himl //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== iul_himl = al_himl end subroutine public function unsignedlong of_getimagelist ();//=========================================================================== // Function: of_Getimagelist (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: UnsignedLong //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== RETURN iul_himl end function public subroutine of_largeicons ();//=========================================================================== // Function: of_Largeicons (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== #LargeIcons = TRUE n_svc_mgr lnv_svc n_svc_resource lnv_res lnv_svc.of_LoadSvc(lnv_res, CSvc.RESOURCE) of_SetImageList(lnv_res.of_GetStandardImageList24(lnv_svc)) IF NOT ib_suspenddraw THEN this.SetRedraw(FALSE) of_setdataobject(#DataObject) of_settoolbarbuttons(ids_buttons) of_buildtoolbar() of_Refresh() //have to reset tooltips when icon size changes of_Tooltips(#Tooltips) end subroutine public subroutine of_smallicons ();//=========================================================================== // Function: of_Smallicons (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== #LargeIcons = FALSE n_svc_mgr lnv_svc n_svc_resource lnv_res lnv_svc.of_LoadSvc(lnv_res, CSvc.RESOURCE) of_SetImageList(lnv_res.of_GetStandardImageList16(lnv_svc)) this.SetRedraw(FALSE) of_setdataobject(#DataObject) of_settoolbarbuttons(ids_buttons) of_buildtoolbar() this.SetRedraw(TRUE) TRY parent.DYNAMIC SetRedraw(TRUE) parent.TriggerEvent("resize") CATCH (RuntimeError ex) END TRY //have to reset tooltips when icon size changes of_Tooltips(#Tooltips) end subroutine public subroutine of_buttonenable (readonly string as_buttonid, readonly boolean ab_enable);//=========================================================================== // Function: of_Buttonenable (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String as_buttonid // readonly Boolean ab_enable //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== string ls_buttonid long n ls_buttonid = inv_tb.of_makebuttonid(as_buttonid) n = inv_tb.of_indexfrombuttonid(ls_buttonid, istr_buttons) //non-existing button IF n = CRet.FAILURE THEN RETURN inv_tb.of_buttonenable(this, ls_buttonid, n, istr_buttons, ab_enable) end subroutine public subroutine of_buttoncheck (readonly string as_buttonid, readonly boolean ab_check);//=========================================================================== // Function: of_Buttoncheck (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String as_buttonid // readonly Boolean ab_check //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== string ls_buttonid long n ls_buttonid = inv_tb.of_makebuttonid(as_buttonid) n = inv_tb.of_indexfrombuttonid(ls_buttonid, istr_buttons) //non-existing button IF n = CRet.FAILURE THEN RETURN inv_tb.of_buttoncheck(this, ls_buttonid, n, istr_buttons, ab_check) end subroutine public function boolean of_isbuttonchecked (readonly string as_buttonid);//=========================================================================== // Function: of_Isbuttonchecked (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String as_buttonid //--------------------------------------------------------------------------- // Returns: Boolean //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== string ls_buttonid ls_buttonid = inv_tb.of_makebuttonid(as_buttonid) RETURN inv_tb.of_isbuttonchecked(as_buttonid, this, istr_buttons) end function public function boolean of_isbuttonenabled (readonly string as_buttonid);//=========================================================================== // Function: of_Isbuttonenabled (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String as_buttonid //--------------------------------------------------------------------------- // Returns: Boolean //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== string ls_buttonid ls_buttonid = inv_tb.of_makebuttonid(as_buttonid) RETURN inv_tb.of_isbuttonenabled(as_buttonid, this, istr_buttons) end function public subroutine of_settheme (readonly integer ai_theme);//=========================================================================== // Function: of_Settheme (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly Integer ai_theme //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc n_svc_theme lnv_t lnv_svc.of_LoadSvc(lnv_t, CSvc.THEME) lnv_t.of_Settheme(ai_theme) istr_theme = lnv_t.of_GetTheme() IF #CacheToolbarDefinition THEN IF inv_tb.of_Buildfromcache(this, istr_buttons) THEN //have to reset tooltips when theme changes of_Tooltips(#Tooltips) RETURN END IF END IF IF NOT ib_suspenddraw THEN this.SetRedraw(FALSE) of_setdataobject(#DataObject) of_settoolbarbuttons(ids_buttons) of_buildtoolbar() IF NOT ib_suspenddraw THEN this.SetRedraw(TRUE) TRY IF NOT ib_suspenddraw THEN parent.DYNAMIC SetRedraw(TRUE) CATCH (RuntimeError ex) END TRY //have to reset tooltips when theme changes of_Tooltips(#Tooltips) end subroutine public subroutine of_buildtoolbar ();//=========================================================================== // Function: of_Buildtoolbar (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc IF #CacheToolbarDefinition THEN IF inv_tb.of_BuildFromCache(this, istr_buttons) THEN RETURN END IF inv_tb.of_Buildtoolbar(lnv_svc, this, istr_buttons, 0, 0, #Gripper, #CacheToolbarDefinition) end subroutine public subroutine of_addtoolbarbuttons (datastore ads);//=========================================================================== // Function: of_Addtoolbarbuttons (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value DataStore ads //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc blob lb IF NOT ISVALID(ads) THEN RETURN ads.GetFullState(lb) ids_buttons.SetFullState(lb) IF #CacheToolbarDefinition THEN IF inv_tb.of_Buildfromcache(this, istr_buttons) THEN RETURN END IF inv_tb.of_AddButtons(lnv_svc, & this, & istr_buttons) of_Buildtoolbar() end subroutine public subroutine of_setdimensions (readonly integer ai_width, readonly integer ai_height);//=========================================================================== // Function: of_Setdimensions (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly Integer ai_width // readonly Integer ai_height //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== ii_width = ai_width ii_height = ai_height IF #FixedWidth THEN #ResizeObjects = FALSE this.Resize(ai_width, ai_height) dw_1.Y = -4 dw_1.Width = ai_width + 24 ELSE this.Resize(this.width, ai_height) END IF end subroutine public subroutine of_refresh ();//=========================================================================== // Function: of_Refresh (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== IF NOT ib_suspendsize THEN this.Resize(ii_width, ii_height) parent.TriggerEvent("resize") END IF IF NOT ib_suspenddraw THEN SetRedraw(TRUE) end subroutine public subroutine of_suspenddraw ();//=========================================================================== // Function: of_Suspenddraw (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== SetRedraw(FALSE) ib_suspenddraw = TRUE end subroutine public subroutine of_resumedraw ();//=========================================================================== // Function: of_Resumedraw (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== ib_suspenddraw = FALSE of_refresh() end subroutine public subroutine of_suspendresize ();//=========================================================================== // Function: of_Suspendresize (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== super::of_suspendresize() ib_suspendsize = TRUE end subroutine public subroutine of_resumeresize ();//=========================================================================== // Function: of_Resumeresize (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== super::of_resumeresize() ib_suspendsize = FALSE this.Resize(ii_width, ii_height) end subroutine public function long of_getindexfromid (readonly string as_buttonid);//=========================================================================== // Function: of_Getindexfromid (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly String as_buttonid //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== long ll_count, n, ll_ret ll_ret = CRet.FAILURE ll_count = UPPERBOUND(istr_buttons) FOR n = 1 to ll_count IF istr_buttons[n].id = as_buttonid THEN ll_ret = n EXIT END IF NEXT RETURN ll_ret end function public function long of_makemenuitems (ref str_menuitem astr_items[]);//=========================================================================== // Function: of_Makemenuitems (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // reference str_menuitem astr_items[] //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== long ll_count, n, ll_row, ll_upper string ls_tmp n_svc_mgr lnv_svc n_svc_isempty lnv_check lnv_svc.of_LoadSvc(lnv_check, CSvc.ISEMPTY) ll_upper = UPPERBOUND(astr_items) ll_count = ids_buttons.RowCount() FOR n = 1 to ll_count ll_row ++ //skip dropwhole IF ids_buttons.GetItemNumber(ll_row, "dropwhole") = 1 THEN ll_count -- n -- CONTINUE END IF //skip dataobjects TRY IF NOT lnv_check.of_IsEmpty(ids_buttons.GetItemString(ll_row, "dwobject")) THEN ll_count -- n -- //check if between dividers IF n < ll_count AND n > 1 THEN IF ids_buttons.GetItemNumber(ll_row + 1, "divider") = 1 THEN ll_count -- n -- END IF END IF CONTINUE END IF CATCH (RunTimeError ex) //swallow END TRY IF ids_buttons.GetItemNumber(ll_row, "divider") = 1 THEN astr_items[ll_upper + n].menutext = "-" ELSE ls_tmp = ids_buttons.GetItemString(ll_row, "id") //skip not visible // IF NOT of_isbuttonvisible(ls_tmp) THEN // ll_count -- // n -- // CONTINUE // END IF astr_items[ll_upper + n].data = ls_tmp astr_items[ll_upper + n].disable = NOT of_IsButtonEnabled(ls_tmp) astr_items[ll_upper + n].checked = of_IsButtonChecked(ls_tmp) ls_tmp = ids_buttons.GetItemString(ll_row, "text") IF lnv_check.of_IsEmpty(ls_tmp) THEN & ls_tmp = ids_buttons.GetItemString(ll_row, "tooltip") astr_items[ll_upper + n].menutext = ls_tmp astr_items[ll_upper + n].subscriber = this astr_items[ll_upper + n].eventname = "ke_routemenu" END IF NEXT RETURN ll_count end function public subroutine of_popmenu (readonly str_menuitem astr[], readonly integer ai_x, readonly integer ai_y);//=========================================================================== // Function: of_Popmenu (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly str_menuitem astr[] // readonly Integer ai_x // readonly Integer ai_y //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc n_svc_menu lnv_m lnv_svc.of_LoadSvc(lnv_m, CSvc.MENU) lnv_m.of_createmenu(astr, ai_x, ai_y) end subroutine public subroutine of_popmenu (readonly integer ai_x, readonly integer ai_y);//=========================================================================== // Function: of_Popmenu (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // readonly Integer ai_x // readonly Integer ai_y //--------------------------------------------------------------------------- // Returns: (none) //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== str_menuitem lstr[] of_MakeMenuitems(lstr) of_PopMenu(lstr, ai_x, ai_y) end subroutine public function str_theme of_gettheme ();//=========================================================================== // Function: of_Gettheme (public ) // Object: u_dwtoolbar //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // //--------------------------------------------------------------------------- // Returns: str_theme //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== RETURN istr_theme end function public subroutine of_tooltips (readonly boolean ab_tooltips);#Tooltips = ab_tooltips IF #Tooltips THEN n_svc_mgr lnv_svc n_svc_tooltip lnv_tip lnv_svc.of_loadsvc(lnv_tip, CSvc.TOOLTIP) ToolTipID = lnv_tip.of_addtool(lnv_svc, dw_1, DEFAULT_TIP, 0, FALSE, FALSE) END IF end subroutine on u_dwtoolbar.create int iCurrent call super::create this.label=create label this.dw_1=create dw_1 this.ids_buttons=create ids_buttons iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.label this.Control[iCurrent+2]=this.dw_1 end on on u_dwtoolbar.destroy call super::destroy destroy(this.label) destroy(this.dw_1) destroy(this.ids_buttons) end on event constructor;call super::constructor;this.Border = FALSE label.Visible = FALSE end event event ke_preopen;call super::ke_preopen;n_svc_mgr lnv_svc n_svc_resource lnv_res ulong ll_himl //load pooled dw toolbar service lnv_svc.of_LoadSvc(inv_tb, DWTB_SVC) //check for standardimages IF #StandardImages THEN lnv_svc.of_LoadSvc(lnv_res, CSvc.RESOURCE) IF #LargeIcons THEN ll_himl = lnv_res.of_GetStandardImageList24(lnv_svc) ELSE ll_himl = lnv_res.of_GetStandardImageList16(lnv_svc) END IF of_SetImageList(ll_himl) ELSE IF #ImageList <> CString.EMPTY THEN lnv_svc.of_LoadSvc(lnv_res, CSvc.RESOURCE) IF #LargeIcons THEN ll_himl = lnv_res.of_GetDWImageList(lnv_svc, #ImageList, 24) ELSE ll_himl = lnv_res.of_GetDWImageList(lnv_svc, #ImageList, 16) END IF IF ll_himl > 0 THEN of_SetImageList(ll_himl) END IF END IF END IF this.of_SetDataObject(this.#DataObject) of_SetToolbarButtons(#ToolbarDataObject) of_Tooltips(#Tooltips) end event event ke_constructcomplete;IF #FixedWidth THEN this.#SizeOrder = -1 end event event destructor;call super::destructor;IF #ToolTips THEN n_svc_mgr lnv_svc n_svc_tooltip lnv_tip lnv_svc.of_LoadSvc(lnv_tip, CSvc.TOOLTIP) //release regular tooltips lnv_tip.of_remove(lnv_svc, this, ToolTipID) END IF end event type label from u_st within u_dwtoolbar integer x = 128 integer y = 48 integer width = 658 integer weight = 700 long backcolor = 1073741824 string text = "Datawindow Toolbar" alignment alignment = center! end type type dw_1 from u_dw within u_dwtoolbar event ke_lbuttondown pbm_lbuttondown event ke_lbuttonup pbm_dwnlbuttonup integer width = 942 integer taborder = 10 boolean border = false boolean #dock = true long #docktype = 1 long #dockpadtop = -4 end type event ke_lbuttondown;//=========================================================================== // Event : Ke_lbuttondown (public ) // Object: dw_1 //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value UnsignedLong flags // value Integer xpos // value Integer ypos //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== MouseDown = TRUE IF HOT_BUTTON = CString.EMPTY THEN RETURN //show pressed state for buttons n_svc_mgr lnv_svc n_svc_dwtoolbar lnv_tb long n string ls, ls_obj ls_obj = GetObjectAtPointer() ls_obj = MID(ls_obj, 1, POS(ls_obj, "~t") - 1) lnv_svc.of_LoadSvc(lnv_tb, DWTB_SVC) ls = lnv_tb.of_GetButtonID(HOT_BUTTON) n = lnv_tb.of_indexfrombuttonid(ls, istr_buttons) lnv_tb.of_Makepressed(parent, ls, n, istr_buttons) IF istr_buttons[n].DropDown THEN integer lix, liy IF NOT istr_buttons[n].DropWhole THEN IF ls_obj <> lnv_tb.of_GetButtonBorder2Name(ls) AND & ls_obj <> lnv_tb.of_GetButtonArrowName(ls) THEN RETURN END IF END IF lnv_tb.of_GetDropCoordinates(parent, ls, lix, liy) //parent.EVENT ke_dropdown(istr_buttons[n].id, istr_buttons[n].Text, istr_buttons[n].Data, lix, liy) parent.EVENT ke_dropdowncoordinate(n, lix, liy) MouseDown = FALSE lnv_tb.of_dwmousemove(lnv_svc, parent, istr_buttons, PointerX(), PointerY(), ls_obj, MouseDown, MouseCaptured, HOT_BUTTON) END IF end event event ke_lbuttonup;//=========================================================================== // Event : Ke_lbuttonup (public ) // Object: dw_1 //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value Integer xpos // value Integer ypos // value Long row // value DWObject dwo //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc n_svc_dwtoolbar lnv_tb MouseDown = FALSE lnv_svc.of_LoadSvc(lnv_tb, DWTB_SVC) string ls, ls_id ls = STRING(dwo.name) IF lnv_tb.of_IsButton(ls) THEN //show normal state for buttons long n ls_id = lnv_tb.of_GetButtonid(ls) n = lnv_tb.of_indexfrombuttonid(ls_id, istr_buttons) lnv_tb.of_MakeHot(parent, ls_id, n, istr_buttons) IF istr_buttons[n].Enabled AND NOT istr_buttons[n].Divider THEN IF NOT istr_buttons[n].DropDown THEN ReleaseCapture() MouseCaptured = FALSE parent.EVENT ke_buttonclicked(istr_buttons[n].id, istr_buttons[n].Text, istr_buttons[n].Data) HOT_BUTTON = CString.EMPTY lnv_tb.of_dwmousemove(lnv_svc, parent, istr_buttons, PointerX(), PointerY(), dwo, MouseDown, MouseCaptured, HOT_BUTTON) ELSE integer lix, liy IF NOT istr_buttons[n].DropWhole THEN IF ls <> lnv_tb.of_GetButtonBorder2Name(ls_id) AND & ls <> lnv_tb.of_GetButtonArrowName(ls_id) THEN parent.EVENT ke_buttonclicked(istr_buttons[n].id, istr_buttons[n].Text, istr_buttons[n].Data) RETURN END IF END IF //pop menu only if arrow is clicked // lnv_tb.of_GetDropCoordinates(parent, ls_id, lix, liy) // parent.EVENT ke_dropdown(istr_buttons[n].id, istr_buttons[n].Text, istr_buttons[n].Data, lix, liy) // lnv_tb.of_dwmousemove(lnv_svc, parent, istr_buttons, PointerX(), PointerY(), dwo, MouseDown, MouseCaptured, HOT_BUTTON) END IF END IF ELSE lnv_tb.of_dwmousemove(lnv_svc, parent, istr_buttons, xpos, ypos, dwo, MouseDown, MouseCaptured, HOT_BUTTON) END IF end event event itemchanged;call super::itemchanged;parent.EVENT ke_itemchanged(row, dwo, data) end event event ke_dwmousemove;call super::ke_dwmousemove;//=========================================================================== // Event : Ke_dwmousemove (public ) // Object: dw_1 //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value Integer xpos // value Integer ypos // value Long row // value DWObject dwo //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== n_svc_mgr lnv_svc n_svc_dwtoolbar lnv_tb IF ii_lastx <> xpos OR ii_lasty <> ypos THEN ii_lastx = xpos ii_lasty = ypos lnv_svc.of_LoadSvc(lnv_tb, DWTB_SVC) lnv_tb.of_DWMouseMove(lnv_svc, & parent, & istr_buttons, & xpos, & ypos, & dwo, & MouseDown, & MouseCaptured, & HOT_BUTTON) END IF IF #ToolTips THEN IF dwToolTip = DEFAULT_TIP THEN RETURN CRet.NO_ACTION n_svc_tooltip lnv_tip long BalloonToolTipID lnv_svc.of_LoadSvc(lnv_tip, CSvc.TOOLTIP) lnv_tip.of_dwmousemove(lnv_svc, this, dwo, dwToolTip, LastDWO, BalloonToolTipID, ToolTipID, HitTest, IsBalloon) END IF end event event ke_mousemove;call super::ke_mousemove;//=========================================================================== // Event : Ke_mousemove (public ) // Object: dw_1 //--------------------------------------------------------------------------- // Description: // Note: //--------------------------------------------------------------------------- // Parameters: // value UnsignedLong flags // value Integer xpos // value Integer ypos //--------------------------------------------------------------------------- // Returns: Long //--------------------------------------------------------------------------- // Author: (Yeyi) Gabriel B. Abulencia //=========================================================================== IF #ToolTips And HitTest THEN n_svc_mgr lnv_svc n_svc_isempty lnv_check n_svc_tooltip lnv_tip IF dwToolTip = DEFAULT_TIP THEN RETURN CRet.NO_ACTION //load service lnv_Svc.of_LoadSvc(lnv_check, CSvc.ISEMPTY) IF lnv_check.of_isempty(dwTooltip) THEN RETURN CRet.NO_ACTION lnv_Svc.of_LoadSvc(lnv_tip, CSvc.TOOLTIP) lnv_tip.of_relaymsg(lnv_svc, this, IsBalloon) END IF end event type ids_buttons from n_ds within u_dwtoolbar descriptor "pb_nvo" = "true" end type on ids_buttons.create call super::create end on on ids_buttons.destroy call super::destroy end on
- Sources
- Kodigo
- OpenExplorer
- u_dwtoolbar.sru
File: u_dwtoolbar.sru
Size: 45687
Date: Mon, 07 Apr 2008 21:31:54 +0200
Size: 45687
Date: Mon, 07 Apr 2008 21:31:54 +0200
- u_base_container u_dwtoolbar(sru)
- constructor
- destructor
- ke_buttonclicked(readonly string buttonid, readonly string buttontext, readonly string buttondata)
- ke_constructcomplete
- ke_dropdown(readonly string buttonid, readonly string buttontext, readonly string buttondata, readonly integer popx, readonly integer popy)
- ke_dropdowncoordinate(readonly integer buttonindex, readonly integer popx, readonly integer popy)
- ke_itemchanged(readonly long row, readonly dwobject dwo, readonly string data)
- ke_menuitemclicked(readonly string buttonid)
- ke_preopen
- ke_routemenu()
- of_addtoolbarbuttons (datastore ads)
- of_buildtoolbar ()
- of_buttoncheck (readonly string as_buttonid, readonly boolean ab_check)
- of_buttonenable (readonly string as_buttonid, readonly boolean ab_enable)
- of_getbuttons (ref str_dwtoolbarbutton astr[]) returns long
- of_getimagelist () returns unsignedlong
- of_getindexfromid (readonly string as_buttonid) returns long
- of_gettheme () returns str_theme
- of_init ()
- of_isbuttonchecked (readonly string as_buttonid) returns boolean
- of_isbuttonenabled (readonly string as_buttonid) returns boolean
- of_largeicons ()
- of_makemenuitems (ref str_menuitem astr_items[]) returns long
- of_popmenu (readonly integer ai_x, readonly integer ai_y)
- of_popmenu (readonly str_menuitem astr[], readonly integer ai_x, readonly integer ai_y)
- of_refresh ()
- of_resumedraw ()
- of_resumeresize ()
- of_setdataobject (readonly string as_dataobject)
- of_setdimensions (readonly integer ai_width, readonly integer ai_height)
- of_setimagelist (readonly unsignedlong al_himl)
- of_settheme (readonly integer ai_theme)
- of_settoolbarbuttons (datastore ads)
- of_settoolbarbuttons (string as_dataobject)
- of_smallicons ()
- of_suspenddraw ()
- of_suspendresize ()
- of_tooltips (readonly boolean ab_tooltips)
- u_st label
- u_dw dw_1
- n_ds ids_buttons