October 17, 2021, 10:01:59

Author Topic: [bb] Labox Function by Apollonius [ 1+ years ago ]  (Read 776 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Labox Function by Apollonius [ 1+ years ago ]
« on: June 29, 2017, 00:28:40 »
Title : Labox Function
Author : Apollonius
Posted : 1+ years ago

Description : Well I created this function to help create "Labox" easly.

UPDATED: FIXED ERRORS.

Code: [Select]
----- Code To Create a Labox --

CreateLabox( b_text$, b_x, b_y, b_width, b_height, lab_width, lab_style, b_parent)

---- To Auto Ajust
SetGadgetLayout labox,1,1,1,1
-------------------------------
b_text$     is for the "Label" text
b_x         its X Location
b_y         its Y Location
b_width     its width
b_height    its height
b_parent    its parent
lab_width   its the label Text width in this direction ->>
lab_style   0 - No border (default) 1 - Flat border 2 - No border? 3 - 3d sunken border

-----------The Function---------------

Function CreateLabox(b_text$,b_x,b_y,b_width,b_height,lab_width,lab_style,b_parent)
; Labox stand for Labeled Box :D
Local pan = CreatePanel(b_x, b_y, b_width,b_height, b_parent)
temp = CreatePanel( 0,5, b_width, 4, pan, 1)             ; Top
SetGadgetLayout temp,1,1,1,0
temp = CreatePanel( 0, 5+2, 4, b_height-3, pan, 1)        ; Left
SetGadgetLayout temp,1,0,1,1
temp = CreatePanel( 0, b_height-2, b_width,4, pan, 1)   ; Bottom
SetGadgetLayout temp,1,1,0,1
temp = CreatePanel( b_width-3, 5, 4, b_height, pan, 1)  ; Right
SetGadgetLayout temp,0,1,1,1
temp = CreateLabel( b_text$, 10, 0, lab_width, 16, pan, lab_style)   ; Text
SetGadgetLayout temp,1,0,1,0
Return pan
End Function
--------------------------------

Just put this and you can access it, anywhere, anytime :) [/i]

Code :
Code: BlitzBasic
  1. ;Heres an example:
  2. ;------------------
  3. ; Create a window and some labels
  4. win=CreateWindow("Labox Test",100,100,300,250);,0),17)
  5.  
  6. labox = CreateLabox(" Label",5,5,160,100,30,0,win) ; Labox Function.
  7.  
  8. SetGadgetLayout labox,1,1,1,1
  9.  
  10. Repeat
  11. Until WaitEvent()=$803
  12. End ; bye!  
  13.  
  14. Function CreateLabox(b_text$,b_x,b_y,b_width,b_height,lab_width,lab_style,b_parent)
  15.         ; Labox stand for Labeled Box :D
  16.         Local pan = CreatePanel(b_x, b_y, b_width,b_height, b_parent)
  17.         temp = CreatePanel( 0,5, b_width, 4, pan, 1)             ; Top
  18.         SetGadgetLayout temp,1,1,1,0
  19.         temp = CreatePanel( 0, 5+2, 4, b_height-3, pan, 1)        ; Left
  20.         SetGadgetLayout temp,1,0,1,1
  21.         temp = CreatePanel( 0, b_height-2, b_width,4, pan, 1)   ; Bottom
  22.         SetGadgetLayout temp,1,1,0,1
  23.         temp = CreatePanel( b_width-3, 5, 4, b_height, pan, 1)  ; Right
  24.         SetGadgetLayout temp,0,1,1,1
  25.         temp = CreateLabel( b_text$, 10, 0, lab_width, 16, pan, lab_style)   ; Text
  26.         SetGadgetLayout temp,1,0,1,0
  27.         Return pan
  28. End Function
  29. ;-----------------------
  30. ;I hope this is helpful for you, until BlitzPlus can do it on its own.


Comments :


TAS(Posted 1+ years ago)

 Very Clever, and useful.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal