Esempio n. 1
0
    virtual void rdp_input_mouse(int device_flags, int x, int y, Keymap2* keymap)
    {
        Widget2 * w = this->widget_at_pos(x, y);

        // Mouse clic release
        // w could be null if mouse is located at an empty space
        if (device_flags == MOUSE_FLAG_BUTTON1) {
            if (this->pressed
                && (w != this->pressed)) {
                this->pressed->rdp_input_mouse(device_flags, x, y, keymap);
            }
        }
        if (w){
            // get focus when mouse clic
            if (device_flags == (MOUSE_FLAG_BUTTON1|MOUSE_FLAG_DOWN)) {
                this->pressed = w;
                if ((w->focus_flag != IGNORE_FOCUS) && (w != this->current_focus)){
                    this->set_widget_focus(w);
                }
            }
            w->rdp_input_mouse(device_flags, x, y, keymap);
        }
        else {
            Widget2::rdp_input_mouse(device_flags, x, y, keymap);
        }
    }
Esempio n. 2
0
    void rdp_input_mouse(int device_flags, int mouse_x, int mouse_y, Keymap2 * keymap) override {
        if (device_flags == (MOUSE_FLAG_BUTTON1 | MOUSE_FLAG_DOWN)) {
            uint16_t y = this->rect.y;
            for (uint16_t row_index = 0; row_index < this->nb_rows; row_index++) {
                uint16_t x = this->rect.x;
                Rect rectRow(x, y, this->rect.cx, this->row_height[row_index] + this->border * 2);

                if (rectRow.contains_pt(mouse_x, mouse_y)) {
                    if (row_index != this->selection_y) {
                        this->click_interval.update();
                        this->set_selection(row_index);
                    }
                    else {
                        if (this->click_interval.tick() <= uint64_t(700000L)) {
                            this->send_notify(NOTIFY_SUBMIT);
                            return;
                        }
                    }
                }

                y += this->row_height[row_index] + this->border * 2;
            }
        }
        else if (device_flags == MOUSE_FLAG_MOVE) {
            Widget2 * wid = this->widget_at_pos(mouse_x, mouse_y);
            if (wid) {
                wid->rdp_input_mouse(device_flags, mouse_x, mouse_y, keymap);
            }
        }

        Widget2::rdp_input_mouse(device_flags, mouse_x, mouse_y, keymap);
    }
Esempio n. 3
0
 void draw(const Rect& clip)
 {
     for (size_t i = 0; i < this->size; ++i) {
         Widget2 *w = this->child_list[i];
         w->refresh(clip.intersect(w->rect));
     }
 }
Esempio n. 4
0
    void rdp_input_mouse(int device_flags, int x, int y, Keymap2 * keymap) override {
        Widget2 * w = this->widget_at_pos(x, y);

        // Mouse clic release
        // w could be null if mouse is located at an empty space
        if (device_flags == MOUSE_FLAG_BUTTON1) {
            if (this->pressed
                && (w != this->pressed)) {
                this->pressed->rdp_input_mouse(device_flags, x, y, keymap);
            }
            this->pressed = nullptr;
        }
        if (w) {
            // get focus when mouse clic
            if (device_flags == (MOUSE_FLAG_BUTTON1 | MOUSE_FLAG_DOWN)) {
                this->pressed = w;
                if (/*(*/w->focus_flag != IGNORE_FOCUS/*) && (w != this->current_focus)*/) {
                    this->set_widget_focus(w, focus_reason_mousebutton1);
                }
            }
            w->rdp_input_mouse(device_flags, x, y, keymap);
        }
        else {
            Widget2::rdp_input_mouse(device_flags, x, y, keymap);
        }
        if (device_flags == MOUSE_FLAG_MOVE && this->pressed) {
            this->pressed->rdp_input_mouse(device_flags, x, y, keymap);
        }
    }
Esempio n. 5
0
    virtual void draw_children(const Rect & clip) {
        CompositeContainer::iterator iter_w_current = this->impl->get_first();
        while (iter_w_current != reinterpret_cast<CompositeContainer::iterator>(CompositeContainer::invalid_iterator)) {
            Widget2 * w = this->impl->get(iter_w_current);
            REDASSERT(w);

            w->refresh(clip.intersect(w->rect));

            iter_w_current = this->impl->get_next(iter_w_current);
        }
    }
Esempio n. 6
0
    void move_xy(int16_t x, int16_t y) {
        CompositeContainer::iterator iter_w_first = this->impl->get_first();
        if (iter_w_first != reinterpret_cast<CompositeContainer::iterator>(CompositeContainer::invalid_iterator)) {
            CompositeContainer::iterator iter_w_current = iter_w_first;
            do {
                Widget2 * w = this->impl->get(iter_w_current);
                REDASSERT(w);
                w->set_xy(x + w->dx(), y + w->dy());

                iter_w_current = this->impl->get_next(iter_w_current);
            }
            while ((iter_w_current != iter_w_first) &&
                   (iter_w_current != reinterpret_cast<CompositeContainer::iterator>(CompositeContainer::invalid_iterator)));
        }
    }
