Recent Posts

Pages: 1 2 3 4 5 [6] 7 8 9 10
51
Development / Re: wxSmith use bad constructor for wxStaticBoxSizer
« Last post by LR83 on January 07, 2026, 06:14:31 pm »
I try to find a patch to correct this.
First, we can add a temporary wxStaticBox when we add the wxStaticBoxSizer.
In the file wxsstaticboxsizer.cpp we replace in OnBuildSizerCreatingCode() function this code:
Quote
        case wxsCPP:
        {
            AddHeader(_T("<wx/sizer.h>"),GetInfo().ClassName,hfInPCH);
            AddHeader(_T("<wx/statbox.h>"),GetInfo().ClassName,hfInPCH);
            Codef(_T("%C(%s, %W, %t);\n"),
                    (Orient!=wxHORIZONTAL)?_T("wxVERTICAL"):_T("wxHORIZONTAL"),
                    Label.wx_str());
            Codef(_T("wxStaticBox *SB_%s = %s->GetStaticBox();\n"),GetVarName().wx_str(),GetVarName().wx_str());
            return;
        }

The problem now is to replace, in all constructors of the children of wxStaticBoxSizer, the parent with this temporary wxStaticBox.
I don't know how to do it right now.
52
Development / Re: wxSmith use bad constructor for wxStaticBoxSizer
« Last post by LR83 on January 07, 2026, 11:42:32 am »
We can correct the code simply by:
- replace this by StaticBoxSizer1->GetStaticBox() in the wxStaticText and wxTextCtrl constructor
- add the include <wx/statbox.h>
53
Development / wxSmith use bad constructor for wxStaticBoxSizer
« Last post by LR83 on January 07, 2026, 11:17:45 am »
The documentation say that the child of a wxStaticBoxSizer should be the wxBoxSizer and not the owner of the wxStaticBoxSizer.
On Linux, for example, I can see the following warning on the console:
Element wxStaticText of wxStaticBoxSizer should be created as child of its wxStaticBox and not of wxDialog.

I test several builder on a very simple case: a dialog window with a wxStaticBoxSizer that contain a wxStaticText and a wxTextCtrl.
With wxSmith:
Quote
DialogFormSmith::DialogFormSmith(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(DialogFormSmith)
    wxStaticBoxSizer* StaticBoxSizer1;

    Create(parent, id, _("Test with wxSmith"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
    StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("StaticBoxSizer"));
    StaticText1 = new wxStaticText(this, wxID_ANY, _("Label"), wxDefaultPosition, wxDefaultSize, 0);
    StaticBoxSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    TextCtrl1 = new wxTextCtrl(this, wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
    StaticBoxSizer1->Add(TextCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    SetSizer(StaticBoxSizer1);
    StaticBoxSizer1->SetSizeHints(this);
    //*)
}

with wxFormBuilder:
Quote
DialogFormBuilder::DialogFormBuilder( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
   this->SetSizeHints( wxDefaultSize, wxDefaultSize );

   wxStaticBoxSizer* sbSizer1;
   sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("StaticBoxSizer") ), wxHORIZONTAL );

   m_staticText1 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
   m_staticText1->Wrap( -1 );
   sbSizer1->Add( m_staticText1, 0, wxALL, 5 );

   m_textCtrl1 = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
   sbSizer1->Add( m_textCtrl1, 0, wxALL, 5 );


   this->SetSizer( sbSizer1 );
   this->Layout();
   sbSizer1->Fit( this );

   this->Centre( wxBOTH );
}

With wxGlade:
Quote
DialogFormGlade::DialogFormGlade(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
    wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE)
{
    // begin wxGlade: DialogFormGlade::DialogFormGlade
    SetTitle(wxT("Test with wxGlade"));
    wxStaticBoxSizer* sizer_1 = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, wxT("StaticBoxSizer")), wxHORIZONTAL);
    wxStaticText* label_1 = new wxStaticText(sizer_1->GetStaticBox(), wxID_ANY, wxT("Label"));
    sizer_1->Add(label_1, 0, 0, 0);
    text_ctrl_1 = new wxTextCtrl(sizer_1->GetStaticBox(), wxID_ANY, wxEmptyString);
    sizer_1->Add(text_ctrl_1, 0, 0, 0);

    SetSizer(sizer_1);
    sizer_1->Fit(this);
    Layout();
    // end wxGlade
}

