gansm / finalcut

A text-based widget toolkit
https://github.com/gansm/finalcut/wiki/First-steps#first-steps-with-the-final-cut-widget-toolkit
GNU Lesser General Public License v3.0
981 stars 52 forks source link

Align Right for FLineedit #107

Closed wimstockman closed 1 year ago

wimstockman commented 1 year ago

Feature Request

Is there a possibility to align right in FLineEdit or align center ? Kind regards, Wim

gansm commented 1 year ago

Very nice idea! I implemented it directly.

#include <final/final.h>

using namespace finalcut;

int main (int argc, char* argv[])
{
  FApplication app(argc, argv);

  // The dialog window
  FDialog dialog("The window title", &app);
  dialog.setGeometry (FPoint{23, 5}, FSize{34, 13});

  // The child objects from dialog
  FLineEdit text_field1("Left", &dialog);
  FLineEdit text_field2("Center", &dialog);
  FLineEdit text_field3("Right", &dialog);
  FButton exit_btn("E&xit", &dialog);

  // Set the geometry of widgets
  text_field1.setGeometry(FPoint{2, 2}, FSize{30, 1});
  text_field2.setGeometry(FPoint{2, 4}, FSize{30, 1});
  text_field3.setGeometry(FPoint{2, 6}, FSize{30, 1});
  exit_btn.setGeometry(FPoint{22, 9}, FSize{10, 1});

  // Set the alignment of text fields
  text_field1.setAlignment(Align::Left);  // default alignment
  text_field2.setAlignment(Align::Center);
  text_field3.setAlignment(Align::Right);

  exit_btn.addCallback
  (
    "clicked",
    finalcut::getFApplication(),
    &finalcut::FApplication::cb_exitApp,
    &dialog
  );

  FWidget::setMainWidget(&dialog);
  dialog.show();
  return app.exec();
}

grafik

wimstockman commented 1 year ago

Great thanks for the quick implementation. Already using it my application. Great Work ! Kind regards, Wim Stockman