April 30, 2024, 05:47:21 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


DRAWING MODE

Started by TexasPete, July 23, 2009, 10:38:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TexasPete

I have got a rough window up but it is not redrawing the screen when I scrool up or down. I assume this has to do with the drawing mode.
Must I issure a repaint command or is it supposed to do this automatically.
Maybe one of my flags isn't right.
From reading the a manual it looks like I can do it either way?

Texas Pete

ZeroDog

you must respond to the @IDVSCROLL and/or @IDHSCROLL messages in your window message handler subroutine, if the scrollbars were created with the window flags @VSCROLL or @HSCROLL.  If the scrollbars were created using the CONTROL command, then you must respond to the @IDCONTROL message, with the appropriate @CONTROLID for the scrollbars. 

There are a few scrollbar messages to respond to depending on what the user does with the scrollbar.  Clicking the scroll area, clicking the up/down buttons, and dragging the scrollbar up/down all send different messages to the window. 

I think you're looking for something like this:

def win,win2:window

window win, 0,0, 300,300, @VSCROLL, 0,"Window 1", winproc
window win2, 0,0, 300,600, @NOCAPTION, win,"", win2proc
' The ID of the horizontal scrollbar created with the @HSCROLL flag is -1
' The ID of the vertical scrollbar created with the @VSCROLL flag is -2
SETSCROLLRANGE win2,   -2,   1,600
print win2, "something"
circle win2, 150,200,100,255,255


run=1
waituntil run=0
closewindow win
end

sub winproc
select @class
case @idvscroll
SELECT @CODE
CASE @SBLINEUP
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))-10
CASE @SBLINEDOWN
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))+10
CASE @SBPAGEUP
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))-50
CASE @SBPAGEDOWN
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))+50
CASE @SBTHUMBPOS
SETSCROLLPOS win, -2, @QUAL
CASE @SBTHUMBTRACK
SETSCROLLPOS win, -2, @QUAL
ENDSELECT
SetSize win2,0,-GETSCROLLPOS(win, -2),300,600

case @idclosewindow
run=0
endselect
return

sub win2proc
select @class
'put your window message handler for win2 here
endselect
return


GWS

Ooh .. that goes into my keeps folder ..  ;D   I can never remember how to do that ..

Thanks ZD ..  :)

Graham
Tomorrow may be too late ..

TexasPete

ZeroDog,
Thanks I will play with it until I understand it a little better. In lb I did not have any messages to deal with.
Also, I notice the SetSize command. In cb it looks like you are recomputing the size of the window and setsize to display all over again. Is that the correct understanding. In effect you are using the SetSize command to repaint the window. Correct or not?
Thanks
Texas Pete

aurelCB

TexasP
Yes with command SETSIZE you can change position and size of selected control or window.
In this case this is child window win2. Like you see x=0 and is alltime same but y use position
from scrollbar with GETSCROLLPOS and all work is under message @IDVSCROLL becose you have
vertical scrollbar.You can also use image and scroll image like circle and text to.

By the way exellent example ZeroD ;D

ZeroDog

July 24, 2009, 04:47:16 PM #5 Last Edit: July 24, 2009, 04:49:25 PM by ZeroDog
QuoteIn effect you are using the SetSize command to repaint the window. Correct or not?

Sort of.  I'm using the SetSize to move the window according to the messages the scrollbar sends to the window when the user clicks/drags the scrollbar.  The SetSize function will in turn send an @IDPAINT message to your window and the window will automatically repaint itself, unless you specify the @NOAUTODRAW flag in the OpenWindow line.  So yes, the SetSize will repaint the window, but thats not its main purpose.

The code isnt as complex as might seem at first.