The codes generated by wxFormBuilder and wxGlade are good: no warning.
I join a complete project for testing

54
Development / Re: AI may help us to create plugins
« Last post by jackmarvia2323 on January 07, 2026, 07:08:59 am »
AI as a helper is fine tbh good for boilerplate or ideas but blind copy-paste is scary tool ≠ replacement use brain first 😅
55
Using Code::Blocks / Re: How to print beautiful PDF files from source code on Linux
« Last post by cdavalillo on January 02, 2026, 12:35:46 am »
I forget to mention that you can create your own custom theme for highlight. If you see at the path
Code
/usr/share/highlight/themes

There are all the theme files, you can create a new file for example mycustomtheme.theme with the proper configuration and place it at /usr/share/highlight/themes, later in the scrip modify the line
Code
--style=github \

and change the github style to the mycustomtheme to apply the custom theme to the generated PDF files.
Code
--style=mycustomtheme \

To see the syntax of the .theme file just see the other files at /usr/share/highlight/themes directory with a text editor.
56
Not the debug tip window, sometimes, the code completion tip(from the clangd_client plugin) window becomes extremely large, see the blow two screen shot, the tip window cover the whole C::B window, also the tip window extended to another screen.  :(
""
In settings>editor>CodeCompletion what have you got set for "Maximum allowed code completion matches" ?
57
Is there any way you could tell me what "auto" actually is or give me an example as to how to re-create the situation you're showing here?

You can simply do this:

1, clone the code repo or download the zip file:  asmwarrior/parserlib: A c++ recursive-descent PEG parsing library that supports left recursion..

2, open the cbp project in the root folder: https://github.com/asmwarrior/parserlib/blob/master/test_parser_lib.cbp

3, open the file: cpp_lexer_grammar.h in the C::B editor

4, you can use clangd_client, and use the mouse to hover the "token" variable in the line 172

5, you will see a very big tip window which cover the whole screen, note I only tested on Windows 10 OS.

Thanks.

For me cpp_lexer_grammar.h has no line 172 and I cannot figure out how to get any large response from hovering over a variable in any of the code.
58
Using Code::Blocks / How to print beautiful PDF files from source code on Linux
« Last post by cdavalillo on January 01, 2026, 10:25:39 pm »
This post is to create a tool that allow the users to create custom PDF files from source code in Linux

1) First we install the needed applications. We need to install highlight and wkhtmltopdf. To install highlight we run the command in the terminal
Code
sudo apt install highlight

To install wkhtmltopdf however we need to download the binaries from the development repositories due to the distributions almost always have an incomplete version lacking of Qt functionality that is needed for proper function of wkhtmltopdf. So we go to the wkhtmltopdf github repositories https://github.com/wkhtmltopdf/packaging/releases and download the needed binary. We install it and then

2) Create a bash scrip with the following code and saved with the name cpp2pdf.sh
Code
#!/bin/bash
INPUT="$1"
USERNAME="$2"
FILENAME=$(basename "${INPUT%.*}")
DATE=$(date +"%Y-%m-%d %H:%M:%S")

PDF_OUTPUT_DIR="$HOME/EXPORTED_PDF"

# Step 1: Generate HTML with syntax highlighting
highlight -O html  \
  --font=Courier \
  --font-size=17 \
  --style=github \
  --line-length=96 \
  --line-numbers \
  --zeroes \
  --reformat=allman \
  --input="$INPUT" \
  --output="$PDF_OUTPUT_DIR/$FILENAME.html"

# Step 2: Convert to PDF
wkhtmltopdf --enable-local-file-access \
  --header-html "$PDF_OUTPUT_DIR/header.html" \
  --header-left "File: $FILENAME" \
  --header-right "Author: $USERNAME" \
  --footer-center "Page [page] of [topage] | $DATE" \
  --page-size A4 \
  --orientation Portrait \
  --margin-top 30mm \
  --margin-bottom 20mm \
  --margin-left 10mm \
  --margin-right 10mm \
  "$PDF_OUTPUT_DIR/$FILENAME.html" \
  "$PDF_OUTPUT_DIR/$FILENAME.pdf"

