Fancy Property Box

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4953
Joined: Sun Apr 12, 2009 6:27 am

Fancy Property Box

Post by RASHAD »

Adapt it for your needs

Code: Select all

LoadFont(0,"Marlett",12,#PB_Font_Bold)
LoadFont(1,"Tahoma",10,#PB_Font_HighQuality)

CreateImage(0,24,24)
StartDrawing(ImageOutput(0))
   DrawingMode(#PB_2DDrawing_Outlined)
    Box(2,2,20,19,$FFFFFF)
   DrawingMode(#PB_2DDrawing_Transparent)
      DrawingFont(FontID(0))
      DrawText(4,4,"5",$FFFFFF)
StopDrawing()

CreateImage(1,24,24)
StartDrawing(ImageOutput(1))
   DrawingMode(#PB_2DDrawing_Outlined)
    Box(2,2,20,19,$FFFFFF)
   DrawingMode(#PB_2DDrawing_Transparent)
      DrawingFont(FontID(0))
      DrawText(4,4,"6",$FFFFFF)
StopDrawing()

Procedure EnumFontProc(*ef.ENUMLOGFONT, *lpntm.NEWTEXTMETRIC, FontType, lParam)
  AddGadgetItem(5,-1,PeekS(@*ef\elfLogFont\lfFaceName[0]))
  ProcedureReturn 1 
EndProcedure 


Procedure ImageCreate(No,Text$,bColor,fColor)
CreateImage(No,310,24)
StartDrawing(ImageOutput(No))
    DrawingMode(#PB_2DDrawing_Gradient)
      BackColor(bColor);$00FFFF)
      FrontColor(fColor);$1123FE)      
      LinearGradient(0, 0, 200, 200)
      Box(0,0,286,24)
    DrawingMode(#PB_2DDrawing_Transparent)
      DrawText(30,4,Text$,0,$FFFFFF)
  StopDrawing()
EndProcedure 

OpenWindow(0,0,0,350,435,"Property Box",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Tool)

ScrollAreaGadget(0, 10, 10, 330,415, 320, 410, 10,#PB_ScrollArea_Flat)

  ;Group One
  ContainerGadget(1,8,10,310,145,#PB_Container_Flat)
  SetGadgetColor(1,#PB_Gadget_BackColor,$D1FEFE)  
  ImageGadget(2,0,0,24,24,ImageID(0))
  ImageCreate(3,"Font Setting",$00FFFF,$1123FE)  
  ImageGadget(3,24,0,320,24,ImageID(3)) 
  TextGadget(4,10,30,120,24,"Font Name",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  ComboBoxGadget(5,140,30,160,24)
  TextGadget(6,10,58,120,24,"Font Size",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  SpinGadget(7,260,60,40,20,12,48,#PB_Spin_Numeric)
  SetGadgetState(7,12)
  TextGadget(8,10,86,120,24,"Font Style",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  ComboBoxGadget(9,140,86,160,24)
  AddGadgetItem(9,-1,"Bold")
  SetGadgetItemData(9, 0, #PB_Font_Bold)
  AddGadgetItem(9,-1,"Italic")
  SetGadgetItemData(9, 1, #PB_Font_Italic)
  AddGadgetItem(9,-1,"Underline")
  SetGadgetItemData(9, 2, #PB_Font_Underline)
  AddGadgetItem(9,-1,"StrikeOut")
  SetGadgetItemData(9, 3, #PB_Font_StrikeOut)
  AddGadgetItem(9,-1,"HighQuality")
  SetGadgetItemData(9, 4, #PB_Font_HighQuality)
  TextGadget(10,10,114,120,24,"Font Color",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  ButtonGadget(11,220,114,80,24,"COLOR")
  CloseGadgetList()
  
  ;Group Two
  ContainerGadget(20,8,160,310,90,#PB_Container_Flat)
  SetGadgetColor(20,#PB_Gadget_BackColor,$D1FEFE)
  ImageGadget(21,0,0,24,24,ImageID(0))
  ImageCreate(22,"Language Setting",$00FFFF,$0FF828) 
  ImageGadget(22,24,0,320,24,ImageID(22))  ;
  TextGadget(23,10,30,120,24,"Default Language",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  TextGadget(24,10,58,120,24,"Oem Language",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  ;TextGadget(15,10,82,120,24,"Font Color",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  ;TextGadget(16,10,110,120,24,"Font Style",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  CloseGadgetList()
  
  ;Group Three
  ContainerGadget(40,8,255,310,145,#PB_Container_Flat)  
  SetGadgetColor(40,#PB_Gadget_BackColor,$D1FEFE)
  ImageGadget(41,0,0,360,24,ImageID(0))
  ImageCreate(42,"Printer Setting",$00FFFF,$FC3519)
  ImageGadget(42,24,0,320,24,ImageID(42))
  TextGadget(43,10,30,120,24,"Printer Name",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  TextGadget(44,10,58,120,24,"Paper Size",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  TextGadget(45,10,86,120,24,"Paper Orientation",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  TextGadget(46,10,114,120,24,"No of Copies",#SS_CENTERIMAGE| #SS_CENTER); #WS_BORDER)
  CloseGadgetList()
  
CloseGadgetList()

ResizeGadget(20,#PB_Ignore,#PB_Ignore,#PB_Ignore,26)
ResizeGadget(40,#PB_Ignore,GadgetY(20)+GadgetHeight(20)+5,#PB_Ignore,26)
SetGadgetState(21,ImageID(1))
SetGadgetState(41,ImageID(1))

hWnd = GetDesktopWindow_() 
hDC = GetDC_(hWnd) 
EnumFonts_(hDC,0, @EnumFontProc(),@Fname$)
SetGadgetState(5, 11) 
ReleaseDC_ (hWnd, hDC)

For x = 1 To 46
   SetGadgetFont(x, FontID(1))
Next

Repeat
  Select WaitWindowEvent()
   Case #PB_Event_CloseWindow
         Quit = 1        
          
   Case #PB_Event_Gadget 
    Select EventGadget() 
      Case 2
            Run_1 ! 1
            If Run_1 = 1
                SetGadgetState(2,ImageID(1)) 
                ResizeGadget(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,26)
                ResizeGadget(20,#PB_Ignore,GadgetY(1)+GadgetHeight(1)+5,#PB_Ignore,#PB_Ignore)
                ResizeGadget(40,#PB_Ignore,GadgetY(20)+GadgetHeight(20)+5,#PB_Ignore,#PB_Ignore)
            Else
                SetGadgetState(2,ImageID(0)) 
                ResizeGadget(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,145)
                ResizeGadget(20,#PB_Ignore,GadgetY(1)+GadgetHeight(1)+5,#PB_Ignore,#PB_Ignore)
                ResizeGadget(40,#PB_Ignore,GadgetY(20)+GadgetHeight(20)+5,#PB_Ignore,#PB_Ignore)
            EndIf

            
      Case 9
            If IsFont(2)
                FreeFont(2)
            EndIf
            LoadFont(2,"Arial",10,GetGadgetItemData(9, GetGadgetState(9)))
            SetGadgetFont(8,FontID(2))
                
           
      Case 11
             Color.l = ColorRequester()
             SetGadgetColor(10, #PB_Gadget_FrontColor, Color)


      Case 21
            Run_2 ! 1
            If Run_2 = 0
                SetGadgetState(21,ImageID(1)) 
                ResizeGadget(20,#PB_Ignore,#PB_Ignore,#PB_Ignore,26)
                ResizeGadget(40,#PB_Ignore,GadgetY(20)+GadgetHeight(20)+5,#PB_Ignore,#PB_Ignore)
            Else
                SetGadgetState(21,ImageID(0)) 
                ResizeGadget(20,#PB_Ignore,#PB_Ignore,#PB_Ignore,90)
                ResizeGadget(40,#PB_Ignore,GadgetY(20)+GadgetHeight(20)+5,#PB_Ignore,#PB_Ignore)
            EndIf
            
      Case 41
            Run_3 ! 1
            If Run_3 = 0
                SetGadgetState(41,ImageID(1)) 
                ResizeGadget(40,#PB_Ignore,#PB_Ignore,#PB_Ignore,26)
            Else
                SetGadgetState(41,ImageID(0)) 
                ResizeGadget(40,#PB_Ignore,#PB_Ignore,#PB_Ignore,145)
            EndIf
            
       

    EndSelect     
  EndSelect 
Until Quit = 1

Edit :Code Updated
Last edited by RASHAD on Fri May 25, 2012 12:35 pm, edited 1 time in total.
Egypt my love
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Fancy Property Box

Post by rsts »

Very impressive!

Thanks for sharing :D
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Fancy Property Box

Post by Kwai chang caine »

Niiiiiiiiice :D
Thanks a lot RASHAD 8)
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4953
Joined: Sun Apr 12, 2009 6:27 am

Re: Fancy Property Box

Post by RASHAD »

Hi @rsts
Long time no see
Thanks mate

Thanks @KCC twice :mrgreen:


First post updated
Egypt my love
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: Fancy Property Box

Post by electrochrisso »

Thanks for another fine example. 8)
Vote 1, RASHAD for new leader of Egypt. :)
PureBasic! Purely the best 8)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4953
Joined: Sun Apr 12, 2009 6:27 am

Re: Fancy Property Box

Post by RASHAD »

:mrgreen:
I am afraid that it is the only vote I can get :D
Egypt my love
Post Reply