CASE @SBLINEUP
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))-10
CASE @SBLINEDOWN
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))+10
The @SBLINEUP and @SBLINEDOWN messages are sent when the user clicks the arrows at the top or bottom of the scrollbar.  So when I get that message I set the position of the scrollbar ( ID -2 ) to the new position, which is the current scrollbar position ( GETSCROLLPOS(win, -2) )    minus 10 if the they clicked up, and plus 10 if they clicked down.

CASE @SBPAGEUP
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))-50
CASE @SBPAGEDOWN
SETSCROLLPOS win, -2, (GETSCROLLPOS(win, -2))+50
The @SBPAGEUP and @SBPAGEDOWN messages work the same way, but we move it 50 instead of 10.  You can set the amount you want it to move to whatever you like.

CASE @SBTHUMBPOS
SETSCROLLPOS win, -2, @QUAL
CASE @SBTHUMBTRACK
SETSCROLLPOS win, -2, @QUAL
These two messages are sent when user drags the scrollbar or uses scrollwheel to move the scrollbar.  The new position of the scrollbar is in the @QUAL so we SetScrollPos with the position of @QUAL.

So now that the scrollbar is all set with the new values, we just need to move the window to the appropriate position to reflect the scroll changes. 

SetSize win2,0,-GETSCROLLPOS(win, -2),300,600
We move, or SetSize, the window to 0 for the left (since the window only scrolls up/down) and for the top, we set it to the inverse of the current scrollbar position.  The farther down the scrollbar is, the higher up we need to place the window.  We get the position of the scrollbar with GETSCROLLPOS and invert it (notice the - sign before GETSCROLLPOS), and we set the window size to 300 width, 600 height, since that is its original size. 


TexasPete

July 25, 2009, 04:33:40 AM #6 Last Edit: July 25, 2009, 06:05:03 AM by TexasPete
Zerodog,
That is what I thought. I have added the horizontal portion as well but the scrool routines are still not funtiioning. Below is a copy of my code. I am not abel to see my bug. I have about four or five hours into this at this point. Any way if someone sees the bug or bugs. Thanks for the help.
Aurel if you see it thanks.

Texas Pete
'---------------------------------------
def win1:window
def win2:window
'def GraphicBox:window
def wstyle1:int
DEF wstyle2:int
def ScreenWidth:int
def ScreenHeight:int
def a$,newline:string
def handle:int
def CursorHandle:int
def MinScroll:int
Def MaxScroll:int
Def VertScroll:int
def HorzScroll:int
def PositionScroll:int
VertScrol=-2
HorzScrol=-1

wstyle1 = @SIZE|@MINBOX
wstyle2 = @NOCAPTION|@BORDER|@HSCROLL|@VSCROLL
'----Get the size of the screen---------------------
GETSCREENSIZE ScreenWidth,ScreenHeight
'--------Set Window Height and Width----
newline = chr$(10)
window win1,0,0,600,800,wstyle1,0,"Main Window Basic",main2
SETWINDOWCOLOR win1,rgb(0,0,40)
'---------Set the caption
SETCAPTION win1,"This is the Name of the Window"
CenterWindow win1
'----second window-----------
window win2,15,45,500,700,wstyle2,win1,"Main Window Basic",main1
SETWINDOWCOLOR win2,rgb(190,200,240):'--:centerwindow win2
DRAWMODE win2,@TRANSPARENT
'--------Set the scroll ranges---------------------
SETSCROLLRANGE win2,VertScrol,1, 1250
SETSCROLLRANGE win2,HorzScrol,1, 3600

'GetscrollRange win2,VertScrol,MinScroll,MaxScroll
'PositionScroll=GETSCROLLPOS win2,VertScrool,1, 1250

'----end second window
'-------Get the Window Handle
handle = GetHDC (win2)
'----Set the cursor---------
'SETCURSOR win2,@CSCUSTOM,CursorHandle


'control win1,"T,,100,30,400,300,@cteditcenter,1"
'setcontrolcolor win1,1,rgb(55,255,160),rgb(0,0,50)
rect win2,99,29,402,302,rgb(0,150,150)