Esempio n. 7
0
    void draw_row(uint16_t row_index, const Rect & clip) {
        uint32_t bg_color;
        uint32_t fg_color;

        if (this->selection_y == row_index) {
            bg_color = (this->has_focus ? this->bg_color_focus : this->bg_color_selection);
            fg_color = (this->has_focus ? this->fg_color_focus : this->fg_color_selection);
        }
        else {
            const bool odd = row_index & 1;
            bg_color = (odd ? this->bg_color_1 : this->bg_color_2);
            fg_color = (odd ? this->fg_color_1 : this->fg_color_2);
        }

        uint16_t y = this->rect.y;
        for (uint16_t r_index = 0, r_count = std::min<uint16_t>(row_index, this->nb_rows);
             r_index < r_count; r_index++) {
            y += this->row_height[r_index] + this->border * 2;
        }

        uint16_t x = this->rect.x;
        Rect rectRow(x, y, this->rect.cx, this->row_height[row_index] + this->border * 2);
        this->drawable.draw(RDPOpaqueRect(rectRow, bg_color), clip);

        x += this->border;
        y += this->border;

        for (uint16_t column_index = 0; column_index < this->nb_columns; column_index++) {
            Widget2 * w = this->widgets[column_index][row_index];
            Rect rectCell(x, y, this->column_width[column_index], this->row_height[row_index]);
            if (w) {
                w->set_xy(rectCell.x, rectCell.y);
                w->set_wh(rectCell.cx, rectCell.cy);

                w->set_color(bg_color, fg_color);

                Rect destRect = clip.intersect(rectCell);
                if (!destRect.isempty()) {
                    w->draw(destRect);
                }
            }

            x += this->column_width[column_index] + this->border * 2;
        }
    }
Esempio n. 8
0
inline
void compute_format(WidgetGrid & grid, ColumnWidthStrategy * column_width_strategies, uint16_t * row_height, uint16_t * column_width) {
    uint16_t column_width_optimal[GRID_NB_COLUMNS_MAX] = { 0 };

    for (uint16_t row_index = 0; row_index < grid.get_nb_rows(); row_index++) {
        for (uint16_t column_index = 0; column_index < grid.nb_columns; column_index++) {
            Widget2 * w = grid.get_widget(row_index, column_index);
            if (!w) {
                continue;
            }

            Dimension dim = w->get_optimal_dim();
            if (column_width_optimal[column_index] < dim.w) {
                column_width_optimal[column_index] = dim.w + 2;
            }

            if (row_height[row_index] < dim.h) {
                row_height[row_index] = dim.h;
            }
        }
    }


    // TODO Optiomize this
    uint16_t unsatisfied_column_count = 0;
    // min
    uint16_t unused_width = static_cast<int16_t>(grid.rect.cx - grid.border * 2 * grid.nb_columns);
    for (uint16_t column_index = 0; column_index < grid.nb_columns; column_index++) {
        column_width[column_index] = column_width_strategies[column_index].min;
        unused_width -= static_cast<int16_t>(column_width_strategies[column_index].min);

        if (column_width[column_index] < std::min(column_width_optimal[column_index], column_width_strategies[column_index].max)) {
            unsatisfied_column_count++;
        }
    }
    // optimal
    while ((unused_width > 0) && (unsatisfied_column_count > 0)) {
        const uint16_t part = unused_width / unsatisfied_column_count;
        if (!part) {
            break;
        }
        unsatisfied_column_count = 0;
        for (uint16_t column_index = 0; column_index < grid.nb_columns; column_index++) {
            uint16_t optimal_max = std::min(column_width_optimal[column_index], column_width_strategies[column_index].max);
            if (column_width[column_index] < optimal_max) {
                uint16_t ajusted_part = std::min<uint16_t>(part, optimal_max - column_width[column_index]);
                column_width[column_index] += ajusted_part;
                unused_width -= ajusted_part;

                if (column_width[column_index] < optimal_max) {
                    unsatisfied_column_count++;
                }
            }
        }
    }
    // max
    unsatisfied_column_count = 0;
    for (uint16_t column_index = 0; column_index < grid.nb_columns; column_index++) {
        if (column_width[column_index] < column_width_strategies[column_index].max) {
            unsatisfied_column_count++;
        }
    }
    while ((unused_width > 0) && (unsatisfied_column_count > 0)) {
        const uint16_t part = unused_width / unsatisfied_column_count;
        if (!part) {
            break;
        }
        unsatisfied_column_count = 0;
        for (uint16_t column_index = 0; column_index < grid.nb_columns; column_index++) {
            if (column_width[column_index] < column_width_strategies[column_index].max) {
                uint16_t ajusted_part = std::min<uint16_t>(part, column_width_strategies[column_index].max - column_width[column_index]);
                column_width[column_index] += ajusted_part;
                unused_width -= ajusted_part;

                if (column_width[column_index] < column_width_strategies[column_index].max) {
                    unsatisfied_column_count++;
                }
            }
        }
    }
}
Esempio n. 9
0
 void move_xy(int16_t x, int16_t y) {
     for (size_t i = 0, max = this->size; i < max; ++i) {
         Widget2 * w = this->child_list[i];
         w->set_xy(x + w->dx(), y + w->dy());
     }
 }
Esempio n. 10
0
 virtual void draw(const Rect& clip) {
     for (size_t i = 0; i < this->nb_items; ++i) {
         Widget2 *w = this->items[i];
         w->refresh(clip.intersect(this->rect));
     }
 }