News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

JWasm and IUP

Started by jcfuller, April 29, 2012, 12:22:00 PM

Previous topic - Next topic

jcfuller

An example of using the IUP GUI library with jwasm, primarily because it is cross platform (win/nix).
http://www.tecgraf.puc-rio.br/iup/
James


    .486
    .model flat, c
    option casemap :none
;=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*   
    ;windows
    include \jwasm\include\crt\crt.inc
    include \jwasm\iup\include\iup.inc
    includelib \jwasm\wininc\Lib\msvcrt.lib
    includelib \iup_dll6\iup.lib
    ;compile / link
    ;gorc /r iuptest.rc        ;for manifest
    ;jwasm /c /coff
    ;polink /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /OUT:iuptest.exe iuptest.obj iuptest.res
;=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*       
    ;linux
    ;include /home/james/jwasm/include/stdio.inc
    ;include /home/james/jwasm/include/stdlib.inc
    ;include /home/james/jwasm/include/string.h
    ;include /home/james/IUP/include/iup.inc
    ;compile / link
    ;jwasm -elf -zcw -Fo testiup.o testiup.asm
    ;gcc -o testiup testiup.o -L~/IUP -liup
   
;==============================================================================
CStr macro pszText:VARARG
local szText
    .const
szText    db pszText,0
    .code
    exitm <offset szText>
endm
;==============================================================================   

    .code
start:
    call main
    invoke exit,0
   
;==============================================================================
quit_cb proc
    mov eax,IUP_CLOSE
    ret
quit_cb endp
;==============================================================================
AddChild proc parent:PTR Ihandle,child:PTR Ihandle
    invoke IupAppend,parent,child
    invoke IupRefresh,parent
    ret
AddChild endp
Create proc Value:PTR BYTE,Attr:PTR BYTE,parent:PTR Ihandle
    LOCAL ihWnd:PTR Ihandle
    mov ihWnd,0
    invoke IupCreate,Value
    .if eax
        mov ihWnd,eax
        invoke strlen,Attr
        .if eax
            invoke IupSetAttributes,ihWnd,Attr
        .endif
        .if parent
            invoke AddChild,parent,ihWnd
        .endif
        mov eax,ihWnd
    .endif
    ret
Create endp
main proc
    LOCAL \
    win:PTR Ihandle,\
    vbox:PTR Ihandle,\
    topBox:PTR Ihandle,\
    serverFrame:PTR Ihandle,\
    serverBox:PTR Ihandle,\
    serverCombo:PTR Ihandle,\
    btnFetch:PTR Ihandle,\
    controlFrame:PTR Ihandle,\
    controlBox:PTR Ihandle,\
    btnAbout:PTR Ihandle,\
    btnClear:PTR Ihandle,\
    btnExit:PTR Ihandle,\
    dictFrame:PTR Ihandle,\
    serverList:PTR Ihandle,\
    transFrame:PTR Ihandle,\
    text:PTR Ihandle,\
    bottomBox:PTR Ihandle,\
    lbl:PTR Ihandle,\
    entry:PTR Ihandle,\
    btnSearch:PTR Ihandle,\
    chkAll:PTR Ihandle,\
    chkUTF:PTR Ihandle
         
    invoke IupOpen,0,0
    invoke Create,CStr("dialog"),CStr("TITLE=Thesaurus, SIZE=500x300"),NULL
    mov win,eax
    invoke Create,CStr("vbox"),CStr("MARGIN=10x10"), NULL
    mov vbox,eax
    invoke Create,CStr("hbox"),CStr(" GAP=10"), vbox
    mov topBox,eax
    invoke Create,CStr("frame"),CStr("TITLE=Servers, EXPAND=YES"), topBox
    mov serverFrame,eax
    invoke Create,CStr("hbox"),CStr("GAP=5"), serverFrame
    mov serverBox,eax
    invoke Create,CStr("list"),CStr("DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1"), serverBox
    mov serverCombo,eax
    invoke Create,CStr("button"),CStr("TITLE=Fetch, SIZE = 50x"), serverBox
    mov btnFetch,eax
    invoke Create,CStr("frame"),CStr("TITLE=Controls"), topBox
    mov controlFrame,eax
    invoke Create,CStr("hbox"),CStr("Margin=6x6, GAP=5"), controlFrame
    mov controlBox,eax
    invoke Create,CStr("button"),CStr("TITLE=About, SIZE = 50x"), controlBox
    mov btnAbout,eax
    invoke Create,CStr("button"),CStr("TITLE=Clear, SIZE = 50x"), controlBox
    mov btnClear,eax
    invoke Create,CStr("button"),CStr("TITLE=Exit, SIZE = 50x"), controlBox
    mov btnExit,eax
    invoke IupSetCallback,btnExit,CStr("ACTION"),OFFSET quit_cb
    invoke Create,CStr("frame"),CStr("TITLE=Dictionaries"), vbox
    mov dictFrame,eax
    invoke Create,CStr("list"),CStr("EXPAND=YES, VISIBLELINES=1"), dictFrame
    mov serverList,eax
    invoke Create,CStr("frame"),CStr("TITLE=Translation"), vbox
    mov transFrame,eax
    invoke Create,CStr("text"),CStr("MULTILINE=YES, EXPAND=YES"), transFrame
    mov text,eax
    invoke Create,CStr("hbox"),CStr("GAP=10"), vbox
    mov bottomBox,eax
    invoke Create,CStr("label"),CStr("TITLE=Enter Word to Search For:,SIZE=x12"), bottomBox
    mov lbl,eax
    invoke Create,CStr("text"),CStr(" EXPAND=HORIZONTAL"), bottomBox
    mov entry,eax
    invoke  Create,CStr("button"),CStr("TITLE=Search, SIZE=50x"), bottomBox
    mov btnSearch,eax
    invoke Create,CStr("toggle"),CStr("TITLE=ALL, VALUE=ON,SIZE=x12"), bottomBox
    mov chkAll,eax
    invoke Create,CStr("toggle"),CStr("TITLE=UTF-8, SIZE=x12"), bottomBox
    invoke AddChild,win,vbox
    invoke IupShow,win
    invoke IupSetFocus,btnFetch
    invoke IupMainLoop
    invoke IupClose
    mov eax,0
    ret