a$ = string$(3,newline) + "A Simple" + newline + "Creative Window"
'setfont win2,"Arial", 20, 700, @SFITALIC,1

'setcontroltext win1,1,a$

waituntil win1 = 0
END


SUB main1
   SELECT @CLASS
      CASE @IDVSCROLL : ' Scrollbar handler
      'SECOND LEVEL--------------------------
        SELECT @CODE
            CASE @SBLINEUP
               SETSCROLLPOS win1,VertScroll, (GETSCROLLPOS(win1,VertScroll))-10
            CASE @SBLINEDOWN
               SETSCROLLPOS win1,VertScroll, (GETSCROLLPOS(win1,VertScroll))+10
            CASE @SBPAGEUP
               SETSCROLLPOS win1,VertScroll, (GETSCROLLPOS(win1,VertScroll))-100
            CASE @SBPAGEDOWN
               SETSCROLLPOS win1,VertScroll, (GETSCROLLPOS(win1,VertScroll))+100
            CASE @SBTHUMBPOS
               SETSCROLLPOS win1,VertScroll, @QUAL
            CASE @SBTHUMBTRACK
               SETSCROLLPOS win1,VertScroll, @QUAL      
                 SetSize win2,VertScroll,-GETSCROLLPOS(win1,VertScroll),500,700
        '--------------------------
         ENDSELECT

       CASE @IDHSCROLL
          SELECT @CODE    
              CASE @SBLINELEFT
               SETSCROLLPOS win1,HorzScroll, (GETSCROLLPOS(win1,HorzScroll))-10
            CASE @SBLINERIGHT
               SETSCROLLPOS win1,HorzScroll, (GETSCROLLPOS(win1,HorzScroll))+10
            CASE @SBPAGELEFT
               SETSCROLLPOS win1,HorzScroll, (GETSCROLLPOS(win1,HorzScroll))-100
            CASE @SBPAGERIGHT
               SETSCROLLPOS win1,HorzScroll, (GETSCROLLPOS(win1,HorzScroll))+100
            CASE @SBTHUMBPOS
               SETSCROLLPOS win1,HorzScroll, @QUAL
            CASE @SBTHUMBTRACK
               SETSCROLLPOS win1,HorzScroll, @QUAL   
             
         ENDSELECT
           SetSize win2,HorzScroll,-GETSCROLLPOS(win1,HorzScroll),500,700
'----------------------------
         case @idclosewindow
                 run=0
   ENDSELECT
RETURN
SUB main2
   IF @CLASS = @IDCLOSEWINDOW
       REM closes the window and sets w1 = 0
       CLOSEWINDOW win1
   ENDIF
RETURN

'--------------------------------------------



TexasPete

Say fellas, SetSize seems to effect the entire size of the original window. This does not allow for the same effect has I had in Lb. Would using a dialog help?
Texas Pete

aurelCB

July 25, 2009, 12:49:18 PM #8 Last Edit: July 25, 2009, 12:52:01 PM by aurelCB
First you must little bit switch off brain from LB and switch to Creative ;)
This tematic is litle bit confusing even for me ::)
But here we are , as Zero says :
Quote' The ID of the horizontal scrollbar created with the @HSCROLL flag is -1
' The ID of the vertical scrollbar created with the @VSCROLL flag is -2
You must remember that.
Here is example which scroll horizontal and vertical so study it .
On first look maby is complex but is not extemly hard.
Yes as i say before with SETSIZE you can change size of window or control. ;)

