1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/*
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#pragma once
#include <mforms/panel.h>
namespace mforms {
class ScrollPanel;
enum ScrollPanelFlags {
ScrollPanelNoFlags = 0,
ScrollPanelBordered = (1<<0),
ScrollPanelDrawBackground = (1<<1)
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef SWIG
struct MFORMS_EXPORT ScrollPanelImplPtrs
{
bool (*create)(ScrollPanel*, ScrollPanelFlags flags);
void (*add)(ScrollPanel*, View*);
void (*remove)(ScrollPanel*);
void (*set_visible_scrollers)(ScrollPanel*, bool vertical, bool horizontal);
void (*set_autohide_scrollers)(ScrollPanel*, bool flag);
void (*scroll_to_view)(ScrollPanel*, View*);
base::Rect (*get_content_rect)(ScrollPanel*);
void (*scroll_to)(ScrollPanel*, int x, int y);
};
#endif
#endif
/** A container panel with scrollbars.
Single item container that will show scrollbars to accommodate arbitrarily sized
contents. */
class MFORMS_EXPORT ScrollPanel : public Container
{
public:
/** Constructor.
@param flags -
@li ScrollPanelBordered - whether a single pixel border should be drawn around the contents
@li ScrollPanelDrawBackground - whether the background of the panel should be transparent
*/
ScrollPanel(ScrollPanelFlags flags=ScrollPanelNoFlags);
~ScrollPanel();
/** Sets whether the vertical and horizontal scrollbars should be created.
By default, both scrollbars are created. */
void set_visible_scrollers(bool vertical, bool horizontal);
/** Sets whether scrollbars are automatically hidden when the contents fit in the
available space. */
void set_autohide_scrollers(bool flag);
/** Sets content view. */
void add(View *child);
/** Removes the content view. */
void remove();
/* Tries to scroll to given child. In other words to make sure child is visible. */
void scroll_to_view(View* child);
base::Rect get_content_rect();
/* Scroll to the given x, y.*/
void scroll_to(int x, int y);
protected:
ScrollPanelImplPtrs *_spanel_impl;
};
};
|