本文整理汇总了C++中redraw函数的典型用法代码示例。如果您正苦于以下问题:C++ redraw函数的具体用法?C++ redraw怎么用?C++ redraw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redraw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toGraph
/**
* mouse wheel event. zooms in/out or scrolls when
* shift or ctrl is pressed.
*/
void QG_GraphicView::wheelEvent(QWheelEvent *e) {
//RS_DEBUG->print("wheel: %d", e->delta());
//printf("state: %d\n", e->state());
//printf("ctrl: %d\n", Qt::ControlButton);
if (container==NULL) {
return;
}
RS_Vector mouse = toGraph(RS_Vector(e->x(), e->y()));
#if QT_VERSION >= 0x050200
QPoint numPixels = e->pixelDelta();
// high-resolution scrolling triggers Pan instead of Zoom logic
isSmoothScrolling |= !numPixels.isNull();
if (isSmoothScrolling) {
if (e->phase() == Qt::ScrollEnd) isSmoothScrolling = false;
if (!numPixels.isNull()) {
if (e->modifiers()==Qt::ControlModifier) {
// Hold ctrl to zoom. 1 % per pixel
double v = -numPixels.y() / 100.;
RS2::ZoomDirection direction;
double factor;
if (v < 0) {
direction = RS2::Out; factor = 1-v;
} else {
direction = RS2::In; factor = 1+v;
}
setCurrentAction(new RS_ActionZoomIn(*container, *this, direction,
RS2::Both, mouse, factor));
} else {
// otherwise, scroll
//scroll by scrollbars: issue #479
hScrollBar->setValue(hScrollBar->value() - numPixels.x());
vScrollBar->setValue(vScrollBar->value() - numPixels.y());
// setCurrentAction(new RS_ActionZoomScroll(numPixels.x(), numPixels.y(),
// *container, *this));
}
redraw();
}
e->accept();
return;
}
#endif
if (e->delta() == 0) {
// A zero delta event occurs when smooth scrolling is ended. Ignore this
e->accept();
return;
}
bool scroll = false;
RS2::Direction direction = RS2::Up;
// scroll up / down:
if (e->modifiers()==Qt::ControlModifier) {
scroll = true;
switch(e->orientation()){
case Qt::Horizontal:
direction=(e->delta()>0)?RS2::Left:RS2::Right;
break;
default:
case Qt::Vertical:
direction=(e->delta()>0)?RS2::Up:RS2::Down;
}
}
// scroll left / right:
else if (e->modifiers()==Qt::ShiftModifier) {
scroll = true;
switch(e->orientation()){
case Qt::Horizontal:
direction=(e->delta()>0)?RS2::Up:RS2::Down;
break;
default:
case Qt::Vertical:
direction=(e->delta()>0)?RS2::Left:RS2::Right;
}
}
if (scroll) {
//scroll by scrollbars: issue #479
switch(direction){
case RS2::Left:
case RS2::Right:
hScrollBar->setValue(hScrollBar->value()+e->delta());
break;
default:
vScrollBar->setValue(vScrollBar->value()+e->delta());
//.........这里部分代码省略.........
示例2: redraw
/**
* Show is called automatically when the window is created.
*/
void WindowMainMenu::show() {
redraw();
}
示例3: switch
int EnvelopeFreeEdit::handle(int event)
{
const int x_=Fl::event_x()-x();
const int y_=Fl::event_y()-y();
static Fl_Widget *old_focus;
int key;
switch(event) {
case FL_ENTER:
old_focus=Fl::focus();
Fl::focus(this);
// Otherwise the underlying window seems to regrab focus,
// and I can't see the KEYDOWN action.
return 1;
case FL_LEAVE:
Fl::focus(old_focus);
break;
case FL_KEYDOWN:
case FL_KEYUP:
key = Fl::event_key();
if (key==FL_Control_L || key==FL_Control_R){
ctrldown = (event==FL_KEYDOWN);
redraw();
if (pair!=NULL) pair->redraw();
}
break;
case FL_PUSH:
currentpoint=getnearest(x_,y_);
cpx=x_;
cpdt=Penvdt[currentpoint];
lastpoint=currentpoint;
redraw();
if (pair)
pair->redraw();
return 1;
case FL_RELEASE:
currentpoint=-1;
redraw();
if (pair)
pair->redraw();
return 1;
case FL_MOUSEWHEEL:
if (lastpoint>=0) {
if (!ctrldown) {
int ny = Penvval[lastpoint] - Fl::event_dy();
ny = ny < 0 ? 0 : ny > 127 ? 127 : ny;
Penvval[lastpoint] = ny;
oscWrite(to_s("Penvval")+to_s(lastpoint), "c", ny);
oscWrite("Penvval","");
} else if (lastpoint > 0) {
int newdt = Fl::event_dy() + Penvdt[lastpoint];
newdt = newdt < 0 ? 0 : newdt > 127 ? 127 : newdt;
Penvdt[lastpoint] = newdt;
oscWrite(to_s("Penvdt")+to_s(lastpoint), "c", newdt);
oscWrite("Penvdt","");
}
redraw();
if (pair!=NULL) pair->redraw();
return 1;
}
case FL_DRAG:
if (currentpoint>=0){
int ny=limit(127-(int) (y_*127.0/h()), 0, 127);
Penvval[currentpoint]=ny;
const int dx=(int)((x_-cpx)*0.1);
const int newdt=limit(cpdt+dx,0,127);
if(currentpoint!=0)
Penvdt[currentpoint]=newdt;
else
Penvdt[currentpoint]=0;
oscWrite(to_s("Penvval")+to_s(currentpoint), "c", ny);
oscWrite(to_s("Penvdt")+to_s(currentpoint), "c", newdt);
oscWrite("Penvdt","");
oscWrite("Penvval","");
redraw();
if(pair)
pair->redraw();
return 1;
}
}
// Needed to propagate undo/redo keys.
return 0;
}
示例4: redraw
void redraw(bool forceredraw){
redraw(Inter::drawScreen,false,forceredraw);
}
示例5: recreateQuestList
void CQuestLog::sliderMoved (int newpos)
{
recreateQuestList (newpos); //move components
redraw();
}
示例6: cursor2rowcol
//.........这里部分代码省略.........
select_row, select_col);
ret = 1;
}
}
break;
default:
ret = 0; // express disinterest
break;
}
_last_row = R;
break;
case FL_DRAG:
if (_auto_drag == 1) {
ret = 1;
break;
}
if ( _resizing_col > -1 )
{
// Dragging column?
//
// Let user drag even /outside/ the row/col widget.
// Don't allow column width smaller than 1.
// Continue to show FL_CURSOR_WE at all times during drag.
//
int offset = _dragging_x - Fl::event_x();
int new_w = col_width(_resizing_col) - offset;
if ( new_w < _col_resize_min ) new_w = _col_resize_min;
col_width(_resizing_col, new_w);
_dragging_x = Fl::event_x();
table_resized();
redraw();
change_cursor(FL_CURSOR_WE);
ret = 1;
if ( Fl_Widget::callback() && when() & FL_WHEN_CHANGED )
{ do_callback(CONTEXT_RC_RESIZE, R, C); }
}
else if ( _resizing_row > -1 )
{
// Dragging row?
//
// Let user drag even /outside/ the row/col widget.
// Don't allow row width smaller than 1.
// Continue to show FL_CURSOR_NS at all times during drag.
//
int offset = _dragging_y - Fl::event_y();
int new_h = row_height(_resizing_row) - offset;
if ( new_h < _row_resize_min ) new_h = _row_resize_min;
row_height(_resizing_row, new_h);
_dragging_y = Fl::event_y();
table_resized();
redraw();
change_cursor(FL_CURSOR_NS);
ret = 1;
if ( Fl_Widget::callback() && when() & FL_WHEN_CHANGED )
{ do_callback(CONTEXT_RC_RESIZE, R, C); }
} else {
if (Fl::event_button() == 1 && _selecting == CONTEXT_CELL
&& context == CONTEXT_CELL)
{
if (select_row != R || select_col != C)
damage_zone(current_row, current_col, select_row, select_col, R, C);
select_row = R;
select_col = C;
示例7: redraw
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Empty the shapes vector, then redraw
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
void Scene::clear(){
shapes.clear();
redraw();
}
示例8: redraw
void Edit::sttitle(String val)
{
title=val;
redraw();
}
示例9: while
//.........这里部分代码省略.........
xml.setTo("AudioUnits");
if (xml.exists("AudioUnit[0]")) {
xml.setTo("AudioUnit[0]");
do {
string synthName = xml.getValue<string>("Name");
synths[synthName]->getSynth().loadCustomPreset(ofToDataPath("presets/"+xml.getValue<string>("Preset")));
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
xml.setTo("Manta");
setKey(xml.getValue<int>("Key"));
setMode(xml.getValue<int>("Mode"));
setOctave(xml.getValue<int>("Octave"));
setPadFreezingEnabled(xml.getValue<int>("FreezeEnabled") == 1 ? true : false);
xml.setTo("Pads");
if (xml.exists("PadMapping[0]")) {
xml.setTo("PadMapping[0]");
do {
int id = xml.getValue<int>("Id");
string synthName = xml.getValue<string>("SynthName");
string parameterName = xml.getValue<string>("ParameterName");
bool toggle = xml.getValue<int>("Toggle") == 1 ? true : false;
mapPadToParameter(floor(id / 8), id % 8, *synths[synthName], parameterName, toggle);
padMap[id]->min = xml.getValue<float>("Min");
padMap[id]->max = xml.getValue<float>("Max");
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
xml.setTo("Sliders");
if (xml.exists("SliderMapping[0]")) {
xml.setTo("SliderMapping[0]");
do {
int id = xml.getValue<int>("Id");
string synthName = xml.getValue<string>("SynthName");
string parameterName = xml.getValue<string>("ParameterName");
mapSliderToParameter(id, *synths[synthName], parameterName);
sliderMap[id]->min = xml.getValue<float>("Min");
sliderMap[id]->max = xml.getValue<float>("Max");
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
xml.setTo("Buttons");
if (xml.exists("ButtonMapping[0]")) {
xml.setTo("ButtonMapping[0]");
do {
int id = xml.getValue<int>("Id");
string synthName = xml.getValue<string>("SynthName");
string parameterName = xml.getValue<string>("ParameterName");
bool toggle = xml.getValue<int>("Toggle") == 1 ? true : false;
mapButtonToParameter(id, *synths[synthName], parameterName, toggle);
buttonMap[id]->min = xml.getValue<float>("Min");
buttonMap[id]->max = xml.getValue<float>("Max");
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
xml.setTo("Stats");
if (xml.exists("StatMapping[0]")) {
xml.setTo("StatMapping[0]");
do {
int id = xml.getValue<int>("Id");
string synthName = xml.getValue<string>("SynthName");
string parameterName = xml.getValue<string>("ParameterName");
mapStatToParameter(id, *synths[synthName], parameterName);
statMap[id]->min = xml.getValue<float>("Min");
statMap[id]->max = xml.getValue<float>("Max");
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
xml.setTo("MidiMap");
if (xml.exists("MidiMapping[0]")) {
clearMidiMapping();
xml.setTo("MidiMapping[0]");
do {
setMidiMapping(xml.getValue<int>("Id"), synths[xml.getValue<string>("SynthName")]);
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
redraw();
}
示例10: toggleCB
void Flu_Toggle_Group :: toggleCB()
{
do_callback();
redraw();
}
示例11: main
int main(int argc, char * argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: %s image_file\n", argv[0]);
return 1;
}
file_name = argv[1];
load_sprite_png(&image, argv[1]);
yctx = yutani_init();
init_decorations();
win = yutani_window_create(yctx, image.width + decor_width(), image.height + decor_height());
yutani_window_move(yctx, win, center_x(image.width + decor_width()), center_y(image.height + decor_height()));
ctx = init_graphics_yutani_double_buffer(win);
int stride;
stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, win->width);
surface_win = cairo_image_surface_create_for_data(ctx->backbuffer, CAIRO_FORMAT_ARGB32, win->width, win->height, stride);
cr_win = cairo_create(surface_win);
yutani_window_advertise_icon(yctx, win, "Image Viewer", "image-viewer");
redraw();
yutani_focus_window(yctx, win->wid);
while (!should_exit) {
yutani_msg_t * m = yutani_poll(yctx);
if (m) {
switch (m->type) {
case YUTANI_MSG_KEY_EVENT:
{
struct yutani_msg_key_event * ke = (void*)m->data;
if (ke->event.key == 'q' && ke->event.action == KEY_ACTION_DOWN) {
should_exit = 1;
}
}
break;
case YUTANI_MSG_WINDOW_FOCUS_CHANGE:
{
struct yutani_msg_window_focus_change * wf = (void*)m->data;
if (wf->wid == win->wid) {
win->focused = wf->focused;
redraw();
}
}
break;
case YUTANI_MSG_WINDOW_MOUSE_EVENT:
{
struct yutani_msg_window_mouse_event * me = (void*)m->data;
if (me->wid != win->wid) break;
int result = decor_handle_event(yctx, m);
switch (result) {
case DECOR_CLOSE:
should_exit = 1;
break;
default:
/* Other actions */
break;
}
}
break;
case YUTANI_MSG_SESSION_END:
should_exit = 1;
break;
default:
break;
}
free(m);
}
}
return 0;
}
示例12: switch
BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
switch (message)
{
case WM_INITDIALOG :
{
switchTo(activeText);
::SendDlgItemMessage(_hSelf, IDC_COL_DEC_RADIO, BM_SETCHECK, TRUE, 0);
goToCenter();
NppParameters *pNppParam = NppParameters::getInstance();
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme)
{
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
redraw();
}
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDCANCEL : // Close
display(false);
return TRUE;
case IDOK :
{
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
const int stringSize = 1024;
TCHAR str[stringSize];
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
if (isTextMode)
{
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, (LPARAM)str);
display(false);
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
{
ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo();
std::sort(colInfos.begin(), colInfos.end(), SortInPositionOrder());
(*_ppEditView)->columnReplace(colInfos, str);
std::sort(colInfos.begin(), colInfos.end(), SortInSelectOrder());
(*_ppEditView)->setMultiSelections(colInfos);
}
else
{
int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
int endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
int lineAllocatedLen = 1024;
TCHAR *line = new TCHAR[lineAllocatedLen];
for (int i = cursorLine ; i <= endLine ; i++)
{
int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
int lineLen = lineEnd - lineBegin + 1;
if (lineLen > lineAllocatedLen)
{
delete [] line;
line = new TCHAR[lineLen];
}
(*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd);
generic_string s2r(line);
if (lineEndCol < cursorCol)
{
generic_string s_space(cursorCol - lineEndCol, ' ');
s2r.append(s_space);
s2r.append(str);
}
else
{
int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
int posRelative2Start = posAbs2Start - lineBegin;
s2r.insert(posRelative2Start, str);
}
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
}
delete [] line;
}
}
else
{
int initialNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, NULL, TRUE);
int increaseNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, NULL, TRUE);
UCHAR format = getFormat();
display(false);
//.........这里部分代码省略.........
示例13: while
void MWList::redraw(bool scrollbarShown)
{
const int _scrollBarWidth = 20; // fetch this from skin?
const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0;
const int spacing = 3;
int viewPosition = -mScrollView->getViewOffset().top;
while (mScrollView->getChildCount())
{
MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0));
}
mItemHeight = 0;
int i=0;
for (std::vector<std::string>::const_iterator it=mItems.begin();
it!=mItems.end(); ++it)
{
if (*it != "")
{
if (mListItemSkin.empty())
return;
MyGUI::Button* button = mScrollView->createWidget<MyGUI::Button>(
mListItemSkin, MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24),
MyGUI::Align::Left | MyGUI::Align::Top, getName() + "_item_" + (*it));
button->setCaption((*it));
button->getSubWidgetText()->setWordWrap(true);
button->getSubWidgetText()->setTextAlign(MyGUI::Align::Left);
button->eventMouseWheel += MyGUI::newDelegate(this, &MWList::onMouseWheel);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWList::onItemSelected);
int height = button->getTextSize().height;
button->setSize(MyGUI::IntSize(button->getSize().width, height));
button->setUserData(i);
mItemHeight += height + spacing;
}
else
{
MyGUI::ImageBox* separator = mScrollView->createWidget<MyGUI::ImageBox>("MW_HLine",
MyGUI::IntCoord(2, mItemHeight, mScrollView->getWidth() - scrollBarWidth - 4, 18),
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
separator->setNeedMouseFocus(false);
mItemHeight += 18 + spacing;
}
++i;
}
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden
mScrollView->setVisibleVScroll(false);
mScrollView->setCanvasSize(mClient->getSize().width, std::max(mItemHeight, mClient->getSize().height));
mScrollView->setVisibleVScroll(true);
if (!scrollbarShown && mItemHeight > mClient->getSize().height)
redraw(true);
int viewRange = mScrollView->getCanvasSize().height;
if(viewPosition > viewRange)
viewPosition = viewRange;
mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition));
}
示例14: redraw
void MWList::adjustSize()
{
redraw();
}
示例15: switch
/**
* performs autozoom
*
* @param axis include axis in zoom
* @param keepAspectRatio true: keep aspect ratio 1:1
* false: factors in x and y are stretched to the max
*/
void RS_GraphicView::zoomAuto(bool axis, bool keepAspectRatio) {
RS_DEBUG->print("RS_GraphicView::zoomAuto");
if (container!=NULL) {
container->calculateBorders();
double sx, sy;
if (axis) {
sx = std::max(container->getMax().x, 0.0)
- std::min(container->getMin().x, 0.0);
sy = std::max(container->getMax().y, 0.0)
- std::min(container->getMin().y, 0.0);
} else {
sx = container->getSize().x;
sy = container->getSize().y;
}
// std::cout<<" RS_GraphicView::zoomAuto("<<axis<<","<<keepAspectRatio<<")"<<std::endl;
double fx=1., fy=1.;
unsigned short fFlags=0;
if (sx>RS_TOLERANCE) {
fx = (getWidth()-borderLeft-borderRight) / sx;
} else {
fFlags += 1; //invalid x factor
}
if (sy>RS_TOLERANCE) {
fy = (getHeight()-borderTop-borderBottom) / sy;
} else {
fFlags += 2; //invalid y factor
}
// std::cout<<"0: fx= "<<fx<<"\tfy="<<fy<<std::endl;
RS_DEBUG->print("f: %f/%f", fx, fy);
switch(fFlags){
case 1:
fx=fy;
break;
case 2:
fy=fx;
break;
case 3:
return; //do not do anything, invalid factors
default:
if (keepAspectRatio) {
fx = fy = std::min(fx, fy);
}
// break;
}
// std::cout<<"1: fx= "<<fx<<"\tfy="<<fy<<std::endl;
RS_DEBUG->print("f: %f/%f", fx, fy);
//exclude invalid factors
fFlags=0;
if (fx<RS_TOLERANCE||fx>RS_MAXDOUBLE) {
fx=1.0;
fFlags += 1;
}
if (fy<RS_TOLERANCE||fy>RS_MAXDOUBLE) {
fy=1.0;
fFlags += 2;
}
if(fFlags == 3 ) return;
saveView();
// std::cout<<"2: fx= "<<fx<<"\tfy="<<fy<<std::endl;
setFactorX(fx);
setFactorY(fy);
RS_DEBUG->print("f: %f/%f", fx, fy);
// RS_DEBUG->print("adjustOffsetControls");
adjustOffsetControls();
// RS_DEBUG->print("adjustZoomControls");
adjustZoomControls();
// RS_DEBUG->print("centerOffsetX");
centerOffsetX();
// RS_DEBUG->print("centerOffsetY");
centerOffsetY();
// RS_DEBUG->print("updateGrid");
// updateGrid();
redraw();
}
RS_DEBUG->print("RS_GraphicView::zoomAuto OK");
}