[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
pad + mvwaddch position problem
From: |
fpga |
Subject: |
pad + mvwaddch position problem |
Date: |
Tue, 12 Sep 2006 02:55:40 -0700 (PDT) |
[CODE]
#include <curses.h>
/*
run this code as is, noting that all 'sets' print out correctly with their
right edges aligned at x=15.
Then change PROBLEM's value to 1 and re-run.
Why does changing b2's 'capacity' to 9 cause it to start printing out
at a position other than x=15?
If I make b2's capacity 8 or 10 I don't get a problem.
Any help in explaining the right shift and how to stop it would be most
appreciated.
Best regards
*/
#define PROBLEM 0
//=============================================
class SetupPad {
public:
WINDOW * ptr; //ie pPad
SetupPad();
~SetupPad() { delwin(ptr); endwin(); }
void linesCols();
};
SetupPad::SetupPad()
{
initscr();
curs_set(0);
};
void SetupPad::linesCols()
{
ptr = newpad(LINES-1,COLS-1);
}
//=============================================
class Set
{
public:
int x,y,cap;
Set(int nx,int ny, int ncap) : x(nx),y(ny),cap(ncap) {}
~Set(){}
};
//=============================================
void drawQ(Set * pS,WINDOW * pWin)
{
int x=pS->x;
int y=pS->y;
char sym = '.';
for (int j=0;j<pS->cap;j++)
mvwaddch(pWin, y, x--, sym);
}
void updtScn(SetupPad * pPad)
{
prefresh(pPad->ptr,0,0,0,0,LINES-1,COLS-1);
doupdate();
}
int main()
{
SetupPad pad;
pad.linesCols();
Set b1(15,1,13);
Set m1(15,2,10);
Set m2(15,3,10);
#if PROBLEM
Set b2(15,4,9);
#else
Set b2(15,4,10); //works with 8 too!
#endif
drawQ(&b1,pad.ptr);
drawQ(&m1,pad.ptr);
drawQ(&m2,pad.ptr);
drawQ(&b2,pad.ptr);
updtScn(&pad);
for (int i=0;i<1000000000;i++); //delay so you can see it
return 0;
}
[/CODE]
--
View this message in context:
http://www.nabble.com/pad-%2B-mvwaddch-position-problem-tf2257874.html#a6262982
Sent from the Gnu - Ncurses forum at Nabble.com.
- pad + mvwaddch position problem,
fpga <=