The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: jcfuller on April 29, 2012, 12:22:00 PM

Title: JWasm and IUP
Post by: jcfuller on April 29, 2012, 12:22:00 PM
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:
(http://www.allbasic.info/forum/index.php?action=dlattach;topic=142.0;attach=368;image)

Linux (Mint12):
(http://www.allbasic.info/forum/index.php?action=dlattach;topic=142.0;attach=370;image)

EDIT: Forgot to attach inc file
EDIT: fixed linux info
Title: Re: JWasm and IUP
Post by: hutch-- on April 29, 2012, 01:30:27 PM
James,

Clever looking stuff, compliments.  :thumbu
Title: Re: JWasm and IUP
Post by: jcfuller on April 29, 2012, 10:16:59 PM
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
Title: Re: JWasm and IUP
Post by: jcfuller on April 30, 2012, 12:06:02 AM
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
Title: Re: JWasm and IUP
Post by: dedndave on April 30, 2012, 01:38:06 AM
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
Title: Re: JWasm and IUP
Post by: Gunner on April 30, 2012, 02:11:38 AM
Handles themes nicely!

(http://www.gunnerinc.com/files/masm32stuff/ThesSS.png)
Title: Re: JWasm and IUP
Post by: dedndave on April 30, 2012, 03:06:12 AM
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
Title: Re: JWasm and IUP
Post by: dedndave on April 30, 2012, 03:12:35 AM
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

(http://www.masm32.com/board/index.php?action=dlattach;topic=18777.0;id=10658)
Title: Re: JWasm and IUP
Post by: TmX on April 30, 2012, 08:34:50 PM
Look good.
BTW, where do you get the "crt\crt.inc" from?
Title: Re: JWasm and IUP
Post by: jcfuller on May 01, 2012, 10:02:36 AM
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
Title: Re: JWasm and IUP
Post by: JD on May 01, 2012, 08:14:44 PM
Quote from: Gunner on April 30, 2012, 02:11:38 AM
Handles themes nicely!

I like that theme.   :U  What is it?
Title: Re: JWasm and IUP
Post by: Gunner on May 01, 2012, 08:40:57 PM
Have to wait till I get home, don't remember the name... Its from windowblinds.
Title: Re: JWasm and IUP
Post by: 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.
Title: Re: JWasm and IUP
Post by: JD on May 01, 2012, 09:24:12 PM
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