khchen / wNim

Nim's Windows GUI Framework
MIT License
319 stars 17 forks source link

How to make the rebar controls align to left #80

Closed leeooox closed 3 years ago

leeooox commented 3 years ago

rebar_test_gui As the demo gui, is there any way to make the combobox align to left (make it close to the left side icons)? I have looked up the document, but seems no method/properties found. Will you please help, thanks?

This is my code


import wNim/[wApp, wFrame, wPanel, wButton, wTextCtrl, wStaticText, wComboBox,
    wStaticBox, wIcon, wSplitter, wToolBar, wImage, 
    wBitmap,wRebar]
import wZeeGrid

type
  MenuID = enum
    idOpen = wIdUser, idSave, idSaveAs, idComPort, idTool5, idExit

let app = App()
let frame = Frame(title="Rebar and wZeeGrid test GUI",size=(1024,600))

let splitter = Splitter(frame, style=wSpVertical or wSpButton, size=(4, 4))
let rebar = Rebar(frame)
let toolbar = ToolBar(rebar)

# tool bar
const resource1 = staticRead(r"icons/FileOpen.ico")
const resource2 = staticRead(r"icons/FileSave.ico")
const resource3 = staticRead(r"icons/FileSaveAs.ico")

let img1 = Image(resource1).scale(24,24)
let img2 = Image(resource2).scale(24,24)
let img3 = Image(resource3).scale(24,24)

toolbar.addTool(idOpen, "", Bitmap(img1), "Open", "This is normal tool.")
toolbar.addTool(idSave, "", Bitmap(img2), "Save", "This is normal tool.")
toolbar.addTool(idSaveAs, "", Bitmap(img3), "Save As", "This is normal tool.")

let combobox = ComboBox(rebar, value="Combobox Item1",
  choices=["Combobox Item1", "Combobox Item2", "Combobox Item3"],
  style=wCB_READONLY)

rebar.addControl(toolBar)

rebar.addControl(combobox,label="COM Port")
rebar.minimize(600)

# Toolbar has the transparent look by default.
toolbar.backgroundColor = splitter.panel1.backgroundColor

let size = frame.clientSize
splitter.move(610, size.height div 2)

#### grid ####
var grid = ZeeGrid(splitter.panel1, pos=(0,0))
grid.setDefaultEdit(1)
grid.setDefaultNumPrecision(0)
grid.dimGrid(7,1)
grid.showRowNumbers(true)
for i in 1 .. 100:
  discard grid.appendRow()

let collabel = ["Dev","R/W","Addr","Length","Data","Delay","Comment"]
let col_size=[40,40,40,50,150,40,200]
for j,lbl in collabel:
  grid.setCellText(j+1,lbl)
  grid.setColWidth(j+1,col_size[j])

##########

splitter.panel1.wEvent_Size do ():
  splitter.panel1.autolayout "HV:|[grid]|"

frame.center()
frame.show()
app.mainLoop()
khchen commented 3 years ago
# rebar.minimize(600)
rebar.minimize(0)
leeooox commented 3 years ago

@khchen thanks, but the combox width will extend to all the remaining space on the left. How to make the width smaller?

image

khchen commented 3 years ago

You can add an empty band in the last version.