echo "Created: $PDF_OUTPUT_DIR/$FILENAME.pdf"
echo "  File: $FILENAME"
echo "  User: $USERNAME"
echo "  Date: $DATE"

# Open the PDF after creation
if [ -f "$PDF_OUTPUT_DIR/$FILENAME.pdf" ]; then
    xdg-open "$PDF_OUTPUT_DIR/$FILENAME.pdf" &
    exit 0
else
    echo "Error: PDF was not created"
    exit 1
fi


3) We give execution permission to the scrip with the command
Code
chmod +x cpp2pdf.sh

4) In our Home directory we create a directory with the name EXPORTED_PDF (see that this name appears in the script and is the place where the PDF files are placed). You can change this directory but you have to change the script too.

5) In the EXPORTED_PDF directory we create a custom HTML file named header.html that contains a custom header

6) Now in Code::Blocks we add an external tool going to the Tools menu then to Configure Tools and we click Add to add the new tool

7) In the name field put: Export clean PDF

8 ) In executable browse to the script file cpp2pdf.sh

9) In working directory put (please note the quotation marks that are needed)
Code
"$(PROJECT_DIR)"

10) In Parameters put (change the "Author name" to your name or organization name), please note the double quotation marks
Code
"$(ACTIVE_EDITOR_FILENAME)" "Author name"

11) Finally we click Ok and the tool is ready

Now we can simply open some source code file and go to Tools -> Export clean PDF and the current file shown in editor is exported to PDF in the EXPORTED_PDF directory.

This simply tools highlight and wkhtmltopdf can be customized to create great quality outputs. Note that there are many styles that can be used in highlight.

Is important to remember to create the header.html file in the EXPORTED_PDF directory for add custom header, you can remove the custom header by removing the following line of the script
Code
--header-html "$PDF_OUTPUT_DIR/header.html" \

You can also add a custom footer by adding the following line just below the "--header-html "$PDF_OUTPUT_DIR/header.html" \" part of the code
Code
--footer-html "$PDF_OUTPUT_DIR/footer.html" \

The custom headers and footers can be customized to include custom fonts, custom formatting, text and so on. See at the attached file to see the results. There are dark themes in highlight too.

The following is an example of a custom header (note that must be a directory inside the EXPORTED_PDF directory named "fonts" containing the custom font Titillium Web)
Code
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="css/index-style.css" type="text/css"/>
  <style>
    @font-face{
      font-family: 'Titillium Web';
      src: url('/fonts/TitilliumWeb-Regular.ttf');
      src: local('Titillium Web'),
          url('/fonts/TitilliumWeb-Regular.ttf') format('truetype');
    }
    body {
      margin: 0;
      padding: 0;
      font-family: Arial, sans-serif;
      font-size: 10px;
      color: #555;
    }
    .header {
      width: 100%;
      text-align: center;
      border-bottom: 1px solid #ccc;
      padding-bottom: 2px;
    }
  </style>
</head>
<body>
  <div class="header">
    <span style="font-family: 'Titillium Web';font-size: 2.5em">My Company</span>
  </div>
</body>
</html>

You can add more wild customization if you wish.
59
Help / Re: Unexpected key mapping when using C::B over X11 with Linux Trixie
« Last post by Pecan on December 30, 2025, 07:06:13 pm »
My guess is that the problem is in the selected keyboard layout or something is intercepting ctrl-8 and sending in the shift-return instead.
60
Help / Re: Unexpected key mapping when using C::B over X11 with Linux Trixie
« Last post by ClassicRover on December 30, 2025, 01:45:05 pm »
I only have MainMenu>Settings>Editor>KeyboardShortcuts if I sudo apt install codeblocks-contrib (which I hadn't done before I discovered this problem). Although I first discovered this problem when I had ported my big project from codeblocks 20.x, I also get the same problem with a vanilla installation of deban trixie (straight from Raspberry Pi Imager) with a vanilla installation of codeblocks 25.03 (using sudo port install codeblocks).

Keyboard Shortcuts:Other:Insert new line is showing as Shift-RETURN

Interestingly, if I try to code a new shortcut and press e.g. control-8 the new shortcut box says Ctrl-RETURN, so codeblocks internally believes my 8 to be RETURN.
Pages: 1 2 3 4 5 [6] 7 8 9 10