Results 1 to 8 of 8

Thread: CL_TextEdit

  1. #1
    Lesser Knight
    Join Date
    Apr 2011
    Location
    Germany
    Posts
    32

    Default CL_TextEdit

    I have a TextEdit

    CL_TextEdit *MsgLog;

    CL_Rect Area = window.get_client_area();

    MsgLog = new CL_TextEdit(&window);
    MsgLog->set_read_only(true);
    MsgLog->set_geometry(CL_Rect(Area.left + 10,Area.top + 105,CL_Size(800,450)));

    How can i add scrollbar verticaly and horizontaly?

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    I'm afraid this requires a patch to ClanLib itself.

    Although CL_TextEdit has long existed in the API of ClanLib, it is only recently that it had any implementaion behind it. It was created by taking the CL_LineEdit class and then adding multi line support. I never got around to adding the scrollbars since it wasn't crucial for the editing I was doing.

    In theory adding the scrollbar support shouldn't be all that hard. Adding the vertical scrollbar is easiest and just requires a CL_ScrollBar added to CL_TextEdit_Impl which is then shown/hidden based on the total height of all span layouts in CL_TextEdit_Impl::lines. And then in CL_TextEdit_Impl:n_render it should start with the line specified by the vertical scrollbar.

    A horizontal scrollbar is slightly more tricky because the current behavior is to automatically word-wrap lines. The text edit class does this by executing "line.layout.layout(gc, content_box.get_width())". To make it stop word-wrapping the max width passed to layout should be something like 0x7fffffff. The word-wrap behavior should probably be a toggle option that can be turned on or off using some CL_TextEdit::enable_word_wrap(bool) function.

    The text edit class uses 3 files in ClanLib: textedit.cpp, textedit_impl.h and textedit.h. You don't have to know anything about the rest of ClanLib's internals to code on this class.

  3. #3
    Lesser Knight
    Join Date
    Apr 2011
    Location
    Germany
    Posts
    32

    Default

    For me it is very important to the scroll bar are included.
    because I'm just here to build one right from the chat already sees something cool out of the only problem is if I get a message from one user to add always there is the matter with \n The newline then made ​​the only message he writes news and further because of the lack of scroll bars he goes down further and nciht shows nothing new.

    i need it do a patch :>> !! with autoscroll :] and wrapline for to long msg

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I think it is you that needs to code a patch.

    ClanLib is developed by people who use it. If we don't use it, we don't develop it

  5. #5
    Lesser Knight
    Join Date
    Apr 2011
    Location
    Germany
    Posts
    32

    Default

    How can i add a scrollbar its important ? and the same with a listview ? i need only vertical an in TextEdit i need worpwrap ? How can i do it ?

  6. #6
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    Magnus Norddahl has already answered this in a long post above.

  7. #7
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Default

    Quote Originally Posted by sphair View Post
    Magnus Norddahl has already answered this in a long post above.

    I really need this. I started trying to write it myself but I don't know the clanlib internals well enough, and its not as simple as magnus thought it would be, because when you move the cursor, it has to synchronize that with the vertical scrollbar, and I haven't even got a clue about how to do the vertical one, because it just calls draw on a bunch of layouts and I don't know how to adjust that based on a scrollbar.

    Can we please get some help on this? It's not like I'm not willing to do it, I just don't know the clanlib internals this well and need to keep things moving.

    Incidentally I wrote the Linux side of the Open/Save file dialog. I can submit it. But I need help with this text edit stuff.

  8. #8
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Cool

    Quote Originally Posted by Nightwind0 View Post
    I really need this. I started trying to write it myself but I don't know the clanlib internals well enough, and its not as simple as magnus thought it would be, because when you move the cursor, it has to synchronize that with the vertical scrollbar, and I haven't even got a clue about how to do the vertical one, because it just calls draw on a bunch of layouts and I don't know how to adjust that based on a scrollbar.

    Can we please get some help on this? It's not like I'm not willing to do it, I just don't know the clanlib internals this well and need to keep things moving.

    Incidentally I wrote the Linux side of the Open/Save file dialog. I can submit it. But I need help with this text edit stuff.
    OK. Fine. I went ahead and implemented the vertical scrollbar for CL_TextEdit.

    Here it is! I'm just including a zip of the two files I changed. Let me know if you desparately need a diff instead.

    EDIT: Fixed a bug and reposted file

    Now anybody want to add the horizontal one? :-)
    Attached Files Attached Files
    Last edited by Nightwind0; 08-13-2012 at 03:09 AM. Reason: Fix a bug

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •