r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

Gregg
4-May-2009
[8632]
REBOL []

; r/3 = 'activate = left-click
; r/3 = 'activate = rt-click+menu-item-sel

hex: func [
    {Returns the base-10 value of a hexadecimal number.}
    value [integer! string! issue!] "A hexadecimal number"
][

    ; Convert to an issue first, so integers can also be translated.
    to integer! to issue! value
]

make-elements: func [name count type /local result][
    if not word? type [type: type?/word type]
    result: copy "^/"
    repeat i count [
        append result join name [i " [" type "]" newline]
    ]
    to block! result
]

NOTIFYICONDATA: make struct! compose [
    cbSize  [integer!]
    hwnd    [integer!]
    uId     [integer!]
    uFlags  [integer!]
    uCallBackMessage [integer!]
    hIcon   [integer!]
    (make-elements 'szTip 64 #"@")  ; CHAR
] none
NOTIFYICONDATA/cbSize: length? third NOTIFYICONDATA

;change at third NOTIFYICONDATA 25 "New ToolTip!"
;probe NOTIFYICONDATA
;halt

;constants required by Shell_NotifyIcon API call:
NIM_ADD:     hex 0
NIM_MODIFY:  hex 1
NIM_DELETE:  hex 2
NIF_MESSAGE: hex 1
NIF_ICON:    hex 2
NIF_TIP:     hex 4
WM_MOUSEMOVE:       hex 200
WM_LBUTTONDOWN:     hex 201  ;   'Button down
WM_LBUTTONUP:       hex 202  ;     'Button up
WM_LBUTTONDBLCLK:   hex 203  ; 'Double-click
WM_RBUTTONDOWN:     hex 204  ;   'Button down
WM_RBUTTONUP:       hex 205  ;     'Button up
WM_RBUTTONDBLCLK:   hex 206  ; 'Double-click


;Public Declare Function SetForegroundWindow Lib "user32" (ByVal 
hwnd As Long) As Long

lib: load/library %shell32.dll

Shell_NotifyIcon: make routine! compose/deep [
    dwMessage [integer!]
    pnid      [struct! [(NOTIFYICONDATA)]]
    return:   [integer!]
] lib "Shell_NotifyIconA"


my-hwnd?: does [second get-modes system/ports/system [window]]

set-tray-tooltip: func [struct string] [
    change at third struct 25 string
    struct
]



system-awake: func [port /local evt][
    if all [evt: pick port 1  (evt/1 = 'tray)] [
        status/text: mold evt
        show status
;         if any [
;             (evt/3 = 'activate)
;             all [(evt/3 = 'menu)  (evt/4 = 'desktop)]
;         ] [
;             if not desktop-loaded [
;                 link-exec-start-desktop/force
;             ]
;         ]
;         if all [(evt/3 = 'menu)  (evt/4 = 'quit)] [quit]
    ]
    false
]

system/ports/system/awake: :system-awake
append system/ports/wait-list system/ports/system

view layout [
    style button button 200
    button "Add Tray Menus" [
        set-modes system/ports/system compose/deep [
            tray: [
                add main [

                    help: (rejoin ["REBOL/Link" any [""]]) ; tooltip

                    menu: [test: "Test" desktop: "Start Desktop" bar quit: "Quit"]
                ]
                add other [
                    ;help: (rejoin ["REBOL/Link" any [""]])
                    menu: [test-2: "Test-2" bar quit-2: "Quit-2"]
                ]
            ]
        ]
    ]
    button "Remove Tray Main Menu" [
        set-modes system/ports/system [
            tray: [remove main]
        ]
    ]
    button "Remove Tray Other Menu" [
        set-modes system/ports/system [
            tray: [remove other]
        ]
    ]
    ;button "Change Tray Other Menu" [
    ;    set-modes system/ports/system [
    ;        tray: [
    ;            change other [
    ;                help: "New Help!"

    ;                menu: [test-3: "Test-3" bar quit-3: "Quit-3"]
    ;            ]
    ;        ]
    ;    ]
    ;]
    button "Modify Tooltip" [
        nid: make struct! NOTIFYICONDATA none
        nid/hwnd: my-hwnd?
        nid/uid: 1
        nid/cbSize: length? third nid
        nid/uFlags:  NIF_TIP  ; NIF_ICON
        ;nid/hIcon:
        ;nid/szTip:  "New ToolTip!^@"
        set-tray-tooltip nid "New ToolTip A!"
        ;print mold third nid
        res: Shell_NotifyIcon NIM_MODIFY nid
        print [res to logic! res]
    ]
    button "Modify Other Tooltip" [
        nid: make struct! NOTIFYICONDATA none
        nid/hwnd: my-hwnd?
        nid/uid: 2
        nid/cbSize: length? third nid
        nid/uFlags:  NIF_TIP  ; NIF_ICON
        ;nid/hIcon:
        ;nid/szTip:  "New ToolTip!^@"
        set-tray-tooltip nid "New ToolTip B!"
        ;print mold third nid
        res: Shell_NotifyIcon NIM_MODIFY nid
        print [res to logic! res]
    ]
    button "Unview" [unview]
    status: text 200
]



free lib
Maxim
7-May-2009
[8633]
thanks!! I'll look into this :-)
Pekr
7-May-2009
[8634]
Systray? Systray was done by Cyphre for me on contract, and released 
for free. IIRC Cheyenne used it at some point ...
Janko
7-May-2009
[8635]
If there wouldn't be a systray I probably wouldn't switch my bigger 
project to rebol and consequently started with all projects in rebol.. 
cheyenne was the most cruicial reason, if there wouldn't be cheyenne 
I would never switch -- but systray was the final nail in the coffin 
of the previous languge for that particular project. So, thanks  
Pekr and Cyphre!
Henrik
9-May-2009
[8636]
Is there a simple way to replace one style with another in a pane? 
I would like to interchange a FIELD and an INFO in the same spot, 
but by directly altering the field face.
ICarii
9-May-2009
[8637]
do you mean as in hidden pane swapping?
Henrik
9-May-2009
[8638]
tighter than that. it must be the face itself that should be swapped.
ICarii
9-May-2009
[8639x2]
define a separate: field/info and swap the face reference i guess
just save then reassign pane/face
Henrik
9-May-2009
[8641]
well, it's about which parameters that need to be brought over. size, 
offset and internal data should be the same.
ICarii
9-May-2009
[8642]
should be simple as a variable swap - just have to use globals in 
R2
Henrik
9-May-2009
[8643x2]
I don't think I want to do it that way. The face I swap with could 
probably be obtained using GET-STYLE. But then certain parameters 
from the old face should be grafted onto the new face.
well, about to test, so we'll see if it works...
ICarii
9-May-2009
[8645]
couldn't you get the same effect by selectively locking teh field 
object?
Henrik
9-May-2009
[8646]
locking, how?
ICarii
9-May-2009
[8647x2]
override the feel
style lockable-field field feel [...]
Henrik
9-May-2009
[8649]
that's not enough. it has to be visual as well.
ICarii
9-May-2009
[8650]
you can intercept the redraw
Henrik
9-May-2009
[8651]
that's too complicated.
ICarii
9-May-2009
[8652]
redraw: func [face act pos] [set-face-look..]  ..  not really that 
complicated..
Henrik
9-May-2009
[8653]
It won't do if it has to be added to every face in VID. Besides I've 
built something simpler now.
ICarii
9-May-2009
[8654x2]
:)
alternately I would add a single redraw check at the top level and 
scan children for a 'lock value in a predefined field / flags.
jocko
9-May-2009
[8656x2]
Steeve, Henrik
Steeve, Henrik, thank you for these infos concerning interpolation 
modes with effect and draw
Maxim
9-May-2009
[8658]
the easiest way I`ve done this henrik is to have a face which has 
two extra facets (style, protected) and a function called change, 
 


calling 'change to another style gets all the values from the global 
style block for that stylename, and changes all facets excluding 
any which are in the protected block.  it also sets the stylename 
within the function, so you can easily do decisions based on that.


alternatively, you can make an external function which does the same, 
but adding the protected inside the 'WITH [ ] spec makes it easier 
to contextualize the system.
Henrik
12-May-2009
[8659]
If I have a window-feel with a 'detect function, could it be performed 
after an 'engage function for a face in that window? Is there a way 
to swap that around?
Maxim
12-May-2009
[8660x3]
you can always modify view*/wake-event to it fires other events after 
the do-event.
to=so
just remember to bind the func block to *view before submitting it 
to func

ex:  

view*: system/view
view*/wake-event: func [port ] bind [ 
	.... your wake event redefinition code ...
] in view* 'self


obviously you can mold/all + load  the wake-event func body directly 
or copy it from sdk code if you want.
Henrik
12-May-2009
[8663]
hmm... it's actually only the sequence of events that needs altering. 
as far as I can tell that function only fires one event at a time 
from the event queue.
Maxim
12-May-2009
[8664x2]
but the detect and engage function are the same original event.  
engage is sent to see who really wants it and then it is sent the 
engage
ooops   "detect  is sent ..."
Henrik
12-May-2009
[8666]
but the detect and engage don't originate from the same face?
Maxim
12-May-2009
[8667x3]
basically, the detect goes from window, thru all children up to the 
face which generated the even, in order for you to trap the event 
in a parent face.
at that point, the event will not be sent to the child face (if you 
decide to capture it)
so if you need to "consume" an event (for hotkeys for example)  the 
window can detect it and it wont reach the child field.
Henrik
12-May-2009
[8670]
so the detect is causing the engage to happen?
Maxim
12-May-2009
[8671x2]
if parent face captures it , it will allow the engege to happen.
darn...  if = if no
Henrik
12-May-2009
[8673]
to me it sounds like there is no way to switch them around.
Maxim
12-May-2009
[8674]
I'm getting Reicharteritis
Henrik
12-May-2009
[8675]
I'm a little thick on the event system. So I ask many dumb questions. 
:-)
Maxim
12-May-2009
[8676]
it makes no sense to switch them around, detect basically serves 
to know where to send the events to.
Henrik
12-May-2009
[8677]
Ok, from the event queue it doesn't make sense, I guess. But from 
what I'm trying to do, I need to do something to a local face _before_ 
something else happens globally.
Maxim
12-May-2009
[8678x4]
this whole system is what the do event call in wake-events is for.
ok, in that case you can insert an event handler, which will be run 
before the default one.
there you can trap the events exactly like the wake-event, and do 
what you want before the default event handling happens.
basically, if you return none, the event is consumed and not sent 
to view's default wake-event

if you return the event itself, the next input handler in the chain 
will be fired.