main endp
end start


windows:


Linux (Mint12):


EDIT: Forgot to attach inc file
EDIT: fixed linux info

hutch--

James,

Clever looking stuff, compliments.  :thumbu
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jcfuller

The original c demo code isn't mine. I don't remember where I got it but it is the best code I've seen that shows exactly how to use the library.
The examples that come with the library are very cryptic "c".

James

jcfuller

One of the nice things about this library is the simplicity of anchoring and expanding controls.
The box within a box concept was/is hard for me to get my head around but I'm getting there.

I attached a statically linked exe so you can see the results of changing the size of the window.
It was created from the "c" version using MinGW gcc hence the large size.
I was not able to figure out how to do it with jwasm tonight but I will!!

James

dedndave

that is interesting
i like the way it sizes stuff
although, i didn't try it with different themes or user-selectioned fonts
i have been playing with ideas in my head that would allow different size buttons and other controls, depending on font and font size

Gunner

~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave

nice   :U

the one that a lot of programs don't handle well is:

Display Properties
Appearance
Font Size = Large Fonts or Extra Large Fonts

let me save what i am working on and try it   :bg

dedndave

seems to be ok
unfortunately, we don't have any buttons with long text strings in that example
the "Enter Word to Search For:" string is a good test, though

but - a lot of programs wouldn't do this well - lol
they'd be clipped and/or overwriting

one thing i noticed - it does not handle WM_THEMECHANGED - probably not WM_DISPLAYCHANGE, either
it might be the responsiblity of the caller to re-initialize



TmX

Look good.
BTW, where do you get the "crt\crt.inc" from?

jcfuller

Quote from: TmX on April 30, 2012, 08:34:50 PM
Look good.
BTW, where do you get the "crt\crt.inc" from?

Tmx,
  Sorry about that. Here it is.

James

JD

Quote from: Gunner on April 30, 2012, 02:11:38 AM
Handles themes nicely!

I like that theme.   :U  What is it?

Gunner

Have to wait till I get home, don't remember the name... Its from windowblinds.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Gunner

It is the Anion Theme by danilloOc for WindowBlinds 7, the other one I use often is Corporate from the same author.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

JD

Quote from: Gunner on May 01, 2012, 09:04:15 PM
It is the Anion Theme by danilloOc for WindowBlinds 7, the other one I use often is Corporate from the same author.

Thanks.  I'll check it out.  :U