'TexasPete Scroll---------------------
def win1:window
def win2:window
'def GraphicBox:window
def wstyle1:int
DEF wstyle2:int
def ScreenWidth:int
def ScreenHeight:int
def x,y,w,h:int
def x2,y2,w2,h2:int
def a$,newline:string
def handle:int
def CursorHandle:int
def MinScroll:int
Def MaxScroll:int
Def VertScroll:int
def HorzScroll:int
def PositionScroll:int
VertScrol=-2
HorzScrol=-1
'add to win2 + 600 pixels
h2=600
w2=600
wstyle1 = @VSCROLL|@HSCROLL
wstyle2 = @NOCAPTION
'----Get the size of the screen---------------------
' i'm curently using 800x600
GETSCREENSIZE ScreenWidth,ScreenHeight

'Set Window Height and Width in main window create
'Main Window - parent
Window win1,0,0,ScreenWidth,ScreenHeight,wstyle1,0,"Main Window Basic",main1
SETWINDOWCOLOR win1,rgb(0,0,40)

'----second window child -----------
Window win2,0,0,ScreenWidth,ScreenHeight,wstyle2,win1,"Child Window ",main1
SETWINDOWCOLOR win2,rgb(190,200,240)

'--------Set the scroll ranges---------------------
SETSCROLLRANGE win1,-2,1,600
SETSCROLLRANGE win1,-1,1,600

Rect win2,99,29,402,302,rgb(0,150,150)

Move win2,100,100:Print win2,"A Simple"
Move win2,100,130:Print win2,"Creative Window"

Move win2,10,550:Print win2,"This text is visible after you move Vscrollbar"
Circle win2,400,550,100

'------------------------
Waituntil win1 = 0
END
'--------------------

SUB main1
   SELECT @CLASS

      CASE @IDVSCROLL : ' Vertical Scrollbar @message
     
SELECT @CODE
            CASE @SBLINEUP
               SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))-10
            CASE @SBLINEDOWN
               SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))+10

            CASE @SBPAGEUP
               SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))-50
            CASE @SBPAGEDOWN
               SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))+50

            CASE @SBTHUMBPOS
               SETSCROLLPOS win1,-2, @QUAL
            CASE @SBTHUMBTRACK
               SETSCROLLPOS win1,-2, @QUAL

       ENDSELECT
            SetSize win2,0,-GETSCROLLPOS(win1,-2),ScreenWidth,ScreenHeight+h2


'----------------------------------------------------------------
        CASE @IDHSCROLL

         SELECT @CODE   
               CASE @SBLINELEFT
               SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))-10
            CASE @SBLINERIGHT
               SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))+10

            CASE @SBPAGELEFT
               SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))-50
            CASE @SBPAGERIGHT
               SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))+50

            CASE @SBTHUMBPOS
               SETSCROLLPOS win1,-1, @QUAL
            CASE @SBTHUMBTRACK
               SETSCROLLPOS win1,-1, @QUAL   
             
         ENDSELECT
           SetSize win2,-GETSCROLLPOS(win1,-1),0,ScreenWidth+w2,ScreenHeight
'----------------------------
          Case @idclosewindow
  'becose we have win2 as child win in main1 win2 is closed automaticly
          Closewindow win1

   ENDSELECT
RETURN

SUB main2
    IF @CLASS = @IDCLOSEWINDOW
        REM closes the window and sets w1 = 0
        CLOSEWINDOW win1
    ENDIF
RETURN

TexasPete

July 26, 2009, 07:52:17 AM #9 Last Edit: July 26, 2009, 08:07:43 AM by TexasPete
AurelCB,

I have studied the example you have sent me and I have a few questions.
It appears to me that I had the windows backwards in my head.

1.  Why do you have @VSscroll and @HScroll set on the parent window in stead of the child window. I see that what you did works. I was trying to put my buttons on the parent window at the top. How would you move the scroll area downward to make room for the buttons. Or would you put the buttons in another window all to- gether. I also need to move the lower part of the window up. Will it work by simply changing the size and location of window number two. I have alread tried this on zerocat's example. With out much success.

2. Why wouldn't the @vscroll and Hsrcoll work on the second window. That's the window that I was trying to add scrolling to.

3. Changing the width and height of the second window does not change the size of the scrolling area on the screen. In order to do that . Do have to make child window have its child window so that I will have a place to put the buttons on the original window.

4. When setting the scrolling area. Is size of the scrolling in dialog units or pixels. On my LB program , I had to write a simple conversion routine in order to set my page length for the XHTML pages.

Thanks Texas Pete

aurelCB

July 26, 2009, 08:43:32 AM #10 Last Edit: July 26, 2009, 09:13:29 AM by aurelCB
Quote1.  Why do you have @VSscroll and @HScroll set on the parent window in stead of the child window. I see that what you did works. I was trying to put my buttons on the parent window at the top. How would you move the scroll area downward to make room for the buttons. Or would you put the buttons in another window all to- gether. I also need to move the lower part of the window up. Will it work by simply changing the size and location of window number two. I have alread tried this on zerocat's example. With out much success.

1.You must have it on parent window becose this scrollbars are in parent window - not in child.
I understand what you want and i think (but i'm not 100% sure) that you must add toolbar on the
top of parent window or make one new window without caption and place them in top of parent
window and add buttons on him.
Another and maby best (i think) option will be - made one @toolwindow and set them 'allways on top'
like i do in 'CB GUI Buider' for editor.Toolwindows i also use in my example 'Creative Paint'.
P.S: -//Is not zero cat then ZeroDog//

Quote2. Why wouldn't the @vscroll and Hsrcoll work on the second window. That's the window that I was trying to add scrolling to.

2.Becose you scroll win2 in win1 - simple you scroll complete win2 not content.

3.I think that you must resize win2 playing with @idsize message.

4.I really don't know how this things work on LB?
Philpe from what i see u use in Chiken html control with scrollbars - right?
So there is no need for scroll second window(i guess...) you only need place html control in win1.
And set size of control with @idsize message.

TexasPete

July 27, 2009, 06:37:00 AM #11 Last Edit: July 27, 2009, 06:42:08 AM by TexasPete
AureCB ,
Below is some changes to your example. I beleive this is what you mean by putting another window on top. If you don't mind please take a peek at it and make any comments to improve my thinking if you see an area that needs improvement. I think that all I have to do is put my buttons or icons at the top and then tie them into sub handler routine.

I just realize while it has the look of what I am after. The Back window is not on top . I accidently clicked it and the other window disappeared. Back to the drawing board. I will reread The windows section again.

Thanks Texas Pete
'----------------
'TexasPete Scroll---------------------
def win1:window
def win2:window
def wMain1:window
'def GraphicBox:window
def wstyle1:int
DEF wstyle2:int
def ScreenWidth:int
def ScreenHeight:int
def x,y,w,h:int
def x2,y2,w2,h2:int
def a$,newline:string
def handle:int
def CursorHandle:int
def MinScroll:int
Def MaxScroll:int
Def VertScroll:int
def HorzScroll:int
def PositionScroll:int
def Mainstyle:int
def MainWidth:int
def MainHeight:int
VertScrol=-2
HorzScrol=-1
'add to win2 + 600 pixels
h2=600
w2=600
wstyle1 = @VSCROLL|@HSCROLL
wstyle2 = @NOCAPTION
Mainstyle=@MINBOX|@MAXBOX|@SIZE
'----Get the size of the screen---------------------
' i'm curently using 800x600
GETSCREENSIZE ScreenWidth,ScreenHeight
MainWidth=ScreenWidth
MainHeight=ScreenHeight
Window wMain1,0,0,MainWidth,MainHeight,Mainstyle,0,"Main Window Basic",main1
'Set Window Height and Width in main window create
'Main Window - parent
ScreenWidth=ScreenWidth-200
ScreenHeight=ScreenHeight-200
Window win1,100,100,ScreenWidth,ScreenHeight,wstyle1,0,"Main Scrolling Window",main1
SETWINDOWCOLOR win1,rgb(0,0,40)

'----second window child -----------
Window win2,0,0,ScreenWidth,ScreenHeight,wstyle2,win1,"Child Window ",main1
SETWINDOWCOLOR win2,rgb(190,200,240)

'--------Set the scroll ranges---------------------
SETSCROLLRANGE win1,-2,1,600
SETSCROLLRANGE win1,-1,1,600

Rect win2,99,29,402,302,rgb(0,150,150)

Move win2,100,100:Print win2,"A Simple"
Move win2,100,130:Print win2,"Creative Window"

Move win2,10,550:Print win2,"This text is visible after you move Vscrollbar"
Circle win2,400,550,100

'------------------------
Waituntil win1 = 0
END
'--------------------

SUB main1
  SELECT @CLASS

     CASE @IDVSCROLL : ' Vertical Scrollbar @message
     
      SELECT @CODE
           CASE @SBLINEUP
              SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))-10
           CASE @SBLINEDOWN
              SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))+10

           CASE @SBPAGEUP
              SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))-50
           CASE @SBPAGEDOWN
              SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))+50

           CASE @SBTHUMBPOS
              SETSCROLLPOS win1,-2, @QUAL
           CASE @SBTHUMBTRACK
              SETSCROLLPOS win1,-2, @QUAL

      ENDSELECT
           SetSize win2,0,-GETSCROLLPOS(win1,-2),ScreenWidth,ScreenHeight+h2

   
