1. question about List text colors

First of all, it's good to be back on the mailing list.  I've been without
a computer since September and now I'm back.
  How do I change the colors of List items?  I can change the font, but not
colors.  I want to display a roster of players, where healthy ones are black
and injured are red.


Thanks,
Derek

new topic     » topic index » view message » categorize

2. Re: question about List text colors

On Sun, 23 Jan 2000 18:01:58 EST, Derek Brown <Cyrusbrown at AOL.COM> wrote:

>  First of all, it's good to be back on the mailing list.  I've been
without
>a computer since September and now I'm back.
>  How do I change the colors of List items?  I can change the font, but not
>colors.  I want to display a roster of players, where healthy ones are
black
>and injured are red.
>
>
>Thanks,
>Derek


Derek,

I'm afraid I've got bad news all the way around for you.  First of all, the
List control can display text in only one color.  Furthermore, you can't
change the foreground or background colors of objects in win32lib (except
the window object)  I did some research on it yesterday, and it wouldn't be
too hard to implement, it just hasn't been done yet...

There is some good news though.  There IS a control that will let you set
different colors on each line, use icons for them, etc.  It is the treeview
control.  *BUT* is isn't implemented in win32lib yet.  I have managed to
create my own WITHOUT using win32lib (YUK!), but treeview objects are class
structures that use dot notation.  I haven't got a clue how you would tell
a treeview to TreeView.InsertItem in Euphoria, so my treeview just sits
there uselessly.  Well, I'm going to go jump off the roof now...

Sorry I wan't any help at all,

Brian

new topic     » goto parent     » topic index » view message » categorize

3. Re: question about List text colors

Derek,

I just remembered WHY I created that treeview.  I was working on an email
client, and wanted to use a listview(treeview) to display the contents of
the INBOX.  I tried faking a listview control, which turned out OK, but it
was just going to be too much work.  Here's the guts of the program,
perhaps you can modify it for your project:


------------------------------- BEGIN CODE --------------------------------
without warning
with trace

include win32lib.ew

