Jump to content

RonShortt

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by RonShortt

  1. A textarea using TEXTAREA_WORDWRAP and SetFontScale does not wrap text correctly. Adding

    textarea->SetFontScale(1.5);

    to the textarea example code results in text which goes off the screen to the right.

     

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Ultra Engine", 0, 0, 640, 480, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE);
    
        //Create User Interface
        auto ui = CreateInterface(window);
    
        //Create widget
        auto sz = ui->root->ClientSize();
        auto textarea = CreateTextArea(10, 10, sz.x - 20, sz.y - 20, ui->root, TEXTAREA_WORDWRAP);
        textarea->SetFontScale(1.5);
    
        WString s = L"Night was falling now, and as I recalled what Akeley had written me about those earlier nights \
    I shuddered to think there would be no moon. Nor did I like the way the farmhouse nestled in the lee of that\
    colossal forested slope leading up to the Dark Mountains unvisited crest. With Akeleys permission I lighted a small oil lamp,\
     turned it low, and set it on a distant bookcase beside the ghostly bust of Milton; but afterward I was sorry I had done so, for \
    it made my hosts strained, immobile face and listless hands look damnably abnormal and corpselike. He seemed half-incapable of motion, \
    though I saw him nod stiffly once in a while.";
    
        textarea->SetText(s);
        textarea->SetLayout(1, 1, 1, 1);
    
        while (true)
        {
            const Event ev = WaitEvent();
            switch (ev.id)
            {
            case EVENT_WINDOWCLOSE:
                return 0;
                break;
            }
        }
        return 0;
    }

     

     

    Untitled.bmp

    • Thanks 1
  2. It is an area of the screen where I am writing output from the program on an ongoing basis as the program runs. I will take a closer look at the text area widget this evening and see if I can use that to accomplish the same thing.

  3. So I dug out my 30 year old copy of Introduction to the X Window System (Updated for XVIIR4) and started reading. In the section on fonts it says:

    Quote

    If there is any special action to be taken for control characters, the application must be programmed to take it explicitly.

    That would indicate that either Ultra App Kit or my program must deal with the newline character as the X Window system simply treats it as just another (unprintable) character.

    • Haha 1
  4. I have used GetText to retrieve the text after it is (improperly) displayed and printed it via cout and the newline in the returned string works as expected. The issue seems to be that the Linux library is not dealing with the newline in the same (proper) manner as the Windows library.

    • Like 1
  5. 3 hours ago, Roland said:

    Have you tested  std::endl

    https://en.cppreference.com/w/cpp/io/manip/endl

     

    Unfortunately std::endl operates on the output I/O system rather than providing a newline character. According to the link you provided:

     

    Quote

     

    Inserts a newline character into the output sequence os and flushes it as if by calling os.put(os.widen('\n')) followed by os.flush().

    This is an output-only I/O manipulator, it may be called with an expression such as out << std::endl for any out of type std::basic_ostream.

     

     

    • Like 1
  6. My program is working fine in Windows when I use '\n' in a c++ string to get a newline in the text of a label. I have now compiled it on Linux and the newline character is displayed as a character block as if the character cannot be displayed. Is there a way to get Linux to execute the same way as Windows. Here is sample code (a slightly modified version of the label sample code)?

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]);
    
        //Create User Interface
        auto ui = CreateInterface(window);
    
        //Create widget
        auto label1 = CreateLabel("Label", 20, 20, 120, 30, ui->root);
        auto label2 = CreateLabel("Border\nLabel", 20, 50, 120, 60, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE);
    
        while (window->Closed() == false)
        {
            WaitEvent();
        }
        return 0;
    }

     

  7. I am loading a number of SVG icon files and wondered if there was a way to embed them in the C++ source code so that I don't need to include the files with the executable. LoadIcon only accepts a file name or Stream as the icon source.

×
×
  • Create New...