'----------------------------------------------------------------
       CASE @IDHSCROLL

        SELECT @CODE    
              CASE @SBLINELEFT
              SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))-10
           CASE @SBLINERIGHT
              SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))+10

           CASE @SBPAGELEFT
              SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))-50
           CASE @SBPAGERIGHT
              SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))+50

           CASE @SBTHUMBPOS
              SETSCROLLPOS win1,-1, @QUAL
           CASE @SBTHUMBTRACK
              SETSCROLLPOS win1,-1, @QUAL  
             
        ENDSELECT
          SetSize win2,-GETSCROLLPOS(win1,-1),0,ScreenWidth+w2,ScreenHeight
'----------------------------
         Case @idclosewindow
        'becose we have win2 as child win in main1 win2 is closed automaticly
            Closewindow   wMain1
           Closewindow win1

  ENDSELECT
RETURN

SUB main2
   IF @CLASS = @IDCLOSEWINDOW
       REM closes the window and sets w1 = 0
       CLOSEWINDOW win1
   ENDIF
RETURN

ZeroDog

If you are using two scrollbars, you will have to check the position of each scrollbar when you move the window, so that you can set the position of the window according to both scrollbar positions.
SetSize win2,-GETSCROLLPOS(win1,-1),-GETSCROLLPOS(win1,-2),screenwidth,screenheight

Just a note:  If you have a window that is larger than the screensize,  you will run into problems when drawing in a position in the window that would be offscreen if the window were at 0,0.   So if your resolution is 800x600, and your window is 1000x1000 you wont be able to draw in the window past 800x600.  Im not sure if there is a quick workaround for this, but, depending on the content of the window, you can scroll the content of the window instead of scrolling the window itself. 

aurelCB

I mean that TPete problem is not in scrolling window if i gues he wants read html files.
And he probably must use html control(browser window) for this task, not scroll window?
I think that he want build some kind of html maker like hee make on LB.

TexasPete

Aurel, I am attempting a translation of my program. I do not need the embeded browser. Lb was getting to slow. I wanted to add some more advanced features. These added features would slow LB down even further. CB Let's me get used the new programming sturcture because I have an intrepreter. Just a little easier.
Texas Pete

aurelCB

OK TPete i gues that you need html control becose you say this:
Quotehad to write a simple conversion routine in order to set my page length for the XHTML pages.
So if you want put somwhere htm files you must have html (browser ) control.
Ok if you have something different on your mind just do it.

all best
Aurel :)