constant WS_FIXEDFRAME = #4A0000
constant WS_PASSWORD = #20
constant MainWin = create(Window,"Fake Listview
Example",0,0,0,522,480,WS_FIXEDFRAME)
constant MainWinStatBar = create(StatusBar,"Ready",MainWin,0,0,0,0,#400000)
constant MainWinListView = create(Pixmap,"Test2",MainWin,0,0,500,374,0)
constant MainWinListViewVScroll = create(VScroll,"",MainWin,500,40,16,374,0)
--=======================================================================
sequence ListViewItem
ListViewItem =
{
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Message for you...","2k"},
  {"noicon","Brian Jackson","Re: Message for you...","5k"}
}
global constant Image   = 1,
                Sender  = 2,
                Subject = 3,
                Size    = 4

sequence ListViewContents
ListViewContents = { 1,      -- selected object(s)
                     30,     -- total objects(s)
                     1}      -- top index
global constant SelectedMembers   = 1,
                TotalMembers      = 2,
                TopVisibleMember  = 3
--========================================================================
procedure repaintListView()
  integer curY
  object  owork

  -- this draws the background
  setPenColor(MainWinListView,rgb(255,255,255))
  drawRectangle(MainWinListView,1,0,0,500,374)
  setPenColor(MainWinListView,rgb(192,192,192))
  drawRectangle(MainWinListView,1,1,0,500,16)
  setPenColor(MainWinListView,Black)
  drawLine(MainWinListView,0,0,0,374)
  drawLine(MainWinListView,1,16,500,16)
  setPosition(MainWinListView,6,2)
  wPuts(MainWinListView,"Flags")
  setPosition(MainWinListView,56,2)
  wPuts(MainWinListView,"Sender")
  setPosition(MainWinListView,256,2)
  wPuts(MainWinListView,"Subject")
  drawLine(MainWinListView,51,1,51,16)
  drawLine(MainWinListView,251,1,251,16)

  setPenColor(MainWinListView,rgb(255,255,255))
  drawLine(MainWinListView,1,1,50,1)
  drawLine(MainWinListView,1,1,1,16)
  drawLine(MainWinListView,52,1,250,1)
  drawLine(MainWinListView,52,1,52,16)
  drawLine(MainWinListView,252,1,500,1)
  drawLine(MainWinListView,252,1,252,16)

  -- now let's display each line one at a time
  if ListViewContents[TotalMembers] then
    curY = 18
    for i = ListViewContents[TopVisibleMember] to
        ListViewContents[TotalMembers] do

      -- display the sender
      setPosition(MainWinListView,56,curY)
      wPuts(MainWinListView,ListViewItem[i][Sender])

      -- display the subject
      setPosition(MainWinListView,256,curY)
      wPuts(MainWinListView,ListViewItem[i][Subject])

      -- move down a line, until we run out of room
      curY += 16
      if curY > 360 then
        -- stop before we go off the bottom of the listview
        exit
      end if

    end for
  end if

  owork = ListViewContents[SelectedMembers]
  if atom(owork) then
    if owork >= ListViewContents[TopVisibleMember] then
      -- draw a box around the selected one
      curY = (owork - ListViewContents[TopVisibleMember] + 1) * 16
      setPenColor(MainWinListView,rgb(0,0,127))
      drawRectangle(MainWinListView, 1, 0, curY, 500, curY + 16)
      setPenColor(MainWinListView,rgb(192,192,192))

      -- set text color to white
      setTextColor(MainWinListView, rgb(255,255,255))

      -- display the sender
      setPosition(MainWinListView,56,curY)
      wPuts(MainWinListView,ListViewItem[owork][Sender])

      -- display the subject
      setPosition(MainWinListView,256,curY)
      wPuts(MainWinListView,ListViewItem[owork][Subject])

      -- set text color to black
      setTextColor(MainWinListView, rgb(0,0,0))

    end if
  else
    for i = 1 to length(owork) do
      -- draw a box around the selected one
      curY = (owork[i] - ListViewContents[TopVisibleMember] + 1) * 16
      setPenColor(MainWinListView,rgb(0,0,127))
      drawRectangle(MainWinListView, 1, 0, curY, 500, curY + 16)
      setPenColor(MainWinListView,rgb(192,192,192))

      -- set text color to white
      setTextColor(MainWinListView, rgb(255,255,255))

      -- display the sender
      setPosition(MainWinListView,56,curY)
      wPuts(MainWinListView,ListViewItem[owork[i]][Sender])

      -- display the subject
      setPosition(MainWinListView,256,curY)
      wPuts(MainWinListView,ListViewItem[owork[i]][Subject])

      -- set text color to black
      setTextColor(MainWinListView, rgb(0,0,0))
    end for
  end if

  copyBlt(MainWin,0,40,MainWinListView)

end procedure
--=======================================================================
procedure onMouseListView(integer event, integer x, integer y, integer z)
  integer ok
  if event = LEFT_DOWN then
    -- set a new selected item
    y -= 40
    y = floor(y/16)
    y += ListViewContents[TopVisibleMember] - 1
    if y <= ListViewContents[TotalMembers] then
      if not z then
        -- no shift key here
        ListViewContents[SelectedMembers] = y
      else
      -- the shift key is pressed
        ListViewContents[SelectedMembers] &= y
      end if
    else
      ListViewContents[SelectedMembers] = 0
    end if

    repaintListView()
  elsif event = LEFT_DOUBLECLICK then
    ok = message_box("dshgdjas","kgfdkjgfd",MB_ICONINFORMATION + MB_OK)
  end if
end procedure
--=======================================================================
procedure onMouseMainWin(integer event,integer x, integer y, integer z)
  if  event = LEFT_DOUBLECLICK then
  trace(1)
  end if
  if x >= 0
  and x <= 500
  and y >= 40
  and y <= 414 then
    onMouseListView(event,x,y,z)
  end if
end procedure
onMouse[MainWin] = routine_id("onMouseMainWin")
--=========================================================================
procedure onPaintMainWin(integer x1, integer y1, integer x2, integer y2)
  repaintListView()
end procedure
onPaint[MainWin] = routine_id("onPaintMainWin")
--=========================================================================
procedure onScrollMainWinListViewVScroll(integer y)
  ListViewContents[TopVisibleMember] = y
  repaintListView()
end procedure
onScroll[MainWinListViewVScroll] =
      routine_id("onScrollMainWinListViewVScroll")
--=========================================================================
procedure onOpenMainWindow()
  setWindowBackColor(MainWin,rgb(192,192,192))

  setIcon(MainWin,"client.ico")

  -- let's set the state of the scrollbar too
  if ListViewContents[TotalMembers] > 22 then
    setEnable(MainWinListViewVScroll, 1)
    setScrollRange(MainWinListViewVScroll,1,
            ListViewContents[TotalMembers] - 22)
    setScrollChange(MainWinListViewVScroll, 1, 22)
    setScrollPos(MainWinListViewVScroll, ListViewContents[TopVisibleMember])
  else
    setEnable(MainWinListViewVScroll, 0)
  end if

end procedure
onOpen[MainWin] = routine_id("onOpenMainWindow")
--=======================================================================
WinMain(MainWin,Normal)
------------------------------ END CODE ------------------------------------

new topic     » goto parent     » topic index » view message » categorize

4. Re: question about List text colors

On Mon, 24 Jan 2000 10:34:09 -0500, Brian Jackson

>a treeview to TreeView.InsertItem in Euphoria, so my treeview just sits
>there uselessly.  Well, I'm going to go jump off the roof now...

   The above statement is a Object Orientated statment. It means to use the

   InsertItem method ( procedure )associated with the TreeView object.

   To use pictures and etc. in a listbox you could use a ownerdraw list box.

  Bernie

new topic     » goto parent     » topic index » view message » categorize

5. Re: question about List text colors

Thanks for the code.  I'll try to modify it to work in my window.  And for
  what it's worth (not too much if you don't like football, and then again, if you
  do like football, probably not too much either) I put you on the list of people
  to receive a registered version.

Thanks again,
Derek

new topic     » goto parent     » topic index » view message » categorize

6. Re: question about List text colors

Derek wrote:
>   <SNIP>
>   I put you on the list of people to receive a registered version.
>   </SNIP>
Thanks.  It's always nice to be appreciated.

Bernie wrote:
>
>   <SNIP>
>   The above statement is a Object Orientated statment. It means to use the
>   InsertItem method ( procedure )associated with the TreeView object.
>   To use pictures and etc.
>   </SNIP>

I understand what OOP is all about, and apologize if I implied otherwise.
I have use it daily in other languages for MFC, COM, and ActiveX class
objects.  What I don't understand is how to access the InsertItem function
within the TreeView class in Euphoria.  In C++, VB, etc., I use
OBJECTNAME.METHOD.  Since Eu doesn't support dot notation, how on earth can
you get at the class functions?

Brian

new topic     » goto parent     » topic index » view message » categorize

7. Re: question about List text colors

On Mon, 24 Jan 2000 12:07:37 -0500, Brian Jackson
<bjackson at 2FARGON.HYPERMART.NET> wrote:

>I understand what OOP is all about, and apologize if I implied otherwise.
>I have use it daily in other languages for MFC, COM, and ActiveX class
>objects.  What I don't understand is how to access the InsertItem function
>within the TreeView class in Euphoria.  In C++, VB, etc., I use
>OBJECTNAME.METHOD.  Since Eu doesn't support dot notation, how on earth can
>you get at the class functions?

 Brian:

  I don't think you can, because Euphoria can not be compiled and linked

  C++ objects.

  There is no way to get pointers to the compiled C++ objects and methods.

  The only way would be to emulate the TreeView class in Euphoria.

 Bernie

new topic     » goto parent     » topic index » view message » categorize

8. Re: question about List text colors

Bernie wrote
> Brian:
>
>  I don't think you can, because Euphoria can not be compiled and linked
>
>  C++ objects.
>
>  There is no way to get pointers to the compiled C++ objects and methods.
>
>  The only way would be to emulate the TreeView class in Euphoria.
>
> Bernie

That's kind of what I had resigned myself to.  In theory though, wouldn't
it be possible to write a DLL that serves as the 'missing link' between Eu
and OOC++?  I mean, you ought to be able to pass this fictitious DLL an
hWnd and a bunch of parameters, tell it to InsertItem (or whatever), let
the DLL do the dirty work, and just pass back the return value(s).  This is
an ugly hack, and would be more trouble than it's worth, but it's one
possibility (I think - I got out of my league in a hurry...)

It seems to me that we shouldn't have to go around trying to fool the
interpreter just in order to use the OS builtins.  Most serious languages
either already use OOP or are moving towards it quickly.  Sounds like a job
for Euphoria 3.0!  Rob?

new topic     » goto parent     » topic index » view message » categorize

9. Re: question about List text colors

Brian Jackson wrote:

> What I don't understand is how to access
> the InsertItem function within the TreeView
> class in Euphoria.

I seem to be missing something here. The *native* Win32 API is just C calls,
but you can talk to it with C, C++, Assembler, BASIC, Euphoria - whatever.
The C++ stuff (especially MFC) is just a wrapper around the C calls.
InsertItem is implemented with a SendMessage( hListView, LVM_INSERTITEM, 0,
hItem ).

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

10. Re: question about List text colors

David wrote:
>I seem to be missing something here. The *native* Win32 API is just C
>calls, but you can talk to it with C, C++, Assembler, BASIC, Euphoria -
>whatever. The C++ stuff (especially MFC) is just a wrapper around the C
>calls. InsertItem is implemented with a SendMessage( hListView,
>LVM_INSERTITEM, 0, hItem ).

DOH! Why is that every time I find a solution to a problem (or more
rightly, THINK i have), you come along and reduce it to a single line of
code?!!  Thank you very much, David.  That clears up a lot of things, and
gives me some interesting new ideas.  From now on I'll try to stick to
solving problems I actually understand....

Brian

new topic     » goto parent     » topic index » view message » categorize

11. Re: question about List text colors

Brian Jackson wrote:

> you come along and reduce it to a single line
> of code?

It's amazing what you can do by leaving out all the messy details, like
defining primary and secondary data structures, defining constants,
allocating and populating structures, making calls, checking results, etc...
blink

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

12. Re: question about List text colors

On Mon, 24 Jan 2000 13:38:18 -0800, Cuny, David at DSS <David.Cuny at
DSS.CA.GOV>
wrote:

>Brian Jackson wrote:
>
>> What I don't understand is how to access
>> the InsertItem function within the TreeView
>> class in Euphoria.
>
>I seem to be missing something here. The *native* Win32 API is just C
calls,
>but you can talk to it with C, C++, Assembler, BASIC, Euphoria - whatever.
>The C++ stuff (especially MFC) is just a wrapper around the C calls.
>InsertItem is implemented with a SendMessage( hListView, LVM_INSERTITEM, 0,
>hItem ).
>
>-- David Cuny

  David:

  DAHHHHHHHHHH !  Thanks for waking this old brain up.

  There are constants for the methods in commctrl header.

  Bernie

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu