mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-05 05:14:13 +01:00
WINGs: merge duplicate code from wtext
This patch is saving about 30 duplicate code lines from WMPrependTextBlock and WMAppendTextBlock to create a static fct called prepareTextBlock.
This commit is contained in:
committed by
Carlos R. Mafra
parent
adebdf41c6
commit
238b8ed3ca
@@ -3322,13 +3322,8 @@ WMGetTextBlockProperties(WMText * tPtr, void *vtb, unsigned int *first,
|
|||||||
*margins = tPtr->margins[tb->marginN];
|
*margins = tPtr->margins[tb->marginN];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMPrependTextBlock(WMText * tPtr, void *vtb)
|
static int prepareTextBlock(WMText *tPtr, TextBlock *tb)
|
||||||
{
|
{
|
||||||
TextBlock *tb = (TextBlock *) vtb;
|
|
||||||
|
|
||||||
if (!tb)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (tb->graphic) {
|
if (tb->graphic) {
|
||||||
if (tb->object) {
|
if (tb->object) {
|
||||||
WMWidget *w = tb->d.widget;
|
WMWidget *w = tb->d.widget;
|
||||||
@@ -3348,13 +3343,24 @@ void WMPrependTextBlock(WMText * tPtr, void *vtb)
|
|||||||
tb->next = tb->prior = NULL;
|
tb->next = tb->prior = NULL;
|
||||||
tb->first = True;
|
tb->first = True;
|
||||||
tPtr->lastTextBlock = tPtr->firstTextBlock = tPtr->currentTextBlock = tb;
|
tPtr->lastTextBlock = tPtr->firstTextBlock = tPtr->currentTextBlock = tb;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tb->first) {
|
if (!tb->first) {
|
||||||
tb->marginN = tPtr->currentTextBlock->marginN;
|
tb->marginN = tPtr->currentTextBlock->marginN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WMPrependTextBlock(WMText *tPtr, void *vtb)
|
||||||
|
{
|
||||||
|
TextBlock *tb = (TextBlock *) vtb;
|
||||||
|
|
||||||
|
if (!tb || !prepareTextBlock(tPtr, tb))
|
||||||
|
return;
|
||||||
|
|
||||||
tb->next = tPtr->currentTextBlock;
|
tb->next = tPtr->currentTextBlock;
|
||||||
tb->prior = tPtr->currentTextBlock->prior;
|
tb->prior = tPtr->currentTextBlock->prior;
|
||||||
if (tPtr->currentTextBlock->prior)
|
if (tPtr->currentTextBlock->prior)
|
||||||
@@ -3367,39 +3373,13 @@ void WMPrependTextBlock(WMText * tPtr, void *vtb)
|
|||||||
tPtr->currentTextBlock = tb;
|
tPtr->currentTextBlock = tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMAppendTextBlock(WMText * tPtr, void *vtb)
|
void WMAppendTextBlock(WMText *tPtr, void *vtb)
|
||||||
{
|
{
|
||||||
TextBlock *tb = (TextBlock *) vtb;
|
TextBlock *tb = (TextBlock *) vtb;
|
||||||
|
|
||||||
if (!tb)
|
if (!tb || !prepareTextBlock(tPtr, tb))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tb->graphic) {
|
|
||||||
if (tb->object) {
|
|
||||||
WMWidget *w = tb->d.widget;
|
|
||||||
if (W_CLASS(w) != WC_TextField && W_CLASS(w) != WC_Text) {
|
|
||||||
(W_VIEW(w))->attribs.cursor = tPtr->view->screen->defaultCursor;
|
|
||||||
(W_VIEW(w))->attribFlags |= CWOverrideRedirect | CWCursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WMAddToArray(tPtr->gfxItems, (void *)tb);
|
|
||||||
tPtr->tpos = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
tPtr->tpos = tb->used;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tPtr->lastTextBlock || !tPtr->firstTextBlock) {
|
|
||||||
tb->next = tb->prior = NULL;
|
|
||||||
tb->first = True;
|
|
||||||
tPtr->lastTextBlock = tPtr->firstTextBlock = tPtr->currentTextBlock = tb;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tb->first) {
|
|
||||||
tb->marginN = tPtr->currentTextBlock->marginN;
|
|
||||||
}
|
|
||||||
|
|
||||||
tb->next = tPtr->currentTextBlock->next;
|
tb->next = tPtr->currentTextBlock->next;
|
||||||
tb->prior = tPtr->currentTextBlock;
|
tb->prior = tPtr->currentTextBlock;
|
||||||
if (tPtr->currentTextBlock->next)
|
if (tPtr->currentTextBlock->next)
|
||||||
|
|||||||
Reference in New Issue
Block a user