$PBExportHeader$u_st_gradient.sru forward global type u_st_gradient from u_paint end type type st_label from statictext within u_st_gradient end type type str_colors from structure within u_st_gradient end type end forward type str_colors from structure long startcolor long endcolor long fontcolor end type global type u_st_gradient from u_paint event ke_drawgradientbackground ( ref n_svc_mgr anv_svc, readonly unsignedlong hdc ) event ke_drawtext ( ref n_svc_mgr anv_svc, readonly unsignedlong hdc, readonly boolean icondrawn ) event ke_drawicon ( ref n_svc_mgr anv_svc, readonly unsignedlong hdc ) event type integer ke_getpadright ( ) event ke_flashicon ( ) st_label st_label end type global u_st_gradient u_st_gradient type prototypes end prototypes type variables Public: boolean #UseTheme string #Text = "Edit Text" Alignment #TextAlignement = left! string #FontName = "Tahoma" integer #FontSize = 8 boolean #FontBold boolean #CenterVertical = TRUE integer #PadText = 8 long #FontColor = -1 long #StartColor = -1, #EndColor = -1 Boolean #VerticalGradient Boolean #InvertGradient Private: CONSTANT string COLOR_SVC = "n_svc_color" integer ii_iconsize ulong iul_font, iul_oldfont, iul_hdc ulong iul_style ulong iul_imagelist long il_iconindex boolean ib_aligniconright str_colors istr_colors[] n_timing inv_timer integer FLASHCOUNT integer ii_flash_ctr boolean SUSPEND_DRAW, IS_FLASHING, FONT_CHANGED CONSTANT DOUBLE TIMER = 0.5 CONSTANT ulong DT_TOP = 0 //0x00000000 CONSTANT ulong DT_LEFT = 0 //0x00000000 CONSTANT ulong DT_CENTER = 1 //0x00000001 CONSTANT ulong DT_RIGHT = 2 //0x00000002 CONSTANT ulong DT_VCENTER = 4 //0x00000004 CONSTANT ulong DT_BOTTOM = 8 //0x00000008 CONSTANT ulong DT_WORDBREAK = 16 //0x00000010 CONSTANT ulong DT_SINGLELINE = 32 //0x00000020 CONSTANT ulong DT_EXPANDTABS = 64 //0x00000040 CONSTANT ulong DT_TABSTOP = 128 //0x00000080 CONSTANT ulong DT_NOCLIP = 256 //0x00000100 CONSTANT ulong DT_EXTERNALLEADING = 512 //0x00000200 CONSTANT ulong DT_CALCRECT = 1024 //0x00000400 CONSTANT ulong DT_NOPREFIX = 2048 //0x00000800 CONSTANT ulong DT_INTERNAL = 4096 //0x00001000 CONSTANT ulong DT_EDITCONTROL = 8192 //0x00002000 CONSTANT ulong DT_PATH_ELLIPSIS = 16384 //0x00004000 CONSTANT ulong DT_END_ELLIPSIS = 32768 //0x00008000 CONSTANT ulong DT_MODIFYSTRING = 65536 //0x00010000 CONSTANT ulong DT_RTLREADING = 131072 //0x00020000 CONSTANT ulong DT_WORD_ELLIPSIS = 262144 //0x00040000 CONSTANT ulong DT_NOFULLWIDTHCHARBREAK = 524288 //0x00080000 CONSTANT ulong DT_HIDEPREFIX = 1048576 //0x00100000 CONSTANT ulong DT_PREFIXONLY = 2097152 //0x00200000 end variables forward prototypes public subroutine of_setcolors (readonly long al_startcolor, readonly long al_endcolor) public subroutine of_setcolor (readonly long al_endcolor) public subroutine of_settext (readonly string as_text) public subroutine of_getcolors (ref long al_startcolor, ref long al_endcolor) public subroutine of_centervertical (readonly boolean ab_center) protected subroutine of_createfont () public subroutine of_setfontbold (readonly boolean ab_bold) public subroutine of_setfontsize (readonly integer ai_fontsize) public subroutine of_setfontname (readonly string as_fontname) public subroutine of_setverticalgradient (readonly boolean ab_vertical) public subroutine of_showborder (readonly boolean ab_show) public function long of_getfontcolor () public subroutine of_seticon (readonly long al_iconindex, readonly boolean ab_alignright) public subroutine of_setimagelist (readonly unsignedlong aul_himl, readonly integer ai_iconsize) public subroutine of_setfontcolor (long al_textcolor) public function boolean of_isiconalignright () public function long of_addcolortheme (readonly long al_startcolor, readonly long al_endcolor, readonly long al_fontcolor) public function integer of_setcolortheme (readonly long al_index) public subroutine of_cancelflash () public subroutine of_flashicon (readonly integer ai_numflash) public subroutine of_flashicon () public subroutine of_invertgradient (readonly boolean ab_invert) public subroutine of_suspenddraw (readonly boolean ab_suspend) public function long of_addcolortheme (readonly long al_endcolor, readonly long al_fontcolor) public subroutine of_refresh () public subroutine of_updatetheme () public subroutine of_settheme (readonly str_theme astr) end prototypes event ke_drawgradientbackground(ref n_svc_mgr anv_svc, readonly unsignedlong hdc);n_svc_color lnv_color anv_svc.of_LoadSvc(lnv_color, COLOR_SVC) IF NOT #InvertGradient THEN lnv_color.of_DrawGradient(hdc, istr_rect, #StartColor, #EndColor, #VerticalGradient) ELSE lnv_color.of_DrawGradient(hdc, istr_rect, #EndColor, #StartColor, #VerticalGradient) END IF end event event ke_drawtext(ref n_svc_mgr anv_svc, readonly unsignedlong hdc, readonly boolean icondrawn);IF #Text <> CString.EMPTY THEN RECT lstr_rect long ll_tmpfont SetBkMode(hdc, 1) SetTextColor(hdc, #FontColor) //set the font if new IF FONT_CHANGED THEN IF iul_oldfont > 0 THEN ll_tmpfont = SelectObject(hdc, iul_font) DeleteObject(ll_tmpfont) ELSE iul_oldfont = SelectObject(hdc, iul_font) iul_hdc = hdc END IF END IF lstr_rect = istr_rect //adjust bottom lstr_rect.bottom -= 1 CHOOSE CASE #textalignement CASE left! IF icondrawn AND NOT ib_aligniconright THEN lstr_rect.Left = ii_iconsize + (#PadText) ELSE lstr_rect.Left = #PadText END IF CASE right! IF icondrawn AND NOT ib_aligniconright THEN lstr_rect.Right -= ii_iconsize + (#PadText) ELSE lstr_rect.Right -= #PadText END IF END CHOOSE DrawText(hdc, #text, LEN(#text), lstr_rect, iul_style) SetBkMode(hdc, 2) // SelectObject(hdc, ll_oldfont) END IF end event event ke_drawicon(ref n_svc_mgr anv_svc, readonly unsignedlong hdc);n_svc_imagelist lnv_img long llx, lly, ll_pad //check for icon flashing IF IS_FLASHING THEN IF MOD(ii_flash_ctr, 2) > 0 THEN RETURN END IF ll_pad = 4 anv_svc.of_LoadSvc(lnv_img, CSvc.IMAGELIST) lly = (UnitsToPixels(uo_pbnicanvas.height, YUnitsToPixels!) - ii_iconsize) / 2 IF of_isiconalignright() THEN llx = UnitsToPixels(uo_pbnicanvas.width, XUnitsToPixels!) & - (ii_iconsize + ll_pad + EVENT ke_getpadright()) ELSE llx = ll_pad END IF lnv_img.of_Draw(iul_imagelist, il_iconindex - 1, hdc, llx, lly, 1) end event event type integer ke_getpadright();//override to adjust icon placement //when right aligned RETURN 0 end event event ke_flashicon();ii_flash_ctr ++ of_Refresh() //check if limited flash IF FLASHCOUNT > 0 THEN IF ii_flash_ctr >= (FLASHCOUNT * 2) THEN of_cancelflash() END IF end event public subroutine of_setcolors (readonly long al_startcolor, readonly long al_endcolor);#StartColor = al_startcolor #EndColor = al_endcolor IF #StartColor < 0 OR #EndColor < 0 THEN n_svc_mgr lnv_svc n_svc_color lnv_color // n_svc_theme lnv_t // str_theme lstr // // lnv_svc.of_LoadSvc(lnv_t, CSvc.THEME) // lstr = lnv_t.of_GetTheme() // // of_SetColors(lstr.panelgradientstart, lstr.panelgradientend) lnv_svc.of_LoadSvc(lnv_color, CSvc.COLOR) of_SetColor(lnv_color.of_GetSysColor(lnv_svc, lnv_color.ACTIVECAPTION)) ELSE of_Refresh() END IF end subroutine public subroutine of_setcolor (readonly long al_endcolor);n_svc_mgr lnv_svc n_svc_color lnv_color lnv_svc.of_LoadSvc(lnv_color, COLOR_SVC) #EndColor = al_endcolor #StartColor = lnv_color.of_LightenColor(.30, #EndColor) of_Refresh() end subroutine public subroutine of_settext (readonly string as_text);#Text = as_text of_Refresh() end subroutine public subroutine of_getcolors (ref long al_startcolor, ref long al_endcolor);al_startcolor = #StartColor al_endcolor = #EndColor end subroutine public subroutine of_centervertical (readonly boolean ab_center);#CenterVertical = TRUE of_CreateFont() of_Refresh() end subroutine protected subroutine of_createfont ();LogFont lstr_Lf uLong lul_Font n_svc_mgr lnv_svc n_svc_iif lnv_iif lnv_svc.of_loadsvc(lnv_iif, CSvc.IIF) lstr_Lf.lffacename = #FontName lstr_Lf.lfweight = lnv_iif.of_iif(#FontBold, 700, 400) lstr_Lf.lfheight = #FontSize * -1 lstr_Lf.lfPitchAndFamily = '1' lstr_Lf.lfClipPrecision = Char(2) lstr_Lf.lfOutPrecision = Char(1) lstr_Lf.lfQuality = Char(1) lstr_Lf.lfCharset = Char(1) IF iul_font <> 0 THEN DeleteObject(iul_font) iul_font = CreateFontIndirect( lstr_Lf ) //set style n_svc_bit lnv_bit long ll_tmp lnv_svc.of_LoadSvc(lnv_bit, CSvc.BIT) iul_style = DT_WORD_ELLIPSIS CHOOSE CASE #TextAlignement CASE left! ll_tmp = DT_LEFT CASE right! ll_tmp = DT_RIGHT CASE ELSE ll_tmp = DT_CENTER END CHOOSE iul_style = lnv_bit.of_BitwiseOR({iul_style, ll_tmp}) IF #CenterVertical THEN iul_style = lnv_bit.of_BitwiseOR({DT_VCENTER, DT_SINGLELINE, iul_style}) END IF FONT_CHANGED = TRUE end subroutine public subroutine of_setfontbold (readonly boolean ab_bold);#FontBold = ab_bold of_CreateFont() of_Refresh() end subroutine public subroutine of_setfontsize (readonly integer ai_fontsize);#FontSize = ai_fontsize of_CreateFont() of_Refresh() end subroutine public subroutine of_setfontname (readonly string as_fontname);#FontName = as_fontname of_CreateFont() of_Refresh() end subroutine public subroutine of_setverticalgradient (readonly boolean ab_vertical);#VerticalGradient = ab_vertical of_Refresh() end subroutine public subroutine of_showborder (readonly boolean ab_show);#ShowBorder = ab_show EVENT ke_resize(this.width, this.height) end subroutine public function long of_getfontcolor ();RETURN #FontColor end function public subroutine of_seticon (readonly long al_iconindex, readonly boolean ab_alignright);il_iconindex = al_iconindex ib_aligniconright = ab_alignright of_Refresh() end subroutine public subroutine of_setimagelist (readonly unsignedlong aul_himl, readonly integer ai_iconsize);iul_imagelist = aul_himl ii_iconsize = ai_iconsize end subroutine public subroutine of_setfontcolor (long al_textcolor);IF al_textcolor < 0 THEN //try to get window title text color al_textcolor = GetSysColor(CWin32.COLOR_CAPTIONTEXT) END IF #FontColor = al_textcolor of_Refresh() end subroutine public function boolean of_isiconalignright ();RETURN ib_aligniconright end function public function long of_addcolortheme (readonly long al_startcolor, readonly long al_endcolor, readonly long al_fontcolor);long n n = UPPERBOUND(istr_colors) + 1 istr_colors[n].startcolor = al_startcolor istr_colors[n].endcolor = al_endcolor istr_colors[n].fontcolor = al_fontcolor RETURN n end function public function integer of_setcolortheme (readonly long al_index);IF al_index > UPPERBOUND(istr_colors) THEN & RETURN CRet.FAILURE of_SuspendDraw(TRUE) of_SetColors(istr_colors[al_index].startcolor, istr_colors[al_index].endcolor) of_SetFontColor(istr_colors[al_index].fontcolor) of_SuspendDraw(FALSE) RETURN CRet.SUCCESS end function public subroutine of_cancelflash ();IS_FLASHING = FALSE IF ISVALID(inv_timer) THEN inv_timer.Stop() DESTROY inv_timer END IF of_Refresh() end subroutine public subroutine of_flashicon (readonly integer ai_numflash);//only when icon is shown IF iul_imagelist > 0 AND il_iconindex >= 0 THEN IF ISVALID(inv_timer) THEN DESTROY inv_timer inv_timer = CREATE n_timing FLASHCOUNT = ai_numflash IS_FLASHING = TRUE ii_flash_ctr = 0 inv_timer.EVENT ke_setparent(this, "ke_flashicon") inv_timer.start(TIMER) END IF end subroutine public subroutine of_flashicon ();of_flashicon(0) end subroutine public subroutine of_invertgradient (readonly boolean ab_invert);#InvertGradient = ab_invert of_Refresh() end subroutine public subroutine of_suspenddraw (readonly boolean ab_suspend);SUSPEND_DRAW = ab_suspend IF NOT SUSPEND_DRAW THEN of_Refresh() end subroutine public function long of_addcolortheme (readonly long al_endcolor, readonly long al_fontcolor);long n n_svc_mgr lnv_svc n_svc_color lnv_color lnv_svc.of_LoadSvc(lnv_color, COLOR_SVC) n = UPPERBOUND(istr_colors) + 1 istr_colors[n].startcolor = lnv_color.of_LightenColor(.30, al_endcolor) istr_colors[n].endcolor = al_endcolor istr_colors[n].fontcolor = al_fontcolor RETURN n end function public subroutine of_refresh ();IF SUSPEND_DRAW THEN RETURN uo_pbnicanvas.SetRedraw(TRUE) end subroutine public subroutine of_updatetheme ();n_svc_mgr lnv_svc n_svc_theme lnv_t lnv_svc.of_LoadSvc(lnv_t, CSvc.THEME) of_SetTheme(lnv_t.of_GetTheme()) end subroutine public subroutine of_settheme (readonly str_theme astr);#StartColor = astr.PanelGradientStart #EndColor = astr.PanelGradientEnd #FontColor = CColor.WHITE end subroutine on u_st_gradient.create int iCurrent call super::create this.st_label=create st_label iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.st_label end on on u_st_gradient.destroy call super::destroy destroy(this.st_label) end on event ke_preopen;call super::ke_preopen;st_label.Visible = FALSE of_SuspendDraw(TRUE) of_CreateFont() IF #UseTheme THEN of_UpdateTheme() ELSE of_SetFontColor(#FontColor) of_SetColors(#StartColor, #EndColor) END IF of_InvertGradient(#InvertGradient) of_SuspendDraw(FALSE) end event event ke_paint;call super::ke_paint;boolean lb_drawicon IF SUSPEND_DRAW THEN RETURN this.EVENT ke_drawgradientbackground(anv_svc, hdc) lb_drawicon = iul_imagelist > 0 AND il_iconindex >= 0 IF lb_drawicon THEN this.EVENT ke_drawicon(anv_svc, hdc) this.EVENT ke_drawtext(anv_svc, hdc, lb_drawicon) end event event destructor;call super::destructor;IF iul_oldfont <> 0 THEN SelectObject(iul_hdc, iul_oldfont) DeleteObject(iul_font) END IF IF iul_font <> 0 THEN DeleteObject(iul_font) IF ISVALID(inv_timer) THEN inv_timer.Stop() DESTROY inv_timer END IF end event type uo_pbnicanvas from u_paint`uo_pbnicanvas within u_st_gradient end type type st_label from statictext within u_st_gradient integer x = 165 integer y = 32 integer width = 402 integer height = 64 boolean bringtotop = true integer textsize = -8 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Gradient Text" boolean focusrectangle = false end type
- Sources
- Kodigo
- OpenExplorer
- u_st_gradient.sru
File: u_st_gradient.sru
Size: 15031
Date: Mon, 07 Apr 2008 21:31:58 +0200
Size: 15031
Date: Mon, 07 Apr 2008 21:31:58 +0200
- u_paint u_st_gradient(sru)
- ke_getpadright() returns integer
- destructor
- ke_drawgradientbackground(ref n_svc_mgr anv_svc, readonly unsignedlong hdc)
- ke_drawicon(ref n_svc_mgr anv_svc, readonly unsignedlong hdc)
- ke_drawtext(ref n_svc_mgr anv_svc, readonly unsignedlong hdc, readonly boolean icondrawn)
- ke_flashicon()
- ke_paint
- ke_preopen
- of_addcolortheme (readonly long al_endcolor, readonly long al_fontcolor) returns long
- of_addcolortheme (readonly long al_startcolor, readonly long al_endcolor, readonly long al_fontcolor) returns long
- of_cancelflash ()
- of_centervertical (readonly boolean ab_center)
- of_createfont ()
- of_flashicon ()
- of_flashicon (readonly integer ai_numflash)
- of_getcolors (ref long al_startcolor, ref long al_endcolor)
- of_getfontcolor () returns long
- of_invertgradient (readonly boolean ab_invert)
- of_isiconalignright () returns boolean
- of_refresh ()
- of_setcolor (readonly long al_endcolor)
- of_setcolors (readonly long al_startcolor, readonly long al_endcolor)
- of_setcolortheme (readonly long al_index) returns integer
- of_setfontbold (readonly boolean ab_bold)
- of_setfontcolor (long al_textcolor)
- of_setfontname (readonly string as_fontname)
- of_setfontsize (readonly integer ai_fontsize)
- of_seticon (readonly long al_iconindex, readonly boolean ab_alignright)
- of_setimagelist (readonly unsignedlong aul_himl, readonly integer ai_iconsize)
- of_settext (readonly string as_text)
- of_settheme (readonly str_theme astr)
- of_setverticalgradient (readonly boolean ab_vertical)
- of_showborder (readonly boolean ab_show)
- of_suspenddraw (readonly boolean ab_suspend)
- of_updatetheme ()
- u_paint`uo_pbnicanvas uo_pbnicanvas
- statictext st_label