Refactor ui_pad_activate
This commit is contained in:
parent
9a36b82d5d
commit
71ec47b32e
|
@ -32,6 +32,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#include "u_mem.h"
|
#include "u_mem.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "varutil.h"
|
#include "varutil.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -394,7 +395,7 @@ extern void menubar_show();
|
||||||
|
|
||||||
void ui_pad_init();
|
void ui_pad_init();
|
||||||
void ui_pad_close();
|
void ui_pad_close();
|
||||||
void ui_pad_activate( UI_DIALOG * dlg, int x, int y );
|
void ui_pad_activate(UI_DIALOG &dlg, uint_fast32_t x, uint_fast32_t y);
|
||||||
void ui_pad_deactivate();
|
void ui_pad_deactivate();
|
||||||
void ui_pad_goto(int n);
|
void ui_pad_goto(int n);
|
||||||
void ui_pad_goto_next();
|
void ui_pad_goto_next();
|
||||||
|
|
|
@ -143,70 +143,75 @@ static void set_short_row(keypad_input_line_t::const_iterator i, const keypad_in
|
||||||
*ob = 0;
|
*ob = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_pad_activate( UI_DIALOG * dlg, int x, int y )
|
static std::unique_ptr<UI_GADGET_BUTTON> ui_create_pad_gadget(UI_DIALOG &dlg, uint_fast32_t x, uint_fast32_t y, uint_fast32_t w, uint_fast32_t h, const grs_font &font)
|
||||||
{
|
{
|
||||||
|
auto r = ui_add_gadget_button(&dlg, x, y, w, h, nullptr, nullptr);
|
||||||
|
r->canvas->cv_font = &font;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_pad_activate(UI_DIALOG &dlg, uint_fast32_t x, uint_fast32_t y)
|
||||||
|
{
|
||||||
|
const uint_fast32_t bw = 56;
|
||||||
|
const uint_fast32_t bh = 30;
|
||||||
|
const uint_fast32_t x5 = x + 5;
|
||||||
|
const uint_fast32_t y20 = y + 20;
|
||||||
|
const auto &font = *ui_small_font.get();
|
||||||
|
const auto fx = [=](uint_fast32_t col) {
|
||||||
|
return x5 + (bw * col);
|
||||||
|
};
|
||||||
|
const auto fy = [=](uint_fast32_t row) {
|
||||||
|
return y20 + (bh * row);
|
||||||
|
};
|
||||||
|
const auto fw = [=](uint_fast32_t w) {
|
||||||
|
return bw * w;
|
||||||
|
};
|
||||||
|
const auto fh = [=](uint_fast32_t h) {
|
||||||
|
return bh * h;
|
||||||
|
};
|
||||||
|
const auto ui_add_pad_gadget = [&dlg, &font](uint_fast32_t n, uint_fast32_t x, uint_fast32_t y, uint_fast32_t w, uint_fast32_t h) {
|
||||||
|
Pad[n] = ui_create_pad_gadget(dlg, x, y, w, h, font);
|
||||||
|
};
|
||||||
|
|
||||||
int w,h,row,col, n;
|
int w,h,row,col, n;
|
||||||
int bh, bw;
|
|
||||||
|
|
||||||
bw = 56; bh = 30;
|
|
||||||
|
|
||||||
x += 5;
|
|
||||||
y += 20;
|
|
||||||
|
|
||||||
desc_x = x+2;
|
desc_x = x+2;
|
||||||
desc_y = y-17;
|
desc_y = y-17;
|
||||||
|
|
||||||
n=0; row = 0; col = 0; w = 1; h = 1;
|
n=0; row = 0; col = 0; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=1; row = 0; col = 1; w = 1; h = 1;
|
n=1; row = 0; col = 1; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=2; row = 0; col = 2; w = 1; h = 1;
|
n=2; row = 0; col = 2; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=3; row = 0; col = 3; w = 1; h = 1;
|
n=3; row = 0; col = 3; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=4; row = 1; col = 0; w = 1; h = 1;
|
n=4; row = 1; col = 0; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=5; row = 1; col = 1; w = 1; h = 1;
|
n=5; row = 1; col = 1; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=6; row = 1; col = 2; w = 1; h = 1;
|
n=6; row = 1; col = 2; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=7; row = 1; col = 3; w = 1; h = 2;
|
n=7; row = 1; col = 3; w = 1; h = 2;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=8; row = 2; col = 0; w = 1; h = 1;
|
n=8; row = 2; col = 0; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=9; row = 2; col = 1; w = 1; h = 1;
|
n=9; row = 2; col = 1; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=10; row = 2; col = 2; w = 1; h = 1;
|
n=10; row = 2; col = 2; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=11; row = 3; col = 0; w = 1; h = 1;
|
n=11; row = 3; col = 0; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=12; row = 3; col = 1; w = 1; h = 1;
|
n=12; row = 3; col = 1; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=13; row = 3; col = 2; w = 1; h = 1;
|
n=13; row = 3; col = 2; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=14; row = 3; col = 3; w = 1; h = 2;
|
n=14; row = 3; col = 3; w = 1; h = 2;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=15; row = 4; col = 0; w = 2; h = 1;
|
n=15; row = 4; col = 0; w = 2; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
n=16; row = 4; col = 2; w = 1; h = 1;
|
n=16; row = 4; col = 2; w = 1; h = 1;
|
||||||
Pad[n] = ui_add_gadget_button( dlg, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
|
ui_add_pad_gadget(n, fx(col), fy(row), fw(w), fh(h));
|
||||||
Pad[n]->canvas->cv_font = ui_small_font.get();
|
|
||||||
|
|
||||||
HotKey[0] = KEY_CTRLED + KEY_NUMLOCK;
|
HotKey[0] = KEY_CTRLED + KEY_NUMLOCK;
|
||||||
HotKey[1] = KEY_CTRLED + KEY_PADDIVIDE;
|
HotKey[1] = KEY_CTRLED + KEY_PADDIVIDE;
|
||||||
|
@ -251,9 +256,9 @@ void ui_pad_activate( UI_DIALOG * dlg, int x, int y )
|
||||||
|
|
||||||
void ui_pad_deactivate()
|
void ui_pad_deactivate()
|
||||||
{
|
{
|
||||||
for (int i=0; i<17; i++ )
|
range_for (auto &i, Pad)
|
||||||
{
|
{
|
||||||
Pad[i]->text.clear();
|
i->text.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -743,7 +743,7 @@ void init_editor_screen()
|
||||||
//ui_add_gadget_button( EditorWindow, 520, 540, 50, 25, "About", ShowAbout );
|
//ui_add_gadget_button( EditorWindow, 520, 540, 50, 25, "About", ShowAbout );
|
||||||
//ui_add_gadget_button( EditorWindow, 640, 540, 50, 25, "Shell", DosShell );
|
//ui_add_gadget_button( EditorWindow, 640, 540, 50, 25, "Shell", DosShell );
|
||||||
|
|
||||||
ui_pad_activate( EditorWindow, PAD_X, PAD_Y );
|
ui_pad_activate(*EditorWindow, PAD_X, PAD_Y);
|
||||||
Pad_info = info_window_create();
|
Pad_info = info_window_create();
|
||||||
ui_add_gadget_button( EditorWindow, PAD_X+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "<<", med_keypad_goto_prev );
|
ui_add_gadget_button( EditorWindow, PAD_X+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "<<", med_keypad_goto_prev );
|
||||||
ui_add_gadget_button( EditorWindow, PAD_X+PAD_WIDTH1+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, ">>", med_keypad_goto_next );
|
ui_add_gadget_button( EditorWindow, PAD_X+PAD_WIDTH1+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, ">>", med_keypad_goto_next );
|
||||||
|
|
Loading…
Reference in a new issue