adime_d_dou...lc_edit_proc(3)

πŸ“¦ version 2.2.1, in fedora 43, fedora 44

✨ NAME ✨

adime_d_double_calc_edit_proc β€” bestie, it's the Allegro GUI proc that gives you an edit box where you type a lil math expression and it hands you back a floating point number πŸ’– (this is from the Adime API Reference, in case you were wondering πŸŽ€)


🌸 SYNOPSIS 🌸

#include <adime.h>

int adime_d_double_calc_edit_proc(int msg, DIALOG *d, int c);

πŸ’… DESCRIPTION πŸ’…

Okay so, no cap: this is a Gui proc for an edit box that accepts a mathematical expression, and the result of that expression is a floating point number. As the user types, the result gets calculated and displayed on a separate gui object. The edit box itself? It's giving 3d-ish look ✨ lowkey iconic.

The dp2 field points to a struct ADIME_EDIT_NUMBER * and that struct is literally holding all the tea about how the edit box should behave:

typedef struct ADIME_EDIT_NUMBER
{
   int is_signed;          /* Set for integer formats if it is signed. */
   int is_float;           /* Set if we only have float, not double. */
   double min_val, max_val;/* Range for numbers. */
   DIALOG *result_object;  /* DIALOG object to display result in. */
} ADIME_EDIT_NUMBER;

The result_object is the one that's gonna display the result of the expression, periodt. There's an adime_d_calc_edit_result_proc object type that was literally designed to be used as the result_object, but bestie, you can of course write your own object to take care of that if you want to be extra πŸ™ˆ.

So whenever the user changes the text in the adime_d_double_calc_edit_proc, the result gets printed to the dp field of result_object. Which means β€” and this is the part you cannot skip, fr fr β€” you must have set the dp field of result_object to a text buffer with enough space. 256 bytes is safe, so like, just do that 🫢.

Then result_object gets sent a MSG_DRAW message, and the c parameter is set to 2 if there's an error in the expression, or 1 if it's ok. That's the whole vibe check right there πŸ‘‘

⚠️ For real though: if you forget to give result_object's dp a big enough buffer, that's on you, and it will not be slay. 256 bytes. Safe. Do it.

πŸ¦‹ SEE ALSO πŸ¦‹


That's the whole page, bestie πŸ’– β€” brought to you by Adime, version 2.2.1, and this little corner of the man pages called adime_d_dou...lc_edit_proc(3) πŸŽ€βœ¨

πŸ“¦ where this page comes from